LABDA3

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

CSE2006 - Microprocessor and Interfacing

LAB ASSIGNMENT 3
Name – Aayushi Agrawal
Reg no. – 20BCE0245
Slot – L57 + L58
Faculty – Dr. Gautam Narayan

a) Develop and ALP to input keystrokes from the keyboard and display
characters on the monitors. Pressing F1 - F10 should interrupt (using
BIOS commands) and exit to DOS (using DOS commands)

AIM – To input keystrokes from the keyboard and print those characters
on the screen using BIOS interrupts. On pressing any non-ascii keys, the
control should stop printing and exit to DOS using DOS commands.

ALGORITHM
1- Start
2- Read keystroke using BIOS interrupt 16H and service number
00H. The ascii value of character read or 0 is stored in AL
register.
3- Check if value of AL is 0 (non-ascii character – F1-F10 keys).
If yes go to step 6 else go to step 4.
4- Print the character stored in AL register using BIOS interrupt
10H in teletype mode (AH=0EH).
5- Repeat from step 2 to read next character.
6- If AL value is 0, exit to DOS using DOS interrupt 21H.
7- End
FLOWCHART

CODE
.model small
.stack 100h
.code
; Aayushi Agrawal
; 20BCE0245
label1 :
MOV AH,00H
INT 16H ; read keystroke input
CMP AL,00H
JZ label2
MOV AH,0EH
INT 10H ; display character
JMP label1
label2:
MOV AX,4C00H
INT 21H
end

OUTPUT
b) Implement the following:
i. Develop an ALP to display your Roll number in the centre of
page 2 of text display (Text colour = Magenta)

AIM – To display my Roll Number(20BCE0245) in magenta


colour in centre of page 2 of text display.

ALGORITHM
1. Start
2. Move the value 0003H to the AX register.
3. Call interrupt 10H with AH set to 00H to set the video mode to
text mode with 80 columns and 25 rows.
4. Move the value 02H to the AH register.
5. Move the value 12 to the DH register to set the cursor position
to the 12th row.
6. Move the value 35 to the DL register to set the cursor position
to the 35th column.
7. Move the value 02H to the BH register to set the cursor to page
2.
8. Call interrupt 10H with AH set to 02H to set the cursor
position.
9. Move the value 0502H to the AX register.
10.Call interrupt 10H to set the active display.
11.Start a loop labeled print:
1. Move the ASCII value for '2' to the AL register.
2. Call the subroutine display to display the character.
3. Repeat steps i - ii for the characters '0', 'B', 'C', 'E', '0',
'2', '4', and '5'.
4. Jump to the loop labeled print.
12.Start a label exit:
i. Move the value 4C00H to the AX register.
ii. Call interrupt 21H to terminate the program.
13.Define the subroutine display:
a. Move the value 0205H to the BX register to set the page to
02H and the color to magenta.
b. Move the value 0001H to the CX register.
c. Move the value 09H to the AH register to set the function
for displaying a character.
d. Call interrupt 10H to display the character in the AL
register.
e. Move the value 02H to the AH register.
f. Increment the value in the DL register to move the cursor
ahead.
g. Call interrupt 10H to move the cursor ahead.
h. Return from the subroutine.
14. Stop

CODE
.model small
.stack 100h
.code
MOV AX,0003H ; set video mode, text, 80x25
INT 10H
MOV AH,02H ; set cursor position
MOV DH,12 ; row
MOV DL,35 ; column
MOV BH,02H
INT 10H
MOV AX,0502H ; set active display
INT 10H
print:
MOV AL,'2'
CALL display
MOV AL,'0'
CALL display
MOV AL,'B'
CALL display
MOV AL,'C'
CALL display
MOV AL,'E'
CALL display
MOV AL,'0'
CALL display
MOV AL,'2'
CALL display
MOV AL,'4'
CALL display
MOV AL,'5'
CALL display
exit:
MOV AX,4C00H
INT 21H

display:
MOV BX,0205H ; page and color (Magenta)
MOV CX,0001H
MOV AH,09H
INT 10H ; display character in AL
MOV AH,02H
INC DL
INT 10H ; move cursor ahead
RET

end

OUTPUT
ii. Develop an ALP to display an equilateral triangle in the centre
of page 3 of a graphics display (Graphics colour = Cyan)
AIM – To display a triangle in centre of page 3 of graphics display
in cyan colour.

ALGORITHM
1. Start
2. Set the video mode to graphics mode with a resolution of
320x200.
3. Set the active display to page 3.
4. Move the value 03H to the BH register to specify the page.
5. Move the value 0CH to the AH register to write a pixel.
6. Move the value 03H to the AL register to set the color to cyan.
7. Move the value 135 to the CX register to specify the column.
8. Move the value 112 to the DX register to specify the row.
9. Move the value 50 to the BL register.
10.Draw the bottom line of the triangle using a loop that
increments CX, decrements BL, and calls INT 10H to draw
pixels, until BL becomes zero.
11.Move the value 0CH to the AH register to write a pixel.
12.Move the value 135 to the CX register to specify the column.
13.Move the value 112 to the DX register to specify the row.
14.Move the value 25 to the BL register.
15.Draw the left line of the triangle using a loop that increments
CX, decrements DX, decrements BL, and calls INT 10H to
draw pixels, until BL becomes zero.
16.Move the value 0CH to the AH register to write a pixel.
17.Move the value 135 to the CX register to specify the column.
18.Move the value 112 to the DX register to specify the row.
19.Move the value 25 to the BL register.
20.Draw the right line of the triangle using a loop that increments
CX, increments DX, decrements BL, and calls INT 10H to draw
pixels, until BL becomes zero.
21.Set AX to 4C00H to indicate the end of the program.
22.Call the DOS interrupt 21H to exit the program.
23.Stop

