0% found this document useful (0 votes)
33 views14 pages

Lab 03

The document discusses a lab assignment on using the debug command prompt to write and run assembly language programs. It provides objectives, descriptions of instructions like MUL, DIV, and memory manipulation. It also gives directions on how to save and load programs using debug commands. An example program is provided to perform math operations on values and store the results in memory locations.

Uploaded by

sp22-bcs-136
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)
33 views14 pages

Lab 03

The document discusses a lab assignment on using the debug command prompt to write and run assembly language programs. It provides objectives, descriptions of instructions like MUL, DIV, and memory manipulation. It also gives directions on how to save and load programs using debug commands. An example program is provided to perform math operations on values and store the results in memory locations.

Uploaded by

sp22-bcs-136
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/ 14

Submitted By: Abdullah Javed.

Submitted To: Sir Munawar-ul-Zaman.

Subject: COAL.

Date: 27-09-2023.
LAB 03: COMMAND PROMPT PROGRAMMING USING DEBUG

Objectives:
1. How to write assembly code on command prompt?
2. Memory manipulation Instructions in debug.
3. How to save a program?
4. How to load the saved program?
5. Practices

Pre-Lab Task
Types of instructions:
1- Data Transfer Instructions
Register to Register
Register to Memory
Memory to Register
Constant to Register
2- Arithmetic Instructions
ADD, SUB, MUL and DIV
3- Logic Instructions
Boolean AND, OR, NOT and XOR
The MUL Instruction
There are two instructions for multiplying binary data. The MUL (Multiply) instruction handles
unsigned data. MUL instructions affect the Carry and Overflow flag.
Syntax
The Syntax for the MUL instructions is as follows −
MUL multiplier
Multiplicand in will be in an accumulator, depending upon the size of the multiplicand and the
multiplier and the generated product is also stored in two registers depending upon the size of the
operands. Following section explains MUL instructions with three different cases
SN Scenarios
1 When two bytes are multiplied -
The multiplicand is in the AL register, and the multiplier is a byte in the memory or in another
register. The product is in AX. High-order 8 bits of the product is stored in AH and the low-order
8 bits are stored in AL.

The DIV Instruction


The division operation generates two elements - a quotient and a remainder. In case of
multiplication, overflow does not occur because double-length registers are used to keep the
product. However, in case of division, overflow may occur. The processor generates an interrupt
if overflow occurs. The DIV (Divide) instruction is used for unsigned data. The dividend is in an
accumulator. The operation affects all six status flags.
Syntax
The format for the DIV/IDIV instruction
DIV divisor
SN Scenarios
1 When the divisor is 1 byte -
The dividend is assumed to be in the AX register (16 bits). After division, the quotient goes to
the AL register and the remainder goes to the AH register.

In-Lab Task:
Debug: M (Move)
Copies the contents of a block of memory to another block of memory.
Syntax
m range address
How to Save Program:
There are three stages to save this program:
Write 'n' and the name of the program like -n first.com Now the interesting point. We should
specify how many bytes will be saved. So, we have to pass a value to CX register. Write r CX
and press enter. And enter the number of bytes you want to save. Practically, write the difference
between where your program starts and where it ends. In this example, 0109-0100=9 bytes. More
practically, look at the last address and take its low byte. It will be sufficient if the high byte of
the address is 01. Finally write 'w' and the program will be saved.

How to Load a Program:


There are two ways. One is, as we have seen above, writing debug and the name of the program
and press enter. Then write 'u' unassembled to see the code.

You see, with ' u 'debug shows us the code with op-codes. So for example, we can easily say that
B8 is the operation code of mov ax, The second way of loading a program is using 'l' (load).
We write 'n' and the name of the file which will be loaded. Then we write just ' l '. And the
program is loaded. If it is wanted to see the code, u can be used.

Program Exercise:
Take two values at two different memory locations i.e. 75 & 80, perform following operation on
numbers
ADD, SUB, MUL, DIV.
Show all the individual results at 5 consecutive memory locations starting from 230. Save and
Load the program.
Note: For each operation take 2 different values, first value should always be greater than second
value and divisible.

Post-Lab Assignment:
Translate the high-level language assignment statement A=30+5*A-12/B into assembly code.
Let A and B be byte variables and suppose there is no overflow also save and load program.
Perform following operations and show result,
Multiply 80 h with FFh
Divide 1250h with 7

Critical Analysis /Conclusion

Performance (15Marks) Viva


(5 Marks) Total/20
Pre Lab Exercise /3
Performance /4
Results /3
Critical Analysis /2
Post Lab Exercise /3
Comments

Solution:
We take different values 75, 80 and store in Ax and Bx respectively then move it to different
location such as 50 and 51 index.
Then add value store in Bx with ax and result is stored in the Ax value then move Ax to 230
locations.
Then perform multiplication in two different values taken and store in Ax and Bx again and
move to different memory location. The final Multiplication result store in 231
Then we choose again two different values stored in AX and Bx register and then perform
Subtraction and the result store in Ax which I move to location 232.
Then Div values which is stored in Ax and take new value which I store in the Cx register and
division result store in 233.
Solution:
First we add two numbers, then multiply that numbers and stored each of them in the memory
and then subtracted and then divide them and stored them in the memory.

You might also like