Ok iv'e been trying to figure out syntax for the register use and its 4 oclock in the morning and ive had several illegal operation errors in my windows even though they compile ok.

I tried these and my window works ok but the code is not used for anything in the program.

mov eax,

and

mov eax, ...........etc

does the second one here jump twice as far from the base?

and with mov eax, i get a compile error

If anyone can explain why i get these errors and perhaps the proper syntax for using the ASSUME directive i will be a happy man.

thanx
Posted on 2001-07-21 03:18:40 by titan
Titan,

Get yourself some sleep and then post what you are trying to do. There is a good section in the Intel manual number 1 on using an INDEX, DISPLACEMENT SCALE etc ...

What you need to get the swing of is that registers in square brackets are basically memory operands so if you have MOV EAX, you have copied the ADDRESS in the variable in the EBX register into EAX. Its called "dereferencing".

Regards,

hutch@pbq.com.au
Posted on 2001-07-21 06:09:22 by hutch--
Titan,

Here is the reference,

Look in this section of the Intel manual number 1
5.3.3.2 SPECIFYING AN OFFSET
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The nominal formula is as follows,

offset = base + (index * scale) + displacement

The Intel manual deals with this technique very well and it should help you with these addressing modes.

Regards,

hutch@pbq.com.au
Posted on 2001-07-21 08:42:25 by hutch--
Hutch....what i'm trying to do is get some info from a BITMAP structure.


invoke SelectObject,cdc,hBitmap
mov obitmap,eax
invoke GetObject,hBitmap,sizeof BITMAP,shb

mov ebx,shb
mov eax,
mov width,eax
invoke BitBlt,hdc,0,0,width,120,cdc,0,0,SRCCOPY

I'm trying to get the width of the bitmap to be used in a variable for bitblt. Then i can make a section of code that can be called for any size bitmap..... the above code is just experimentation. This will compile but program will crash.
Posted on 2001-07-21 14:31:30 by titan
What type does shb has? Is it the buffer itself? In that case, Change this:
invoke GetObject,hBitmap,sizeof BITMAP,shb

to this
invoke GetObject,hBitmap,sizeof BITMAP, ADDR shb

GetObject wants a pointer to a buffer, not the value in the buffer.
You should also change the mov ebx, shd to mov ebx, offset shd or lea ebx, shd.

Thomas
Posted on 2001-07-21 15:32:02 by Thomas
Additionally: the syntax of the ASSUME directive is simple. Take for example that ebx would point to a BITMAP structure. You can then use:


;assume ebx is a pointer to a bitmap structure:

ASSUME ebx: PTR BITMAP

;... do your stuff with ebx here like this:

mov eax, [ebx].bmWidth

;...when you're done, don't forget to
; close the assumption:

ASSUME ebx:nothing

; if you leave this line accidentally out, masm
; will think ebx is a pointer to a BITMAP
; structure in all further code


Thomas
Posted on 2001-07-21 15:35:26 by Thomas