CODE
.model small
.stack 100h
.code
MOV AX,000DH ; set video mode, graphics, 320x200
INT 10H
MOV AX,0503H ; set active display to page 3
INT 10H

writepixel1:
MOV BH,03H ; page
MOV AH,0CH ; to write pixel
MOV AL,03H ; cyan
MOV CX,135 ; column
MOV DX,112 ; row
MOV BL,50
bottomline:
INT 10H ; draw the bottom line triangle
INC CX
DEC BL
JNZ bottomline
writepixel2:
MOV AH,0CH ; to write pixel
MOV CX,135 ; column
MOV DX,112 ; row
MOV BL,25
leftline:
INT 10H ; draw the bottom line triangle
INC CX
DEC DX
DEC BL
JNZ leftline
writepixel3:
MOV AH,0CH ; to write pixel
MOV AL,03H ; cyan
MOV BL,25
rightline:
INT 10H ; draw the bottom line triangle
INC CX
INC DX
DEC BL
JNZ rightline
exit:
MOV AX,4C00H
INT 21H
end

OUTPUT
c) Develop an ALP to display your name with an underline in the centre
of page 3 of a graphics display. (Name in magenta, underline in cyan)
AIM – To display my name in the centre of page 3 in magenta colour and
underline it in cyan.

ALGORITHM
1. Start
2. Move the value 000DH into the AX register to set the video mode to
graphics mode with a resolution of 320x200.
3. Trigger interrupt 10H to set the video mode.
4. Move the value 0503H into the AX register to set the active display to
page 3.
5. Trigger interrupt 10H to set the active display page to 3.
6. Define the procedure "writepixel".
7. Move the value 03H into the BH register to set the page.
8. Move the value 0CH into the AH register to write a pixel.
9. Move the value 03H into the AL register to set the pixel color to cyan.
10.Move the value 135 into the CX register to set the column.
11.Move the value 100 into the DX register to set the row.
12.Move the value 55 into the BL register to set the end of the line.
13.Define the loop "line".
14.Trigger interrupt 10H to draw a line.
15.Increment the CX register.
16.Decrement the BL register.
17.Check if the BL register is not zero, if not, jump to the "line" loop.
18.Define the procedure "writechar".
19.Move the value 02H into the AH register to set the cursor position.
20.Move the value 03H into the BH register to set the page.
21.Move the value 11 into the DH register to set the row.
22.Move the value 17 into the DL register to set the column.
23.Trigger interrupt 10H to set the cursor position.
24.Move the character 'A' into the AL register.
25.Call the procedure "display" to display the character 'A'.
26.Repeat steps 25-26 for the characters 'A', 'Y', 'U', 'S', 'H', and 'I'.
27.Define the procedure "display".
28.Move the value 0305H into the BX register to set the page and color
(Magenta).
29.Move the value 0001H into the CX register to set the count.
30.Move the value 09H into the AH register to display the character in
AL.
31.Trigger interrupt 10H to display the character in AL.
32.Move the value 02H into the AH register to set the cursor position.
33.Increment the DL register to move the cursor ahead.
34.Trigger interrupt 10H to move the cursor ahead.
35.Return from the "display" procedure.
36.Define the "exit" label.
37.Move the value 4C00H into the AX register to terminate the program.
38.Trigger interrupt 21H to terminate the program.
39.Define the end of the code segment.
40.Stop

CODE
.model small
.stack 100h
.code
MOV AX,000DH ; set video mode, graphics, 320x200
INT 10H
MOV AX,0503H ; set active display to page 3
INT 10H

writepixel:
MOV BH,03H ; page
MOV AH,0CH ; to write pixel
MOV AL,03H ; cyan
MOV CX,135 ; column
MOV DX,100 ; row
MOV BL,55
line:
INT 10H ; draw a line
INC CX
DEC BL
JNZ line
writechar:
MOV AH,02H ; to set cursor
MOV BH,03H ; page
MOV DH,11 ; row
MOV DL,17 ; column
INT 10H ; set cursor
MOV AL,'A'
CALL display
MOV AL,'A'
CALL display
MOV AL,'Y'
CALL display
MOV AL,'U'
CALL display
MOV AL,'S'
CALL display
MOV AL,'H'
CALL display
MOV AL,'I'
CALL display
exit:
MOV AX,4C00H
INT 21H
display:
MOV BX,0305H ; page and color (Magenta)
MOV CX,0001H
MOV AH,09H
INT 10H ; display character in AL
MOV AH,02H
INC DL
INT 10H ; move cursor ahead
RET
end

OUTPUT

You might also like