Need Help error A2155: cannot use 16-bit register with a 32-bit address

Started by bala_j, May 09, 2007, 06:29:13 AM

Previous topic - Next topic

bala_j

Hi,

I am new to assembly programming . I am trying to copy the array elements. It is throwing error but i am not able to figure out, kindly help


; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    .486                                ; create 32 bit code
    .model flat, stdcall                ; 32 bit memory model
    option casemap :none                ; case sensitive
 
    include \masm32\include\windows.inc
    include \masm32\include\masm32.inc
    include \masm32\include\gdi32.inc
    include \masm32\include\user32.inc
    include \masm32\include\kernel32.inc
    include \masm32\include\Comctl32.inc
    include \masm32\include\comdlg32.inc
    include \masm32\include\shell32.inc
    include \masm32\include\oleaut32.inc
    include \masm32\include\msvcrt.inc

    includelib \masm32\lib\masm32.lib
    includelib \masm32\lib\gdi32.lib
    includelib \masm32\lib\user32.lib
    includelib \masm32\lib\kernel32.lib
    includelib \masm32\lib\Comctl32.lib
    includelib \masm32\lib\comdlg32.lib
    includelib \masm32\lib\shell32.lib
    includelib \masm32\lib\oleaut32.lib
    includelib \masm32\lib\msvcrt.lib

    .data?


    .data
     double REAL8 0.1,1.0,10.0, 100.5, 1000.0, 400.0, 40.5, 60.6,8.9,10.1
     count db 0ah

    .code

start:

 
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
;
;   write your code here

    Lea si, double
    Mov cl, count
    Mov al,[si] ; A2155: cannot use 16-bit register with a 32-bit address


;
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

end start

sinsi

You need to use 32-bit registers for 32-bit addresses i.e. ESI instead of SI

    Lea esi, double
    Mov cl, count
    Mov al,[esi]
Light travels faster than sound, that's why some people seem bright until you hear them.

hutch--

The error message is telling what the problem is. An address in 32 bit is a 32 bit operand, not 16 bit as you have tried.


    Lea esi, double    ; use ESI, the 32 bit version of the register.
    Mov cl, count
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php