Inline x86 ASM
PureBasic allows you to include any x86 assembler commands (including MMX and FPU one) directly in the source code, as if it was a real assembler. And it gives you even more: you can use directly any variables or pointers in the assembler keywords, you can put any ASM commands on the same line, ... The syntaxe is the NAsm one, so if you want more informations about the ASM syntax, just read the NAsm guide.
You have several rules to closely follow if you want to include asm in a Basic code :
- The used variables or
pointers must be declared before to use them in an assembler keyword
- When you reference a label, you must put the letter 'p' before the name. This
is because PureBasic add a 'p' before a BASIC label to avoid conflit with internal
labels.
Example :
MOV ebx,pMyLabel ... MyLabel:
- The errors in an asm
part are not reported by PureBasic but by NAsm. Just check your code if a such
error happen
- The registers available registers are : eax, ebx, edx, esi, edi and ebp. All
other must be always preserved.
Example :