How can I use a constant in assembler?

Bare metal programming in PureBasic, for experienced users
Wolfram
Enthusiast
Enthusiast
Posts: 533
Joined: Thu May 30, 2013 4:39 pm

How can I use a constant in assembler?

Post 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
User avatar
mk-soft
Addict
Addict
Posts: 3269
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: How can I use a constant in assembler?

Post 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()
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace
Post Reply