Sie sind auf Seite 1von 13

Class

: BE (SW) EEE

Name

AngsAnanth
Semester

: 05

Roll No.: C5592

MODULE 1
DATA TRANSFER OPERATIONS & FLAG
OPERATIONS
OBJECTIVES
1.

To illustrate
operations.

2.

various

addressing

modes

using

data

transfer

To demonstrate flag manipulation and control.


NOTE

1.

All addresses and data are in hex-form unless otherwise specified.

2.

Flow charts are given wherever it is necessary.


The following are the symbols that are used in the forthcoming
explanations.
(X)

- Contents of X.
X can be memory location or any valid
Register of 8085A.
LSB
- Least Significant Bit.
MSB
- Most Significant Bit.
LSD
- Least Significant Digit (Byte).
MSD
- Most Significant Digit (Byte).
LN
- Lower Nibble.
HN
- Higher Nibble.
B
- Binary.
H
- Hex.
D
- Decimal.
(X)4>(Y
)
- Contents of X is copied to Y.

Microprocessors & Microcontrollers Laboratory Manual

Class

: BE (SW) EEE

Name

AngsAnanth
Semester

: 05

Roll No.: C5592

EXERCISE 1.1 - IMMEDIATE, DIRECT & REGISTER


ADDRESSING
OBJECTIVE : To initialise the Accumulator and the general purpose
registers to specific values using either Immediate or Direct addressing
mode.
THEORY
: To initialise a register, using immediate addressing, the
data is held by the instruction itself. In the case of Direct addressing, the
data is held in memory locations. Using these two addressing modes, let
us see how data transfer can be achieved between registers and memory.
EXERCISE

To initialise data to registers as shown.

(A) = 23, (B) = 50, (C) = 1A, (D) = 63, (E) = FE, (H) = 76, (L) =
AC
PROCEDURE
1.

Key in the opcodes from the address shown into the trainer.

2.

Enter data at 4150 and 4151.

3.

Single step the program and check the register contents at every
point.

4.

Ensure that the registers contain the data as specified.


DISCUSSION

Microprocessors & Microcontrollers Laboratory Manual

Class

: BE (SW) EEE

Name

AngsAnanth
Semester

: 05

Roll No.: C5592

PROGRAM
; Load BC with immediate data
LXI B,501A of
; 501A. (B) = 50, (C) = 1A
LDA 4150
; Load A with direct data of FE.
MOV E,A
; (E) = FE
LDA 4151
; Load A with direct data of 63
MOV D,A
; (D) = 63
MVI A,23
; (A) = 23
; Load Immediate data of 76AC
LXI H,76AC to HL
;Pair. (H) = 76, (L) = AC.
HLT
OBJECT CODES
Memory
address

Opcodes

4100

01

4101

1A

4102

50

4103

3A

4104

50

4105

41

4106

Mnemonics
LXI

B, 501A

LDA

4150

5F

MOV

E, A

4107

3A

LDA

4151

4108

51

4109

41

410A

57

MOV

D, A

410B

3E

MVI

A, 23

410C

23

410D

21

410E

AC

410F

76

4110

76

LXI H, 76AC

HLT

Microprocessors & Microcontrollers Laboratory Manual

Class

: BE (SW) EEE

Name

AngsAnanth
Semester

: 05

Roll No.: C5592

EXERCISE1.2 - REGISTER INDIRECT ADDRESSING


OBJECTIVE
Using Register Indirect Addressing for loading and storing data.
THEORY
The 16-Bit register pairs BC, DE and HL can be used for Register Indirect
addressing purposes. Initialisation of these register pairs must be done
before using them to load or store data.
EXERCISE:
location 4160.
Data
Result

To load from memory location 4150 and store at

: (4150) = 29
: (4160) = 29

PROCEDURE
1. Key in the opcodes from the address specified.
2. Enter data at 4150.
3. Execute the program and check for result at 4160.
DISCUSSION

