Click here to load reader
View
1.151
Download
22
Embed Size (px)
How does microprocessor differentiate between data and instruction and code?As soon as p is turned on it begins execution of code in the memory sequentially - Both opcode and data are in binary numbers, so how to differentiate? - The p interprets the first byte it fetches as opcode and second as data - Eg. We tell the processor that our program begins at 2000h. The first code it fetches is 3Eh, when it decodes it knows that it is a 2 byte instruction, hence the second code i.e. 32h is a data byte. If we enter 06h instead of 32h then it will load 06 in the accumulator instead of 32 -
One byte instructionsTASK Copy contents of accumulator in register C Complement each bit in the accumulator OPCODE MOV OPERAND C,A BINARY CODE 0100 1111 HEX CODE 4FH
CMA
-
0010 1111
2FH
As soon as p decodes this it understands that it is a 1 byte instruction
Tw o b y t e i n s t r u c t i o n sTASK Load an 8 bit data byte in the accumulator Load an 8 bit data byte in register B OPCODE MVI OPERAND A,32H BINARY CODE 0011 1110 0011 0010 0000 0110 1111 0010 HEX CODE 3E(first byte) 32(second byte) 06 F2
MVI
B,F2H
2 memory locations required
As soon as p decodes this it understands that it is a 2 byte instruction
Three byte instructionsTASK Load of contents of memory location 2050H into A Transfer the program sequence to memory location 2085H OPCODE LDA OPERAND 2050H BINARY CODE 0011 1010 0101 0000 0010 0000 1100 0011 1000 0101 0010 0000 HEX CODE 3A(first byte) 50(second byte) 20(third byte) C3 85 20
JMP
2085H
As soon as p decodes this it understands that it is a 3 byte instruction
C L A S S I F I C AT I O N O F INSTRUCTION SET1.Data transfer(copy) instructions 2.Arithmetic instructions 3.Logical instructions 4. Branching instructions 5.Machine control instructions
Data transfer instructionsDefinition : Copies data from source to destination, retaining the contents in the source. Note:NOTATIONS M r rp rs rd addr MEANING Memory location pointed by HL register pair 8 bit register 16 bit register pair Source register Destination register 8 bit/16 bit address
The various data transfer instructions are MOV rd,rs MVI rd,data(8bit) MVI M, data (8 bit) MOV M ,rs MOV rd, M LXI rp , data (16 bit) STA, addr( 16 bit) LDA addr (16 bit) SHLD addr(16 bit) LHLD addr (16 bit) STAX, rp LDAX rp XCHG
Instruction MVI r,8 bit data
Description Loads specified register with 8 bit data Addressing mode : Immediate No. of bytes: 2 bytes Example: MVI C,30H
Example details C 30H
MVI M,8 bit data
Loads 8 bit data into a memory location whose address is specified by contents of HL register pair Addressing mode : Register indirect No. of bytes: 2 bytes Example: MVI M,90H Content of source register is copied into the destination register Addressing mode : Register No. of bytes: 1 bytes Example: MOV E,A
assume H = 30H L = 50H [3050] 90H
MOV rd , rs
A = 15H E 15H
MOV M , rs
Contents of source register is copied into the assume HL = 2055 memory location whose address is specified by C = 25H HL register pair [2055] 25H Addressing mode : register indirect No. of bytes: 1 bytes Example: MOV M,C
Instruction MOV rd,M
Description
Example details
Contents in the memory location specified by Assume HL = 2055 HL register pair are copied to the destination Contents of memory location 2055 = 30H register rd Addressing mode : Register indirect B 30H No. of bytes: 1 byte Example: MOV B,M Loads 16 bit data into the register pair B specified C Addressing mode : immediate No. of bytes: 3 bytes Only higher order register is mentioned Example: LXI B,6051H 60H 51H
LXI rp,16 bit data
LDA addr
It loads the content specified by the memory Assume [3500H] = 54H location into the accumulator A 54H Addressing mode : direct No. of bytes: 3 bytes Example: LDA 3500H Contents of accumulator are copied to the A = 54H specified memory location (3800) Addressing mode : direct No. of bytes: 3 bytes Example: STA 3800H
STA addr
54H
Instruction LDAX rp
Description
Example details
Instruction copies content of memory location Assume whose address is specified by register pair in the DE = [4515H] = FFH accumulator only BC or DE register pair is used Addressing mode : Immediate A FFH No. of bytes: 1 byte Example: LDAX D Copies the content of accumulator in the Assume A = 10H memory location specified by register pair BC = 4324H Addressing mode : register indirect [4324] No. of bytes: 1 byte Example: STAX B Copies the content from the memory(address specified) into register L and content of next memory location in register H Addressing mode : direct No. of bytes: 3 bytes Example: LHLD 2500H Copies the contents of the L register in the memory(address specified) and contents of H register in the next memory location Addressing mode : direct No. of bytes: 3 bytes Example: SHLD 2500H Assume [2500] = 35H [2501] = 60H H 60H L 35H Assume L = 30H H = 55H [2500] = 30H [2501] = 55H
STAX rp
10H
LHLD addr
SHLD addr
Instruction XCHG
Description
Example details
Exchange contents of H with D Assume HL = 2060H register and L with E register DE = 3055H Addressing mode : register H = 30H L = 55H No. of bytes: 1 byte D = 20H E = 60H Example: XCHG
MOV rd , rs MOV rd,rs this is the one byte instruction use to transfer the the contents of source register to destination register. Operation : rd