Code: Select all
! var db 255
Debug var
Code: Select all
! var db 255
Debug var
I think you was right, it was executing binary data.You can somewhat verify that by replacing 255 with 0x90, the opcode for NOP (no operation).
Hm, didn't get your idea exactly, maybe you could elaborate on this a bit, if you got some spare minutes(I started to learn asm just today, so take it easy )So is you remove your fasm line to prevent the crash, debug will print the value of the PB variable "var", mapped to "v_var" in fasm
Code: Select all
Define var ; this is the PB "var", it will translated to "v_var" to the ASM output to be sent to FASM
! mov eax, [var] ; this will copy your FASM "var" into a register
! mov [v_var], eax ; this will copy that value to the "v_var" the debug command can access
Debug var ; and here it is
End ; end to stop the program here
! var dd 1234567 ; your fasm data (double word to comply easily with register size)
Code: Select all
Define var.l
Code: Select all
EnableASM
var2 = 255
var1 = 123
mov rax, var2
add rax,1
mov var2, rax
DisableASM
Global gDebug
Macro debugASM(val)
! if val in <rax,rbx,rcx,rdx,rsp,rdi>
! mov [v_gDebug], val
! else
!if defined v_#val
! push rax
! mov rax, [v_#val]
!mov [v_gDebug], rax
!pop rax
!else
!push rax
!add rsp, 8
!mov rax, [p.v_#val]
!mov [v_gDebug], rax
!sub rsp, 8
!pop rax
!end If
! end If
Debug gDebug
EndMacro
Procedure foo()
Protected b
b = 4
debugASM(b)
EndProcedure
DebugASM(rax)
DebugAsm(var1)
foo()
A bit advanced for me, but I suspect, this will come in handy later. Thanks!as a little fasm processor debug experiment it's not very useful, x64 only
If your variable is within the code section, you are not allowed to write to it by default. Better put data/variables in a data section.luis wrote:So to read from you FASM data and print through debug, you could do something like this:
Code: Select all
Define var ; this is the PB "var", it will translated to "v_var" to the ASM output to be sent to FASM ! mov eax, [var] ; this will copy your FASM "var" into a register ! mov [v_var], eax ; this will copy that value to the "v_var" the debug command can access Debug var ; and here it is End ; end to stop the program here ! var dd 1234567 ; your fasm data (double word to comply easily with register size)
Code: Select all
Define var.l ; this is the PB "var", it will translated to "v_var" to the ASM output to be sent to FASM
! mov eax, [var] ; this will copy your FASM "var" into a register
! mov [v_var], eax ; this will copy that value to the "v_var" the debug command can access
Debug var ; and here it is
! mov dword [var], 987654321 ; write to your var -> THIS WORKS ONLY IF YOUR VAR IS IN DATA SECTION
! mov eax, [var] ; this will copy your FASM "var" into a register
! mov [v_var], eax ; this will copy that value to the "v_var" the debug command can access
Debug var ; and here it is
End
DataSection
! var dd 1234567 ; your fasm data (double word to comply easily with register size)
EndDataSection
Thanks, understood.If your variable is within the code section, you are not allowed to write to it by default. Better put data/variables in a data section.