Everything else that doesn't fall into one of the other PB categories.
Polo
Addict
Posts: 2422 Joined: Tue May 06, 2003 5:07 pm
Location: UK
Post
by Polo » Mon Feb 16, 2004 6:51 pm
I'm searching an alternative to all the peek/poke function, I mean, I want to do the same things as these functions do, but without using them. Is it possible ?
If yes, ... how ?
Kale
PureBasic Expert
Posts: 3000 Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:
Post
by Kale » Mon Feb 16, 2004 6:55 pm
er...why?
--Kale
Polo
Addict
Posts: 2422 Joined: Tue May 06, 2003 5:07 pm
Location: UK
Post
by Polo » Mon Feb 16, 2004 7:00 pm
Because I'm searching to do things more complicated than they are actually
And because the size of the misc memory is 4.45k, and it's too big for me
coma
Enthusiast
Posts: 164 Joined: Fri Aug 15, 2003 3:46 am
Location: Canada
Post
by coma » Mon Feb 16, 2004 8:27 pm
or use asm.
poke :
Code: Select all
MOV eax,val
MOV edi,*mem
MOV [edi],eax
peek:
Code: Select all
MOV edi,*mem
MOV eax,[edi]
MOV val,eax
Polo
Addict
Posts: 2422 Joined: Tue May 06, 2003 5:07 pm
Location: UK
Post
by Polo » Mon Feb 16, 2004 11:09 pm
Coma => Amazing ! It works fine !
Polo
Addict
Posts: 2422 Joined: Tue May 06, 2003 5:07 pm
Location: UK
Post
by Polo » Mon Feb 16, 2004 11:25 pm
Edit: Sorry, I made a mistake
Polo
Addict
Posts: 2422 Joined: Tue May 06, 2003 5:07 pm
Location: UK
Post
by Polo » Mon Feb 16, 2004 11:37 pm
I can't make it work for byte...
*MemoryBuffer = AllocateMemory(0, 16, 0)
byte.b=1
MOV eax,byte
MOV edi,*MemoryBuffer
MOV [edi],eax
Froggerprogger
Enthusiast
Posts: 423 Joined: Fri Apr 25, 2003 5:22 pm
Contact:
Post
by Froggerprogger » Mon Feb 16, 2004 11:58 pm
You have to specify the operand size, because EAX doesn't match with byte. Therefore you have to use ASM-syntax directly (by using a ! at start of the line) and therefore you have to refer to your variable's value as [v_variable].
Code: Select all
*MemoryBuffer = AllocateMemory(0, 16, 0)
byte.b=1
!MOV eax, dword [v_byte]
MOV edi,*MemoryBuffer
MOV [edi],eax
Read the flatassembler-help for all details. You get it here:
http://www.flatassembler.net
%1>>1+1*1/1-1!1|1&1<<$1=1
Kale
PureBasic Expert
Posts: 3000 Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:
Post
by Kale » Tue Feb 17, 2004 12:12 am
Polo wrote: Because I'm searching to do things more complicated than they are actually
And because the size of the misc memory is 4.45k, and it's too big for me
lol 8O
--Kale
Pupil
Enthusiast
Posts: 715 Joined: Fri Apr 25, 2003 3:56 pm
Post
by Pupil » Tue Feb 17, 2004 12:18 am
this should work without the '!' stuff...
Code: Select all
byte.b
*memorybuffer = @byte
MOV al, byte
MOV edi, *memorybuffer
MOV [edi], al
Froggerprogger
Enthusiast
Posts: 423 Joined: Fri Apr 25, 2003 5:22 pm
Contact:
Post
by Froggerprogger » Tue Feb 17, 2004 1:34 am
The rest of the eax is not resetted when copying to al only, so you would have to be very careful in the following not to use MOV [edi], eax
%1>>1+1*1/1-1!1|1&1<<$1=1
filperj
User
Posts: 77 Joined: Tue Sep 16, 2003 8:53 pm
Location: Nevers(France)
Post
by filperj » Tue Feb 17, 2004 4:34 am
They say you have to protect every register exept EAX and EDX when writing a userlib, maybe should do the same for an inline-asm block... No?
:roll: I wonder what really need to be protected or not...
Fred
Administrator
Posts: 18350 Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:
Post
by Fred » Wed Feb 18, 2004 5:43 pm
Using pointer as freedimension said is the way to go. It's the same than using asm but much more easier
Polo
Addict
Posts: 2422 Joined: Tue May 06, 2003 5:07 pm
Location: UK
Post
by Polo » Wed Feb 18, 2004 6:22 pm
I have maked the function works with ASM
I don't know why, but I understand it better than pointer 8O