Microprocessors & Microcontrollers Laboratory Manual

Class

: BE (SW) EEE

Name

AngsAnanth
Semester
PROGRA
M

: 05

LXI

H,4150

LXI

D,4160

MOV
STAX
HLT

A,M
D

Roll No.: C5592

; Initialise HL as memory pointer for source.


; Initialise DE as memory pointer for
destination.
; (4150)
=>
(A)
; (A)=> (4160)

OBJECT CODES
Memory
address

Opcodes

4100

21

4101

50

4102

41

4103

11

4104

60

4105

41

4106

Mnemonics
LXI

H,4150

LXI

D,4160

7E

MOV

A, M

4107

12

STAX D

4108

76

HLT

Microprocessors & Microcontrollers Laboratory Manual

Class

: BE (SW) EEE

Name

AngsAnanth
Semester

: 05

Roll No.: C5592

EXERCISE 1.3 - DIRECT ADDRESSING (16-BIT)


OBJECTIVE
To load and store 16-bit data using direct addressing.
THEORY
16-bit loading of data using direct addressing is supported only by the HL
pair. But DE pair can also be loaded with 16-bit data from HL register
using the XCHG (Exchange HL with DE) instruction.
EXERCISE: To load and store the data using XCHG.
Data

:
(4150) = 99
: (4151) = 77 (DE) = 005B

Result

:
(4160) = 5B
(4161) = 00

PROCEDURE
1.

Enter the opcodes from the address specified.

2.

Enter the data at 4150 and 4151.

3.

Execute the program and check for results at 4160.


DISCUSSION

Microprocessors & Microcontrollers Laboratory Manual

Class

: BE (SW) EEE

Name

AngsAnanth
Semester

: 05

Roll No.: C5592

PROGRAM
D,
005B

LXI
LHL
D
4150

XCH
G
SHL
D
4160

; Initialise (D)=00, (E)=5B


; Load direct data 9977 to HL.
;
(4150) => (L) = 99
;
(4151) => (H) = 77
; (D) = 77 (H) = 00
; (E) = 99 (L) = 5B
; Store direct data from HL to
memory
; (L) => (4160) = 5B
; (H) => (4161) = 00

HLT
OBJECT CODES
Memory address

Opcodes

Mnemonics

4100

11

4101

5B

4102

00

4103

2A

4104

50

4105

41

4106

EB

XCHG

4107

22

SHLD

4108

60

4109

41

410A

76

LXI

D, 005B

LHLD

4150

4160

HLT

Microprocessors & Microcontrollers Laboratory Manual

Class

: BE (SW) EEE

Name

AngsAnanth
Semester

: 05

Roll No.: C5592

Microprocessors & Microcontrollers Laboratory Manual

Class

: BE (SW) EEE

Name

AngsAnanth
Semester

: 05

Roll No.: C5592

PROGRAM 4 - FLAG OPERATIONS:


