You are on page 1of 34

Mansoura University

Faculty of Computers and Information


Department of Computer Science
First Semester: 2020-2021

[CS214P] Assembly Language


Grade: Third Year (Computer Science)

Sara El-Metwally, Ph.D.


Faculty of Computers and Information,
Mansoura University,
Egypt.
Debug Program

o DEBUG program allows you to view memory, to


enter programs in memory, and to trace their
execution.
o DEBUG program is used for testing and
debugging executable programs.
o DEBUG displays all program code and data in
hexadecimal format.
o DEBUG has a single-step mode, which allows
you to execute a program one instruction at a
time.
Debug Commands

o A: Assemble symbolic instructions into


machine code.
o D: Display the contents of an area of memory
in hex format.
o E: Enter data into memory, beginning at a
specific location.
o G: Run the executable program in memory (G
means “Go”).
o H: Perform hexadecimal arithmetic.
Debug Commands

o N: Name a program.
o P: Proceed, or execute a set of related
instructions.
o R: Display the contents of one or more
registers in hex format.
o T: Trace the execution of one instruction.
o U: Unassemble ( or disassemble) machine
code into symbolic code.
Rules of Debug Commands

o DEBUG: lowercase = uppercase letters.


o DEBUG: assumes that all numbers in
hexadecimal format.
o DEBUG: spaces in commands are used only to
separate parameters.
o DEBUG : segments and offsets are specified
with a colon, in the form segment: offset
Your Working environment
Your Working environment

o Install DOSBox
o Open DOSBox
Your Working environment

o Type:

could be any chars Location of debug.exe

o Then, change the path to the named directory


i.e. c .
o Type: debug.exe
Your Working environment

name
location of my debug.exe
change path to the new name

execute debug.exe
Debug Display Command

? why

The address of left Hex representation ASCII representation


most displayed byte of the displayed of the displayed area.
segment : offset area.
Debug Display Command
(BIOS data area, 40[0]H)
Address of first Address of second
Address of one
serial port (?) serial port (?)
parallel port (?)

4 words : addresses of The first 16 bytes: the addresses of the 4 words : addresses of
serial ports COM1 serial and parallel ports. parallel ports LPT1
through COM4. through LPT4.
Debug Display Command
(BIOS data area, 40[0]H)
Equipment status word
(indication of installed devices)
D426

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

1 1 0 1 0 1 0 0 0 0 1 0 0 1 1 0
Debug Display Command
(BIOS data area, 40[0]H)
Numeric coprocessor is present =1
D426
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

1 1 0 1 0 1 0 0 0 0 1 0 0 1 1 0

Diskette drive is
Number of parallel printer Number of serial ports present =1
ports attached attached
Initial video mode =10
01=40x25 color
10=80x25 color
11=80x25 monochrome

Number of diskette
devices attached
00=1, 01=2,10=3, 11=4
Debug Display Command
(ROM BIOS, copyright, FE00:0)
Debug Display Command
(ROM BIOS Date, FFFF:5)
Machine Language Example
(Using Immediate Data)

B82301 MOV AX, 0123


052500 ADD AX, 0025
8BD8 MOV BX,AX
03D8 ADD BX,AX
8BCB MOV CX,BX
2BC8 SUB CX,AX
2BC0 SUB AX,AX
EBEE JMP 100
Machine Instruction Symbolic Code
Machine Language Example
(Using Immediate Data)
First 6 bytes of machine codes
starting from 100 ending with 105
B82301
052500
8BD8
Starting memory address CS:100
03D8
8BCB Enter data into memory beginning at
specific location
2BC8
2BC0
EBEE
Machine Instruction
Machine Language Example
(Using Immediate Data)

Display Registers contents No carry


No auxiliary

Address of next instruction to be Parity odd


executed

Non zero

Plus sign
No overflow Enable Interrupt
Up (right)
direction
Machine Language Example
(Using Immediate Data)
Trace the execution of one
instruction
Machine Language Example
(Using Immediate Data)
Machine Language Example
(Using Immediate Data)
Reset IP value
(R IP)
Assembly Language Program
(A: assemble command)

A command tells DEBUG to begin


accepting symbolic assembly
instructions and to convert them
into machine code.
Assembly Language Program
(U: unassemble command)
Using INT Instruction
(INT)

o INT: is an assembly language instruction


for x86 processors that generates a software
interrupt.

o When written in assembly language, the


instruction is written like this: INT X
o where X is the software interrupt that should
be generated (How many?).
Using INT Instruction
(INT)

o There are different types of INT operations,


some of which require a function code in the
AH register to request a specific action.

o We will use P command to execute through the


whole interrupt routine.
Using INT Instruction
(INT)

o There are different types of INT operations,


some of which require a function code in the
AH register to request a specific action.

o We will use P command to execute through the


whole interrupt routine.
Using INT Instruction
(INT)

0A2E0 ISR INSTRUCTIONS

0A2D0

255

.. ……………
Interrupt Vector Table
2 0FFF:1210
1 0A2D:0230
0 0A2D:0010
Using INT Instruction
(current date, INT 21, AH=2A)

Day of the week, 0 =Sunday DH: month (01 H to 0CH)


DL: Day (01 H to 1FH)
Using INT Instruction
(current time, INT 21, AH=2C)

seconds

minutes
Hours in 24-hour format
Using INT Instruction
(Displaying, INT 21, AH=09, starting address DX)
Using INT Instruction
(Displaying, INT 21, AH=09, starting address DX)
Using INT Instruction
(Accept chars from keyboard)
(INT 16, AH=10, AL=result)

You might also like