Microprocessor Lab One
Microprocessor Lab One
Entering ' r ' all by itself will display all of the 8086 register's contents and the next
instruction which the IP register points to in both machine code and an unassembled
(Assembly Language) form.
E.g.
Note:
If you enter the ' r ' followed by the abbreviation for an 8086 register, such as: ' rcx ', then
DEBUG will display only the contents of that register followed by a line with a colon symbol (:)
on which you can enter a hex number to change the contents of that register. If you simply press
the ENTER key, the contents remain the same. For example:
-rcx
CX 0100
:273
-
means the Register command was used to change the contents of the CX register from 0100 to
0273. The command rcx could also be used again to verify the change had indeed taken place.
1
Abrham Debasu (Assistant Professor)
Typing the letter f (for Flags) after the r: rf, causes DEBUG to display all the FLAG register bits
and its 'prompt' on the same line. This prompt allows you to change all, or none, of the individual
flag bits. For example, here's how you would display the flags and change only the Zero and
Carry flag bits from being cleared (a 0 bit) to being set (a 1 bit) and check them without making
any further changes:
Overflow ov nv
Zero zr nz
Auxiliary Carry ac na
Carry cy nc
Exercise
1. Change/Update the value of AX, BX, CX,DX with 01,02,03,04 respectively and finally
display all the contents of the register.
2. Display only flag register and change all the flag register from clear State to Set State
and finally show.
2
Abrham Debasu (Assistant Professor)
Enter: E
Used to enter data or instructions (as machine code) directly into Memory locations. This next
example shows that either single(') or double(") quote marks are acceptable for entering ASCII
data. By allowing both forms, entry strings can be created to include either type of quote mark as
data:
Syntax
eaddress [list]
Parameters
address
Specifies the first memory location where you want to enter data.
list
Specifies the data you want to enter into successive bytes of memory.
E.g.
Dump: D
One of the other main features of DEBUG is the ability to display areas of
storage.
Notice that the output from the Dump command is divided into three parts.
1. On the left, we have the address of the first byte on the line. This is in the format
Segment:Offset.
2. Next comes the hex data at that location.
3. The third area is the ASCII representation of the data.
3
Abrham Debasu (Assistant Professor)
Fill: F
The Fill command is useful for storing a lot of data of the same data. It differs from the Enter
command in that the list will be repeated until the requested amount of memory is filled. If the
list is longer than the amount of memory to be filled, the extra items are ignored. Like the
Enter command, it will take hexadecimal or character data.
E.g.
Display
Search: S
Search is used to find the occurrence of a specific byte or series of bytes within a segment.
Syntax
S range list
E.g.
Exercise
1. Enter your full name to [0450:400] and finally show the contents
2. Display only your Name located on [0450:400]
3. Clear your Name only located on [0450:400]
4. Fill the word “Hello World” from DS:600 to 900 where DS=1650
5. Display the filled data from 600 to 900
4
Abrham Debasu (Assistant Professor)
Mov instruction
The Mov instruction takes two operands, representing the destination where data is to be placed
and the source of that data.
Example
XCHG Instruction
The XCHG (exchange data) instruction exchanges the contents of two operands.
You can exchange data between registers or between registers and memory, but not from
memory to memory:
5
Abrham Debasu (Assistant Professor)
xchg ax, bx ; Put AX in BX and BX in AX
xchg memory, ax ; Put "memory" in AX and AX in "memory"
xchg mem1, mem2 ; Illegal, can't exchange memory locations
Example
Exercise
6
Abrham Debasu (Assistant Professor)
Mathematical Operators
These are two of the most basic and useful instructions in the instruction set. The instruction
"inc" adds one to the parameter, while the instruction "dec" subtracts one from the parameter.
These operations are generally faster than using an add instruction to add one to the value.
Example
Write a debugger code that add 03 and 05 finally store the result in CX register
7
Abrham Debasu (Assistant Professor)
SUB dest, src
dest := dest – src
=
Exercise
8
Abrham Debasu (Assistant Professor)
The Interrupt Instruction
Pentium processor has two memory architectures: real and protected. In real mode a Pentium
works like fast 8086 processor. Real mode uses 16 bit addresses. The Real mode is also called as
16-bit mode, because all 20 bit physical address is constructed by 16 bit address. MS-DOS
Operating system was the first operating system to implement Real-Address mode on IBM
personal computer.
CHARACTER INPUT
The Codes The Result
mov AH, 01h The program is waiting for the input. Once a user presses a key, the
int 21h ASCII Code of the input character is returned in the AL register and
the input character is displayed as well.
CHARACTER OUTPUT
The Initial requirement The result
9
Abrham Debasu (Assistant Professor)
Accepting input from the user and put in to AL
10
Abrham Debasu (Assistant Professor)
1. Write an assembly program that accept one character and display the entered
character
2. Write an assembly program that accept a character and stored in to DS:SI
where SI=450
3. Write an assembly program that accept “Hello” character by character and
stored starting from DS:SI where SI=550
4. Write an assembly program that displays the word “Hello World”
5. Write an assembly program that displays the word “Hello World” 5 times
using loop and without loop
11
Abrham Debasu (Assistant Professor)