如何在x86汇编跳转后返回主代码?



.stack 100h
.data    
~the offsets here
total db 0
mesajfinal db ' intrebari corecte din 4',13,10,'$'
**.code**
mov ax,@data
mov ds,ax
mov ah,9h

mov dx,offset m11
int 21h
mov ah,9h
mov dx,offset m12
int 21h
mov ah,9h
mov dx,offset m13
int 21h
mov ah,9h
mov dx,offset m14
int 21h
mov ah,1
int 21h
mov bl,al
cmp bl,'2'
je @CORECT
jmp @GRESIT

>**;there i want to continue after jump**
mov ah,9h
mov dx,offset m21
int 21h
mov ah,9h
mov dx,offset m22
int 21h
mov ah,9h
mov dx,offset m23
int 21h
mov ah,9h
mov dx,offset m24
int 21h
mov ah,1
int 21h
mov bl,al
cmp bl,'2'
je @CORECT
jmp @GRESIT


@CORECT:
inc total
mov ah, 2
mov dl,0ah
int 21h
mov dl,0dh
int 21h

@GRESIT:
mov ah, 2
mov dl,0ah
int 21h
mov dl,0dh
int 21h



mov dl,total
add dl,48
mov ah,2
int 21h

mov ah,9h
mov dx,offset mesajfinal
int 21h
mov ah,4ch
int 21h
end

我对汇编非常新,我试图在汇编x86中进行测验,其中问题和答案显示在屏幕上,用户输入答案(从1到3),如果它是正确的答案,它包括总分问题是,在第一个问题之后,它已经显示了最终的分数,跳过了其他问题

如果你不跳开,那么你就不需要跳回来

对于正确答案,增加total变量并输出换行符。
对于错误的答案,您只需输出一个换行符。

简单(简短)的解决方案是将换行符与消息一起输出(我添加了一个额外的字节10)$标记),然后对total变量进行局部递增。
提示:您可以一次输出4个字符串
...
m11 db 'In ce an a fost lansat procesorul Intel 8086?',13,10
db '1. 1980',13,10
db '2. 1978',13,10
db '3. 1986',13,10,10,'$'
m21 db 'In ce zi a fost lansat sistemul de operare WINDOWS 10?',13,10
db '1. 12 iulie 2014',13,10
db '2. 24 octombrie 2015',13,10
db '3. 29 iulie 2015',13,10,10,'$'
...
@Q1:
mov dx, offset m11    ;
mov ah, 09h           ; Just 1 output needed
int 21h               ;
mov ah, 01h
int 21h
cmp al, '2'           ;
jne @Q2               ;
inc total             ; Do this locally (close to the Q/A)
@Q2:                    ;
mov dx, offset m21
mov ah, 09h
int 21h
mov ah, 01h
int 21h
cmp al, '2'
jne @Q3
inc total
@Q3:
...
@Final:
mov dl, total
add dl, 48
mov ah, 02h
int 21h
...

最新更新