OBJECTIVE
To manipulate the carry ( C ), Zero (Z), sign (S0 and parity (P) flags and to
determine the conditions that set and reset these flags.
THEORY
Conditional jump instructions give the computer the power to make
decisions based upon data or computed results. The flags always monitor the
accumulator and registers and signal the presence of a specific condition. A
profound knowledge of the role of flag register, the instructions that affect
them, is necessary to enhance your ability as a programmer. The flag
register of 8085A is as follows.

76

AC

C
1

wher
e,
S

Sign
- Flag:

Zero
- Flag:

AC

Auxiliary carry
- flag:

Parity
- Flag:

Carry
- Flag:

Acquires the value of the most significant bit of


the result
following the execution of any BCD or Boolean
instruction.
It is set to 1 whenever any Arithmetic or
Boolean operation
generates 0 result. Reset if result
is non zero.
Holds any carry from bit 3 to 4 resulting from
an arithmetic
operatio
n.
Set if the result of an Arithmetic or Boolean
operatio produces
a result which contains an even number of 1
bits. Cleared if
there is odd number of 1
bits.
Holds carry out of the most significant bit in
any arithmetic
operatio

Microprocessors & Microcontrollers Laboratory Manual

Class

: BE (SW) EEE

Name

AngsAnanth
Semester

: 05

Roll No.: C5592


n.

In the example given below, you will be testing the status of S, Z, C and P
flags which lead to conditional jumps, calls and returns. This program is a
do nothing program. Each instruction sets and resets flags which can
be monitored separately using the sihgle step command.
PROGRAM:
NOP
MVI
ADI
ANI
ORI
ADI
RAL
XRA
HLT

A,05
FF
F4
14
90
A

OBJECT CODES
Memory
address

Opcodes

Mnemonics

4100

00

NOP

4101

3E

MVI

A, 05

4102

05

4103

C6

ADI

FF

4104

FF

4105

E6

ANI

F4

4106

F4

4107

F6

ORI

14

4108

14

4109

C6

ADI

90

410A

90

410B

17

RAL

410C

AF

XRA

Microprocessors & Microcontrollers Laboratory Manual

10

Class

: BE (SW) EEE

Name

AngsAnanth
Semester

: 05
410D

Roll No.: C5592


76

HLT

PROCEDURE
1.

Key in the opcodes in the trainer from the address 4100.

2.

Only by single-stepping through the program, you can view the Flag
status corresponding to individual instructions.

3.

The first instruction is a "NOP". Its primary function is to make you


see the first instruction before it is executed (Remember that only after
executing the first instruction, the STEP command will wait).

4.

Press the STEP key when prompted for entry.

5.

Enter the address 4100 and press NEXT.

6.

Now, the NOP would have been executed and the display shows the
address from where the program actually starts. Record this address in
the table.

7.

Press INT to display command prompt.

8.

Press REG key.

9.

Press 4 for Flag Register Key.

10.
Note down the value in hex in its equivalent binary form in the table
given below.
11.

Press INT to come back to prompt.

12.

Press STEP key followed by NEXT.

13.
Now the next instruction is executed and the flags are updated
accordingly.
14.
Repeat the same from step (vii) and record the values of Flag register
after each operation.

Microprocessors & Microcontrollers Laboratory Manual

11

Class

: BE (SW) EEE

Name

AngsAnanth
Semester : 05
Roll No.: C5592
15.
Repeat until the address 410D is displayed when STEP key is
pressed.
Mnemoni
Step
c
No.

Flag
Register

Executed
S

1.
2.
3.
4.
5.
6.
7.
8.
9.

Progra
m

AC

- P

- C

Counter
Content
s

NOP
MVI A, 05
ADI FF
ANI F4
ORI 14
ADI 90
RAL
XRA A
HLT
DISCUSSION

Microprocessors & Microcontrollers Laboratory Manual

12

Class

: BE (SW) EEE

Name

AngsAnanth
Semester

: 05

Roll No.: C5592

MODULE 1 - POST LAB EXERCISES


1.

What are the instructions that always set the Auxiliary Carry Flag
to 1 ?

2.

What does the instruction CMC do? Will Carry Flag be set to 1 or 0
after the execution of the instruction CMC ?

3.

Will the rotate instruction affect both Carry and Auxiliary Carry
Flag ?

4.

Will the Parity Flag be set if the number of zeroes is even in a


number ?

5.

Assume B and C contain 2243. What is the status of flags if DCX B


is done? How to set the Zero flag during a 16-bit decrement?

6.

Do all Logical operations reset Carry Flag to zero ?

7.

Name the instructions that clear the Auxiliary Carry Flag to Zero ?

8.

Assume A to have a data of F5. Now, write the status of flags after
execution of the following instructions one by one and give reasons for
the same.
SUI FB
DAA
XRA A

Microprocessors & Microcontrollers Laboratory Manual

13