100% found this document useful (1 vote)
398 views5 pages

COAL Lab Manual 1 FAST NUCES

The document provides instructions for setting up NASM, AFD and DOSBOX to write, assemble, and debug assembly language programs on a PC. It includes an example program that adds three numbers in registers and instructions to run the program in a debugger, observing the program execution and register values. Students are tasked with modifying the program to calculate the sum of the first five entries of a table of 3 using registers, experimenting with different approaches.

Uploaded by

Ameer Hamza
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
100% found this document useful (1 vote)
398 views5 pages

COAL Lab Manual 1 FAST NUCES

The document provides instructions for setting up NASM, AFD and DOSBOX to write, assemble, and debug assembly language programs on a PC. It includes an example program that adds three numbers in registers and instructions to run the program in a debugger, observing the program execution and register values. Students are tasked with modifying the program to calculate the sum of the first five entries of a table of 3 using registers, experimenting with different approaches.

Uploaded by

Ameer Hamza
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/ 5

National University of Computer and Emerging Sciences

Lab Manual 01
Computer Organization and Assembly Language Lab

Course Instructor Dr. Asma


Lab Instructor Maham Saleem
Section 3F
Semester Fall 2021

Department of Computer Science


FAST-NU, Lahore, Pakistan
Activity 1: Setup
Download and install NASM, AFD and DOSBOX, according to the instructions, in your NASM folder.

AFD: https://drive.google.com/file/d/1eXnD3JEwBelFiJT6iIk7gluudV2Fu_iX/view?usp=sharing
NASM: https://drive.google.com/file/d/1ZoeE2MxjNaK7DdJKCacYfAJyn006MI_F/view?usp=sharing
Dosbox: https://drive.google.com/file/d/1DnaDIk4RoGBFDP1y4Dr3q89xwM3gx1d1/view?usp=sharing

Tutorial part 1: https://drive.google.com/file/d/1N3lWL8hsN0ZbhF3tlNwCWWwjJ_eHQqk6/view?


usp=sharing
Tutorial part 2: https://drive.google.com/file/d/10p8qyaOVOwF5lDighrMKE-uNYQX-c3bL/view?
usp=sharing

After installations double click “DOSBox 0.74-2 Options.bat” file and at the end of the file paste following
lines:

MOUNT C D://COAL//NASM

C:

(We are mounting C drive to our folder where we have saved AFD and we will save our .asm file in this
directory)

Activity 2: Running your First Program


Follow these step in order to run your first program:

1- Copy/paste following code in notepad

; this is a comment. Comment starts with semicolon


; this program adds three numbers in registers
[org 0x0100] ;we will see org directive later

mov ax, 5 ; AX = 5
mov bx, 10 ; BX = 10
add ax, bx ; AX = AX + BX
mov bx, 15 ; BX = 15
add ax, bx ; AX = AX + BX

mov ax, 0x4c00 ;terminate the program


int 0x21

2- Save this file as “ex01.asm” in your NASM folder e.g. “D:\COAL\NASM”:

3- Go to NASM installation directory ( e.g. “D:\COAL\NASM”). Double click nasmpath.bat (batch


file) and type following command there. (Your .asm file and nasm should be in one folder)

nasm ex01.asm -o ex01.com -l ex01.lst


4- Above command will assemble your code and create ex01.com and ex01.lst files. Open ex01.lst
file in notepad.
a. What is opcode of instruction “mov ax, someConstant”
b. Verify the above opcode everywhere the instruction has been used.
c. What does “B80500” mean?
d. Verify the opcode of instruction “mov bx, someConstant” throughout the machine code.
e. What is the offset of first instruction?
f. Why are offsets of second and third instructions 3 and 6?
g. What should be the size of ex01.com file?
h. Right click ex01.com and verify its size.

5- Open DOSBox (by double clicking dosbox.exe), following window will appear:

6- Write following command and press enter.


Afd ex01.com
(Your AFD.exe should be in same directory where we have installed everything)
7- Above command will open the debugger and load your ex01.com file in it.
a. What is the value of IP register? And what will be its effect?
b. Note the initial values of data registers
c. Press F1 and watch the values of data registers

Activity 3: Explore different functions available in debugger (after completing


activity 4).
Activity 4: Modify this program to generate the sum of first five entries of table of 3, using registers,
and watch its execution in the debugger.

Help: [Approach 1] Can you do this using two registers only? [Approach 2] Can you do this using one
register only if we have add ax, 3 available in our instruction set? Try both of these approaches and
watch the first five entries of table of 3 in AX.

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