Sign in

username:

password:



Not a member?

Search hc11



Search tips

Subscribe to hc11



Ads

Discussion Groups

Technical discussions about Freescale Microcontrollers: M68HC11. (Freescale Semiconductor is a Subsidiary of Motorola).

Text - bal_gill21 - Dec 15 13:12:00 2004


hi,
when I am writing ASII into memory ie fcc 'hello', i am having to
check the very last memory location for 'o' to see when it has
finished writing to the display. This value obviously changes when I
add code (and I have to keep changing it). Is there a way of
recognising the last letter so I don't have to keep changing the
memory location every time my code changes? I could recognise
that 'o' has been written but in some cases I have 2 blank spaces or
two of the same letter.

Thanks

bal






(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )


Re: Text - Tony Papadimitriou - Dec 15 13:21:00 2004

----- Original Message -----
From: "bal_gill21" <>
To: < > when I am writing ASII into memory ie fcc 'hello', i am having to
> check the very last memory location for 'o' to see when it has
> finished writing to the display. This value obviously changes when I
> add code (and I have to keep changing it). Is there a way of
> recognising the last letter so I don't have to keep changing the
> memory location every time my code changes? I could recognise
> that 'o' has been written but in some cases I have 2 blank spaces or
> two of the same letter.

Yes, put zero at the end.

fcc 'hello',0

or
fcc 'hello'
fcb 0

or (using my ASM11)
fcs 'hello'

It's also quicker to check for the end because LDA instructions also set the Z
flag. So, there is no need to CMP against a specific value.

> bal






(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )

Re: Text - Scott Grodevant - Dec 15 13:46:00 2004

Hi all,

If memory is critical and you have lots of messages, sometimes one sets the parity bit (bit 7) of the last character in the message, thus saving a byte of storage for each message. You then check for the character's value being above $7F. fcc 'hell','o'+$80 Scott Tony Papadimitriou <> wrote:

----- Original Message -----
From: "bal_gill21"
To: > when I am writing ASII into memory ie fcc 'hello', i am having to
> check the very last memory location for 'o' to see when it has
> finished writing to the display. This value obviously changes when I
> add code (and I have to keep changing it). Is there a way of
> recognising the last letter so I don't have to keep changing the
> memory location every time my code changes? I could recognise
> that 'o' has been written but in some cases I have 2 blank spaces or
> two of the same letter.

Yes, put zero at the end.

fcc 'hello',0

or
fcc 'hello'
fcb 0

or (using my ASM11)
fcs 'hello'

It's also quicker to check for the end because LDA instructions also set the Z
flag. So, there is no need to CMP against a specific value.

> bal

Yahoo! Groups Links
---------------------------------




(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )

Re: Text - David Kelly - Dec 15 13:49:00 2004

>
> Yes, put zero at the end.
>
> fcc 'hello',0
...
> It's also quicker to check for the end because LDA instructions also set
> the Z flag. So, there is no need to CMP against a specific value.

