Page 1 of 1

How can I use a constant in assembler?

Posted: Sun Jul 07, 2019 2:31 pm
by Wolfram
How can I use the content #myValue instead of the value 8 in this example?

Code: Select all

#myValue = 8

!add edx, 8

Re: How can I use a constant in assembler?

Posted: Sun Jul 07, 2019 2:51 pm
by mk-soft
Constants are replaced at compile time from pb-code to asm-code.
Thus these constants are not stored as named constants in the asm-code.

Update with asm constants

Code: Select all

#myValue = 8

Procedure foo()
  EnableASM
  XOr rax,rax
  add rax, #myValue
  ProcedureReturn
  DisableASM
EndProcedure

! myValue equ 16

Procedure foo2()
  !xor rax,rax
  !add rax, myValue
  ProcedureReturn
EndProcedure

Debug foo()
Debug foo2()