DosBox is buggy with int 15h ah = 86h

无人久伴 提交于 2021-02-11 08:46:11

问题


I am currently working on an assembly program, but I need to make the program wait every once in a while.

So, I have been using int 15h/ah = 86h, but for some reason DosBox is giving me a hard time, and the program either gets confused with pixels (wierd colors) or in the worse case; crash.

Can someone please help me?


回答1:


I had this issue as well. Based on the answer at Problems with BIOS delay function (INT 15h / AH = 86h), I was able to get it working by making sure to set AL to zero before calling the interrupt:

    mov     counter, 10
L1:

    mov     cx, 0007H
    mov     dx, 8480H
    mov     ah, 86h
    mov     al, 0
    int     15h

    mov     dl, '*'
    mov     ah, 02h
    int     21h

    dec     counter
    jnz     L1

(the program prints 10 *'s, pausing for 1 second between each.) With out the 'mov al, 0', the program would hang or give other undefined behavior while DOSBox spews illegal read/write messages. By setting al to zero, the program works correctly but, strangely, error messages still appear on the DOSBox log.




回答2:


Replace int 15h by something else, for example a procedure that waits "n" seconds:

.stack 100h
.data.

text     db 'text$'
seconds  db 99
delay    db ?  ;HOW MANY SECONDS TO WAIT.

.code          
  mov  ax, @data
  mov  ds, ax     ;INITIALIZE DATA SEGMENT.

forever:                      
  mov  delay, 5  ;DELAY 5 SECONDS.
  call my_delay  ;◄■■ CALL PROCEDURE HERE.
;DISPLAY TEXT EVERY 5 SECONDS.
  mov  ah, 9
  mov  dx, offset text
  int  21h       
  jmp  forever

  mov  ax, 4c00h
  int  21h       ;FINISH PROGRAM.

;--------------------------------------------------------
;PROCEDURE TO WAIT "N" SECONDS.
;SECONDS ENTER IN VARIABLE "DELAY".
;VARIABLE "SECONDS" MUST EXIST. USED AS LOCAL COUNTER.

my_delay proc  
delaying:   
;GET SYSTEM TIME.
  mov  ah, 2ch
  int  21h ;RETURN SECONDS IN DH.
;CHECK IF ONE SECOND HAS PASSED. 
  cmp  dh, seconds
  je   delaying
;IF NO JUMP, ONE SECOND HAS PASSED. VERY IMPORTANT : PRESERVE
;SECONDS TO USE THEM TO COMPARE WITH NEXT SECONDS. THIS IS HOW
;WE KNOW ONE SECOND HAS PASSED.
  mov  seconds, dh
  dec  delay   
  jnz  delaying  ;IF DELAY IS NOT ZERO, REPEAT.

  ret 
my_delay endp


来源:https://stackoverflow.com/questions/43194265/dosbox-is-buggy-with-int-15h-ah-86h

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!