Memoria programma Memoria dati Piedinatura Memoria dati interna

Transcript

Memoria programma Memoria dati Piedinatura Memoria dati interna
Piedinatura
Memoria programma
Memoria dati
Registri (SFR)
Memoria dati
interna
Simbolo
ACC
B
PSW
SP
DPTR
DPL
DPH
PO
P1
P2
P3
IP
IE
TMOD
TCON
THO
TLO
THI
TL1
SCON
SBUF
PCON
Nome
Accumulatore
Registro B
Registro di stato (FLAG)
Stack pointer
Puntatore dati (2 byte)
parte bassa
parte alta
Porta O
Porta 1
Porta 2
Porta 3
Registro priorità interrupt
Registro abilitazione interrupt
Modo contatore/timer
Controllo contatore/timer
Contatore/timer 0 byte alto
Contatore/timer 0 byte basso
Contatore/timer 1 byte alto
Contatore/timer 1 byte basso
Controllo porta seriale
Buffer dati porta seriale
Controllo alimentazione
Indirizzo
(*) OE0H
(*) OF0H
(*) OD0H
81H
82H
83H
(*) 80H
(*) 90H
(*) 0A0H
(*) OB0H
(*) OB8H
(*) OA8H
89H
(*) 88H
8CH
8AH
8DH
8BH
(*) 98H
99H
97H
Arithmetic Operations
Mnemonic
ADD A,Rn
ADD A,direct
ADD A,@Ri
ADD A,#data
ADDC A,Rn
ADDC A,direct
ADDC A,@Ri
ADDC A,#data
SUBB A,Rn
SUBB A,direct
SUBB A,@Ri
SUBB A,#data
INC A
INC Rn
INC direct
INC @Ri
DEC A
DEC Rn
DEC direct
DEC @Ri
INC DPTR
MUL AB
DIV AB
DA A
Logical Operations
Description
Osc.
Period
Add register to Accumulator
12
Add direct byte to Accumulator
12
Add indirect RAM to Accumulator
12
Add immediate data to Accumulator
12
Add register to Acc. with Carry
12
Add direct byte to Acc. with Carry
12
Add indirect RAM to Acc. with Carry
12
Add immediate data to Acc. / Carry
12
Subtract reg. from Acc. with borrow
12
Sub. direct byte from Acc. / borrow
12
Sub. indirect RAM from Acc./ borrow
12
Sub. imm. data from Acc. / borrow
12
Increment Accumulator
12
Increment register
12
Increment direct byte
12
Increment indirect RAM
12
Decrement Accumulator
12
Decrement register
12
Decrement direct byte
12
Decrement indirect RAM
12
Increment Data Pointer
24
Multiply A and B
48
Divide A by B
48
Decimal adjust Accumulator
12
Mnemonic
ANL A,Rn
ANL A,direct
ANL A,@Ri
ANL A,#data
ANL direct,A
ANL direct,#data
ORL A,Rn
ORL A,direct
ORL A,@Ri
ORL A,#data
ORL direct,A
ORL direct,#data
XRL A,Rn
XRL A,direct
XRL A,@Ri
XRL A,#data
XRL direct,A
XRL direct,#data
CLR A
CPL A
RL A
RLC A
RR A
RRC A
SWAP A
Description
Osc.
Period
AND register to Accumulator
12
AND direct byte to Accumulator
12
AND indirect RAM to Accumulator
12
AND immediate data to Accumulator
12
AND Accumulator to direct byte
12
AND immediate data to direct byte
24
OR register to Accumulator
12
OR direct byte to Accumulator
12
OR indirect RAM to Accumulator
12
OR immediate data to Accumulator
12
OR Accumulator to direct byte
12
OR immediate data to direct byte
24
Exc-OR register to Accumulator
12
Exc-OR direct byte to Accumulator
24
Exc-OR indirect RAM to Accumulator
12
Exc-OR immediate data to Acc.
12
Exc-OR Accumulator to direct byte
12
Exc-OR imm. data to direct byte
24
Clear Accumulator
12
Complement Accumulator
12
Rotate Accumulator left
12
Rotate Acc. left through Carry
12
Rotate Accumulator right
12
Rotate Acc. right through Carry
12
Swap nibbles within the Accumulator
12
Data Transfer
Mnemonic
MOV A,Rn
MOV A,direct
MOV A,@Ri
MOV A,#data
MOV Rn,A
MOV Rn,direct
MOV Rn,#data
MOV direct,A
MOV direct,Rn
MOV direct,direct
MOV direct,@Ri
MOV direct,#data
MOV @Ri,A
MOV @Ri,direct
MOV @Ri,#data
MOV DPTR,#data16
MOVC A,@A+DPTR
MOVC A,@A+PC
MOVX A,@Ri
MOVX A,@DPTR
MOVX @Ri,A
MOVX @DPTR,A
PUSH direct
POP direct
XCH A,Rn
XCH A,direct
XCH A,@Ri
XCHD A,@Ri
Description
Move register to Accumulator
Move direct byte to Accumulator
Move indirect RAM to Accumulator
Move immediate data to Accumulator
Move Accumulator to register
Move direct byte to register
Move immediate data to register
Move Accumulator to direct byte
Move register to direct byte
Move direct byte to direct byte
Move indirect RAM to direct byte
Move immediate data to direct byte
Move Accumulator to indirect RAM
Move direct byte to indirect RAM
Move immediate data to indirect RAM
Load Data Pointer with 16-bit const
Move Code byte rel. to DPTR to Acc.
Move Code byte rel. to PC to Acc.
Move Ext. RAM (8-bit addr.) to Acc.
Move Ext. RAM (16-bit addr) to Acc.
Move Acc. to Ext. RAM (8-bit addr.)
Move Acc. to Ext. RAM (16-bit addr)
Push direct byte onto stack
Pop direct byte from stack
Exchange register with Accumulator
Exchange direct byte with Acc.
Exchange indirect RAM with Acc.
Exchange low order digit indirect
RAM with Accumulator
Program Branching
Osc.
Period
12
12
12
12
12
24
12
12
24
24
24
24
12
24
12
24
24
24
24
24
24
24
24
24
12
12
12
12
Mnemonic
ACALL addr11
LCALL addr16
RET
RETI
AJMP addr11
LJMP addr16
SJMP rel
JMP @A+DPTR
JZ rel
JNZ rel
CJNE A,direct,rel
CJNE A,#data,rel
CJNE
Rn,#data,rel
CJNE
@Ri,#data,rel
DJNZ Rn,rel
DJNZ direct,rel
NOP
Description - Program
Branching
Absolute subroutine call
Long subroutine call
Return from subroutine
Return from interrupt
Absolute jump
Long jump
Short jump (relative address)
Jump indirect relative to the
DPTR
Jump if Accumulator is zero
Jump if Accumulator is not
zero
Compare direct byte to
Accumulator
and jump if not equal
Compare immediate data to
Accumulator and jump if not
equal
Compare immediate data to
register
and jump if not equal
Compare immediate data to
indirect
RAM and jump if not equal
Decr. register and jump if not
zero
Decrement direct byte and
jump if
not zero
No operation
Osc.
Period
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
12
Notes on Instruction Set and Addressing
Modes
•
•
•
•
•
•
•
•
Rn = Register R0 - R7 of the currently selected
register bank. direct = 8-bit internal data
location's address.This could be an internal
Data RAM location (0-127) or a SFR.
@Ri = 8-bit internal Data RAM location
addressed indirectly through register R0 or R1.
#data = 8-bit constant included in instruction.
#data16 = 16-bit constant included in
instruction.
Addr11 = 11-bit destination address. Used by
ACALL and AJMP. The branch will be within the
same 2K byte page of Program Memory as the
first byte of the following instruction.
addr16 = 16-bit destination address. Used by
LCALL and LJMP. A branch can be anywhere within
the 64K byte Program Memory address space.
rel = Signed (two's complement) 8-bit offset
byte. Used by SJMP and all conditional jumps.
Range is -128 to +127 bytes relative to first
byte of the following instruction.
bit = Direct addressed bit in internal Data RAM
or SFR.
Bit Operations
Mnemonic
CLR C
CLR bit
SETB C
SETB bit
CPL C
CPL bit
ANL C,bit
ANL C,/bit
ORL C,bit
ORL C,/bit
MOV C,bit
MOV bit,C
JC rel
JNC rel
JB bit,rel
JNB bit,rel
JBC bit,rel
Description
Clear Carry
Clear direct bit
Set Carry
Set direct bit
Complement Carry
Complement direct bit
AND direct bit to Carry
AND complement of dir. bit to Carry
OR direct bit to Carry
OR complement of dir. bit to Carry
Move direct bit to Carry
Move Carry to direct bit
Jump if Carry is set
Jump if Carry not set
Jump if direct bit is set
Jump if direct bit is not set
Jump if dir. bit is set & clear bit
Osc.
Period
12
12
12
12
12
12
24
24
24
24
12
24
24
24
24
24
24
PSW: il registro di stato
CY AC F0 RS1 RS0 OV P
I bit del registro di stato sono indirizzabili separatamente:
•
CY (PSW.7) : CarrY flag, ossia flag di riporto. Questo bit viene utilizzato come accumulatore dalle istruzioni che operano sui singoli bit. In
tal caso il bit suddetto viene indicato con la lettera C.
•
AC(PSW.6) : Auxiliary Carry ovvero flag di riporto ausiliario; utilizzato nelle operazioni in BCD, rappresenta il riporto che si può
verificare tra il 4° e il 5° bit di un dato da 1 byte.
•
FO (PSW.5) : Flag 0 utilizzabile dall'utente.
•
RS1 (PSW.4) : Register bank Selector bit 1.
•
RSO (PSW.3) : Register bank Selector bit 0. Insieme a RS1 seleziona il banco di 8 registri. R0 - R7 nella memoria RAM interna da 128
byte:
RS1
RS0 REGISTER BANK ADDRESS
0
0
00H-07H
0
1
08H-0FH
1
0
10H-17H
1
1
18H-1FH
•
OV(PSW.2) : OVerflow; flag che indica il superamento dei limiti dell 'operando. - (PSW. 1) : flag definibile dall'utente.
•
P (PSW.O) : Parity flag flag di parità. I1 suo valore rispecchia direttamente il numero di 1 presenti nell'accumulatore. P = 1 se il numero di
bit ad 1 nell'accumulatore è dispari; P = O se il numero di bit ad 1 nell'accumulatore è pari.
Tabella vettori di interruzione
Indirizzo di salto Sorgente interruzione
0003H(3)
INTO
000BH(11)
Timer0
0013H (19)
INT1
001BH(27)
Timerl
0023H (35)
Porta seriale
Indirizzo di memoria scheda DB8051
80A1H
80A4H
80A7H
80AAH
80ADH
Esempio di inizializzazione vettore di interrupt:
MOV DPTR,#80A7H
MOV A,#85H
MOVX @DPTR,A
INC DPTR
MOV A,#00
MOVX @DPTR,A
il servizio di interruzione per INT1 di trova alla 8500h