Showing posts with label Materials. Show all posts
Showing posts with label Materials. Show all posts

MICRO CONTROLLER 8051 INSTRUCTION SET

Don’t forget to :  Follow us on Twitter or  Facebook for updates.


MICRO CONTROLLER 8051 INSTRUCTION SET

The micro controller 8051 instruction set include 110 instructions,49 of which are single byte instruction , 45 are two bytes instruction and 17 are three byte instructions and 17 are three byte instructions.The instruction format consists of a function mnemonic followed by destination and source field.

All the instruction of micro controller 8051 may be classified based on the functional aspect are given below

1.Data transfer group
2.arithmetic group
3.Logical group
4.Bit manipulation group
5.Branching or control transfer group

we deal about addressing methods in the previous post.

DATA TRANSFER - GENERAL PURPOSE

Data transfer operations are divided into three classes general purpose, accumulator specific ,Address-object , Normally none of these operations affect the PSW flag settings except a POP or MOV directly to the PSW.

MOVe perform a byte or bit transfer from the specified source operand to the destination operand.

Execution of PUSH instruction first increments the Sp register and then transfer a byte from the specified source to the stack memory location addressed by SP.

POP instruction transfer a byte from the stack memory location pointed by SP to the destination and then decrements SP.
DATA TRANSFER-ACCUMULATOR SPECIFIC

XCH exchange the specified source byte with accumulator.

XCHD exchange the lower-order nibble of the specified source byte with the low-order nibble
pf the accumulator.Higher nibble of the accumulator and source byte remain same.

MOVX perform a byte transfer from the external data memory address is pointed by DPTR
( 16 bit address) or the internal pointer R0 or R1 ( 8 bit address ) register.

MOVC moves a byte from program memory to the accumulator . The accumulator is used as an index
into 256 byte table pointed to by the base register DPTR or PC .
The required byte is transferred to the accumulator.

DATA TRANSFER -ADDRESS TRANSFER

MOV DPTR , # address initializes the given immediate address into pair of destination register,
DPH and DPL.

ARITHMETIC INSTRUCTION

The 8051 micro-controller has four mathematical operations.8 bit operations using unsigned arithmetic
are supported directly .The overflow flag helps the user to do addition and subtraction to serve for
both signed and unsigned binary numbers.Arithmetic operation can also be performed directly on BCD.
Carry flag helps to indicate that the result is not an 8 bit instead it is an 9 bit in addition process.
The same carry flag helps us to indicates that the result is in two's compliment from the subtraction process.


ADDITION

ADD instruction adds accumulator content to the specified source content and returns the result to a
accumulator.Based on the result , the carry flag is set or reset.

ADDC ( add with carry ) instruction adds accumulator content, the specified source content and thr carry flag
and returns the result accumulator .Based on the result the carry flag is set or reset.

DA ( decimal adujst for BCD addition ) correct the sum which result from the binary addition of two two digit
decimal operands.The packed decimal sum formed by the instruction DA is returned to accumulator .The carry flag is
set if the result is greater than 99,otherwise i=it is cleared.

INC ( increment ) adds one to the specified source content and the result is put in the same source register.

SUBTRACTION

SUBB ( subtract with borrow)instruction subtracts the specified source content and the carry flag content from the accumulator , the result is transferred into accumulator .Based on the result the carry flag is set or reset .If the result is positive , the carry flag is set then the result is available in two's compliment form.

DEC ( decrement ) instruction subtracts one from the specified source and returns the result to same source.

MULTIPLICATION

MUL instruction perform an unsigned multiplication of the accumulator content and B register content .It returns a double byte result . B register receives the high order result byte and accumulator receives the low order result.This carry flag is always cleared.

DIVISION

DIV instruction performs an unsigned division of the accumulator content by the B register . The quotient is returned to accumulator and remainder to the B register. The carry flag is always cleared . Division by ZERO leaves indeterminate data in accumulator and B registers, It will set over flow flag.

LOGIC INSTRUCTIONS


the micro-controller 8051 performs basic logic operations on both byte and bit operands.

BIT OPERATIONS

CLR instruction clears ( made as 0 ) the accumulator or the specified addressable bit.
SETB instruction set ( made as 1 ) any directly addressable bit.

CPL instruction set is used to compliment the contents of the accumulator or directly addressable bit without affecting any flags.

