首页 文章

如果零相对1则跳转

提问于
浏览
0

我有以下asm代码(x86) .

.input:
mov ah, 00h         ; get key from keyboard buffer
int 16h         ; interrupt 16h 
mov dl, al      ; move ASCII code into dl
mov ah, 02h     ; function 02
int 21h         ; interrupt 21h
mov ah, 0Eh     ; tell the BIOS to print the character in the AL register
mov al, dl      ; copy dl into al
int 10h         ; print al
sub al,0Dh      ; check if it's carriage return
jz 01h          ; jump relative 1 (to skip newLine)
call newLine        ; add CR LF
jmp .input      ; loop

但是,如果零指令的跳转没有按预期工作(希望),即jz 01h .

我想跳过相对1指令(或加一个IP),跳过调用newLine子程序 .

目前,当我按下回车键并调用jz指令时,我相信该程序在程序运行的早期就像一段代码一样跳跃 .

有任何想法吗?

谢谢,史蒂夫

2 回答

  • 5

    跳跃01h实际上不会跳过调用,因为它计算字节数,而不是指令数 . 调用指令由多个字节组成 . 为什么不在你可以跳转到的电话之后添加另一个标签,比如jz .afterCall?

  • 1

    关于什么

    jz _no_newLine      ; jump 
    call newLine        ; add CR LF
    _no_newLine:
    jmp .input          ; loop
    

相关问题