我编写了一个代码来计算16位x86汇编语言中数组元素的平均值。它适用于32h
和C8h
元素,但当我把190h
错误发生在LEA si, array
。为什么?x86汇编语言中的LEA错误
数组的前2个字节表示数组大小。
我使用emu8086。
data segment
array db 32h, 00, 3, -10, 7, 14, 9, 3, -10, 7, 14, 9, 3, -10, 7, 14, 9, 3, -10, 7, 14, 9, 3, -10, 7, 14, 9, 3, -10, 7, 14, 9, 3, -10, 7, 14, 9, 3, -10, 7, 14, 9, 3, -10, 7, 14, 9, 3, -10, 7, 14, 9
min db ?
max db ?
msg_average db 'The average = $'
msg_min db 'The minimum element is: $'
msg_max db 'The maximum element is: $'
xxh dw ?
xxl dw ?
ends
stack segment
dw 128 dup(0)
ends
code segment
start:
lea ax, data
mov ds, ax
mov es, ax
;Getting array size
lea si, array ; HERE IS THE ERROR
mov cx, [si]
;Moving si to the location of the first element
mov si, 0002h
.
.
.
.
你会得到什么错误?当您尝试使用0190h大小时,您可以显示代码吗? – Devolus