Spring 2023 - CS401 - 2 - MC210400095

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Computer Architecture and Assembly Language Student Name: Adnan Naveed

Spring 2023 Student ID: MC210400095


Assignment # 02

Student Name : Adnan Naveed


Student ID : MC210400095
Q. No. 1: Write an assembly language program that performs following operations:
 Prints your name on the 1st row screen
 Prints your VUID on the 2nd row of screen
 If Right shift is pressed, it prints your VUID in the ascending order on the 3 rd row of
screen,
OR
If Left shift is pressed, it prints your VUID in the descending order on the 3 rd row of
screen,

Solution.

Solution: ( Code Part )

; TSR to show status of shift keys on top left of screen


[org 0x0100]
jmp start

nam db 'Name : Adnan Naveed','$'


vuid db 'VUID : 210400095','$'
vs db 'VUID SORTED:','$'
id_acs db '00012459','$'
id_des db '95421000','$'
Computer Architecture and Assembly Language Student Name: Adnan Naveed
Spring 2023 Student ID: MC210400095
Assignment # 02

start:

; Clear screen

MOV AH , 06h
MOV AL , 0
MOV BH, 07h
MOV CX, 0
MOV DX, 184Fh
INT 10h

; Print Student Name on First Line


MOV AH , 02h
MOV BH , 00h
MOV DH, 00h
MOV DL , 00h
INT 10h

MOV AH , 09h
MOV DX , nam
INT 21h

;Print Student ID on 2nd Line


MOV AH , 02h
MOV BH , 00h
MOV DH, 01h
MOV DL , 00h
INT 10h

MOV AH , 09h
MOV DX , vuid
INT 21h
Computer Architecture and Assembly Language Student Name: Adnan Naveed
Spring 2023 Student ID: MC210400095
Assignment # 02

;Print Sorted

MOV AH , 02h
MOV BH , 00h
MOV DH, 02h
MOV DL , 00h
INT 10h

MOV AH , 09h
MOV DX , vs
INT 21h

xor ax , ax
mov es , ax
cli
mov word[es:9*4],kbisr
mov [es:9*4+2],cs
sti

l1: jmp l1

kbisr: push ax
push es
mov ax , 0xb800
mov es , ax
in al , 0x60
cmp al , 0x2a
jne nextcmp

MOV AH , 02h
MOV BH , 00h
Computer Architecture and Assembly Language Student Name: Adnan Naveed
Spring 2023 Student ID: MC210400095
Assignment # 02

MOV DH, 02h


MOV DL , 13
INT 10h

MOV AH,09h
MOV DX,id_des
INT 21h

jmp nomatch
nextcmp:
cmp al , 0x36

jne nomatch

MOV AH , 02h
MOV BH , 00h
MOV DH, 02h
MOV DL , 13
INT 10h

mov AH,09h
mov dx ,id_acs

INT 21h

nomatch:

MOV AL, 0x20


out 0x20,AL
pop es
pop ax
iret
Computer Architecture and Assembly Language Student Name: Adnan Naveed
Spring 2023 Student ID: MC210400095
Assignment # 02

MOV AX , 4C00h
INT 21h

You might also like