0% found this document useful (0 votes)
26 views

Microprocessor Lab One

micropeocessor

Uploaded by

kulesta2
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Microprocessor Lab One

micropeocessor

Uploaded by

kulesta2
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Register: R [register]

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:

Flag name Set Clear

Overflow ov nv

Direction dn (decrement) up (increment)

Interrupt ei (enabled) di (disabled)

Sign ng (negative) pl (positive)

Zero zr nz

Auxiliary Carry ac na

Parity pe (even) po (odd)

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.

General Form of Mov Instruction

mov destination, source


where destination must be either a register or memory location and source may be a constant,
another register or a memory location.

Example

Note: T command is used to execute line by line

XCHG Instruction
The XCHG (exchange data) instruction exchanges the contents of two operands.

There are three variants:

 XCHG reg, reg


 XCHG reg, mem
 XCHG mem, reg

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

 xchg ax, bx ; exchange 16-bit register


 xchg ah, al ; exchange 8 bit register

Exercise

1. Copy the immediate value 03 to AX,BX,CX,DX register using


(a) 1 register, (b) 2 registers, (c) 3 registers
2. Copy 04 and 05 to ax and dx and finally exchange the value of ax,and dx
3. Copy 1234 to AX and then Copy contents of ax to bx and dx
4. What errors are present in the following lines of code:
mov ax 3d
mov 23, ax
mov cx, ch
move ax, 1h

6
Abrham Debasu (Assistant Professor)
Mathematical Operators

Increment and Decrement

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.

inc ax ;add one to contents of ax register


dec b[bx] ;subtract one from byte pointed to by bx register
inc var_name ;increment the variable var_name
Basic Arithmetic Operators

 Add and Sub


 Addition and subtraction is a double operand

ADD dest, src


dest := dest + src (bitwise add)

 dest is both a source and destination operand

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

 dest is both a source and destination operand


Example
Write a debugger code that Sub 12 and 14 finally store the result in DX register and verify which flag
register is affected

=

Exercise

1. Write a debugger code that compute 1+2+3+4+5+6+7+8+9+10


2. Write a debugger code that compute 10+9+8+7+6+5+4+3+2+1
3. Write a debugger code that compute 5 + (6-2) finally store the result in DS:SI where
SI=350
4. Write a debugger code that Sub 16 and 18 finally store the result in DX register and verify which
flag register is affected
5. Write a debugger code that compute 03+05 and store the result BX register finally exchange with
DX register

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.

DOS FUNCTION CALLS (INT 21H)


DOS function calls preserve the contents of all the registers except the AH register and any other
register or registers in which they explicitly return data.

TERMINATE PROGRAM AND RETURN TO DOS


Every time you want to terminate the program and return to DOS, you have to put the following
codes:

Assembly Language C Language Meaning

mov AH , 4Ch exit(0) Program terminates normally


int 21h or int 20

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

AH = 02h The character stored in DL will be displayed.

DL = Character or ASCII Code

DISPLAYING A STRING (SERVICE 09h)

Example: Character input and output

9
Abrham Debasu (Assistant Professor)
Accepting input from the user and put in to AL

Displaying the entered text from DL

Exit the debugger and returned to DOS

Example 2: Displaying String

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)

You might also like