NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: jdubya on December 07, 2013, 03:52:41 AM
-
Can anyone tell me how to convert this line of masm code to nasm?
mov array[ESI*Type array], '0'
-
You may need to show us how "array" is defined. Nasm wants the entire memory reference inside the square brackets, so...
mov [array + esi * ?], '0'
We will also need to specify a size. The character " '0' " looks like a byte to me. However, that would make "Type array" 1, and they probably wouldn't have mentioned it(?). Could be 2, 4, or 8 also. I would guess either:
mov byte [array + esi], '0'
or possibly:
mov dword [array + esi * 4], '0'
... there are other possibilities...
When I was doing a lot of Masm to Nasm conversion, I used to ask myself, "What does the code need to do here to make sense?" If you can't figure it out from that, show us more of the code..
Best,
Frank
-
You may need to show us how "array" is defined. Nasm wants the entire memory reference inside the square brackets, so...
mov [array + esi * ?], '0'
We will also need to specify a size. The character " '0' " looks like a byte to me. However, that would make "Type array" 1, and they probably wouldn't have mentioned it(?). Could be 2, 4, or 8 also. I would guess either:
mov byte [array + esi], '0'
or possibly:
mov dword [array + esi * 4], '0'
... there are other possibilities...
When I was doing a lot of Masm to Nasm conversion, I used to ask myself, "What does the code need to do here to make sense?" If you can't figure it out from that, show us more of the code..
Best,
Frank
It was defined like this:
array byte '0','1','2',0
array1 byte '3','4','5',0
array2 byte '6','7','8',0
I changed it to this:
array dd '0','1','2',0
array1 dd '3','4','5',0
array2 dd '6','7','8',0
-
Well... that's a different thing. If you want to not change the meaning...
section .data
array db '0', '1', '2', 0
array1 db '3', '4', '5', 0
array2 db '6', '7', '8', 0
;
; and then...
section .text
;
mov byte [array + esi], '0'
;
I don't know why the "* Type array" was in the original Masm code - I don't think it does anything. Of course, I could still be confused about what the Masm code is trying to do. Does it work as expected?
Best,
Frank