Professional Documents
Culture Documents
Microprocessor and Assembly Language: Lecture-4-Introduction To Assembly Language Programming With Debug Utility
Microprocessor and Assembly Language: Lecture-4-Introduction To Assembly Language Programming With Debug Utility
ASSEMBLY LANGUAGE
LECTURE-4-INTRODUCTION TO
ASSEMBLY LANGUAGE PROGRAMMING
WITH DEBUG UTILITY
MUHAMMAD HAFEEZ
DEPARTMENT OF COMPUTER SCIENCE
GC UNIVERSITY LAHORE
TODAY’S AGENDA
Syntax is,
Size of the operands must be same
Memory Yes No
Location
ARITHMETIC
INSTRUCTIONS
ADD Instruction
SUB Instruction
INC Instruction
DEC Instruction
ADD & SUB INSTRUCTIONS
ADD Syntax
ADD Source, Destination
SUB Syntax
SUB Source, Destination
LEGAL COMBINATIONS OF
ADD & SUB INSTRUCTIONS
Destination
Source General Register Memory Location
General Yes Yes
Register
Memory Yes No
Location
DEC Syntax
DEC Destination
NEG Syntax
DEC Destination
Using Debug
INSTALL DOSBOX
DOSBox is an Emulator which emulate old
8086/88 and 80286/386 environment on
your current i3/i5/i7 processor.
Follow the steps given in online post
”Installing MASM on Windows 7”
DEBUG UTILITY
A debugger displays the content of memory
quickly and easily, showing registers and
variables.
You can step through a program one line at
a time (called tracing).
Some debugging functions are:
Assemble short program
View a program’s source code, along with its machine code
View the CPU registers and flags
Trace or execute a program, watching variables for changes
Enter new values in memory
Fill a block of memory
load and write disk files
DEBUG UTILITY
Debug assume all the numbers in HEX
C:\Masm>Debug [Press Enter]
R [to see the Registers]
R Register name to change the content
R AX
A Start Address [Assemble the Code]
A 0100
U Start Address End Address
U Start Address L #of bytes
U 0100 010D
U 0100 LD
DEBUG UTILITY
G [Run a program till breakpoint]
G=start Address End Address
G [press enter]
G=0100 010D
R [to see the Registers]
T [Trace, to run a program step by step]
T = Start Address # of instruction
T [press Enter]
T=0100 2 [Run Two instructions]
T 3 [only number of instructions, assume
IP=0100]
DEBUG UTILITY
Common Errors with Register Usage
MOV AH,FF3
MOV AX,12345
MOV DS,1240
MOV SI,DH
MOV BX,AH
MOV AL,CX
[Errors]
DATA MANIPULATION IN
DEBUG UTILITY
F [fill the block of memory with data]
F [start address] [end address] [data]
F [start address] [L no of bytes] [data]
F 0 10 FF
F 0 LD EF
F 0 20 20 41 [alternate pattern]
D [Dump command, examine the content of
memory]
D [start address] [end address]
D [start address] [L no. of bytes]
Variation of D
DATA MANIPULATION IN
DEBUG UTILITY
D [dump will be shown from DS:0100 to
128 bytes]
D offset [D will assume DS as segment]
Fill and look up the Dump
Enter Command and Use Dump to examine
machine code
E [Enter Data with E command]
E [start address] data
E Start Address
E DS:0 41 42 43 44
E DS:0 ‘Adam Smith’
E CS:0100
DATA MANIPULATION IN
DEBUG UTILITY
Alter data using E
E 106 [press enter]
P [Procedure], used to execute procedure
P [start address] [no. of instructions]
??????????????????????????