Rotate Left , Rotate Left through Carry, Rotate Right. Rotate Right Carry and SWAP instructions are the rotate operations that can be performed on accumulator.

TWO OPERAND OPERATIONS

ANL ( AND logic ) performs bit wise logical AND of with two specified source operands and returns the result to the specified location of the first operand.

ORL ( OR logic ) perform bit wise logical OR of with two specified source operand and returns the result to the specified location of the first operand.

CONTROL TRANSFER INSTRUCTION

There are three type of control transfer instructions

*1* Un-conditional calls, Returns and jumps.
*2* Conditional Jumps and.
*3*Interrupts

All branching / control transfer operations cause, some upon a specified condition , the program
execution to continue at a non-sequential locations in program memory

UNCONDITIONAL CALLS,RETURNS AND JUMPS

Unconditional calls , Return and jumps transfers control from the current position of main/sub program to the new target address.The program counter is loaded with the address of called program.
ACALL ( Absolute CALL) and LCALL ( Long CALL ) push the address of the next instruction to be executed onto the stack memory and then transfer control to target address.ACALL is a two byte instruction used when the target address is in current 2K page . LCALL is a three byte instruction that addresses the full 64K program memory space.

RET transfers the control back to the called program by getting the return address saved on the stack by a previous call operation and decrements the SP register by two to adjust the SP for the popped address .Always the SP will pint , Where the last data is available.

SJMP,AJMP and LJMP transfer control to the target operand.The operation of AJMP and LJMP are similar to ACALL and LCALL .The short Jump ( SJMP)instruction provides transfer within a 256 byte range centered about the starting address of the next instruction.

JMP @A+DPTR perform a jump relative to the DPTR register. Hence DATA pointer holds the base address. The content in accumulator is used as the offset address.The effective destination address is sum of accumulator and DPTR register .Jump can be anywhere in the program memory space.

CONDITIONAL JUMP's

Conditional JUMPS perform jump when a specified condition is satisfied .The destination will b within a 256 byte range centered about the starting address of the next instruction.

JZ instruction perform a jump if accumulator is ZERO.

JNZ instruction perform a jump if the accumulator content is not ZERO.

JC instruction perform a jump if the carry flag is SET

JNC instruction perform a jump if the carry flag is not SET.

JB instruction perform a jump if the direct addressed bit is SET.

JNB instruction perform a jump if the direct addressed bit not SET.

JBC instruction perform a jump if the direct addressed bit is set and before jump the direct addressed bit is cleared.

CJNE compare the first operand to the second operand and performs a jump if they are not equal .Carry flag is set if the first operand is less than the second,otherwise carry flag is cleared
.Four instruction are available.

DJNZ decrements the specified source operand and returns the result to the operand . JUMP is performed if the result is not ZERO.The source operand of the DJNZ instruction may be any byte in the internal data memory .Register direct or indirect addressing may be used as the source operand.

INTERRUPT RETURNS

RETI transfers control as similar to RET , but additionally enable interrupts of the current priority level.

WORKING OF MICRO-PROCESSOR SOME MORE DEEPLY

































































* address bus is a uni-directional bus
from micro-processor to peripheral >>16 bit width

* data bus: bi-directional

# 8 bit AD0-AD7
# 2^8 peripherals

* control bus


# MEMR==memory read
# MEMW==memory write
# IOR==input output read
# IOW==input output write

***control bus compared of various single lines that carries synchronization signals . the micro-processor use this lines to provide timing signals

the micro-processor generate specific controller signals for every operations. it performs , such as memory read or input/output write

these signals are used to identified a device time with which micro-processor intense to communicate


** general purpose register:::store data during programe execution.this register are accessible by the user. or it is programmable. 
B,C,D,E,H,L 
register .they are 8 bit register.
accumulator also 8 bit register

** stack pointer & program counter are 16 bit register
**if there is a need of 16 bit operation. they can pair. that means they can pair as BC,DE, HL total 8+8 = 16 bit( BL like pairing not possible)

.................................................................................................
**FLAG REGISTER**


.............................................................................................














# C - carry flag
# P - parity flag
# AC - auxiliary carry flag
# Z - zero flag
# S - sign flag

****************flag register also 8-bit register***************

5 flip - flop that set or reset according to the result of the arithmetic operation perform by ALU

** CARRY FLAG**

during the addition of two number . if they have sum in accumulator is greater than 8-bit . the flip-flop used to indicate the carry is set to one otherwise reset

