0% found this document useful (0 votes)
259 views9 pages

I. Assembler Commands: A) Command A: Assemble A Program

This document describes commands for assembling, disassembling, and executing programs using the DEBUG utility. It discusses the A and U commands for assembling and disassembling programs, and the G, R, and T commands for executing programs, checking registers, and single-step tracing. Examples are provided of using each command, including assembling code to set register values, disassembling the code to view opcodes and addresses, and using the T command to single-step through the code and observe changing register values. Activities are included to have the reader practice assembling code, disassembling to analyze opcodes and instruction lengths, and using the T command to execute and analyze a program.

Uploaded by

Mohib Uddin
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)
259 views9 pages

I. Assembler Commands: A) Command A: Assemble A Program

This document describes commands for assembling, disassembling, and executing programs using the DEBUG utility. It discusses the A and U commands for assembling and disassembling programs, and the G, R, and T commands for executing programs, checking registers, and single-step tracing. Examples are provided of using each command, including assembling code to set register values, disassembling the code to view opcodes and addresses, and using the T command to single-step through the code and observe changing register values. Activities are included to have the reader practice assembling code, disassembling to analyze opcodes and instruction lengths, and using the T command to execute and analyze a program.

Uploaded by

Mohib Uddin
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/ 9

Computer Organization & Assembly Language (CS-215L) LAB # 02

LAB#02

ASSEMBLER & PROGRAM EXECUTION COMMANDS


USING DEBUG UTILITY
Introduction to system commands using DEBUG programming utility (at command
prompt using PC).

I. Assembler Commands
The following letters stands for,
 A Assemble a program.
 U Disassemble a program

a) Command A: Assemble a program

Command syntax A [<Address>]

It is used to assemble a program using the 8088 assembly language as shown in Figure 2.1

Figure 2.1 Assembler Command

b) Command U: Disassemble a program

Command syntax U [<Range>]

 It is used to disassemble assembly language instructions into machine code as shown


in Figure 2.2.
 If no U command has been executed, the default starting address is CS: IP, which is
set to 0100:0000 after power-on.
 The default length is 20H.

Sir Syed University of Engineering & Technology 7|Page


Department of Computer Science & Information Technology
Computer Organization & Assembly Language (CS-215L) LAB # 02

Figure 2.2 Disassemble Command with addresses and machine codes for each instruction

II. Program Execution Commands

The program control commands are considered as the part of System commands. The three
basic commands are as under:
 G Execute program
 R Display or modify the contents of registers.
 T Trace program execution.

a) Command G: “Go” or Execute program

Command syntax G [=<Start address>], [<Break point 1>, <Break point 2>... <Break point
n>]

 The ‘=’ sign in the above syntax indicates a <Start address> parameter to be given.
 If “=” is not used, then the system assumes any parameters as break points.
 <Start address> specifies the beginning address of the program to be executed.
 f <Start address> not given, execution will start at the default value, which is the
current CS: IP location.
 <Break point> shows the program results (at the specified instruction locations given
by programmer) as to determine whether the program runs as expected.
 Up to 10 break points are allowed.
 Multiple break points make debugging easier when the program contains flow
control instructions, such as conditional jumps (e.g., JNZ, JC, JNE).
 If no break point is set, control will not return to the user, until the program
execution is completed.
Figure 2.3 shows the execution of code using G command.

Sir Syed University of Engineering & Technology 8|Page


Department of Computer Science & Information Technology
Computer Organization & Assembly Language (CS-215L) LAB # 02

Figure 2.3 Program Execution using “G” Command


b) Command R: Check / Change the register contents

Command syntax R [<Register>]


The R command is used to check or change the contents of the registers.
R: (Display the register contents)
 If there is no <Register> specified, the R command is used to dump all the register
contents to the screen, as shown in Figure 2.4 (a).
 The registers are displayed in the following order:
AX, CX, DX, BX, SP, BP, SI, DI, ES, CS, SS, DS, IP and FG.

Figure 2.4 (a) Displaying Registers Contents using “R” Command

R: <Register>: (Display and allow to modify the register contents)


 After executing this command, the name and contents of the specified register are
displayed, as mentioned in Figure 2.4 (b) where the content of AX are modified.
 The user can then modify the register contents, or press the Return key to display the
next register in the order mentioned in Figure 2.4 (b).

RF: (Display and allow to modify the contents of the FG register)


 The RF command displays the current status of each flag.

Figure 2.4 (b) Modifying Registers Contents using “R” Command

Table 2.1 Values of each flag Bits


FLAGS NAMES BIT=1 BIT=0
OF Overflow Flag OV (overflow) NV (no overflow)
DF Direction Flag DN (down) UP (up)
IF Interrupt Flag EI (enable interrupt) DI (disable interrupt)
TF Trap Flag
SF Sign Flag NG (negative) PL (positive)
ZF Zero Flag ZR (zero) NZ (not zero)
AF Auxiliary Carry Flag AC (auxiliary carry) NA (no auxiliary carry)
PF Parity Flag PE (parity even) PO (parity odd)
CY Carry Flag CY (carry) NC (no carry)

Sir Syed University of Engineering & Technology 9|Page


Department of Computer Science & Information Technology
Computer Organization & Assembly Language (CS-215L) LAB # 02

MSB LSB
bit # bit #
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

