Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views7 pages

Exp 4

Uploaded by

Sumit Rathod
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views7 pages

Exp 4

Uploaded by

Sumit Rathod
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Name: Sumit Raghunath Rathod

UID: 2023800094

Experiment No. 4

AIM: Program to display Shape using BIOS interrupts in assembly Language.

CODE: .model small


.DATA
MESS1 DB 0AH,0DH,07H,'THIS PROGRAM WILL DRAW A Triangle $'

ROW1 DW 30
COL1 DW 120
LASTROW1 DW 70
LASTCOL1 DW 180

ROW2 DW 30
COL2 DW 480
LASTROW2 DW 70
LASTCOL2 DW 540

ROW3 DW 100
COL3 DW 230
LASTROW3 DW 150
LASTCOL3 DW 330

ROW4 DW 100
COL4 DW 430
LASTROW4 DW 150
LASTCOL4 DW 330

ROW5 DW 10
COL5 DW 75
LASTROW5 DW 12
LASTCOL5 DW 585
ROW6 DW 160
COL6 DW 75
LASTROW6 DW 162
LASTCOL6 DW 585

ROW7 DW 10
COL7 DW 75
LASTROW7 DW 162
LASTCOL7 DW 78

ROW8 DW 10
COL8 DW 583
LASTROW8 DW 162
LASTCOL8 DW 585

PIXEL DB 01
MODE DB 00H
PG DB 00H

DISPLAY MACRO DISP


LEA DX,DISP
MOV AH,09H
INT 21H
ENDM

.CODE
MOV AX,@DATA
MOV DS,AX

DISPLAY MESS1

MOV AH,01H ;read keyboard


INT 21H

MOV AH,0FH ;read current video mode


INT 10H
MOV MODE,AL ; al=video mode
MOV PG,BH ; bh=page number

MOV AH,00H ; set video mode


MOV AL,06H ; graphics 640 x 200
MOV BH,00H ; set page 0
INT 10H

MOV DX,ROW1 ; dx=row number


LOOP2: MOV CX,COL1 ; cx=column number
LOOP1: MOV AH,0CH ; put pixel
MOV AL,PIXEL ; al=type of pixel
INT 10H
INC CX
CMP CX,LASTCOL1
JNZ LOOP1
INC DX
CMP DX,LASTROW1
JNZ LOOP2

MOV DX,ROW2 ; dx=row number


LOOP4: MOV CX,COL2 ; cx=column number
LOOP3: MOV AH,0CH ; put pixel
MOV AL,PIXEL ; al=type of pixel
INT 10H
INC CX
CMP CX,LASTCOL2
JNZ LOOP3
INC DX
CMP DX,LASTROW2
JNZ LOOP4

MOV DX,ROW3 ; dx=row number


LOOP5: MOV CX,COL3 ; cx=column number
LOOP6: MOV AH,0CH ; put pixel
MOV AL,PIXEL ; al=type of pixel
INT 10H
INC CX
CMP CX,LASTCOL3
JNZ LOOP6
INC DX
INC COL3
INC COL3
CMP DX,LASTROW3
JNZ LOOP5

MOV DX,ROW4 ; dx=row number


LOOP7: MOV CX,COL4 ; cx=column number
LOOP8: MOV AH,0CH ; put pixel
MOV AL,PIXEL ; al=type of pixel
INT 10H
DEC CX
CMP CX,LASTCOL4
JNZ LOOP8
INC DX
DEC COL4
DEC COL4
CMP DX,LASTROW4
JNZ LOOP7

MOV DX,ROW5 ; dx=row number


LOOP9: MOV CX,COL5 ; cx=column number
LOOP10: MOV AH,0CH ; put pixel
MOV AL,PIXEL ; al=type of pixel
INT 10H
INC CX
CMP CX,LASTCOL5
JNZ LOOP10
INC DX
CMP DX,LASTROW5
JNZ LOOP9

MOV DX,ROW6 ; dx=row number


LOOP11: MOV CX,COL6 ; cx=column number
LOOP12: MOV AH,0CH ; put pixel
MOV AL,PIXEL ; al=type of pixel
INT 10H
INC CX
CMP CX,LASTCOL6
JNZ LOOP12
INC DX
CMP DX,LASTROW6
JNZ LOOP11

MOV DX,ROW7 ; dx=row number


LOOP13: MOV CX,COL7 ; cx=column number
LOOP14: MOV AH,0CH ; put pixel
MOV AL,PIXEL ; al=type of pixel
INT 10H
INC CX
CMP CX,LASTCOL7
JNZ LOOP14
INC DX
CMP DX,LASTROW7
JNZ LOOP13

MOV DX,ROW8 ; dx=row number


LOOP15: MOV CX,COL8 ; cx=column number
LOOP16: MOV AH,0CH ; put pixel
MOV AL,PIXEL ; al=type of pixel
INT 10H
INC CX
CMP CX,LASTCOL8
JNZ LOOP16
INC DX
CMP DX,LASTROW8
JNZ LOOP15

MOV AH,01H ; read keyboard


INT 21H

MOV AH,00H ; initialize previous mode


MOV AL,MODE
MOV BH,PG
INT 10H

MOV AX,4C00H
INT 21H

END

EXPLANATION: This assembly program uses BIOS interrupts to draw an emoji on the
screen. It starts by setting the video mode to graphics (640x200) using INT
10H. The program defines the starting row and column positions for
various segments of the emoji, and loops through these coordinates to
place pixels on the screen using the 0CH function of INT 10H. Each loop
increments or decrements the column values to create the desired shape.
After drawing, it waits for a key press before restoring the previous video
mode and exiting.

RESULT:
CONCLUSION: I understood how to display shapes on the screen using BIOS and DOS
interrupts by executing the above code. This experiment enhances
understanding of graphics programming and BIOS interrupt handling in
assembly language.

You might also like