In the heyday of Apple ][ and 6502 a common convention was to toggle the
sign bit (test for N rather than Z) on the last character. Assemblers of
the day had pseudo-opcodes for easily defining these strings. In an odd
twist we usually set the N bit on most and cleared it on the last because
straight ASCII displayed inverse.

You will use more than one byte coding a test for the N bit then
clearing/setting before display but if you have lots and lots of text
strings a savings of one byte each may add up to something significant.

The Pascal, VMS, and mainframe way was to prefix the string with a count.
The Unix/C way of null termination has become dominant. Probably want to
stick with the Unix/C way as most all string handling routines that you
might borrow for your project will expect null terminated strings.




(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )

Re: Text - Tony Papadimitriou - Dec 15 14:14:00 2004

This 'trick' was used with OS/9 (for the 6809). For me, it has two problems:

1. It is visually displeasing unless the assembler provides a pseudo-op to do it
behind the scenes (e.g., fcs).
2. It only works for lower ASCII strings (i.e., useless for multilingual
messaging).
----- Original Message -----
From: "Scott Grodevant" <>
To: <
Hi all,

If memory is critical and you have lots of messages, sometimes one sets the
parity bit (bit 7) of the last character in the message, thus saving a byte of
storage for each message. You then check for the character's value being above
$7F. fcc 'hell','o'+$80 Scott




(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )

Re: Text - Jim Peterson - Dec 16 8:42:00 2004

I am not sure whether you realize it or not, but you now have a write
text routine that (with some slight modification) could be made a
subroutine to write any zero delimited string.

See if you can push the address of the string onto the stack, JSR to the
write string routine, whre it will pop the address off the stack
(remember to preserve the JSR stack contents), write to the end of the
string, then RTS back to the caller.

A simpler approach might be to just assume D is pointing at the string
on entry to the subroutine, but learning to manage the stack is an
important step in advancing your programming skill.

I deliberately did not include the specific details, it is important to
make use of the reference manual for your MCU to keep this kind of
sequence correct for any processor.

Good luck,
Jim
bal_gill21 wrote:

>Thanks for all the advice given, I have added a zero at the end and
>it now saves me time by not having to change the compare address
>every time the code changes.
>
>Bal >
>
>Yahoo! Groups Links




(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )

Re: Text - David Kelly - Dec 16 8:44:00 2004


On Dec 16, 2004, at 4:15 AM, bal_gill21 wrote:

> Thanks for all the advice given, I have added a zero at the end and
> it now saves me time by not having to change the compare address
> every time the code changes.

*Manually* changing the compare address? Not something like this?

hello_start fcc "Hello, World!"
hello_end equ *
hello_len equ hello_end-hello-start
hello_len_too equ *-hello_start

--
David Kelly N4HHE,
========================================================================
Whom computers would destroy, they must first drive mad.




(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )

Re: Text - Mark Schultz - Dec 16 10:29:00 2004


--- In , "bal_gill21" <bal_gill21@y...> wrote:
>
> when I am writing ASII into memory ie fcc 'hello', i am having to
> check the very last memory location for 'o' to see when it has
> finished writing to the display. This value obviously changes when
> I add code (and I have to keep changing it). Is there a way of
> recognising the last letter so I don't have to keep changing the
> memory location every time my code changes? I could recognise
> that 'o' has been written but in some cases I have 2 blank spaces
> or two of the same letter.

One last note to add on this subject. As others have suggested, the
typical way to terminate a string is to add a "zero terminator" to
the end of it. You may encounter the term "ASCIIZ string" in some
of the documentation or code you read; this term refers to the
technique of terminating a string with a null/0 byte.

If you use this technique, it is very easy to create a general-
purpose subroutine to output a string (to the SCI or any other
device). If you have a existing subroutine that outputs a single
byte to, say, the SCI named "CharOut", the code below will allow you
to output ANY zero-terminated string:

; Part of main program:

... ;(init code not shown)
LDY #Hello ;Point to "Hello" text
JSR Msg ;Output
LDY #Goodbye ;Point to "Goodbye" text
JSR Msg ;Output
... ;(rest of program)

Hello FCS "Hello, world!",0
Goodbye FCS "Goodbye, cruel world.",0

; Subroutine to output a single character

CharOut ... ;(code not shown)

; Subroutine to output a ASCIIZ string
; Y <- Address of string to output

Msg LDAA 0,Y ;Get char from string
BEQ MsgX ;Exit if zero (end of str)
JSR CharOut ;Output character
INY ;Point to next character
BRA Msg ;Continue until end of str
MsgX RTS ;End of string, exit Note that I use the Y register as the string pointer - just LDY
#String and call Msg to output it. You will need to create a
subroutine named CharOut that handles single-character output to
your device. If using the SCI for output, don't forget to include
code to check if the transmit data register is empty. For SCI
output, the CharOut subroutine will consist of 3 to 6 instructions,
depending on how you choose to write it. Let me know if you need
help with this part.

-- Mark





(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )