Page 1 of 1

Posted: Wed Dec 25, 2002 12:11 pm
by BackupUser
Restored from previous forum. Originally posted by Denis.

Hi,

is it possible to get an adress of a string constant in PB ?
i.e.

#Try ="PB"
adress.l

i want to put the adress of #Try into adress
adress=@#Try don't run (@ only for variable)
(if #Try is not used before, PB compiler doesn't declare it in ASM; but even if it used before, i don't be able to get the adress even using ASM code)

Thanks :)


Denis

Posted: Wed Dec 25, 2002 12:54 pm
by BackupUser
Restored from previous forum. Originally posted by Danilo.

Code: Select all

#Try ="PB"
*address.s = #TRY  ; get Pointer to this String

MessageBox_(0,PeekS(*address),*address,0)
cya,
...Danilo

(registered PureBasic user)

Posted: Thu Dec 26, 2002 11:00 am
by BackupUser
Restored from previous forum. Originally posted by Denis.

Hi Danilo and Thanks :).

I try to obtain the adress of constant without using pointer as it can be done using ASM (Win32 etc.).

will it be possible in a futur version of PB to obtain an adress of constant in a simpler way... :)

Denis

Posted: Thu Dec 26, 2002 2:46 pm
by BackupUser
Restored from previous forum. Originally posted by Danilo.

How do you get a pointer to a constant in ASM ??

IMO, thats not possible. Constants are 'nothing', they
are not compiled nor assembled in the executable.
For strings, its the same in ASM: you can get a pointer
to the string, thats all.

Constants are values (or strings) that give a value
at compile/assemble time, thats very different from
variables.

cya,
...Danilo

(registered PureBasic user)

Posted: Fri Dec 27, 2002 12:09 pm
by BackupUser
Restored from previous forum. Originally posted by tinman.
Originally posted by Danilo

How do you get a pointer to a constant in ASM ??

IMO, thats not possible. Constants are 'nothing', they
are not compiled nor assembled in the executable.
Maybe Denis means getting the address of the string contents in the executable (as they would need to be stored somewhere if they are used in the program)?


--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.40)

Posted: Sat Dec 28, 2002 1:46 pm
by BackupUser
Restored from previous forum. Originally posted by Denis.

Hi Danilo and Tinman.

‘In ASM, Constants are 'nothing', they are not compiled nor assembled in the executable’.

I agree with you, you are completely right. I wrote a big Stupidity about ASM constants...

It is because I thought of the way witch string constants are declared in ASM by PB, i.e. in data section. PB Constants are different from those in ASM


‘Maybe Denis means getting the address of the string contents in the executable (as they would need to be stored somewhere if they are used in the program)?’
You’re right Tinman. That’s what I wanted to do.

Sometimes, my ideas become muddled…

Have a nice day.

Salut
Denis,
PB beginner user

- - - - - - - - - - - - - - - - - - - - - - - -
#Try="PB string Constant" - -> a sring constant
b.s=#Try - -> a sring var
c.l=@b

In PB ASM generated File

; #Try="PB string Constant" - -> no ASM code generated
; b.s=#Try
MOV edx,dword _S149 --> _S149 = mnemonic of #Try in data section
LEA ecx,[v_b]
CALL PB_FastAllocateStringFree
;
; c.l=@b
MOV eax,dword [v_b]
MOV dword [v_c],eax

SEGMENT .data CLASS=DATA
;
_S149: db "PB string Constant",0

;
SEGMENT .bss CLASS=DATA2
;
v_b RESD 1
v_c RESD 1

Posted: Sat Dec 28, 2002 7:31 pm
by BackupUser
Restored from previous forum. Originally posted by Danilo.

Is *String1 = @"Testing" enough for you ??

cya,
...Danilo

(registered PureBasic user)

Posted: Tue Jan 07, 2003 9:11 am
by BackupUser
Restored from previous forum. Originally posted by Denis.

Hi Danilo,

that's what i'm looking for ...
Tks again for your help.

Salut


Denis