0% found this document useful (0 votes)
117 views12 pages

Coal Lab Assignment 2 - v5 - f2019266302

The document summarizes the objectives and tasks for Lab 10 & 11. It includes 4 programming tasks: 1. Write a program to read two digits, display them, and calculate their sum. 2. Write a program to read a person's initials and display them down the left margin. 3. Write a program to read a hex digit and display its decimal equivalent. 4. Write a program to display a 10x10 box using asterisks.

Uploaded by

Talha Choudary
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)
117 views12 pages

Coal Lab Assignment 2 - v5 - f2019266302

The document summarizes the objectives and tasks for Lab 10 & 11. It includes 4 programming tasks: 1. Write a program to read two digits, display them, and calculate their sum. 2. Write a program to read a person's initials and display them down the left margin. 3. Write a program to read a hex digit and display its decimal equivalent. 4. Write a program to display a 10x10 box using asterisks.

Uploaded by

Talha Choudary
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/ 12

Assignment No.

2
Name: Talha Ahmad Bin Shafqat
ID: F2019266302
Section: V5
Lab Instructor: Maham Saleem
Lab 10 & 11 – Using Basic Instruction: A programming exercise
II
Objectives
In this lab, students are assigned a programming exercise related to what they have learned in
previous labs. Also, viva will be conducted from each student.

Lab Tasks
Task 1: Write a program to (a) display a “?”, (b) read two decimal digits whose sum is less
than 10, (c) display them and their sum on the next line, with an appropriate message.
Sample Execution:
?27
THE SUM OF 2 AND 7 is 9.

ANSWER:
.model small
.stack 100h

.data
output db 0Ah,0Dh,'THE SUM OF ','$'
output1 db ' AND ','$'
output2 db ' is ','$'
.code

main proc

Mov ax, @data


Mov ds, ax

mov dl,'?'
mov ah,02h
int 21h

Mov ah,01h
; Taking Input
Int 21h

Mov bl,al ; Moving the first input to another register

int 21h

mov bh,al ; Moving the second input to another register

mov ah,09h
lea dx,output
int 21h

mov ah,02h
mov dl,bl
int 21h

mov ah,09h
lea dx,output1
int 21h

mov ah,02h
mov dl,bh
int 21h

mov ah,09h
lea dx,output2
int 21h

add bl,bh
sub bl,30h ; Adding using ascii
mov dl,bl

mov ah,02h
Int 21h ; Printing the Sum

main endp

end main
SCREENSHOT:

Task 2: Write a program to (a) prompt the user, (b) read first, middle, and last initials of a
person’s name, and (c) display them down the left margin.
Sample Execution:
Enter three initials: JFK
J
K
F

ANSWER:

.model small
.stack 100h

.data
start db 'Enter three initials:','$'

.code

main proc

Mov ax, @data


Mov ds, ax

mov ah,09h
lea dx,start
Int 21h

Mov ah,01h

Int 21h ; Taking Input


Mov bl,al ; Moving the third input to another register

int 21h ; Taking Input


Mov bh,al ; Moving the third input to another register

int 21h ; Taking Input


mov cl,al ; Moving the third input to another register

Mov ah,02h
mov dl,0Ah
Int 21h ; Moving to Next Line

mov dl,0Dh
Int 21h ; Moving to Start of Line

mov dl,bl ; Moving the result 1 to print


int 21h

mov dl,0Ah
Int 21h ; Moving to Next Line

mov dl,0Dh
Int 21h ; Moving to Start of Line

mov dl,bh
Int 21h ; Moving the result 2 to print
mov dl,0Ah
Int 21h ; Moving to Next Line

mov dl,0Dh
Int 21h ; Moving to Start of Line

mov dl,cl ; Moving the result 3 to print


int 21h

main endp

end main

SCREENSHOT:

Task 3: Write a program to read one of the hex digits A-F, and display it on the next line in
decimal.
Sample Execution:
Enter a hex digit: C
In decimal it is 12

ANSWER:
.model small
.stack 100h

.data
hex db 'Enter a hex digit:','$'
decimal db 0Ah,0Dh,'In decimal it is ','$'
.code

main proc

Mov ax, @data


Mov ds, ax

mov ah,09h
lea dx,hex
Int 21h

Mov ah,01h

Int 21h ; Taking Input


Mov bl,al ; Moving the input to another register

sub bl,11h ; Converting into decimal

mov ah,09h
lea dx,decimal
Int 21h

mov ah,02h
mov dl,31h ; Moving 31 in hexa to print one
int 21h
mov dl,bl
int 21h

main endp

end main

SCREENSHOT:
Task 4: Write a program to display a 10*10 solid box of asterisk. Hint: Declare a string in
the data segment that specifies the box, and display it with INT 21h, function 9h?

ANSWER:

CODE 1

.model small
.stack 100h

.data
Steric db '**********',0Ah,0Dh ,'$' ;Create Character Array of 10

.code

main proc

Mov ax, @data


Mov ds, ax

Mov ah,09h
; For Displaying String
lea dx,Steric

Int 21h
Int 21h
Int 21h
Int 21h
Int 21h ; Printing 10 X 10 Sterics
Int 21h
Int 21h
Int 21h
Int 21h
Int 21h

main endp
end main

SCREENSHOT:

CODE 2
To make Empty box of 10 X 10

.model small
.stack 100h
.data
Steric db '**********',0Ah,0Dh ,'$'
Steric1 db '* *',0Ah,0Dh ,'$'

.code

main proc

Mov ax, @data


Mov ds, ax

Mov ah,09h
; For Displaying String
lea dx,Steric

Int 21h

lea dx,Steric1

Int 21h
Int 21h
Int 21h
Int 21h
Int 21h
Int 21h
Int 21h
Int 21h

lea dx,Steric

Int 21h

main endp

end main

SCREENSHOT:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy