我正在使用TASM 16位程序集处理项目,我似乎遇到了包含以下代码片段的循环问题:
assume cs:code,ds:code
code segment
start:
mov ah,1 ;read 1st digit from keyboard
int 21h ;add it to register
mov ch,10 ;prepare to multply by 10
sub al,'0' ;covert first digit to data from ascii
mul ch ;multiply first digit by 10
mov dl,al ;save digit to dl
mov ah, 1 ;read second digit
int 21h; ;save it to al register
sub al,'0' ;convert second value from ascii
add dl,al ;add al to furst value for final desired result
mov cl,2 ;set start point for squaring
reset:
mov bh,0
mov ch,0
add bh,cl
code ends
end start
但在重置后添加标签会导致"意外结束文件"错误:
assume cs:code,ds:code
code segment
start:
mov ah,1 ;read 1st digit from keyboard
int 21h ;add it to register
mov ch,10 ;prepare to multply by 10
sub al,'0' ;covert first digit to data from ascii
mul ch ;multiply first digit by 10
mov dl,al ;save digit to dl
mov ah, 1 ;read second digit
int 21h; ;save it to al register
sub al,'0' ;convert second value from ascii
add dl,al ;add al to furst value for final desired result
mov cl,2 ;set start point for squaring
reset:
mov bh,0
mov ch,0
loop1:
add bh,cl
code ends
end start
答案 0 :(得分:0)
我认为你的end start
错位了。我很确定需要在code ends
之前。让我想知道为什么在loop1:
缺失时你没有收到错误。 :)
答案 1 :(得分:0)
想出来,我使用的模拟器存在一个问题,即复制/粘贴我在记事本中编写的代码导致模拟器发生故障。手动输入每一行解决了问题。