Problems with BIOS delay function (INT 15h / AH = 86h)

后端 未结 2 1993
悲哀的现实
悲哀的现实 2021-01-28 01:07

I began studying assembly this year in my school, and we just started learning about pixels.

Our teacher gave us some code and told us to mess around with it, he also to

相关标签:
2条回答
  • 2021-01-28 01:37

    Try using a debugger to make sure all the registers still have the values you expect, after the int 10h system/BIOS call (whatever it is). I haven't checked docs, but it may clobber some other registers?

    Or maybe your problem is:

    mov ax, [red]
    mov ah,0ch 
    int 10h
    

    Remember that ah is the high half of ax. So if you modify ah right after loading something into ax, it's YOUR code that modified your color value.


    Also, code like

    add [y], 2
    mov dx, [y]
    

    is horrible. Try to keep variables in registers when you can. If you need to spill some, try to avoid doing it with variables that change every time through the loop.

    mov dx, [y] 
    add dx, 2 
    mov [y], dx
    

    Would be somewhat better, because dx would come from the first load, not a chain of read-modify-write -> load. It is more instructions, which is why keeping important loop variables in memory is bad.

    0 讨论(0)
  • 2021-01-28 01:43

    There is a weird fact, about int 15h ah=86h you also need to set al=0, unless it get an erratic behavior

    Delay Code:

    mov al, 0 mov ah, 86h mov cx, 1 mov dx, 2 int 15h

    I discovered it with try-and-error method and I realize when al=0 it works.

    0 讨论(0)
提交回复
热议问题