Page 1 of 1

Low word without peek?

Posted: Wed Jun 11, 2003 11:33 pm
by Justin
Is there any way(i guess using shift operators) to get the low word of a long without using peekw(@long) ? , i do this to reduce exe size.

i did this asm proc but i think can be done using operators ¿?

Code: Select all

procedure peekw_(hbuf)
r.w
mov edi,hbuf 
mov ax,word [edi]
mov r,ax
procedurereturn r
endprocedure

Posted: Wed Jun 11, 2003 11:38 pm
by freak

Code: Select all

LoWord = Long & $FFFF
HiWord = Long >> 16
Timo

Re: Low word without peek?

Posted: Wed Jun 11, 2003 11:43 pm
by traumatic
loWord = var.l & $FFFF
hiWord = var.l >> 16

Re: Low word without peek?

Posted: Wed Jun 11, 2003 11:44 pm
by traumatic
ahhhh, too late... damn dial-up!

Posted: Wed Jun 11, 2003 11:46 pm
by Justin
Ok thanks, much easier. Do you know if it's faster or slower?, i'll use to process the WM_COMMAND msg inside the window callback.

Posted: Thu Jun 12, 2003 12:12 am
by tinman
Justin wrote:Ok thanks, much easier. Do you know if it's faster or slower?, i'll use to process the WM_COMMAND msg inside the window callback.
Don't know about quicker, but I guess using the & and >> operators would be preferrable as your peek method relies on little endian byte ordering (i.e. would not work on 68k, probably not on PPC depending on what mode it was in). I guess it only matters if you care about portability and hope that there is one day a PPC/Linux or Mac version of PB ;)

I think Fred once said that simple commands like Peek, Sin, etc were all made inline by the compiler, but I could be wrong.

Posted: Thu Jun 12, 2003 1:01 am
by El_Choni
Freak's code is much faster than calling that peekw procedure, no doubt.