I have defined the array in data segment like - myArray byte 01, 03, 02, 05
In the code I have a line mov eax, BYTE PTR myArray[ecx]
the assembler throws a build error here
instruction operands must be of the same size
What could be the reason for this. How do I fix this. I want to loop over this array and print it's
elements
TITLE Subtract Two Nums (SubTwoNums.asm)
; This program collects two numbers and subtracts the second from the first
INCLUDE Irvine32.inc
.data
prompt BYTE "Please enter a number: ", 0
data byte 0A9h
fib dword 01030205h
msg byte ", " , 0
dwordzeros DWORD 000000h
myArray dword 01, 03, 02, 05
.code
main PROC
mov eax, 0
mov ecx, 0
loop_start:
cmp ecx, 3
jge loop_end
mov eax, myArray[ecx]
call WriteDec
mov edx, offset msg
call WriteString
add ecx, 1
jmp loop_start
loop_end:
exit
main ENDP END main