Boriel Basic Forum
hex numbers in asm blocks - Printable Version

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



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

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 - 2014-07-23

have you tried defb $ff ?


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

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 - 2014-07-24

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 - 2014-07-24

Gotcha! That makes perfect sense.

Thanks, guys!