Qbasicnews.com
July 04, 2020, 09:58:11 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: FB Inline assembly  (Read 2064 times)
digger
New Member

Posts: 6


« on: February 15, 2005, 01:19:59 PM »

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
Logged
v3cz0r
I hold this place together
*****
Posts: 924



WWW
« Reply #1 on: February 15, 2005, 01:38:26 PM »

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.
Logged

digger
New Member

Posts: 6


« Reply #2 on: February 15, 2005, 02:32:01 PM »

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?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!