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 told us to try and implement delay in the code(ah=86h|int 15h), but when i tried to use it the location and colors of some pixels got changed, and i don't understand why
code: (just a piece of the code, there is some more there also get's ruined after the delay)
mov cx, 20
add [y], 2
mov dx, [y]
paint1RowOf10:
mov bh, 0h
mov bx, cx
add [x], 1
mov cx, [x]
add [y], 4
mov dx, [y]
mov ax, [red]
mov ah,0ch
int 10h
; here is a delay part, it waits for 1 seconde
; from the help of assembly:
; INT 15h / AH = 86h - BIOS wait function.
;CX:DX = interval in microseconds (these are notes from my teacher)
mov ah, 86h
mov cx, 1
mov dx, 2
int 15h
mov cx, bx
loop paint1RowOf10
This is the result http://prntscr.com/9a8lpw can you tell me why does this happen? because as far as i see, the pixels are supposed to go in one line, and not change colors.
mov bh, 0h;
followed bymov bx, cx
. . First you move 0 to BH for theint 10h/ah=0ch call
(BH=page number). That is fine, then right after that you overwrite ALL of BX (including BH and BL) by doingmov bx, cx
. BL and BH are parts of the BX register. Moving something into BX will trash BH/BL . Either push CX on the stack (and pop it later) or use a register other than BX as temporary storage (in this case SI or DI) look safe with code given. – LitigantInt 15h/AH=86h
has bugs in DOSBox. Try to use video mode 13 (09h) instead of 19 (13h). That works here. – Levin