Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
FB Inline assembly
#1
FB Inline assembly. Head scratching time...
The first instruction will always return zero.
The register eax will always be loaded with 0 not 0ffh as expected.
The reason is the compiler changes '0ffh' to '0 ffh'.
Using '&hff' works. How would you do binary in FB? However, using
FB syntax inside an asm block may lead to existing code conversion
problems.
Is this a bug or, am i doing something wrong?

mov eax,0ffh ' <- Changes to: '0 ffh' returns 0
mov eax,01b ' <- Changes to: '01 b' returns 1
mov eax,011b ' <- Changes to: '011 b' returns 9 octal
mov eax,11d ' <- Changes to: '11e' junk 'e' error
mov eax,011 ' <- Unchanged returns 9 octal
mov eax,11 ' <- Unchanged returns 11
mov eax,012 ' <- Unchanged returns 10 octal
mov eax,12 ' <- Unchanged returns 12

' Test code
dim r1 as integer, r2 as integer
dim r3 as integer, r4 as integer

asm
mov eax,0ffh
mov [r1],eax
mov eax,011b
mov [r2],eax
mov eax,011
mov [r3],eax
mov eax,012
mov [r4],eax
end asm

print "mov eax,0ffh =";r1
print "mov eax,011b =";r2
print "mov eax,011 =";r3
print "mov eax,012 =";r4
Reply
#2
Binary literals have the &b prefix in FB, octagonal &o and &h for hexagonal.

GAS hex notation is the same as in C, using the 0x prefix, but that won't work as FB only accepts QB's notation and because the ASM block has to be parsed to translate variables, constants and functions names to the real ones.
Reply
#3
Much thanks v3cz0r
I will carry on...


Also with labels in an asm block:
I find numbering each label confusing in a large project, anyway to make labels local to the procedure?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)