Assembler question -- #

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Assembler question -- #

Jump to solution
3,096 Views
Curt
Contributor IV
Can anyone tell me where, in the 'HSO8 assembler docs., I will find the usage of the
"#" symbol defined?  I've been through the .pdf assembler docs several times -- but
darned if I can find it!  For example:
 
Stuff     DS.B  1
...
 
  LDA   Stuff     ;  move the current content of the address "Stuff" into A
...
  LDA  #Stuff    ;  move the address of "Stuff" into A
 
I think I understand how # is supposed to work -- but where is it in the docs?
 
Labels (1)
Tags (1)
0 Kudos
1 Solution
793 Views
Curt
Contributor IV
Hi mke_et and bigmac.
 
Thanks for the inputs.  I guess the answer to my question is that #  alone is not defined in the assembler docs -- on purpose:smileyhappy:
 
 

View solution in original post

0 Kudos
7 Replies
793 Views
CompilerGuru
NXP Employee
NXP Employee
Which version do you use?
In
CodeWarrior for HC08 V5.1\Help\PDF\Assembler_HC08.pdf
all addressing modes are described in the chapter
Operand field: Addressing modes (HC08 /
HCS08) from page (HC08 V5.1 version) 265 up to 276.

But what you probably should have a look first is the HCS08 Family Reference Manual. The assembler just uses the same syntax, and this manual contains the description of all instructions and their behavior.


Daniel
0 Kudos
793 Views
Curt
Contributor IV
Hi Daniel,
Thanks for the quick reply!  This isn't an important issue -- just one that causes
a little disquiet, since you feel better if you can find a usage in the docs.  I'm using the 'RS08 and observe the following (for example):
 
data:   DS.B  1
...
lda #Low(data)     ; places the low byte of the address of data in a -- documented
 
lda #High(data)    ; places the high byte of the address of data in a -- documented
 
lda #data              ;  ??  -- not documented (that I can see), but seems to the same
                             ;  as lda #Low(data)
 
In #data, the # is acting as an operator, rather than just an immediate operand signal to the assembler -- which is very handy, if a bona fide, supported use of the syntax.
 
I don't think I have a copy of the Family Reference Manual, but will see about downloading one today.
 
Thanks again,
Curt
 
 
0 Kudos
793 Views
bigmac
Specialist III
Hello Curt,
 
   lda #(data%256)
should give the same result as
   lda #Low(data)
and
   lda #(data/256)
the same result as
   lda #High(data)
 
lda #data  is potentially problematic if data is located at other than page zero, and should be avoided when referring to an address (rather than an immediate byte value).
 
Regards,
Mac
 
0 Kudos
794 Views
Curt
Contributor IV
Hi mke_et and bigmac.
 
Thanks for the inputs.  I guess the answer to my question is that #  alone is not defined in the assembler docs -- on purpose:smileyhappy:
 
 
0 Kudos
793 Views
bigmac
Specialist III
Hello Curt,
 
Actually, the instruction format is well defined - in the context you are using, the hash symbol always represents "immediate" addressing mode, where the value to be loaded will follow the instruction byte.  The value may be either a byte value, or in some cases a word value (but not for the RS08).
 
Regards,
Mac
 
 
 
0 Kudos
793 Views
Curt
Contributor IV
Enough said bigmac.  Its not that important:smileyhappy:
 
0 Kudos
793 Views
mke_et
Contributor IV
I've found that when I couldn't figure out what something did in an example, or wasn't sure even of my own code, I just look at the op codes and go back to the chip specs.

I know, pretty tedious.

But years ago (about 1988) I did a project using an Hitachi 63701. (A variant of the 6801) I had 100 of these things, and I couldn't get the program to work. For some reason I noticed that a 'call' to a subroutine was to the wrong address. It was off my 1. In fact, all the addresses at the end of the program were off by 1, but were fine at the start. Working back from both ends, I finally tracked it down to one spot in the program and I looked at the op-codes it generated. Turned out there was a bug in the assembler. If I generated a certain type of jump it used the opcode for a 16 bit offset to jump to, but only put the lower 8-bits in the next byte and threw away the high byte which was zero. That meant that EVERY single reference in the source after that point was 'offset' by 1 from where the program was trying to jump and call too. What a mess. I ended up making a 'db' sequence to do what I needed and everything worked.

Anyway, while that little story doesn't really apply to your case, what I'm getting at is going in and looking at the opcode bytes your program generates isn't a bad skill to have. Start doing it when it's not critical so that you understand things and it will be a lot easy to do when it is critical.
0 Kudos