hey guys how are you all? i am working on a mini screen saver which moves the character 'A' to the end of the screen that gives the effect of it crawling on the screen. the problem with it is that the speed is too fast and i can see the character actually moving. so my teacher told me to slow the speed down we can waste the processor's time by doing unneccesary tasks.
my program works fine when i do not call the wastetime function. but when i call it the character doesnt print on the screen.
in the function waste time i am just doing some calculations that wil take the processor's time.
please note that i am working on x88 processor assembly language.
thanx guys also note that this question was given as a practice question to my class by my teacher.
also we have just finished printing the screen, and have done the basics and have just started the intermediate topics.
[org 0x0100]
jmp start
char: db 'A'
;main function of the program
start:
call clrscl
mov ax,[char]
push ax
call printstr
pop ax
jmp endp
;end main
;this clears the screen
clrscl:
push bp
mov bp,sp
mov ax,0xb800
mov es,ax
mov di,0
clear:
mov word[es:di],0x0720
add di,2
cmp di,4000
jne clear
pop bp
ret
;end clear screen
;this sets up the screen memory
printstr:
push bp
mov bp,sp
mov ax,0xb800
mov es,ax
mov di,0
call printchar
pop bp
ret
;end printstr
;this prints the character
printchar:
call remove
call wastetime
mov bx,[bp+4]
mov bh,0x07
mov word[es:di],bx
add di,2
cmp di,4000
jne printchar
ret
;end printcharacter
;this removes the previous printed character
remove:
mov si,di
sub si,2
mov word[es:si],0x0720
ret
;end remove
;this should waste the time of the compiler
wastetime:
push bx
push bp
mov bp,sp
sub sp,6
mov si,0
mov word[bp-2],4
add bx,[bp-2]
cmp bx,100
jne wastetime
add sp,6
pop bp
pop bx
ret
;end the wastetime
endp:
mov ax,0x4c00
int 0x21