** PARITY FLAG**

after the arithmetic operation if the result have been even number of one then the parity flag set.for odd number of one then the parity flag reset.

** AUXILIARY CARRY FLAG**

in an arithmetic operation , when a carry is given by 3rdbit and passed on 4thbit. the AC flag will set.
for example : 1001 1100 and 1000 1001
1001 1100
1001 1001
......................
10011 0101
here position 1 and 1( 1001 1100 and 1001 1001) when we find sum there is sum=0 and carry = 1. then carry goto 3 rd bit to 4 th bit. then auxiliary carry flag set . equal=1.blue color 1 is present then carry flag set equal=1.

** ZERO FLAG**

after the arithmetic operation if the result is ZERO then the zero flag will set

** SIGN FLAG**

after the arithmetic operation if the last bit is one ( bit D7 result is one ) sign flag will set . equal= 1.

more ex: 101
0010
0101 1110
..................
10000 0000

#########################

**PROGRAM COUNTER**
......................................................

it is 16 bit register also memory pointer, micro-processor use this register to sequence the execution of instruction , the function of PROGRAM COUNTER is to point the memory address from which next bytes is to be fetch
when a bytes is being fetched program counter is incremented by one to point to the next memory location

#########################

**STACK POINTER**
.......................................................

stack pointer is also 16 bit register use as a memory pointer it points to the memory location in the read,write memory called stacks. beginning
of the stack is defined by loading a 16 bit address to the stack pointer

###########################

**INSTRUCTION REGISTER **
..........................................................


IR hold op-code of the current instruction.

###########################

**TEMPORARY REGISTER **
.........................................................
temporary register are 8 bit register associated with ALU. which hold data during arithmetic or logic operation . this register used by micro-processor and not accessibly by the user






















8085 pin diagram and explanation









DETAILS 8085 MICRO-PROCESSOR PIN DIAGRAM
X1 and X2: are clock input pin. Crystal oscillator connected to these two pin
RESET OUT: indicate that micro-processor RESET. This signal can be used to RESET other devices
SID (sid in diagram. my mistake): SERIAL INPUT DATA is input pin used to accept serial one bit data
SOD: SERIAL OUTPUT DATA pin used to send serial 1 bit data
TRAP: it is an EDGE triggered highest priority non maskable interrupt
RST 7.5,RST 6.5,RST 5.5 : these are markable interrupt and have low priority than TRAP
Priority is in the order 7.5>6.5>5.5




INTR and INTA: INTR is a interrupt request signal after which micro-processor generate INTA or interrupt acknowledge signal
AD0-AD7: address data multiplexer bus
A8-A15: tri-state higher order address line
Tri state means it have 3 terminal one normal input and normal out put and one high impedance state . so we can control the output effectively . if there is high impedance state circuit act as a open circuit

IO/M(m bar) : this is output pin or signal used to indicate used to whether 8085 is working in I/O mode (IO/M( m bar)=1 , memory mode (IO/M( bar)=0.
READY: this is an output to check the status of output device. If it is low , the micro-processor will wait until it is high
RESET IN: this is input signal .when RESET IN is low micro-processor restart and starts executing from location 000H
ALE: address latch enable is output signal it goes high when operation is started by processor
SO, SI: these are the status signals used to indicates type of operations
RD: READ is active low input signal to read data from I/O devices or memory
WR : WRITE is an active low output signals used to write data on memory or I/O device
CLK (out) : it is the clock for users ,use for other digital circuits. It’s frequency is same as processor frequency
HOLD&HLDA: HOLD is on input signal this signal indicates that a peripherals requesting the use of address and data bus. In respond to hold micro-processor
Generates HLDA that is HOLD acknowledgement signal
VCC & VSS : power supplied to the micro-processor VCC positive supply And VSS is a negative supply
READY pin is used to communicate slow peripherals
When ALE is high it indicates that bits on AD0-AD7 pins address pin

Working details of S0 and S1
S0 and S1 indicates type of operations
IO/M (ACTIVE LOW)
S0
S1
DATA BUS STATUS(OUTPUT)
0
0
0
Halt(stop)
0
0
1
MEMORY WRITE
0
1
0
MEMORY READ
1
0
1
IO WRITE
1
1
0
IO READ
0
1
1
OP-CODE FETCH
1
1
1
INTERUPT ACKNOWLEDGE
 
Blogger Widgets