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

Coal Lab02

The document summarizes 9 tasks from an assembly language lab, including writing programs to print 'Hello World', input and output characters, and perform basic math operations. Common code elements like declaring memory models and using interrupts are also discussed. Screenshots provide examples of code for tasks like incrementing, decrementing, and converting between uppercase and lowercase letters.

Uploaded by

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

Coal Lab02

The document summarizes 9 tasks from an assembly language lab, including writing programs to print 'Hello World', input and output characters, and perform basic math operations. Common code elements like declaring memory models and using interrupts are also discussed. Screenshots provide examples of code for tasks like incrementing, decrementing, and converting between uppercase and lowercase letters.

Uploaded by

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

COAL-LAB02

Ahmad Abdullah
I22-1609
Introduction
This report is written as an explanation of code/steps done in COAL-LAB#2. There were a total of
9 tasks described in the manual to code and then make a document with the right explanation
of the code to ensure that the students did the tasks themselves and got the understanding of
the code.

The nine tasks were:

1. Write an assembly language program to print Hello World using mov ah,02 service
routine.
2. Write an Assembly program to Input Characters from the user and display it.

3. Take a number and print the next number

4. Take a number and print the previous number

5. Write an Assembly program to Input a Lower Case letter from the user and display its
upper case. (Subtract 32 in ASCII)

6. Write an Assembly program to Input an Upper-case letter from the user and display it’s
lower case. (ADD 32 from ASCII)

7. Write an Assembly program to input a letter from the user and display the next
Character.
8. Write an assembly language program to ADD two values.

9. Write an assembly language program to subtract two values.

Common Code
First of all in every code we use the following commands to tell the CPU exactly how much
memory and stack we will be using and other types of commands that we use in asm files.

.model small: This tells the CPU how much memory our data and code directives will use.

The small directive tells that our data and code directive will use a total of 64kb of memory.

.data: We use this directive to store the data or variables that we are going to use in our code.

.code: After this directive we code our program and functions that will do our calculations.

main proc: This tells the assembler that our main code starts from here.

mov ah,2: This command is used to insert/move 2 in the ah register. 2 is used to print the value.

Int 21h: This is an interrupt that interrupts the CPU to call whatever command is in ah register.

So, when the CPU is interrupted and mov ah,2 is called, it prints the value in dl register on the
screen.

mov ah, 4ch: This is used to move 4ch into the ah register which is a command when int 21h is
called the main program is terminated.
Task#1
The assembly code file of task#1 is provided in the same zip file as this document.

The Two commands that I used to print the whole “Hello World!” string are:

1. mov dl, ‘Desired Character’


2. mov ah,2
3. int 21h
Task#2

In this task, we use mov ah,01 to print the character at the same time we take as input.

Task#3 & 4
This is the screenshot of task#3 where after running the command mov dl, al which copies the
value of al to dl register we run the command inc dl which increments the value in dl and then
prints it.

In Task#4 we just replaced inc dl with dec dl to decrements the value in dl.

Task#5 & 6
In this code, after copying the value from al to dl we use the command sub dl,32 which
subtracts 32 from ASCII from the value in dl.
In task#6 we just replaced sub dl,32 command with add dl,32 to print lower case of the
character.

Tasl#7
This Task is the same as above but we just add dl,1 instead of add dl,32 to show the next
character.
Task# 8&9
In Task#8 we take input from users and after running the command mov dl, al we run sub dl,4 to
subtract 4 from the input given by the user. In the given screenshot the user inputs 6 which gives
2 after subtracting from 4.

In task#9 we just replaced the sub dl,4 commands with add dl,4 command which adds 4 to the
input given by the user. In this screenshot the user inputs 4 which is added to the 4 in the code.

You might also like