You are on page 1of 9

# Introduction Concept 1 Concept 2 Concept 3 Concept 4

Home
Contact
The 8051 Programmer's Reference: A must have for Assembly Programming

This guide helps in easy Understanding and Visualisation of the instruction Set (Compare the Mnemonic and the Description) Internal RAM Accumulator A (add) Register Banks Rn (add) Rest Of The Bytes add Moving Data in RAM Arithmetic operations Logic Operations Moving Data in ROM Bit Operations and No operations! Comments Welcome! The 8051 programmer's model External RAM Any Program can be written using the following operations:

Program Memory

PSW Addressing Methods for the above blocks

Opcode Mnemonic

Description MOVING DATA FROM ROM

B C Flags

93 83

movC A,@A+DPTR move Code into A ,from the address given by A+DPTR (@A+DPTR) movC A,@A+PC move Code into A ,from the address given by A+PC (@A+PC) MOVING DATA FROM EXTERNAL RAM

1 2 P 1 2 P

E0 E2+p

movX A,@DPTR movX A,@Rp

move from eXt.RAM into A, the value in the addr. pointed by DPTR move from eXt.RAM into A, the val. in the addr. pointed by R0 or R1(@Rp) MOVING DATA INTO EXTERNAL RAM

1 2 P 1 2 P

F0 F2+p

movX @DPTR,A movX @Rp,A

move into eXt.RAM at the addr. pointed by DPTR ,the value in A move into eXt.RAM at the addr. pointed by R0 or R1( @Rp),the value in A MOVING A WORD INTO DPTR

1 2 1 2

90

mov DPTR, # w

move into DPTR, a word(two bytes) (# w)

3 2

Opcode Mnemonic

Description Push and Pop

B C Flags

C0 D0

2 2 SP 2 2 SP

C8+n C5

Exchange the values in A and Rn Exchange the values in A and dir. Addr. add (name)

1 1 P 2 1 P

C6+p D6+p

xch A, @Rp xchD A, @Rp

Exchange the values in A and the address pointed by R0 or R1 (@Rp) Exchange the LSDs of A and the value in addr.pointed by R0 or R1 (@Rp) SWAP Swap the nibbles(hex digits) in A MOVE ZERO INTO A

1 1 P 1 1 P

C4

swap A

1 1

E4

clr A

Clear the Accumulator ROTATION

1 1 P

23 03 33 13

rlA rr A rlc A rrc A

Rotate left the contents of A(bits moved left once,msb into lsb) Rotate right the contents of A(bits moved rt. once,lsb into msb) Rotate left into carry the contents of A (move msb into carry) Rotate right into carry the contents of A (move lsb into carry)

1 1 1 1

1 1 1 C P 1 C P

98+n 95 96+p

subb A,Rn subb A,add subb A,@Rp

sub borrow (C) from the value in A, and also the value in Rn. sub borrow (C) from the value inA,and also the value in add. sub borrow (C) from the val. in A,and also the val. pntd by R0 or R1(@Rp) MULTIPLICATION

1 1 C AC OV P 2 1 C AC OV P 1 1 C AC OV P

A4

mulAB

Multiply the values in A and B . store lsbyte in A,msbyte in B DIVISION

1 4 C OV P

84

divAB

Divide the value in A by the value in B.store quotient in A,remainder in B

1 4 C OV P

Opcode Mnemonic

Description INCREMENT

B C Flags

04 08+n 05 06+p A3

incA inc Rn inc add inc @Rp inc DPTR

Increment the value in A by 1 Increment the value in Register Rn by 1 Increment the value in dir.addr.add(name) by 1 Increment the value in the addr.pointed by R0 or R1(@Rp) by 1 Increment the value in DPTR by 1 DECREMENT

1 1 2 1 1

1 P 1 1 1 2

14 18+n 15 16+p

dec A dec Rn dec add dec @Rp

Decrement the value in A by 1 Decrement the value in Register Rn by 1 Decrement the value in dir.addr.add(name) by 1 Decrement the value in the addr.pointed by R0 or R1(@Rp) by 1 DECIMAL ADJUST ACCUMULATOR

1 1 2 1

1 P 1 1 1

D4

da A

1 1 CP

LOGIC OPERATIONS

Opcode Mnemonic

Description AND LOGIC, IN ACCUMULATOR

B C Flags

54 58+n 55 56+p

anl A,#n anl A,Rn anl A,add anl A,@Rp

Apply AND Logic to value in A and the number n(#n). Apply AND Logic to value in A and value in Rn. Apply AND Logic to value in A and value in addr.add.(name) Apply AND Logic to val. in A and val. in addr.pointed by R0 or R1(@Rp) OR LOGIC, IN ACCUMULATOR

2 1 2 1

1 1 1 1

P P P P

44 48+n 45 46+p

orl A,#n orlA,Rn orl A,add orlA,@Rp

Apply OR Logic to value in A and the number n(#n). Apply OR Logic to value in A and value in Rn. Apply OR Logic to value in A and value in addr.add (name) Apply OR Logic to val. in A and val. in addr.pointed by R0 or R1(@Rp). EXCLUSIVE OR LOGIC, IN ACCUMULATOR

2 1 2 1

1 1 1 1

P P P P

64 68+n 65 66+p

xrl A,#n xrl A,Rn xrl A,add xrl A,@Rp

Apply EX OR Logic to value in A and the number n(#n). Apply EX OR Logic to value in A and value in Rn. Apply EX OR Logic to value in A and value in addr.add (name). Apply EX OR Logic to val. in A and val. in addr.pointed by R0 or R1(@Rp). AND LOGIC, IN DIRECT ADDRESS

2 1 2 1

1 1 1 1

P P P P

53 52

Apply AND Logic to value in the dir.addr.add and the number n(#n). Apply AND Logic to value in the dir.addr.add (name)and value in A. OR LOGIC, IN DIRECT ADDRESS

3 2 2 1

43 42

Apply OR Logic to value in the dir. Addr.add and the number n(#n). Apply OR Logic to value in the dir.addr.add (name)and value in A. EXCLUSIVE OR LOGIC, IN DIRECT ADDRESS

3 2 2 1

63 62

Apply EX OR Logic to value in the dir. Addr.add and the number n(#n). Apply EX OR Logic to value in the dir.addr. add (name)and value in A. COMPLEMENTING ACCUMULATOR

3 2 2 1

F4

cpl A

Compliment the value in A

1 1 P

BIT OPERATIONS Opcode Mnemonic Description BIT MOVEMENT A2 92 mov C,bit movbit, C move into Carry,the value in bit address(name) bit move into the bit address(name) bit,the value in the Carry bit 2 1 C 2 2 B C Flags

Opcode Mnemonic

Description NO OPERATION

B C Flags

00

nop

No operation

1 1

Contact: praveensss@netscape.net