Thursday, March 3, 2011

Scrolling window up & down (8086 programming)


.model small 
.stack 100h 
.data 
str1 db 10,13,'$' 
msg1 db 10,13,'Press 0 or 1 to scroll$'
msg2 db 10,13,'Press ENTER to finish$'  
.code
mov ax,@data 
mov ds,ax
xor cx,cx
mov dx,184fh 
mov ah,07h
mov bh,07h
int 10h
; set cursor position to top
mov ah, 2
mov dh, 0
mov dl, 0  
mov bh, 0 
int 10h
;Hide Blinking cursor
mov ch, 32
mov ah, 1
int 10h 
; print strings:
mov cx,07h
loop1:lea dx, str1
mov ah, 9 
int 21h 
loop loop1
lea dx, msg1
mov ah, 9
int 21h
lea dx, msg2 
mov ah, 9
int 21h
; wait key press:
loop2:xor ax, ax
int 16h
cmp al,0dh
je exit 
cmp al,31h
je up
cmp al,30h
jne loop2
; scroll window down:
mov ah, 07h
mov al, 1
mov bh, 07 
mov cl, 0 
mov ch, 0  
mov dl, 50  
mov dh, 50  
int 10h  
jmp loop2
up:; scroll window up:
mov ah, 06h 
mov al, 1
mov bh, 07
mov cl, 0
mov ch, 0
mov dl, 50
mov dh, 50
int 10h 
jmp loop2
exit:xor cx,cx 
mov dx,184fh 
mov ah,07h  
mov bh,07h  
int 10h 
mov ah,4ch
int 21h 
end

No comments: