delay using INT 1ah

i'm trying to play with delay for animation using 1ah - should be pretty simple, but the animation sequence holds and appears to be in an infinite loop so the image never moves. i'll attach two files below:

mydelay.asm is the file that is called by the main animation (myan.asm) file to cause a delay of an amount that is put in the bx register in myan.asm (in this case, 20 ticks)

subint.asm is the file used to call the interrupt 1ah. i am told i have to separate the interrupt call into its own sub proc for the health and safety of my computer.

what is happening is that it compiles fine, but it never seems to leave the "tloop" in mydelay.asm. can anyone see what the problem is?

thanks!

//myan.asm has put a value of 20 into dx before this is called
mydelay.asm:

INCLUDE PCMAC.INC
.MODEL SMALL
.586
.DATA

.CODE
EXTRN PutHex : NEAR, SubInt : NEAR
DELAY PROC
PUBLIC DELAY

push ax
push bx
push cx
push dx


mov ah, 0
mov dx, 0
mov cx, 0
call SubInt
add bx, dx ; now bx holds the desired num. of ticks

tloop:
mov ax, 0
mov cx, 0
mov dx, 0
call SubInt
.IF dx < bx
jmp tloop
.ENDIF


pop dx
pop cx
pop bx
pop ax

ret

DELAY ENDP

END



subint.asm:

INCLUDE PCMAC.INC
.MODEL SMALL
.586

.DATA


.CODE

SubInt PROC
PUBLIC SubInt

push ax
push bx
push cx
push dx

INT 1ah ; puts number of ticks since midnight into cx:dx

pop dx
pop cx
pop bx
pop ax

ret

SubInt ENDP

END

Comments

  • now i kinda destroyed your code here but it works in nasm the way it sits now you will probably have to convert it back to whatever you where programming in.

    ; on entrance bx = number of ticks to wait as not to interfer with dx -
    ; wich will contain the count
    DELAY:
    push ax
    push bx
    push cx
    push dx

    mov ah, 0 ; only AH needs to be zero for call
    INT 1ah ; took out subint because you only need this
    add bx, dx ; now bx holds the desired num. of ticks

    tloop:
    mov ah, 0 ; only AH needs to be zero for call
    INT 1ah ; took out subint because you only need this
    cmp dx, bx ; compare DX and BX
    jg tloop2 ; if DX is greater then BX exit loop
    jmp tloop ;loop

    tloop2:
    pop dx
    pop cx
    pop bx
    pop ax
    ret
  • what the?... it works like a charm! why? was it my jump that was the problem? i tried ja, jb, jbe (adjusting the logic with bx and dx each time, of course) and none of them worked... then this jg does the trick?

    and when you say i don't need to go into another sub proc to call the interrupt, i was told that you did to keep your computer from freezing up entirely - is that completely incorrect? or is there such a small chance of that happening that it's not worth the trouble?

    thanks so much for your attention! if you have a sec to answer those questions, i would be forever grateful! :D




    : now i kinda destroyed your code here but it works in nasm the way it sits now you will probably have to convert it back to whatever you where programming in.
    :
    : ; on entrance bx = number of ticks to wait as not to interfer with dx -
    : ; wich will contain the count
    : DELAY:
    : push ax
    : push bx
    : push cx
    : push dx
    :
    : mov ah, 0 ; only AH needs to be zero for call
    : INT 1ah ; took out subint because you only need this
    : add bx, dx ; now bx holds the desired num. of ticks
    :
    : tloop:
    : mov ah, 0 ; only AH needs to be zero for call
    : INT 1ah ; took out subint because you only need this
    : cmp dx, bx ; compare DX and BX
    : jg tloop2 ; if DX is greater then BX exit loop
    : jmp tloop ;loop
    :
    : tloop2:
    : pop dx
    : pop cx
    : pop bx
    : pop ax
    : ret
    :

  • you said you where putting the delay value in dx if this is true it might just have been you where wrighting over it when you called the fist subint
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories