Thursday, March 3, 2011

Display a character-Attributes(Blinking,Reverse Video,Foreground & Background color)

print macro msg
lea dx,msg
mov ah,09h
int 21h
endm
.model small
.stack 100h
.data
menu db 10,13,'MENU',10,13,'1.Display ',10,13,'2.Blink ',10,13,'3.Reverse Video',10,13,'4.Change foreground color',10,13,'5.Change background color',10,13,'6.Exit$'
str1 db 10,13,'Enter ur choice: $'
str2 db 10,13,'Enter the character $'
str3 db 10,13,'Enter the foreground color(1-9&A-F) $'
str4 db 10,13,'Enter the background color(1-9&A-F) $'
invalid db 10,13,'Invalid Entry $'
newline db 10,13,'$'
data1 db ?
fcolor db 5
bcolor db 0fh
.code
main proc
mov ax,@data
mov ds,ax
print str2
mov ah,01h
int 21h
mov data1,al


loop1: print menu
print str1
mov ah,01h
int 21h


cmp al,31h
jne case2
jump1: call screen
mov bl,bcolor
call rotbl
add bl,fcolor
call display
call hide
call noblink
call endscreen
jmp loop1
case2: cmp al,32h
jne case3
 
call screen
mov bl,bcolor
call rotbl
add bl,fcolor
call display
call blink
call hide
call endscreen
jmp loop1
case3: cmp al,33h
jne case4


call screen
mov bl,fcolor
call rotbl 
add bl,bcolor
call display
call hide
call endscreen
jmp loop1
case4: cmp al,34
jne case5
 
print str3
mov ah,01h
int 21h
cmp al,3ah
jc j2
sub al,07h j2:
sub al,30h 
mov fcolor,al
jmp jump1


case5: cmp al,35h
jne case6
print str4
mov ah,01h
int 21h 
cmp al,3ah
jc j1
sub al,07h j1:
sub al,30h
mov bcolor,al
 
jmp jump1
case6: cmp al,36h
je stop


print invalid
jmp loop1
stop:
mov ah,4ch
int 21h
main endp
printmul proc
mov bx,000ah
xor cx,cx
;push into stack
l2:xor dx,dx
div bx
push dx
inc cx
cmp ax,0000h
jne l2
;pop from stack
l3:pop dx
add dl,30h
mov ah,02h
int 21h
loop l3
ret
printmul endp
rotbl proc
rol bl,1
rol bl,1
rol bl,1
rol bl,1
ret 
rotbl endp


screen proc
xor ax,ax
xor bx,bx
;selecting screen
mov ah,00
int 10h
;select mode 3
mov al,03h
int 10h
ret
screen endp


endscreen proc
mov ah,00
int 16h
mov ax,0003
int 10h
ret
endscreen endp


display proc
mov ah,09h
mov al,data1
mov bh,00h
mov cx,01h
int 10h
ret
display endp


blink proc
;for blinking
mov ax, 1003h
mov bx, 0001h
int 10h
ret
blink endp


noblink proc
;for not blinking
mov ax, 1003h
mov bx, 0000h
int 10h
ret
noblink endp


hide proc
;for hide the blinking cursor
mov ch, 32
mov ah, 1
int 10h
ret
hide endp
end  
end

No comments: