Name a variable after a register

General FreeBASIC programming questions.
Posts: 52
Joined: Jan 13, 2018 8:47
Location: Germany

Name a variable after a register

Postby IchMagBier » Aug 10, 2019 4:22

Hi! :)

I have a problem with a variable named "rax" (like the x86_64 register). It all worked fine until I wrote a bit of inline assembler, that uses the actual rax register:

Code: Select all

dim as integer rax
asm mov rax,42 ' This should work with the register, not the variable
print rax ' 42

The bit of asm should actually move 42 to the register, not the variable. I thought you would need "[rax]" in inline asm to move to/from memory.
Temporarily I renamed the variable to "_rax", which is ugly, but works. Is there another solution maybe?
Posts: 9817
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Name a variable after a register

Postby fxm » Aug 10, 2019 6:36

In the asm code, the square brackets (around FB variable or FB function return) are mandatory for "gas", but optional for "gcc" (your case).

Return to “General”

Who is online

Users browsing this forum: coderJeff and 6 guests