From here, I have the following example:
clr r16 ; Clear r16
ser r17 ; Set r17
out $18,r16 ; Write zeros to Port B
nop ; Wait (do nothing)
out $18,r17 ; Write ones to Port B
My question is that what does $18
mean in the last line?
I know it stands for PortB. I would like to know more about its syntax.
Best Answer
If you look at the AVR memory map you'll see that the address of PortB is $18 (hex) (which would be written as 0x18 in C-- syntax varies with assemblers- often they'll accept the C method). It's equivalent to decimal 24 (1 * 16 + 8 ) since hex is base 16.
It's correct, but ugly to write assembler code like that.. Normally you'd prefer to use an include file that has a line such as
after which you can refer to PortB using the symbol PORTB, which is a heck of a lot easier to follow