indirect addressing when not using extended registered in DosBox

Started by Steven, October 30, 2009, 09:07:39 PM

Previous topic - Next topic

Rockphorr

Quote from: Steven on October 30, 2009, 09:07:39 PM
Hello,
I am trying to use indirect addressing to access elements in array.   The program is to run in a DOSBox environment .... so extended registers are not available, such as  esi

I get error which indicates the size of the operands are not equal when I do this

Mov si, offset name_of_array

It works fine if I code this
mov esi, offset name_of_array

but then when I try to store this value in esi  into a variable so I can later use it

address_of_start_of_array  dw ?
:
:
Mov  address_of_start_of_array, esi      I get same error ...  the size of esi is different than the variable   address_of_start_of_array

I think this is because there are 32 bits in the address  and si is a 16 bit register and dw variables are 16 bits

I have see two possibilities:

1. change the directives to MASM  to make it think it is assembling for a 16bit address space ...  does anyone know how to do this?   If this could be  done, would that stop the debugging functions, such as those in
.include \masm32\include\debug.inc        which I must have, at least until I get it to work the first time.


2. define a variable that is 32 bits in length ..    so that the   mov variable,esi   would work .... does anyone know how to do this ?   If I do this, then, after I get the code developled in MASM, I would move to a crappy assembler in DOSBox and take out the esi and put in si  and recompile.


Any help would be appreciated.




you must understand what is the size of operands.



Strike while the iron is hot - Бей утюгом, пока он горячий

Rockphorr


sample for you

array db 16 dup (0)

array_ofs dw offset(array)
...

mov SI,array_ofs
mov AL,'A'
mov [SI],AL ; just after 1 element of array will letter A
....

lea SI,array
mov AL,'B'
mov [SI+1],AL ; just after 2 element of array will letter A

....
mov SI,array_ofs
add SI,2
mov array_ofs,SI
...
mov BX,array_ofs
mov AL,'C'
mov [BX],AL ; just after 3 element of array will letter C

:8)
Strike while the iron is hot - Бей утюгом, пока он горячий

Steven

Thank you all for you many thoughtful responses.   I  tried seveal ideas from them, including instructing MASM to use 16 bit mode using   CODE    SEGMENT USE16     which then prevented the debug features (PrintHex & PrintText) from working ... so I used the idea of setting the variable which hold the address as  DD  and was careful to use only   esi as the register to hold the address of the arrays. 

address_of_start_of_array  DD ?


mov esi, offset data_array
mov [address_of_start_of_array],esi

When I move back to dosbox, after getting the program to work well,  I will  change the DD to DW and change   esi to si     and I expect to be OK

Thanks again, Steven