PureBasic Forum
https://www.purebasic.fr/english/

How can I use a constant in assembler?
https://www.purebasic.fr/english/viewtopic.php?f=35&t=73148
Page 1 of 1

Author:  Wolfram [ Sun Jul 07, 2019 2:31 pm ]
Post subject:  How can I use a constant in assembler?

How can I use the content #myValue instead of the value 8 in this example?

Code:
#myValue = 8

!add edx, 8

Author:  mk-soft [ Sun Jul 07, 2019 2:51 pm ]
Post subject:  Re: How can I use a constant in assembler?

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:
#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()

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/