Forum
hex numbers in asm blocks - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16)
+---- Thread: hex numbers in asm blocks (/showthread.php?tid=600)



hex numbers in asm blocks - LTee - 07-23-2014

Sorry to be creating so many posts the last couple of days. Smile

Should this work?
Code:
asm
defb ffh
end asm

I read a post elsewhere which suggested that that was the correct syntax to use for hex numbers in an asm block, but I get this:
Code:
test.bas:1: Error: Undefined label 'ffh'

If I switch the 'ffh' for a '255' then all is fine. 1.4.0-s1885, as before. Thanks!


Re: hex numbers in asm blocks - LCD - 07-23-2014

have you tried defb $ff ?


Re: hex numbers in asm blocks - LTee - 07-23-2014

I hadn't, no - and that seems to work fine. I'm obviously basing my tests on outdated info. Smile

Many thanks!


Re: hex numbers in asm blocks - boriel - 07-24-2014

LTee Wrote:I hadn't, no - and that seems to work fine. I'm obviously basing my tests on outdated info. Smile

Many thanks!
The FFh is all letter, and the compiler/assembler think its an identifier.
If you want to ensure it knows it's a hex number, prefix it with 0. So FFh should be 0FFh.
This is common to all assemblers. Any hex number starting with a letter and ending with 'h' must be prefixed with 0. Thus:

A3h => Error (it's an 'identifier'). Use 0A3h
2Bh => Ok (Already starts with a number).

Using the $ prefix is always ok and avoids this problem. Smile


Re: hex numbers in asm blocks - LTee - 07-24-2014

Gotcha! That makes perfect sense.

Thanks, guys!