Professional Documents
Culture Documents
============================================
.model small
data_seg segment 'data'
ball db "o$"
space db " ",'$'
row db 12d
column db 0d
switch dw 1
data_seg ends
code_seg segment 'code'
assume cs:code_seg,ds:data_seg,ss:stack_seg
main proc far
mov ax,data_seg
mov ds,ax
jmp clear_screen
mov ah,09h
mov dx,offset ball
int 21h
mov_ball:
mov ax,switch
cmp ax,1
je up
cmp ax,2
je right
cmp ax,3
je downleft
cmp ax,4
je upleft
jmp exit
exit:
mov ah,4ch
int 21h
main endp
up:
mov dh,row
cmp dh,12
je state1
state1:
mov dl,column
cmp dl,36
jb case1
jmp cc2
right:
cc2:
mov al,row
cmp al,0
jbe state2
state2:
mov bl,column
cmp bl,77
jb case2
jmp cc3
downleft:
cc3:
mov al,row
cmp al,24
jb state3
state3:
mov bl,column
cmp bl,79
jbe case3
jmp cc4
upleft:
cc4:
mov al,row
cmp al,24
je state4
state4:
mov bl,column
cmp bl,79
jb case4
case1:
jmp mov_up_right
case2:
jmp mov_down_right
case3:
jmp mov_down_left
case4:
jmp mov_up_left
clear_screen:
; clear screen and goto middle left of the screen
mov ah,06h ;for clear screen
mov al,25 ; 25 lines to scroll
mov bh,07 ; character attributes
mov ch,0 ;top row=0
mov cl,0 ;left column=0
mov dh,24 ;bottom row=24
mov dl,79 ;right column=79
int 10h ; calling interrupt for clear screen
gotoxy:
; now gotoxy and display ball on the screen
mov ah,02h ;for gotoxy screen
mov bh,0h ; no of pages to scroll
mov dh,row ;default row no=12
mov dl,column ; default column=0
int 10h ; calling intrerrupt for gotoxy
jmp mov_ball
code_seg ends
stack_seg segment stack
dw 100 dup (?)
stack_seg ends
end main
http://www.ravianeducation.blogspot.com
FARHAN: 03008855006