Copy PbConstant value in variable ASM [Resolved]

Just starting out? Need help? Post your questions and find answers here.
bosker
Enthusiast
Enthusiast
Posts: 105
Joined: Fri Jan 08, 2010 11:04 pm
Location: Hampshire, UK

Re: Copy PbConstant value in variable ASM [Resolved]

Post by bosker »

The data declared in asm - in the DB statement - is used in Purebasic.
Which when wrapping the statements in EnableASM/DisableASM blocks, it works.
No, it doesn't. You can't write a DB statement without the !. When you write a statement with a ! at the beginning, you can't use a PB #Const.
This is where I fail to see the problem...
Ok.
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: Copy PbConstant value in variable ASM [Resolved]

Post by Foz »

bosker wrote:No, it doesn't. You can't write a DB statement without the !. When you write a statement with a ! at the beginning, you can't use a PB #Const.
And Comprehesion finally dawns on my rather slow mind - thank you :)
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5709
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Copy PbConstant value in variable ASM [Resolved]

Post by Kwai chang caine »

For good understanding my problem, i have try to create a little code with the problem :wink:

Code: Select all

; In the begining of all my program, i have numerous PbConstant for create a style of "Identity card" for each different soft

#NameOfSoftware = "Kcc Soft"
#VersionOfSoftware = "v1.0"
#DateCreationOfSoftware = "12/10/2010"
#ReferenceOfSoftware =  "1240"
#AgainCharacteristicOfSoftware = "xxxxx"
#AgainCharacteristicOfSoftware = "xxxxx"
#AgainCharacteristicOfSoftware = "xxxxx"
#AgainCharacteristicOfSoftware = "xxxxx"
#AgainCharacteristicOfSoftware = "xxxxx"
#AgainCharacteristicOfSoftware = "xxxxx"
#AgainCharacteristicOfSoftware = "xxxxx"
#AgainCharacteristicOfSoftware = "xxxxx"
#AgainCharacteristicOfSoftware = "xxxxx"
#AgainCharacteristicOfSoftware = "xxxxx"
#AgainCharacteristicOfSoftware = "xxxxx"
; .........
; .........
; .........
; .........
; .........
; .........

!SizeOfDataSection = 1000 ; <==== Here thanks to the code of Breeze4me i can choose the size of the datasection, :-)
#SizeOfDataSection = 1000 ; But here i'm forced to create the same line for have the value for PB :-(
; My goal is to find a way for using the value of !SizeOfDataSection in #SizeOfDataSection for have just one line, 
; because have To line can create error If the !SizeOfDataSection is different of #SizeOfDataSection

Restore my_data

For i = 1 To #SizeOfDataSection ; <== After at several time, i need to have the value of the DATA, and here IMPOSSIBLE TO USE ASM CONSTANT
 Read.c TheData ; it's the reason why, i need have the ASM value in a PbConstant
 Debug TheData
 x + 1
Next

Debug "Number of data = " + Str(x) 

DataSection
 my_data:
 
 !repeat SizeOfDataSection ; <== But here impossible to use the PBConstant :-((
  CompilerIf #PB_Compiler_Unicode
   !dw '*'
  CompilerElse
    !db '*'
  CompilerEndIf
!end repeat

EndDataSection
@FOZ
I have try your tips, but no chance...REPEAT is also a PB command :(
Furthermore i can't use EnableASM/DisableASM in dataSection :(

Code: Select all

EnableASM
   Repeat #SizeOfDataSection ; <== But here impossible to use the PBConstant :-((
  DisableASM 
ImageThe happiness is a road...
Not a destination

PureBasic French Forum
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: Copy PbConstant value in variable ASM [Resolved]

Post by Foz »

I think I understand what is going on now. KCC - you are trying to fight the PureBasic compiler:
- PureBasic keeps track of, and allows use of the ASM keywords - the keywords of the CPU.
- Repeat, If, While are *not* ASM keywords - they are keywords of the FASM compiler to help people who code in FASM; this is where the conflicts are arising.

Now this is entirely conjecture on my part, as I am not privy to the working of PureBasic, but this is how I'm guessing the ASM in PureBasic works:
- Inline ASM either through the IDE checkbox, commandline or EnableASM/DisableASM goes through the PB Compiler, which transforms the code into ASM recognisable output. This allows variables, constants and such like to be used with instructions like MOV, ADD, etc, but is completely incompatible with the FASM directives.
- The special ! pushes that line *directly* to FASM as it is written - nothing is changed, except for (and accessed completely differently) pointers and variables. Due to that, the FASM directives are within your grasp.

Now as it stands KCC, the ! method for declaring FASM constants is the only way you can manage what you are doing, because it's the pre-processors that you are having to talk to here - not the compilers.

What I think is needed is a Feature Request to add constants to the ! syntax so you can have one common constant that can be used in PB and passed through to the assembler directives.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5709
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Copy PbConstant value in variable ASM [Resolved]

Post by Kwai chang caine »

What I think is needed is a Feature Request to add constants to the ! syntax so you can have one common constant that can be used in PB and passed through to the assembler directives.
So if i good understand..it's not tomorrow i can do what i want :lol:
I'm very surprising, that FRED want to do this style of request for only KCC :shock:
Because apparently, i'm again the one to need this function, because i'm the first who ask this question :oops:
I think I understand what is going on now. KCC - you are trying to fight the PureBasic compiler
Fight !!!! :shock:Image

No no no...i come in peace.... :mrgreen:
I want to fight nobody...even the compiler :lol: :lol: :lol:
For KCC....everybody is kind in PB world...and KCC never fight the kind persons :lol:

So thanks to have tried to help KCC with his always impossible request :oops:
Have a good day
ImageThe happiness is a road...
Not a destination

PureBasic French Forum
Post Reply