If i have a constant
Code: Select all
#ConstantPb = 10Code: Select all
#ConstantPb = 10
! ConstantAsm = ????

Code: Select all
#ConstantPb = 10Code: Select all
#ConstantPb = 10
! ConstantAsm = ????
Code: Select all
EnableExplicit
Macro ConstantPB ; Use this instead of #ConstantPB = 9
9
EndMacro
Macro DeclareConstantASM(k)
! ConstantASM = k
EndMacro
Define.l i
OpenConsole()
For i = 1 To ConstantPB ; Constant used in PB
PrintN(Str(i))
Next
PrintN(Str(PeekA(?T1)))
DeclareConstantASM(ConstantPB) ; Constant declared for asm
DataSection
T1:
! db ConstantASM
EndDataSection

In fact...it's simple...I don't know of any way to get a #Const value substituted into assembler.
Code: Select all
!KCC_DataSection = 10
!RepNum = 17
ShowMemoryViewer(?my_data, 500)
DataSection
my_data:
!repeat KCC_DataSection
!repeat RepNum
CompilerIf #PB_Compiler_Unicode
!dw '*'
CompilerElse
!db '*'
CompilerEndIf
!end repeat
!end repeat
EndDataSectionCode: Select all
#SizeOfDataSection = 10Code: Select all
!KCC_DataSection = 10
#SizeOfDataSection = 10
Code: Select all
Macro DeclareConstantASM(k)
#KccConstant = k
! ConstantASM = k
EndMacro
DeclareConstantASM(10) ; Constant declared for asm
Debug "ConstanteASM = " + Str(PeekA(?T1))
Debug "ConstantePB = " + Str(#KccConstant)
DataSection
T1:
! db ConstantASM
EndDataSectionCode: Select all
EnableExplicit
Macro DeclareConstant(k)
#ConstantPB = k
! ConstantASM = k
EndMacro
Procedure.l GetConstant() ; just a demo - not needed to make it work
! MOV EAX, ConstantASM
ProcedureReturn
EndProcedure
DeclareConstant(9) ; declare PB and ASM constants
Debug #ConstantPB
Debug GetConstant() ; get the value of ConstantASM in PB
Debug PeekS(?T1)
DataSection
T1:
! times ConstantASM db "**********"
Data.c 0 ; terminate the string
EndDataSection

Then here !!!!!!! When i have read this line, i'm so happy, then i believe it's the most nice day of my lifeHey KCC, I like your constant declaration macro better than my original. I can use that in my code, thank you.



Code: Select all
#ConstantPB = 10
Macro DeclareConstant(k)
!ConstantASM = k
EndMacro
DeclareConstant(#ConstantPB)Code: Select all
Macro DeclareConstant(k)
#ConstantPB = k
!ConstantASM = k
EndMacro
DeclareConstant(9) ; declare PB and ASM constants
Code: Select all
Macro mHash
#
EndMacro
Macro DeclareConstant(Name, Value)
mHash#Name#PB = Value
! Name#ASM = Value
EndMacro
DeclareConstant(NewConst, 7) ; declare #NewConstPB and NewConstASM with value 7
DeclareConstant(OldConst, 99) ; declare #OldConstPB and OldConstASM with value 99

Code: Select all
#myconst = 10
Procedure Test(*Pointer, Variable)
Protected this.l
EnableASM
MOV dword [p.v_this], #myconst
MOV dword [p.p_Pointer], 20
MOV dword [p.v_Variable], 30
DisableASM
Debug this
Debug *Pointer
Debug Variable
EndProcedure
Test(0, 0)
Code: Select all
EnableASM
MOV this, #myconst
MOV *Pointer, 20 ; didn't know this worked either until I just tried it
MOV Variable, 30
DisableASM

I'm happy...in fact it's do for that.KCC, thank you for your unique response - it made me smile - and that's a good thing.
Code: Select all
Macro mHash
#
EndMacro
Macro DeclareConstant(Name, Value)
mHash#Name#PB = Value
! Name#ASM = Value
EndMacro
DeclareConstant(NewConst, 7) ; declare #NewConstPB and NewConstASM with value 7
DeclareConstant(OldConst, 99) ; declare #OldConstPB and OldConstASM with value 99
; Procedure just for see the result :-)
Procedure.l GetConstant(ConstantToGet)
Select ConstantToGet
Case #NewConstpb
!MOV EAX, NewConstASM
Case #OldConstpb
!MOV EAX, OldConstASM
EndSelect
ProcedureReturn
EndProcedure
Debug "DeclareConstant(NewConst, 7)"
Debug "ConstantePB = " + Str(#NewConstpb)
Debug "ConstanteASM = " + Str(GetConstant(#NewConstpb))
Debug ""
Debug "DeclareConstant(OldConst, 99)"
Debug "ConstantePB = " + Str(#OldConstpb)
Debug "ConstanteASM = " + Str(GetConstant(#OldConstpb))Code: Select all
Procedure.l GetConstant(NewConstASM)
!MOV EAX, NewConstASM
ProcedureReturn
EndProcedureCode: Select all
Procedure.l GetConstant(ConstantToGet)
Select ConstantToGet
Case #NewConstpb
!MOV EAX, NewConstASM
Case #OldConstpb
!MOV EAX, OldConstASM
EndSelect
ProcedureReturn
EndProcedure

Code: Select all
#PbConstant = 10Code: Select all
!AsmConstant = #PbConstantCode: Select all
!AsmConstant = 10Code: Select all
#PbConstant = !AsmConstantCode: Select all
#PbConstant = 10Code: Select all
#NewConst = 7
#OldConst = 99
Procedure.l GetConstant(ConstantToGet)
Select ConstantToGet
Case #NewConst
EnableASM
MOV EAX, #NewConst
DisableASM
Case #OldConst
EnableASM
MOV EAX, #OldConst
DisableASM
EndSelect
ProcedureReturn
EndProcedure
Debug "ConstantePB = " + Str(#NewConst)
Debug "ConstanteASM = " + Str(GetConstant(#NewConst))
Debug ""
Debug "ConstantePB = " + Str(#OldConst)
Debug "ConstanteASM = " + Str(GetConstant(#OldConst))Code: Select all
EnableExplicit
Macro DeclareConstant(k)
#ConstantPB = k
! ConstantASM = k
EndMacro
DeclareConstant(9) ; declare PB and ASM constants
Debug #ConstantPB
Debug PeekS(?T1)
DataSection
T1:
! times ConstantASM db "**********"
Data.c 0 ; terminate the string
EndDataSection