In my venture to customize and hide some of the stuff, I stumble along this.. spent an hour searching through the forum until I was light-headed and at my wits end for what I know is a simple answer and then I will say 'doh!' and slap myself on the head once again:




Paint_Proc proc hDC:DWORD, x:DWORD, y:DWORD, XWid:DWORD, YWid:DWORD, lstyle:BYTE, lcolor:DWORD

LOCAL hPen :DWORD
LOCAL hPenOld :DWORD
LOCAL hBrush :DWORD
LOCAL hBrushOld :DWORD

LOCAL lb :LOGBRUSH

invoke CreatePen,0,1,lcolor
mov hPen, eax
; lbstyle was BS_SOLID

mov lb.lbStyle, lstyle
mov lb.lbColor, lcolor
mov lb.lbHatch, NULL

It gives me an invalid instruction error. I tried moving the lstyle to AL, AX, EAX, I still can't make any progress.

The BYTE does not agree with the DWORD. Also from what I understand, I cannot move memory to memory data. Must be to a register.

What would be the syntax to get the above to work properly? I assume I need to also move lcolor to a 16-bit register, then move the register to the lb.lbColor...

Thank you for your time =)
Posted on 2001-08-31 16:30:00 by drarem
Hey, heres a tip when troubleshooting... You can read and trust all the references you want, but the bottom line is what the compiler gets to see.

Everything on the surface would appear to be ok (which is why your posting this), the only place a prob would be (if there is as the compiler is suggesting), would be in:

mov lb.lbStyle, lstyle

lb.lbStyle is part of a structure, so we check the API reference and get:
typedef struct tagLOGBRUSH { // lb

UINT lbStyle;
COLORREF lbColor;
LONG lbHatch;
} LOGBRUSH;


Unsigned int eh?, sound odd to me ~ remember this was written for C++ folk. The bottom line is what the compiler gets to read. So next i check Windows.inc (where all structs are defined (well most)).
LOGBRUSH STRUCT
lbStyle DWORD ?
lbColor DWORD ?
lbHatch DWORD ?
LOGBRUSH ENDS


Ahh ha!.. now it makes more sense!.. Your trying to move a BYTE into a DWORD... and the compilers doesnt like it...

Solution: change the param to :DWORD or do something like this:


xor eax, eax
mov al, lstyle
mov lb.lbStyle, eax


I wouldnt slap your head over this :) , its easy to TRUST what you read..

NaN

Oh!! Ya, I almost over looked this, This is realy the problem (the above is just me blabbering, take what you can from it ;) ). You cant MOV from memory to memory!! "lstyle" is on the stack segment (in memory) and your trying to place it in "lb.lbStyle" which is also in stack memeory. So my solution gets around this as well, by using eax as a swapping register. You could also use push/pop like this:



push lstyle
pop lb.lbStyle


I dont use this alot, but if i remember, pushing a byte will actually push a full DWORD with the leading 24 bits 0'd.

Anyways, hope i helped... (and not confused you :) )
NaN
Posted on 2001-08-31 16:55:21 by NaN
Nan -

thank you :) works great!


what i did try was:

mov al,lstyle
mov lb.lbStyle, ax <==== I kept thinking in 8 bit terms

Now I get it that eax = extended ax? = doubleword. And I see now why you can't move from memory to memory, as the data is stored in the stack.

Need to have the win32api reference handy. Forgot about the push lstyle and pop lb.lbStyle, making a mental note - ouch!..

I am forever in your debt.. and the debt isn't gettin any smaller.
Posted on 2001-08-31 17:18:12 by drarem
al = register ax low 8 bits
ah = register ax high 8 bits
ax =
eax = [16 bits]

so If I were to mov al, 0ffh
this is what it would look like:
eax: 000000ffh
ax:00ffh
ah:00h
al:0ffh

mov ah, 0ffh
eax: 0000ff00h
ax: 0ff00h
ah: 0ffh
al: 00h

same goes for all the other registers, just exchange the register letter... bx, bl, bh, cx, ch, cl, dx, dh, dl

sorta see it now?
Posted on 2001-08-31 23:13:31 by Kenny