;program starts
TABLE DB 0, 2, 0, 2, 0, 0, 4, 0, 0, 1, 0, 0, 3, 0, 1, 0
TABLE1 DB ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
MOV SI, OFFSET TABLE
MOV DI, OFFSET TABLE1
MOV AL, [SI]
MOV [DI], AL
MOV AL, [SI+1]
MOV [DI+4], AL
MOV AL, [SI+2]
MOV [DI+8], AL
MOV AL, [SI+3]
MOV [DI+12], AL
MOV AL, [SI+4]
MOV [DI+1], AL
;program ends
这是一个简单的代码,用于复制来自' TABLE'到表1'当我在emu8086中运行该程序时,值[SI]显示在AL寄存器中(MOV AL,[SI])。 ' TABLE'中的值因此在AL寄存器中显示,并且在逻辑上应该相同。但是当线路“MOV AL”,[SI + 1]'执行时,AL寄存器显示4而不是2.如果我用3替换第二个元素,Al寄存器显示6而不是3.任何人都可以解释这个事件背后的原因以及如何对付它?
答案 0 :(得分:0)
EMU的汇编程序需要一些代码中缺少的结构:
.model small ◄■■■ PROGRAM SIZE.
.stack 100h ◄■■■ STACK SEGMENT DECLARATION.
.data ◄■■■ DATA SEGMENT DECLARATION.
TABLE DB 1, 2, 3, 4, 5, 0, 4, 0, 0, 1, 0, 0, 3, 0, 1, 0
TABLE1 DB ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
.code ◄■■■ CODE SEGMENT DECLARATION.
mov ax, @data ◄■■■ INITIALIZATION
mov ds, ax ◄■■■ OF DATA SEGMENT.
MOV SI, OFFSET TABLE
MOV DI, OFFSET TABLE1
MOV AL, [SI]
MOV [DI], AL
MOV AL, [SI+1]
MOV [DI+4], AL
MOV AL, [SI+2]
MOV [DI+8], AL
MOV AL, [SI+3]
MOV [DI+12], AL
MOV AL, [SI+4]
MOV [DI+1], AL
mov ax, 4c00h ◄■■■ FINISH PROGRAM PROPERLY.
int 21h
使用此结构,您的代码可以正常工作(为了测试目的,我替换了TABLE
的某些值)。