0

test.asm

program_intialization:
     org 0x7C00
     mov bp,0x7C00
program_start:
    mov ax,0x0013
    int 0x10
    mov ax,0x0002
    int 0x10
    
    mov al,0x41
    call output
    call input

library:
    %include "io.asm"

times 510-($-$$) db 0
dw 0xaa55
program_end:
   jmp $

io.asm (1)

input:
    call intialize
    mov ah,0x00             ;reading keyboard code
    int 0x16
    cmp al,0x0D
    je  end                 ;call bios to read it                    
    mov ah,0x0E
    mov bl,0x000F
    int 0x10
    jmp input
output:
    call intialize
    mov ah,0x0E
    int 0x10
    jmp end
intialize:
    push ax
    push bx
    ret
end:
    pop bx
    pop ax
    ret

io.asm (2)

input:
    push ax
    push bx
    mov ah,0x00             ;reading keyboard code
    int 0x16
    cmp al,0x0D
    je  end                 ;call bios to read it                    
    mov ah,0x0E
    mov bl,0x000F
    int 0x10
    jmp input
output:
    push ax
    push bx
    mov ah,0x0E
    int 0x10
    jmp end
end:
    pop bx
    pop ax
    ret

in case of io.asm (1) :

  • in qemu the screen blinks blue lines and doesn't output nor input
  • in bochs it doesn't output and while input it gives this error : internal keyboard buffer full , ignoring scan code (the scan code)

in case of io.asm (2) :

  • it works fine .

so :

  1. what is the difference between io.asm (1) & io.asm (2)
  2. why this error happens
  3. what is the solution
  • 2
    `push bx / ret` will jump to whatever value was in `bx`, which apparently is garbage. Subroutines implemented with `call / ret` have to balance the stack or they won't return to the right place. You can't `call` a subroutine to push or pop registers for you. – Nate Eldredge Apr 06 '22 at 07:33

0 Answers0