Hi everyone, i'm learning assembler so maybe this is an easy question.
I need to know why does this code throws this error:
bitmap.asm(322) : error A2029: multiple base registers not allowed
mov ofst, eax
mov eax, memDC
mov ebx, [hBmpBack]+ofst
mov [memDC]+ofst, ebx ;this is line 322
Thanks
You don't show us what these variables are, i.e. local or global dwords etc
Are you sure you don't want this?
mov ofst, eax
mov eax, memDC
mov ebx, hBmpBack
add ebx, ofst
mov memDC, ebx ;this is line 322
Looks like he wants to move a dword from the hBmpBack array to the memDC array. An alternative could be:
mov ofst,eax ;only if required to store ofst for future use
mov ebx,hBmpBack
mov ebx,[ebx+eax] ;EBX = dword from hBmpBack+ofst
add eax,memDC ;EAX = memDC+ofst
mov [eax],ebx
masitecno,
The problem is with your indirect memory operands. In 32-bit code any 32-bit register can serve as a base or index register, and an indirect memory operand can include one base register, one index register, with an optional scaling factor of 1, 2, 4, or 8, and any number of displacements. So for example, all of these statements will assemble without error:
mov eax, [ebx] ; base
mov eax, [ebx+4] ; base+displacement
mov eax, [ebx+ecx] ; base+index
mov eax, [ebx+ecx*4] ; base+index*scalingfactor
mov eax, [ebx+ecx*4+8] ; base+index*scalingfactor+displacement
mov eax, memDC[ebx] ; base+displacement
mov eax, [memDC][ebx] ; base+displacement
mov eax, [memDC+ebx] ; base+displacement
mov eax, [memDC+ebx*4] ; index*scalingfactor+displacement
mov eax, [memDC+ebx+ecx*4+8] ; base+index*scalingfactor+displacement
mov eax, [memDC+ebx+ecx*4][8] ; base+index*scalingfactor+displacement
Note that MASM effectively treats the index operator (square brackets enclosing an index value) as a plus operator, and that multiple displacements are effectively combined into one.
Thanks Everyone for your help!
Well let me explain what am i trying to do:
I load a bitmap into 2 global vars
invoke LoadBitmap,hInstance,100
mov hBmp, eax
mov hBmpBack, eax
I show one of them in a window
invoke BitBlt,hDC,0,0,768,576,memDC,var1,0,SRCCOPY
I apply an algorithm to the hBmpBack that moves all the image 1 pixel to the left to emulate a banner (moving to the left)
In the algorithm i need to move the pixels from de hBmpBack to the hBmp to show it again using bitblit.
Mov Eax, 00H
Mov j, Eax
repeatRows:
Mov Eax, init
Mov k, Eax
Mov Eax, maxX
Dec Eax
Mov i, Eax
repeatCols:
push eax
push ebx
mov eax, k
mov ebx, j
mul ebx
mov ofst, eax
mov eax, memDC
mov ebx, [hBmpBack]+ofst
;mov memDC[ofst], ebx ;set pixel in change bitmap
DEC k
mov eax, k
cmp eax, -1
je cilinderK
jmp continue
cilinderK:
mov eax, maxX
dec eax
mov k, eax
jmp continue
continue:
Mov Eax, i
Dec Eax
Mov i, Eax
Cmp i, 0
Jne repeatCols
Mov Eax, maxY
Mov Ebx, j
Cmp Eax, Ebx
Jb repeatrows
Mov Eax, init
Inc Eax
Mov init, Eax
Mov Ebx, maxY
Dec Ebx
Cmp Eax, Ebx
Jg setzero
endroutine:
Xor Eax, Eax
Ret
setzero:
Mov Eax, 0
Mov init, Eax
Jmp endroutine
It was when i was trying to send the bitmap i've gotten in eax to the other variable
bitmap.asm(322) : error A2029: multiple base registers not allowed
mov ofst, eax
mov eax, memDC
mov ebx, [hBmpBack]+ofst
mov [memDC]+ofst, ebx ;this is line 322
So I'm gonna try all the help you nicely gave me to fix this up.
But if you see any other wrong thing in my code, please let me know, i will appreciatte it very much.
Thanks to all.
well - you store the bitmap handle twice
that does not create 2 seperate copies :P
if you want to make a copy:
1) get a DC (desktop should work)
2) create a compatible DC for the original bitmap (DC 1)
3) select the original bitmap into DC 1 - save the previous value
4) create a compatible DC for the copy (DC 2)
5) create a compatible bitmap - save this handle as your copy bitmap handle
6) select the compatible bitmap into DC 2 - save the previous value
7) blit it from DC 1 to DC 2
8) select the original bitmap back into DC 2
9) delete DC 2
10) select the original bitmap back into DC 1
11) delete DC 1
12) release the desktop DC
when you are done using the copy bitmap, use DeleteObject to get rid of it
that sounds like a lot of trouble - lol
it's not as bad as you might think
now - a simpler way might be to use LoadImage instead of LoadBitmap
load the same bitmap twice - be sure to use the proper flags
you should be able get 2 non-aliased handles
Oh!
I didn't copy a line. Does this code is doing the same? or it loads 2 copies?
invoke LoadBitmap,hInstance,100
mov hBmp, eax
invoke LoadBitmap,hInstance,100
mov hBmpBack, eax
that's probably ok - you'll have to try it
just note that LoadImage is prefered
i happen to remember that LoadImage has a flag for sharing a handle
so - it follows that it must be capable of creating individual handles :P