Microcontroller 8051 Instruction Set
Microcontroller 8051 Instruction Set
Contents:
Introduction Block Diagram and Pin Description of the 8051 Registers Some Simple Instructions Structure of Assembly language and Running an 8051 program Memory mapping in 8051 8051 Flag bits and the PSW register Addressing Modes 16-bit, BCD and Signed Arithmetic in 8051 Stack in the 8051 LOOP and JUMP Instructions CALL Instructions I/O Port Programming
General-purpose microprocessor
CPU for Computers No RAM, ROM, I/O on CPU chip itself Example Intels x86, Motorolas 680x0
Introduction
Data Bus
RAM
ROM
I/O Port
Timer
Microcontroller :
A smaller computer On-chip RAM, ROM, I/O ports... Example Motorolas 6811, Intels 8051, Zilogs Z8 and PIC 16X
A single chip
Microcontroller
Embedded System
Embedded system means the processor is embedded into that application. An embedded product uses a microprocessor or microcontroller to do one task only. In an embedded system, there is only one application software that is typically burned into ROM. Example printer, keyboard, video game player
Block Diagram
External interrupts Interrupt Control On-chip ROM for program code
Timer/Counter
On-chip RAM
Timer 1 Timer 0
Counter Inputs
OSC
Bus Control
4 I/O Ports
P0 P1 P2 P3
TxD RxD
Feature 8051 ROM (program space in bytes) 4K RAM (bytes) 128 Timers 2 I/O pins 32 Serial port 1 Interrupt sources 6
8052 8K 256 3 32 1 8
8031 0K 128 2 32 1 6
8051 (8031)
Registers
A B R0 R1 R2 R3 R4 R5 R6 R7 Some 8-bitt Registers of the 8051 Some 8051 16-bit Register PC PC DPTR DPH DPL
8k
0000H
32k
30H 2FH Bit-Addressable RAM 20H 1FH 18H 17H 10H 0FH 08H 07H 00H Register Bank 3 Register Bank 2 Stack) Register Bank 1) Register Bank 0
RAM memory space allocation in the 8051 Total of 128 bytes of RAM inside the 8051 are assigned addresses 00H to 7FH (a) Total of 32 bytes from locations 00H to 1FH are set aside for register bank and the stack. (b) Total of 16 bytes from locations 20H to 2FH are set aside for bit addressable read/write memory. (c) Total of 80 bytes from locations 30H to 7FH are used for read and write storage, called Scratch pad area used for storing data.
Wednesday, September 4, 2013
Carry flag Auxiliary carry flag Available to the user for general purpose Register Bank selector bit 1 Register Bank selector bit 0 Overflow flag User define bit Parity flag Set/Reset odd/even parity
RS1 0 0 1 1 RS0 0 1 0 1 Register Bank 0 1 2 3
Note: X can be 0 or 1
MOV A,#data(8bit) load accumulator with 8bit data eg: MOV A,#16h A 16h MOV A,10h the data from RAM location 10 will be loaded to accumulator.
12 11 10 0F 0E 34
34h
MOV Rn,# data Eg: MOV R4,#56h R4 56h MOV 03h, # 45h 03h 45h (03 0r R3 is address) MOV A,Rn Eg: MOV A,R3 load Accumulator with the content of R3 MOV Rn,A Rn A
Wednesday, September 4, 2013
MOV addr(8),addr(8) To represent data starting with alphabets from A to F, should be added 0 as prefix Eg : MOV 00h,# 0AEh MOV addr(8), A Addr A MOV Rn,Rn is invalid
Wednesday, September 4, 2013
[Rp is R0 or R1) MOV A, @Rn The content of memory location whose address is stored in the register Rp will be moved to the accumulator. MOV addr(8),@Rp MOV @Rp, #data MOV @Rp, A MOV @Rp,addr(8)
DATA POINTER
The Data Pointer (DPTR) is the 8051s only useraccessable 16-bit (2-byte) register. The Accumulator, "R" registers, and "B" register are all 1-byte values. DPTR, as the name suggests, is used to point to data. It is used by a number of commands which allow the 8051 to access external memory. When the 8051 accesses external memory it will access external memory at the address indicated by DPTR. While DPTR is most often used to point to data in external memory, many programmers often take advantage of the fact that its the only true 16-bit register available. It is often used to store 2-byte values which have nothing to do with memory locations.
Wednesday, September 4, 2013
Function: Move Data To/From External Memory (XRAM) Syntax: MOVX operand1,operand2 Instructions MOVX @DPTR,A MOVX @Rp, A MOVX A,@DPTR MOVX A, @Rp Description: MOVX moves a byte to or from External Memory into or from the Accumulator. If operand1 is @DPTR, the Accumulator is moved to the 16-bit External Memory address indicated by DPTR. This instruction uses both P0 (port 0) and P2 (port 2) to output the 16-bit address and data.
Wednesday, September 4, 2013
MOVX
MOVX
If operand2 is DPTR then the byte is moved from External Memory into the Accumulator. If operand1 is @R0 or @R1, the Accumulator is moved to the 8-bit External Memory address indicated by the specified Register. This instruction uses only P0 (port 0) to output the 8bit address and data. P2 (port 2) is not affected. If operand2 is @R0 or @R1 then the byte is moved from External Memory into the Accumulator.
Wednesday, September 4, 2013
MOVC
Operation: MOVC Function: Move Code Byte to Accumulator Syntax: MOVC A, @A+register Instructions : MOVC A,@A+DPTR MOVC A,@A+PC Description: MOVC moves a byte from Code Memory into the Accumulator. The Code Memory address from which the byte will be moved is calculated by summing the value of the Accumulator with either DPTR or the Program Counter (PC). In the case of the Program Counter, PC is first incremented by 1 before being summed with the Wednesday, September 4, 2013 Accumulator.
ARITHMETIC INSTRUCTIONS All addition is done with the A register as the destination of the result ADD A,#data(8) A+data(8) A ADD A, Rn(n=0 to 7) add A and the content of Rn, result is in A A+addr(8) A ADD A,add(8) - add A and the content of address, result is in A A+addr(8) A ADD A, @Rp (Rp is R0 or R1) add the contents of address in Rp ; put result in A
Wednesday, September 4, 2013
ADDC A,@Rp add the content of A, the content of indirect address in Rp,and the C flag; put result in A
Wednesday, September 4, 2013
SUBTRACTION
Subtraction can be done by taking the twos complement of the number to be subtracted, the subtrahend and adding it to the other number. The 8051 has commands to perform the direct subtraction of two unsigned and signed numbers. Like addition Register A is the destination address for the subtraction. Subtraction always subtract the carry flag (borrow) as part of the operation
Wednesday, September 4, 2013
Subtraction
SUBB A,#data(8) A - data(8)- CY A Subtract immediate data(8) and the C Flag from A and the result will be in A. SUBB A, add(8) A add(8) - CY SUBB A, Rn A- Rn- CY A
SUBB A, @Rp: Subtract the contents of the address in Rp and the C Flag from A and result is stored in A
Wednesday, September 4, 2013
Unsigned subtraction
In the above instruction C Flag is always subtracted from A along with the source byte. It must be set to 0, if programmer does not want the carry Flag to be included in the subtraction. In a multibyte subtraction the carry flag has to be cleared for first byte and then included for the subsequent higher byte operations. The result will be in the true form, with no borrow if the source number is smaller than A. The result will be in Twos complement form, with borrow if the source is larger than A. All bits are considered as the magnitude.
Wednesday, September 4, 2013
Example
MOV A, #7B H ;A=7Bh MOV 0F0h,#02h ;B=02h MUL AB ;A=F6h and B=00h,OV=0 MOV B, #0FEh ;B= FEh MUL AB ;A=14h, B=F4h,OV Flag=1
Division operation use registers A and B as both the source and destination addresses for the operation. DIV AB Divide A by B; the integer part of quotient in register A and the integer part of the remainder in B. The OV flag is cleared to 0 unless B holds 00h before the DIV. Then the overflow flag is set to 1 to show division by 0. This division is undefined. The carry flag is always reset. Wednesday, September 4, 2013
Division
Example MOV A,#0FFh MOV 0F0h,#2Ch DIV AB DIV AB DIV AB DIV AB A = FFh B = 2Ch A = 05h and B = 23h A = 00h and B = 05h A = 00h and B = 00h A = ? and B = ?; OV = 1
Decimal arithmetic
Most of the real world application which involves interacting with the human beings, which insists the numbering to be done in decimal number system. Four bits are required to represent the decimal 0-9 (0000h-1001h) DA A Adjust the sum of two packed BCD numbers found in A register; result in A The DA A will work with the instruction ADDC or ADD.
Wednesday, September 4, 2013
INCREMENT
Operation: INC No flags are affected(C,AC,OV) Function: Increment Register Instructions INC A INC Rn INC @Rp INC addr INC DPTR Description: INC increments the value of register or content of address by 1. In the case of "INC DPTR", the value two-byte unsigned integer value of DPTR is incremented.
Wednesday, September 4, 2013
Decrement
Operation:DEC Instructions DEC A DEC Rn DEC @Rp DEC addr(8) Description: DEC decrements the value of register or the content of address by 1.
Clear
Operation:CLR Instructions CLR addr(8) Clear the content of address specified CLR C Clear carry flag CLR A Clear the content of accumulator Description: CLR clears (sets to 0) all the bit(s) of the indicated register. If the register is a bit (including the carry bit), only the specified bit is affected. Clearing the Accumulator sets the Accumulators value to 0.
Wednesday, September 4, 2013
Logical Instruction
Operation: CPL Function: Complement Syntax: CPL operand Instructions CPL A - complement each bit of A CPL C - complement Carry
Operation: ANL Function: Bitwise AND Instructions ANL addr(8), A AND each bit of A with same bit of direct RAM address and store the result in addr(8) ANL A,addr(8) -AND each bit of A with same bit of direct RAM address and store the result in A ANL addr(8), #data ANL A, #data ANL A, Rn ANL A, @Rp ANL A,R0 ANL C, bit addr
AND operation
XOR
Operation: XRL Function: Bitwise Exclusive OR Instructions XRL addr(8), A XRL addr(8), #data XRL A, #data XRL A, addr(8) XRL A, @Rp
Description: XRL does a bitwise "EXCLUSIVE OR" operation between operand1 and operand2, leaving the resulting value in operand1. The value of operand2 is not affected.
Wednesday, September 4, 2013
OR Operation
Operation: ORL Function: Bitwise OR Instructions ORL addr(8), A ORL addr(8), #data ORL A, #data ORL A, addr(8) ORL A,@R0 ORL C, bit
Description: ORL does a bitwise "OR" operation between operand1 and operand2, leaving the resulting value in operand1. The value of operand2 is not affected.
Wednesday, September 4, 2013
ROTATE LEFT
Operation: RL Function: Rotate Accumulator Left Syntax: RL A Description: Shifts the bits of the Accumulator to the left. The left-most bit -bit 7 of the Accumulator is loaded into bit0. Operation: RLC Function: Rotate Accumulator Left Through Carry Syntax: RLC A Description: Shifts the bits of the Accumulator to the left. The left-most bit (bit 7) of the Accumulator is loaded into the Carry Flag, and the original Carry Flag is loaded into bit 0 of the Accumulator. This function can be used to quickly multiply a byte by 2.
ROTATE RIGHT
Operation: RR Function: Rotate Accumulator Right Syntax: RR A Description: Shifts the bits of the Accumulator to the right. The right-most bit -bit 0 of the Accumulator is loaded into bit7. Operation: RRC Function: Rotate Accumulator Right Through Carry Syntax: RRC A Description: Shifts the bits of the Accumulator to the right. The right-most bit (bit 0) of the Accumulator is loaded into the Carry Flag, and the original Carry Flag is loaded into bit 7. This function can be used to quickly divide a byte by 2.
LJMP(long jump) LJMP is an unconditional jump. It is a 3-byte instruction. It allows a jump to any memory location from 0000 to FFFFH. AJMP(absolute jump) In this 2-byte instruction, It allows a jump to any memory location within the 2k block of program memory. SJMP(short jump) In this 2-byte instruction. The relative address range of 00FFH is divided into forward and backward jumps, that is , within -128 to +127 bytes of memory relative to the address of the current PC.
JMP
Operation: JMP Function: Jump to Data Pointer + Accumulator Syntax: JMP @A+DPTR Description: JMP jumps unconditionally to the address represented by the sum of the value of DPTR and the value of the Accumulator.
Wednesday, September 4, 2013
Operation: CJNE Function: Compare and Jump If Not Equal Syntax: CJNE operand1,operand2,reladdr CJNE A, #data ,relative-address
Compare the content of the accumulator and the data and branch to the relative address if not equal
CJNE
CJNE A, addr(8),relative-address CJNE @Rp, #data, relative-address Description: CJNE compares the value of operand1 and operand2 and branches to the indicated relative address if operand1 and operand2 are not equal. If the two operands are equal program flow continues with the instruction following the CJNE instruction. The Carry bit (C) is set if operand1 is less than operand2, otherwise it is cleared.
Wednesday, September 4, 2013
JNC
Operation: JNC Function: Jump if Carry Not Set Syntax: JNC reladdr Description: JNC branches to the address indicated by reladdr if the carry bit is not set. If the carry bit is set program execution continues with the instruction following the JNC instruction.
JC
Operation: JC Function:Jump if Carry Set Syntax:JC reladdr Description: JC will branch to the address indicated by reladdr if the Carry Bit is set. If the Carry Bit is not set program execution continues with the instruction following the JC instruction.
JNZ
Operation: JNZ Function: Jump if Accumulator Not Zero Syntax:JNZ reladdr Description: JNZ will branch to the address indicated by reladdr if the Accumulator contains any value except 0. If the value of the Accumulator is zero program execution continues with the instruction following the JNZ instruction.
JZ
Operation: JZ Function:Jump if Accumulator Zero Syntax:JZ reladdr Description: JZ branches to the address indicated by reladdr if the Accumulator contains the value 0. If the value of the Accumulator is non-zero program execution continues with the instruction following the JZ instruction.
JNB
Operation: JNB Function: Jump if Bit Not Set Syntax: JNB bit addr, reladdr Description: JNB will branch to the address indicated by relative address if the indicated bit is not set. If the bit is set program execution continues with the instruction following the JNB instruction.
JB
Operation: JB Function:Jump if Bit Set Syntax:JB bit addr, reladdr Description: JB branches to the address indicated by relative address if the bit indicated by bit addr is set. If the bit is not set program execution continues with the instruction following the JB instruction.
JBC
Operation: JBC Function: Jump if Bit Set and Clear Bit Syntax: JB bit addr, reladdr Description: JBC will branch to the address indicated by reladdr if the bit indicated by bit addr is set. Before branching to reladdr the instruction will clear the indicated bit. If the bit is not set program execution continues with the instruction following the JBC instruction.
SETB
Operation: SETB Function: Set Bit Syntax: SETB bit addr Description: Sets the specified bit.
SWAP
Operation: SWAP Function: Swap Accumulator Nibbles Syntax: SWAP A Description: SWAP swaps bits 0-3 of the Accumulator with bits 4-7 of the Accumulator. This instruction is identical to executing "RR A" or "RL A" four times.
Wednesday, September 4, 2013
Operation: PUSH Function: Push Value Onto Stack PUSH addr(8); Description: PUSH "pushes" the value of the specified addr(8) onto the stack. PUSH first increments the value of the Stack Pointer by 1, then takes the value stored in internal RAM addr and stores it in Internal RAM at the location pointed to by the incremented Stack Pointer.
PUSH
POP
Operation: POP Function: Pop Value From Stack Syntax: POP POP addr(8) Description: POP "pops" the last value placed on the stack into the internal RAM address specified. In other words, POP will load addr(8) with the value of the Internal RAM address pointed to by the current Stack Pointer. The stack pointer is then decremented by 1.
CALL Instructions
Another control transfer instruction is the CALL instruction, which is used to call a subroutine.
LCALL(long call) This 3-byte instruction can be used to call subroutines located anywhere within the 64K byte address space of the 8051. ACALL (absolute call) ACALL is 2-byte instruction. The target address of the subroutine must be within 2K byte range.
Wednesday, September 4, 2013
RETURN
Operation: RET Function: Return From Subroutine Syntax: RET Description: RET is used to return from a subroutine previously called by LCALL or ACALL. Program execution continues at the address that is calculated by popping the topmost 2 bytes off the stack. The most-significant-byte is popped off the stack first, followed by the least-significant-byte.
Wednesday, September 4, 2013
XCH
Function: Exchange Bytes Syntax: XCH A, Rn XCH A, @Rp XCH A, addr Description: Exchanges the value of the Accumulator with the value contained in register.
Function: Exchange Digit Syntax: XCHD A,@Rp XCHD A,@R0 XCHD A,@R1 Description: Exchanges bits 0-3 of the Accumulator with bits 0-3 of the Internal RAM address pointed to indirectly by R0 or R1. Bits 4-7 of each register are unaffected. Eg: RAM location 40H = 97H MOV A,#12H MOV R1,#40H XCHD A,@R1 After execution A = 17H and RAM location 40H =92H
Wednesday, September 4, 2013
XCHD
Operation: NOP Function: None, waste time Syntax: No Operation Description: NOP, as its name suggests, causes No Operation to take place for one machine cycle. NOP is generally used only for timing purposes. Absolutely no flags or registers are affected.
Wednesday, September 4, 2013
Addressing Modes
Immediate Register Direct Register Indirect Indexed
IRAN
Although the entire of 128 bytes of RAM can be accessed using direct addressing mode, it is most often used to access RAM loc. 30 7FH. MOV MOV MOV MOV R0, 40H 56H, A A, 4 6, 2
In other word, the content of register R0 or R1 is sources or target in MOV, ADD and SUBB insructions. Example: Write a program to copy a block of 10 bytes from RAM location sterting at 37h to RAM location starting at 59h. Solution: MOV R0,37h MOV R1,59h MOV R2,10 L1: MOV A,@R0 MOV @R1,A INC R0 INC R1 DJNZ R2,L1
jump
XTAL2
XTAL1
GND
Example :
Find the machine cycle for (a) XTAL = 11.0592 MHz (b) XTAL = 16 MHz. Solution: (a) 11.0592 MHz / 12 = 921.6 kHz; machine cycle = 1 / 921.6 kHz = 1.085 s (b) 16 MHz / 12 = 1.333 MHz; machine cycle = 1 / 1.333 MHz = 0.75 s
9 RST
31 10 uF 30 pF
EA/VPP X1
9 8.2 K
X2 RST
Note 1: MOV A,#72H After instruction MOV 8086 MOV MOV MOV MOV
MOV A,72H A,72H the content of 72th byte of RAM will replace in Accumulator. 8051 MOV MOV MOV
MOV
A,3
ADD A, Source
;A=A+SOURCE
SETB CLR
SETB SETB SETB SETB SETB
Note:
bit bit
C P0.0 P3.7 ACC.2 05
; bit=1 ; bit=0
; CY=1 ;bit 0 from port 0 =1 ;bit 7 from port 3 =1 ;bit 2 from ACCUMULATOR =1 ;set high D5 of RAM loc. 20h
Bit Addressable Page 359,360
CLR instruction is as same as SETB i.e: CLR C ;CY=0 But following instruction is only for CLR: CLR A ;A=0
Wednesday, September 4, 2013
SUBB
SETB C SUBB A,R5
A,source ;A=A-source-CY
;CY=1 ;A=A-R5-1
ADC
SETB C ADC
A,source ;A=A+source+CY
;CY=1 A,R5 ;A=A+R5+1
DEC INC
INC DEC DEC
byte byte
R7 A 40H
;byte=byte-1 ;byte=byte+1
; [40]=[40]-1
CPL
Example: L01: MOV CPL MOV ACALL SJMP
;1s complement
A,#55H ;A=01010101 B A P1,A DELAY L01
CALL
ANL - ORL - XRL EXAMPLE: MOV R5,#89H ANL R5,#08H RR RL RRC RLC EXAMPLE:
RR A
Wednesday, September 4, 2013
Example: MOV A,#88H ADD A,#93H 88 10001000 +93 +10010011 ---- -------------11B 00011011 CY=1 AC=0 P=0
Example: MOV A,#9CH ADD A,#64H 9C +64 ---100 CY=1 AC=1 10011100 +01100100 -------------00000000 P=0
Example: MOV A,#38H ADD A,#2FH 38 +2F ---67 CY=0 AC=1 00111000 +00101111 -------------01100111 P=1
Example: Assuming that ROM space starting at 250h contains Hello., write a program to transfer the bytes into RAM locations starting at 40h. Solution: ORG 0 MOV DPTR,#MYDATA MOV R0,#40H L1: CLR A MOVC A,@A+DPTR JZ L2 MOV @R0,A INC DPTR INC R0 SJMP L1 L2: SJMP L2 ;------------------------------------ORG 250H MYDATA: DB Hello,0 END Notice the NULL character ,0, as end of string and how we use the JZ instruction to detect that.
Example: Write a program to get the x value from P1 and send x 2 to P2, continuously . Solution: ORG 0 MOV DPTR, #TAB1 MOV A,#0FFH MOV P1,A L01: MOV A,P1 MOVC A,@A+DPTR MOV P2,A SJMP L01 ;---------------------------------------------------ORG 300H TAB1: DB 0,1,4,9,16,25,36,49,64,81 END
;A=2, B=5
Example: MOV MOV MOV PUSH PUSH PUSH R6,#25H R1,#12H R4,#0F3H 6 1 4
SP=08H
SP=09H
SP=08H
SJMP and LJMP: LJMP(long jump) LJMP is an unconditional jump. It is a 3-byte instruction in which the first byte is the opcode, and the second and third bytes represent the 16-bit address of the target location. The 20byte target address allows a jump to any memory location from 0000 to FFFFH. SJMP(short jump) In this 2-byte instruction. The first byte is the opcode and the second byte is the relative address of the target location. The relative address range of 00-FFH is divided into forward and backward jumps, that is , within -128 to +127 bytes of memory relative to the address of the current PC.
Wednesday, September 4, 2013
CJNE , JNC
Exercise: Write a program that compare R0,R1. If R0>R1 then send 1 to port 2, else if R0<R1 then send 0FFh to port 2, else send 0 to port 2.
CALL Instructions
Another control transfer instruction is the CALL instruction, which is used to call a subroutine. LCALL(long call) In this 3-byte instruction, the first byte is the opcode an the second and third bytes are used for the address of target subroutine. Therefore, LCALL can be used to call subroutines located anywhere within the 64K byte address space of the 8051.
Wednesday, September 4, 2013
Port 1 is denoted by P1. P1.0 ~ P1.7 We use P1 as examples to show the operations on ports. P1 as an output port (i.e., write CPU data to the external pin) P1 as an input port (i.e., read pin data into CPU bus)
A Pin of Port 1
Read latch TB2 Vcc Load(L1) Internal CPU bus Write to latch
D Q
P1.X
Clk Q
P1.X pin M1
8051 IC
P0.x
2 Tri-state buffer
TB1: controlled by Read pin
Read pin 1 really read the data present at the pin
A transistor M1 gate
Gate=0: open Wednesday, September 4, 2013
Tri-state Buffer
Output Input
Low
Highimpedance (open-circuit)
Vcc
1 0
M1
P1.X
Clk Q
P1.X pin
output 1
8051 IC
ground
P1.X pin
0 1
M1
P1.X
Clk Q
output 0
8051 IC
BACK:
Q
P1.X
Write to latch
Clk
M1
8051 IC
Q
P1.X
P1.X pin
Write to latch
Clk
M1
8051 IC
BACK:
Reading Latch
Exclusive-or the Port 1 MOV P1,#55H ;P1=01010101 ORL P1,#0F0H ;P1=11110101 1. The read latch activates TB2 and bring the data from the Q latch into CPU. Read P1.0=0 2. CPU performs an operation. This data is ORed with bit 1 of register A. Get 1. 3. The latch is modified. D latch of P1.0 has value 1. 4. The result is written to the external pin. External pin (pin 1: P1.0) has value 1.
Q
P1.X
Clk
M1
Read-modify-write Feature
Read-modify-write Instructions Table C-6 This features combines 3 actions in a single instruction 1. CPU reads the latch of the port 2. CPU perform the operation 3. Modifying the latch 4. Writing to the pin Note that 8 pins of P1 work independently.
Read-Modify-Write Instructions
Mnemonics
ANL
Example
ANL P1,A
ORL
XRL
ORL P1,A
XRL P1,A
SETB PX.Y
SETB P1.4
Other Pins
P1, P2, and P3 have internal pull-up resisters. P1, P2, and P3 are not open drain. P0 has no internal pull-up resistors and does not connects to Vcc inside the 8051. P0 is open drain. Compare the figures of P1.X and P0.X. However, for a programmer, it is the same to program P0, P1, P2 and P3. All the ports upon RESET are configured as output.
A Pin of Port 0
Read latch TB2
P1.X
Clk Q
P0.X pin M1
P1.x
8051 IC
P0.0 DS5000 P0.1 P0.2 8751 P0.3 P0.4 8951 P0.5 P0.6 P0.7
Port 0
74LS373
PSEN ALE P0.0 P0.7
G D
74LS373
OE OC A0 A7 D0
EA P2.0 P2.7
D7
A8 A15
ROM
A7
A8 A12
8051
Wednesday, September 4, 2013
ROM
74LS373
OE OC A0 A7 D0
Address
EA P2.0 P2.7
ROM
ALE Pin
The ALE pin is used for de-multiplexing the address and data by connecting to the G pin of the 74LS373 latch.
When ALE=0, P0 provides data D0-D7. When ALE=1, P0 provides address A0-A7. The reason is to allow P0 to multiplex address and data.