Tis relies on a change of opcode interpretation.
In 32 bit mode 48h means decrement the eax register
In 64 bit mode 48h signifies 64 bit data width
Detect64BitMode:
'===============
xor rax,rax
or rax,rax 'in 32bit mode: seen as dec eax : or eax,eax
jz Code64bit
'detecting 64 bit mode at run time
Declare Function MessageBox Lib "user32.dll" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
zstring msg[]= "Happy Christmas"
Detect64BitMode:
'===============
xor rax,rax
or rax,rax 'in 32bit mode: seen as dec eax : or eax,eax
jz Code64bit
Code32bit:
'=========
zstring cap[]= "The 32Bit world of OxygenBasic..."
push 0
lea eax,cap
push eax
lea eax,msg
push eax
push 0
call MessageBox
jmp fwd done
Code64bit:
'=========
zstring cap[]= "The 64Bit world of OxygenBasic..."
sub rsp,32
mov rcx, 0
lea rdx, msg
lea r8, cap
mov r9, 0
call MessageBox
add rsp,32
done:
Charles