XX X X XX OF D IF TF S ZF X A XX P X CY
X X F F X F F X

Flag register is a bit-addressable register and holds 16 different bits. These bits are used
individually to indicate different status as well as control. The 16 flag bits are shown above
with their bit locations. Among the 16 bits, only nine bits are used and the rest are reserved for
future. There are six status flags and three control flags. Overflow, Sign, Zero, Auxiliary,
Parity, and Carry flags are considered as status flags whereas Direction, Interrupt, and Trap
flags are the control flags. The Flag registers are described in Table 2.1 with their names and
possible values.

c) Command T: Trace program execution

Command syntax T [<Start address>], [<Value>]


 The T command provides single step program execution.
 It executes one instruction at a time and displays the register contents after execution
of each instruction.
 <Start address> is the beginning address for program to be executed.
 If <Start address> is not specified, the program starts at the current address of CS:
IP.
 <Value> defines the number of instructions to be executed.
 The default value is 1.
 The P command (Procedure command) is used, instead of T command, for LOOP
instructions to pass through the looping as well as INT instructions.

Figure 2.5 shows a program execution with Trace command in which three (3) numbers of
instructions are executed.

Sir Syed University of Engineering & Technology 10 | P a g e


Department of Computer Science & Information Technology
Computer Organization & Assembly Language (CS-215L) LAB # 02

Figure 2.5 Program execution using Trace command

Activity- 1:
Assemble and unassemble the following code and fill the following table.

Logical Address Opcode Assembly code Comments


073F:100 B80002 MOV AX, 0200H ; AX=200

073F:103 BB0004 MOV BX, 0400H ;BX=400

073F:106 01D8 ADD AX, BX ;AX=AX+BX

Activity- 2:
Give answers to the following questions after unassemble the code:

Why the values 0200H and 0400H are written as 0002 and 0004, in the opcode, respectively?

Answer:
Due to the little endian convention lower byte is filled in the lower memory and higher byte is
filled in the higher memory.

Write the number of bytes and the value of IP register taken by each instruction.
Answer:
 3 Bytes
 3 Bytes
Sir Syed University of Engineering & Technology 11 | P a g e
Department of Computer Science & Information Technology
Computer Organization & Assembly Language (CS-215L) LAB # 02

 2 Bytes

Activity- 3:
Assemble a program using the DEBUG programming utility to move the decimal values in the
registers, as given below:
AX = 543110
BX = 932110
CX = 4503210
DX = 2310210
(Hint: First convert the above numbers in Hexadecimal system)

Activity- 4:
Apply the program control command T to execute the code give in Activity -1 & 3. Capture
the screenshot. Write down and analyze the values of each registers including IP and Flag
registers.

TASK#01:

1)
AX=0200 , BX=0000
2)
BX=0400 , AX=0200
3)

Sir Syed University of Engineering & Technology 12 | P a g e


Department of Computer Science & Information Technology
Computer Organization & Assembly Language (CS-215L) LAB # 02

AX=0600, BX=0400

Flags Output Step 1 Output Step 2 Output Step 3


Overflow Flag 0 0 0
Direction Flag 0 0 0
Interrupt Flag 1 1 1
Trap Flag 0 0 0
Sign Flag 0 0 0
Zero Flag 0 0 0
Auxiliary Carry Flag 0 0 0
Parity Flag 0 0 1
Carry Flag 0 0 0

TASK#03:
To Check 200 Offset Value We First Have To Change The Value Of Instruction Pointer To
200.

1) AX=1533 , BX=0000 , CX=0000,DX=0000


2) AX=1533 ,BX=2469 , CX=0000,DX=0000
3) AX=1533 ,BX=2469, CX=AFE8,DX=0000
4) AX=1533 ,BX=2469, CX=AFE8,DX=5A3E

Flags Output Step 1 Output Step 2 Output Step 3


Overflow Flag 0 0 0

Sir Syed University of Engineering & Technology 13 | P a g e


Department of Computer Science & Information Technology
Computer Organization & Assembly Language (CS-215L) LAB # 02

Direction Flag 0 0 0
Interrupt Flag 1 1 1
Trap Flag 0 0 0
Sign Flag 0 0 0
Zero Flag 0 0 0
Auxiliary Carry Flag 0 0 0
Parity Flag 1 1 1
Carry Flag 0 0 0

Activity- 5:
Apply the program control command G to execute the code give in Activity -1 & 3. Capture
the screenshot. Write down and analyze the values of each registers including IP and Flag
registers.

TASK#01:

AX=600,BX=0400

Flags Output
Overflow Flag 0
Direction Flag 0
Interrupt Flag 1
Trap Flag 0
Sign Flag 0
Zero Flag 0
Auxiliary Carry Flag 0
Parity Flag 1

Sir Syed University of Engineering & Technology 14 | P a g e


Department of Computer Science & Information Technology
Computer Organization & Assembly Language (CS-215L) LAB # 02

Carry Flag 0

TASK#03:

AX=1533 , BX=2469, CX=AFE8, DX=5A3E

Flags Output
Overflow Flag 0
Direction Flag 0
Interrupt Flag 1
Trap Flag 0
Sign Flag 0
Zero Flag 0
Auxiliary Carry Flag 0
Parity Flag 1
Carry Flag 0

Sir Syed University of Engineering & Technology 15 | P a g e


Department of Computer Science & Information Technology

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