DRAW your college roll number on the screen. Examples are
BCSS05M012 |
OR
B C S S 0 5 M 0 1 2 |
Solution
.model small
.stack 100h
.data
.code
pHorizontalLine proc
; SI = X1
; DI = X2
; DX = Y
; BL = LineWidth
; AL = Color
; X1 should be smaller than X2
cmp si, di ; Compare si (X1) with di (X2)
jbe ok1 ; if smaller or equal, ok
xchg si, di ; else, exchange values so X1 is smaller than X2
ok1:
mov ah, 0ch ; service number
mov bh, 0 ; page number
width1:
mov cx, si ; column number (X1)
start1:
int 10h ; Call the interrupt
cmp cx, di ; Check if the target (X2) has been reached
je checkwidth1
inc cx ; if not, increment the value
jmp start1 ; and loop back
checkwidth1:
; We have make the line wide
; by printing adjacent lines
inc dx ; move to next row
dec bl ; decrement the width
cmp bl, 0 ; and check the remaining width
je exit1 ; if its 0 then exit
jmp width1 ; otherwise loop back
exit1:
ret
pHorizontalLine endp
pVerticalLine proc
; SI = Y1
; DI = Y2
; CX = X
; BL = LineWidth
; AL = Color
cmp si, di
jb ok2
xchg si , di
ok2:
mov ah, 0ch
mov bh, 0
width2:
mov dx, si
start2:
int 10h
cmp dx , di
je checkwidth2
inc dx
jmp start2
checkwidth2:
inc cx
dec bl
cmp bl, 0
je exit2
jmp width2
exit2:
ret
pVerticalLine endp
pDiagonalLine proc ; \ or / line
; CX = X1
; DX = Y1
; SI = X2
; DI = Y2
; BL = LineWidth
; AL = Color
; Make X1 less than X2 first
cmp cx, si
jb ok3
xchg cx , si ; if X1 is swaped with X2
xchg dx, di ; swap Y1 with Y2 as well
ok3:
mov ah, 0ch ; Service number
mov bh, 0 ; Page number
width3:
push cx ; Save the value of cx (X1)
push dx ; and dx (Y1)
start3:
int 10h ; Call the interrupt
cmp cx, si ; Check if the line reached si (X2)
je checkwidth3 ; then stop printing the line
inc cx ; otherwise increment cx
cmp dx, di ; or if the line reached di (Y2)
je checkwidth3 ; then too; stop
jb less ; if the value of Y1 is less than Y2 ...
dec dx ; else Y should DECREMENT from Y1 to Y2
jmp start3 ; loop back
less:
inc dx ; ... then Y should INCREMENT from Y1 to Y2
jmp start3 ; loop back
checkwidth3:
; Line complete
; now make it wide
pop dx ; restore the value of X1
pop cx ; and Y1
inc cx ; For next line, move X1
inc si ; and X2 a point further
dec bl ; dec the total width of line
cmp bl, 0 ; if the width is zero
je exit3 ; then exit
jmp width3 ; loop for next line
exit3:
ret
pDiagonalLine endp
; Utility Macros
; to make the procedure call easy (one line)
mHL macro X1, X2, Y, LWidth ; Horizontal Line
mov si, X1
mov di, X2
mov dx, Y
mov bl , LWidth
call pHorizontalLine
endm
mVL macro Y1, Y2, X, LWidth ; Vertical Line
mov si, Y1
mov di, Y2
mov cx, X
mov bl, LWidth
call pVerticalLine
endm
mDL macro X1, Y1, X2, Y2, LWidth ; Diagonal Line
mov cx, X1
mov dx, Y1
mov si, X2
mov di, Y2
mov bl, LWidth
call pDiagonalLine
endm
main:
mov ah, 0h
mov al, 13h
int 10h
;============================
; B
;============================
mov al, 05 ; Set the color for the letter
; And draw
mVL 20, 60, 90, 10
mHL 100, 110, 20 , 5
mHL 100, 110, 38, 5
mHL 100, 110, 56, 5
mVL 30, 32, 110, 10
mDl 101, 20, 110, 30, 10
mDl 101, 42, 110, 32, 10
mVL 48, 50, 110 , 10
mDl 101, 38, 110, 48, 10
mDl 101, 60, 110, 50, 10
;============================
; C
;============================
mov al, 06
mVL 25, 55, 145, 10
mHL 155, 167, 20 , 5
mHL 155, 167, 56, 5
mDl 145 , 24, 155, 20, 10
mDl 145, 56, 155, 60, 10
mDl 158, 20, 168, 26 , 10
mDl 158, 60, 168, 54, 10
;============================
; S
;============================
mov al, 07
mHL 210, 220, 20, 5
mHL 210, 220, 38, 5
mHL 210, 220, 56, 5
mVL 28, 34, 200, 10
mVL 45, 53, 221, 10
mDl 214, 20, 224, 26, 10
mDl 214, 38, 224, 44, 10
mDl 214, 60, 224, 54, 10
mDl 200, 27, 210 , 20, 10
mDl 200, 35, 210, 42, 10
mDl 200, 54, 210, 60, 10
;============================
; S
;============================
mov al, 01
mHL 100, 110, 80, 5
mHL 100, 110 , 98, 5
mHL 100, 110, 116, 5
mVL 88, 94, 90, 10
mVL 105, 113, 111, 10
mDl 104, 80, 114, 86, 10
mDl 104, 98, 114, 104, 10
mDl 104, 120, 114, 114, 10
mDl 90, 87, 100 , 80, 10
mDl 90, 95, 100, 102, 10
mDl 90, 114, 100, 120, 10
;============================
; 0
;============================
mov al, 09
mVL 85, 115, 145, 10
mVL 85, 115 , 163, 10
mHL 155, 167, 80, 5
mHL 155, 167, 116, 5
mDl 145, 84, 155, 80, 10
mDl 145, 116, 155, 120, 10
mDl 158, 80, 168, 84, 10
mDl 158, 120, 168, 116, 10
;============================
; 5
;============================
mov al, 10
mHL 210, 230, 80, 5
mHL 210, 220, 98, 5
mHL 210, 220, 116, 5
mVL 80, 102, 200, 10
mVL 105, 113, 221, 10
mDl 214, 98, 224, 104, 10
mDl 214, 120, 224, 114, 10
mDl 200, 114, 210 , 120, 10
;============================
; M
;============================
mov al, 11
mVL 145, 180, 63, 10
mVL 145, 180, 83, 10
mVL 145 , 180, 103, 10
mHL 69, 107, 140, 5
mDl 63, 144, 68, 140, 10
mDl 99, 140, 104, 144, 10
;============================
; 0
;============================
mov al, 12
mVL 145, 175, 137, 10
mVL 145, 175, 155, 10
mHL 142, 159, 140, 5
mHL 142, 159, 176, 5
mDl 137, 144, 147, 140 , 10
mDl 137, 176, 147, 180, 10
mDl 150, 140, 160, 144, 10
mDl 150, 180, 160, 176, 10
;============================
; 1
;============================
mov al, 13
mVL 140, 144, 197, 5
mVL 145, 180, 192, 10
mDl 192, 144, 196, 140, 5
;============================
; 2
;============================
mov al, 14
mHL 238, 248, 140, 5
mHL 238, 248 , 158, 5
mHL 238, 258, 176, 5
mVL 158, 180, 228, 10
mVL 147, 155, 248, 10
mDl 227, 146, 237, 140, 10
mDl 241, 140, 251, 146, 10
mDl 241, 162, 251, 156, 10
;============================
; Wait for keypress
mov ah, 01h
int 21h
; Change graphics mode back
mov ah, 0h
mov al, 03h
int 10h
; and exit
mov ah, 4ch
int 21h
end main