Docsity

MSI :LAB 2 MP LAB REPORT, Study Guides, Projects, Research of Microprocessor and Interfacing

Partial preview of the text

Download MSI :LAB 2 MP LAB REPORT and more Study Guides, Projects, Research Microprocessor and Interfacing in PDF only on Docsity!

Submitted By: (Zaheer ul Islam) (M.Bilal Arshad) (Rehmat Faraz Danish)

LAB#

Introduction to Addressing Modes and Program Status Word Register

Objectives:

The objective of this lab is to get awareness and use different addressing modes for different

instructions, PSW Register and the condition on which they change.

Introduction:

Addressing Mode: Addressing mode is a way to address an operand. Operand means the data

we are operating upon.

 Immediate addressing mode can be used to load information into any of the registers,

including the DPTR register. MOV Register,#Data.

 Register addressing mode involves the use of registers to hold the data to be

manipulated. MOV Rn,A.

 In the direct addressing mode, the data is in a RAM memory location whose address is

known can be accessed. MOV Register,Address.

 In the register indirect addressing mode , a register is used as a pointer to the data.

When R0 and R1 are used as pointers and they hold the addresses of RAM locations.

MOV A,@Rn where n=0/1.

PSW (Program Status Word) Register:

The PSW register is 8 bits wide. Four of the flags are called conditional flags, meaning that they

indicate some conditions that result after an instruction is executed. Two bits are unused and

two are to select register bank.

 Carry Flag: Set to 1 when there is carry from D7 to D

 Auxiliary Carry Flag: Set to 1 when there is carry form D3 to D

 Overflow: Set to 1 when the result of signed number operation is too large to

accommodate in 8 bit.

 Parity: Even parity, if the A register contains an odd number of is, then P = 1

The flag bits affected by ADD instruction are CY , P , AC and OV.

PROCEDURE

 Write the following code in KEIL

 Build target

 Use debugging tools for results analysis

 Note down your observations

Submitted By: (Zaheer ul Islam) (M.Bilal Arshad) (Rehmat Faraz Danish) Serial Instructions Initial Value of Registers Final Value of Registers 1

MOV A,#0A4H

ADD A,#0BEH

MOV R0,A

MOV A,#067H

ADDC A,#079H

MOV R1,A

MOV A,#035H

ADDC A,#0A6H

MOV R2,A

CY AC OV P A CY AC OV P A

0X

0X

0X

0X

0X

0X

TASK FLOW CHART

Submitted By: (Zaheer ul Islam) (M.Bilal Arshad) (Rehmat Faraz Danish)

TASK ( B ) CODE

ORG 0000H

MOV A, #0A4h // moving value in A

MOV R0, #0BEh // moving value in R0 register

SUBB A,R0 // Adding valus stored in A and R

MOV R1,A //moving answer stored in A to R

MOV R0,#00H

MOV A,#67H

SUBB A,R

MOV R0,#79H

SUBB A,R

MOV R2,A

MOV R0,#00H

MOV A,#35H

SUBB A,R

MOV R0,#0A6H

SUBB A,R

MOV A,R

End

1 ORG 0000H

MOV A,#0A4h

MOVR0,#0BEh

SUBB A,R

MOV R1,A

MOV R0,#00H

MOV A,#67H

SUBB A,R

MOV R0,#79H

SUBB A,R

MOV R2,A

MOV R0,#00H

MOV A,#35H

SUBB A,R

MOV R0,#0A6H

SUBB A,R

MOV A,R

End

CY AC OV P A CY AC OV P A

0X

0X

0X

0X

0X

0X

0X

0X

0X

0X

0X

0X

0X

0X

Submitted By: (Zaheer ul Islam) (M.Bilal Arshad) (Rehmat Faraz Danish)

RESULTS AND DISCUSSIONS:

From this task we become familiar how we can add two hexadecimal numbers of n number of

bits we also learned how we can add keeping the dry run in mind such as AC,CY,P shown

above.

Task#

Write code and debugging results in tabular form for the following number’s addition and

subtraction.

ABEDA123H + CDEAB272H – 37456789H

Examine the PSW register after each instruction and explain it with the help of dry run.

TASK DESCRIPTION:

In this task we have to add two numbers first and then we have to subtract them the task is same

as task no 1.

TASK CODE

ORG 0000H

MOV A,#023H

ADD A,#072H // starting code by adding two numbers

MOV R0,A

MOV A,#0A1H

ADDC A,#0B2H

MOV R1,A

MOV A,#0EDH

ADDC A,#0EAH

MOV R2,A

MOV A,0ABH

ADDC A,0CDH

MOV R3,A // here the process of addition is over

MOV A,#089H

SUBB A,R0 // here the process of SUBTRACTION BEGINS

MOV R4,A

MOV A,#067H

SUBB A,R

MOV R5,A

MOV A,#045H

SUBB A,R

MOV R6,A

MOV A,#037H

SUBB A,R

MOV R7,A // here the process of SUBTRACTION ENDS

End

Submitted By: (Zaheer ul Islam) (M.Bilal Arshad) (Rehmat Faraz Danish)

TASK FLOW CHART

Submitted By: (Zaheer ul Islam) (M.Bilal Arshad) (Rehmat Faraz Danish)

Post-Lab Tasks

Task#

Perform the following instructions:

 Using Immediate Addressing write and add 55H to A

 Using Register Addressing write and add 10H to A and R

 Using Direct Addressing write and add 55H to A from R

 Using Register Indirect Addressing mode write 55H to address 40H on RAM and A,

then 40H address Add to A

Explain the addressing mode in with each instruction.

TASK DESCRIPTION:

In this task we have to code a program which will help us determine the type of addressing.

TASK CODE:

Submitted By: (Zaheer ul Islam) (M.Bilal Arshad) (Rehmat Faraz Danish) Immediate Addressing Mode: Serial Instructions Initial Value of Registers Final Value of Registers 1 MOV A,#55H A=00H A=55H 2 ADD A,#55H A=55H A=AAH Register Addressing Mode: Serial Instructions Initial Value of Registers Final Value of Registers 1 MOV A,#10H A=AAH A=10H 2 MOV R0,A R0=00H R0=10H 3 Add A,R0 A=10H A=20H Direct Addressing Mode: Serial Instructions Initial Value of Registers Final Value of Registers 1 Mov R4,#55H R4=00H R4=55H 2 Mov A,04H A=20H A=55H 3 Add A,04H A=55H A=AAH Indirect Addressing Mode: Serial Instructions Initial Value of Registers Final Value of Registers 1 MOV 40H,#55H 2 MOV R0,#40H R0=10H R0=40H 3 MOV A,@R0 A=AAH A=55H 4 MOV A,@R0 A=55H A=AAH

RESULTS AND CONCLUSION:

In this task we performed the different types of addressing provided to us in the question also

we did a dry run on it for our better understanding.