Wednesday, September 11, 2013

PUSH & POP
STACK:
it s part of RAM in which data will store temporary during execution of program.
STACK work on last in first out principal.to store and retrieve data during program execution in stack push and pop instruction work for it.
PUSH:
its used to store data into stack.
POP:
to retrieve data from stack.
SP:
stack pointer is 8 bit register which store value of top of the stack.
by default stack pointer contain 07h.

PUSH AND POP OPERATION:

PUSH:
using push operation stack pointer increased first and then content of register or memory will store on that stack location which stored in SP.
here SP contain =07h

PUSH R6;SP increased by one and contain of R6 store into 08 location.
PUSH R1;SP increased again by one and contain of R1 stored into 09 location.
PUSH R4;SP increased again by one and contain of R4 stored into 0A location.

POP:
In this retrieve data first and then stack pointer decreased by one.
if we write
POP 20h;then content at 0Ah location will copy into 20h then stack pointer decrease by 1.
POP 21h;then content at 09h location will copy into 21h then stack pointer decrease by 1.

-----------------------------------------------------------------------------------------------------------------------
 NEXT: serial communication                                        PREVIOUS:how to access external memory






In 8051 micro controller have in built RAM and ROM,but size of this memory is limited size of RAM is 128 byte while size of ROM is 4KB some time we need more memory then this so we connect external memory with micro controller.

access external RAM

To access external RAM we used MOVX instruction.

MOVX A,@DPTR;this code used for read data from external RAM.

MOVX @DPTR,A;this code used for write data into external RAM.

access External ROM

MOVC A,@A+DPTR; to read data from ROM.

here we add content of A and DPTR and then using indirect addressing mode we copy the content of that location into A.

MOVC A,@A+PC; to read data from ROM.

we increment content of PC and then add with A.then we copy the content of that location into A using indirect addressing mode.


External program memory is accessed under the following condition.
  1. Whenever is low, or
  2. Whenever PC contains a number higher than 0FFFH (for 8051) or 1FFF (for 8052). 
Some typical use of code/program memory access: External program memory can be not only used to store the code, but also for lookup table of various functions required for a particular application. Mathematical functions such as Sine, Square root, Exponential, etc. can be stored in the program memory (Internal or eternal)  and these functions can be accessed using MOVC instruction.
 ----------------------------------------------------------------------------------------------------------------------
PREVIOUS:Serial communication                                                       NEXT: push & pop operation

Wednesday, September 4, 2013

Serial Interface
  • The serial port of 8051 is full duplex, i.e., it can transmit and receive simultaneously.
  • The register SBUF is used to hold the data. The special function register SBUF is physically two registers. 
  • One is, write-only and is used to hold data to be transmitted out of the 8051 via TXD. 
  • The other is, read-only and holds the received data from external sources via RXD. Both mutually exclusive registers have the same address 099H. 
Serial Port Control Register (SCON)
  • Register SCON controls serial data communication.
    Address: 098H (Bit addressable

Data Transmission
  • Transmission of serial data begins at any time when data is written to SBUF. 
  • Pin P3.1 (Alternate function bit TXD) is used to transmit data to the serial data network. 
  • TI is set to 1 when data has been transmitted. This signifies that SBUF is empty so that another byte can be sent. 
Data Reception
  • Reception of serial data begins if the receive enable bit is set to 1 for all modes. 
  • Pin P3.0 (Alternate function bit RXD) is used to receive data from the serial data network. 
  • Receive interrupt flag, RI, is set after the data has been received in all modes. The data gets stored in SBUF register from where it can be read. 
Serial Data Modes 
8051 micro controller communicate with another peripheral device through RXD and TXD pin of port3.controller have four mode of serial communication.this four mode of serial communication are below.
1. Serial data mode 0-fixed buad Rate.
2. Serial data mode 1-variable baud rate.
3. Serial data mode 2 -fixed baud Rate.
4. Serial Data mode 3 -variable baud rate.

                                          Serial Data Mode-0
                                           (Baud Rate Fixed)

  • In this mode, the serial port works like a shift register and the data transmission works synchronously with a clock frequency of fosc /12. 
  • Serial data is received and transmitted through RXD. 8 bits are transmitted/ received aty a time. 
  • Pin TXD outputs the shift clock pulses of frequency fosc /12, which is connected to the external circuitry for synchronization. 
  • The shift frequency or baud rate is always 1/12 of the oscillator frequency.   

Serial Data Mode-1 (standard UART mode)
(baud rate is variable)
  • In mode-1, the serial port functions as a standard Universal Asynchronous Receiver Transmitter (UART) mode. 10 bits are transmitted through TXD or received through RXD. 
  • The 10 bits consist of one start bit (which is usually '0'), 8 data bits (LSB is sent first/received first), and a stop bit (which is usually '1'). Once received, the stop bit goes into RB8 in the special function register SCON. The baud rate is variable.
 


Serial Data Mode-2 Multiprocessor 
(baud rate is fixed)
  • In this mode 11 bits are transmitted through TXD or received through RXD.
  • The various bits are as follows: a start bit (usually '0'), 8 data bits (LSB first), a programmable 9 th (TB8 or RB8)bit and a stop bit (usually '1').  
  • While transmitting, the 9 th data bit (TB8 in SCON) can be assigned the value '0' or '1'. For example, if the information of parity is to be transmitted, the parity bit (P) in PSW could be moved into TB8.
  • On reception of the data, the 9 th bit goes into RB8 in 'SCON', while the stop bit is ignored. 
  • The baud rate is programmable to either 1/32 or 1/64 of the oscillator frequency.

f baud = (2 SMOD /64) fosc 


Serial Data Mode-3 - Multi processor mode
(Variable baud rate)

  • In this mode 11 bits are transmitted through TXD or received through RXD.
  • The various bits are: a start bit (usually '0'), 8 data bits (LSB first), a programmable 9 th bit and a stop bit (usually '1').  
  • Mode-3 is same as mode-2, except the fact that the baud rate in mode-3 is variable (i.e., just as in mode-1). 
f baud = (2 SMOD /32) * ( fosc / 12 (256-TH1))  
-----------------------------------------------------------------------------------------------------------------------
PREVIOUS:Power Saving mode                                                 NEXT:write and read serial port
 

In this mode PCON (power control register).in this register two bit play important role for power control of 8051.
Below show the format of PCON

8051 has two power saving modes.they are
  1. idle mode
  2. power down mode.
  • The two power saving modes are entered by setting two bits IDL and PD in the special function register (PCON) respectively.
POWER DOWN MODE:

the schematic diagram of power down mode shown below.
  • By setting the PD bit of the PCON register from within the program, the microcontroller is set to Power down mode.
  • thus turning off its internal oscillator and reduces power consumption enormously.
  • The microcontroller can operate using only 2V power supply in power- down mode, while a total power consumption is less than 40uA.
  • The only way to get the micro controller back to normal mode is by reset.
  • While the microcontroller is in Power Down mode, the state of all SFR registers and I/O ports remains unchanged.
  • By setting it back into the normal mode, the contents of the SFR register is lost, but the content of internal RAM is saved.
  • Reset signal must be long enough, approximately 10mS, to enable stable operation of the quartz oscillator.
IDLE MODE:
  • Upon the IDL bit of the PCON register is set, the microcontroller turns off the greatest power consumer- CPU unit while peripheral units such as serial port, timers and interrupt system continue operating normally consuming 6.5mA. 
  • In Idle mode, the state of all registers and I/O ports remains unchanged.
  • n order to exit the Idle mode and make the microcontroller operate normally, it is necessary to enable and execute any interrupt or reset.
  • It will cause the IDL bit to be automatically cleared and the program resumes operation from instruction having set the IDL bit. 
  • It is recommended that first three instructions to execute now are NOP instructions.
  • They don't perform any operation but provide some time for the microcontroller to stabilize and prevents undesired changes on the I/O ports.
-----------------------------------------------------------------------------------------------------------------------
PREVIOUS:serial communication                                                     NEXT:write and read serial port



Tuesday, September 3, 2013

To write data to serial port
  • To write a byte to the serial port one must simply write the value to the SBUF (99h) SFR.
  • if you wanted to send the letter "A" to the serial port, it could be accomplished as easily as
                                         MOV SBUF,#A

  • Upon execution of the above instruction the 8051 will begin transmitting the character via the serial port.
  • Obviously transmission is not instantaneous--it takes a measureable amount of time to transmit.  
  • And since the 8051 does not have a serial output buffer we need to be sure that a character is completely transmitted before we try to transmit the next character.
  • The 8051 lets us know when it is done transmitting a character by setting the TI bit in SCON.
  • When this bit is set we know that the last character has been transmitted and that we may send the next character.
                                         CLR TI ;Be sure the bit is initially clear
                                         MOV SBUF,#A ;Send the letter A to the serial port
                                         JNB TI,$ ;Pause until the TI bit is set.
 
  • The above three instructions will successfully transmit a character and wait for the TI bit to be set before continuing.
  • The last instruction says "Jump if the TI bit is not set to $"--$, in most assemblers, means "the same address of the current instruction.".
  • Thus the 8051 will pause on the JNB instruction until the TI bit is set by the 8051 upon successful transmission of the character.
To read Data from serial port
  • Reading data received by the serial port is equally easy.
  • To read a byte from the serial port one just needs to read the value stored in the SBUF (99h) SFR after the 8051 has automatically set the RI flag in SCON. 
  • For example, if your program wants to wait for a character to be received and subsequently read it into the Accumulator, the following code segment may be used:
                                          JNB RI,$ ;Wait for the 8051 to set the RI flag
                                          MOV A,SBUF ;Read the character from the serial port
 
  • The first line of the above code segment waits for the 8051 to set the RI flag; again, the 8051 sets the RI flag automatically when it receives a character via the serial port.
  • So as long as the bit is not set the program repeats the "JNB" instruction continuously. 
  • Once the RI bit is set upon character reception the above condition automatically fails and program flow falls through to the "MOV" instruction which reads the value.
-----------------------------------------------------------------------------------------------------------------------
 PREVIOUS: Serial communication                                            NEXT: Power Saving Operation

Tuesday, July 9, 2013

Interrupt
  • There are five interrupt sources for the 8051, which means that they can recognize 5 different events that can interrupt regular program execution. 
  • there are five interrupts :,TF0,(INTR1)',TF1,RI/TI
  • Each interrupt can be enabled or disabled by setting bits of the IE register. Likewise, the whole interrupt system can be disabled by clearing the EA bit of the same register. .
  • Now, it is necessary to explain a few details referring to external interrupts- INT0 and INT1. If the IT0 and IT1 bits of the TCON register are set, an interrupt will be generated on high to low transition. 

Here we are mention vector address of interrupt.

 

IE Register (Interrupt Enable)
 

Priority level structure: 

Each interrupt source can be programmed to have one of the two priority levels by setting (high priority) or clearing (low priority) a bit in the IP (Interrupt Priority) Register.
A low priority interrupt can itself be interrupted by a high priority interrupt, but not by another low priority interrupt.
If two interrupts of different priority levels are received simultaneously, the request of higher priority level is served.
If the requests of the same priority level are received simultaneously, an internal polling sequence determines which request is to be serviced. Thus, within each priority level, there is a second priority level determined by the polling sequence, as follows.

 

IP Register (Interrupt Priority)

The IP register bits specify the priority level of each interrupt (high or low priority).

Interrupt handling:
  • The interrupt flags are sampled at P2 of S5 of every instruction cycle (Note that every instruction cycle has six states each consisting of P1 and P2 pulses).
  • The samples are polled during the next machine cycle (or instruction cycle). If one of the flags was set at S5P2 of the preceding instruction cycle, the polling detects it and the interrupt process generates a long call (LCALL) to the appropriate vector location of the interrupt. 
  • The LCALL is generated provided this hardware generated LCALL is not blocked by any one of the following conditions. 
  1. An interrupt of equal or higher priority level is already in progress.
  2. The current polling cycle is not the final cycle in the execution of the instruction in progress.
  3. The instruction in progress is RETI or any write to IE or IP registers.



TIMING 

  • If a counter is programmed to be a timer, it will count the internal clock frequency of the 8051 oscillator divided by 12d. 
  • As an example, if the crystal frequency is 6.0 megahertz, then the timer clock will have a frequency of 500 kilohertz.
  • The resultant timer clock is gated to the timer by means of the circuit shown in Figure. 
  • In order for oscillator clock pulses to reach the timer, the C/(T)' bit in the TMOD register must be set to 0 (timer operation). 
  • Bit TRX in the TCON register must be set to 1 (timer run), and the gate bit in the TMOD register must be 0, or external pin (INTX)' must he a 1. 
  • In other words, the counter is configured as a timer, then the timer pulses are gated to the counter by the run bit and the gate bit or the external input bits (INTX)'

 

COUNTING

  • The only difference between counting and timing is the source of the clock pulses to the counters. When used as a timer, the clock pulses are sourced from the oscillator through the divide-by-12d circuit.
  • When used as a counter, pin T0 (P3.4) supplies pulses to counter 0. and pin T1 (P3.5) to counter 1.
  • The C/(T)' bit in TMOD must be set to 1 to enable pulses from the TX pin to reach the control circuit shown in above Figure .
  • The input pulse on TX is sampled during P2 of state 5 every machine cycle. A change on the input from high to low between samples will increment the counter.
  • Each high and low state of the input pulse must thus be held constant for at least one machine cycle to ensure reliable counting. Since this takes 24 pulses, the maximum input frequency that can be accurately counted is the oscillator frequency divided by 24. for our 6 megahertz crystal. the calculation yields a maximum external frequency of 250 kilohertz.





Monday, July 8, 2013

Counters and Timers

Many microcontroller applications require the counting of external events, such as the frequency of a pulse train, or the generation of precise internal time delays between com­puter actions. Both of these tasks can be accomplished using software techniques, but software loops for counting or timing keep the processor occupied so that other, perhaps more important, functions are not done. To relieve the processor of this burden, two 16-bit up counters, named T0 and T1, are provided for the general use of the programmer. Each counter may be programmed to count internal clock pulses, acting as a timer, or pro­grammed to count external pulses as a counter. 


 

TCON(TIMER/COUNTER CONTROL REGISTER)
  1. To control the timer/counter we need TCON register.
  2. its bit addressable
  3. address:88h
 

TMOD(THE TIMER MODE CONTROL REGISTER)
  1. it dedicated two timer.
  2. it is byte addressable
  3. address:89h
 

Timer Mode
The timers may operate in anyone of four modes that are determined by the mode bits, M I and MO, in the TMOD register. Figure 12 shows the four timer modes.

Timer Mode 0

  • Setting timer X mode bits to 00b in the TMOD register.
  • theTHX register as an 8-bit counter and TLX as a 5-bit counter.
  • As an example, the 6 megahertz oscillator frequency would result in a final frequency to TH of 15625 hertz. 
  • The timer flag is set whenever THX goes from FFh to 00h

Timer Mode 1

  • the mode bits are set to 0lb in TMOD
  • Mode 1 is similar to mode 0 except TLX is configured as a full 8-bit counter when .

Timer Mode 2

  • Setting the mode bits to l0b in TMOD configures.
  • the timer to use only the TLX counter as an 8-bit counter. 
  • THX is used to hold a value that is loaded into TLX every time TLX overflows from FFh to 00h. The timer flag is also set when TLX overflows.
  • This mode exhibits an auto-reload feature: TLX will count up from the number in THX. overflow. and be initialized again with the contents of THX.

Timer Mode 3

    • Timer 1 in mode-3 simply holds its count. The effect is same as setting TR1=0. Timer0 in mode-3 establishes TL0 and TH0 as two separate counters.
    • Control bits TR1 and TF1 are used by Timer-0 (higher 8 bits) (TH0) in Mode-3 while TR0 and TF0 are available to Timer-0 lower 8 bits(TL0). 
      figure of Timer Modes

      Branch Instructions

      There are two kinds of branch instructions:
      Unconditional jump instructions: upon their execution a jump to a new location from where the program continues execution is executed.

      Conditional jump instructions: a jump to a new program location is executed only if a specified condition is met. Otherwise, the program normally proceeds with the next instruction.


      ACALL addr11 - Absolute subroutine call
      addr11: Subroutine address
      Description: Instruction unconditionally calls a subroutine located at the specified code address. Therefore, the current address and the address of called subroutine must be within the same 2K byte block of the program memory, starting from the first byte of the instruction following ACALL.

      EXAMPLE:
      ACALL
      Before execution: PC=0123h
      After execution: PC=0345h

      AJMP addr11 - Absoulte jump
      addr11: Jump address
      Description: Program continues execution after executing a jump to the specified address. Similar to the ACALL instruction, the jump must be executed within the same 2K byte block of program memory starting from the first byte of the instruction following AJMP.

      EXAMPLE:
      AJMP address
      Before execution: PC=0345h SP=07h
      After execution: PC=0123h SP=09h

      CJNE A,direct,rel - Compares direct byte to the accumulator and jumps if not equal
      A: accumulator
       Direct: arbitrary register with address 0-255 (0-FFh)
       addr: jump address
      Description: Instruction first compares the number in the accumulator with the directly addressed byte. If they are equal, the program proceeds with execution. Otherwise, a jump to the specified address will be executed. This is a short jump instruction, which means that the address of a new location must be relatively near the current one (-128 to +127 locations relative to the first following instruction).

      EXAMPLE:
      CJNE A,Rx,rel
      Before execution: PC=0145h A=27h
      After execution: if MAX≠27: PC=0123h
      If MAX=27: PC=0146h

      CJNE A,#data,rel - Compares immediate data to the accumulator and jumps if not equal
      A: accumulator
       Data: constant in the range of 0-255 (0-FFh)
      Description: Instruction first compares the number in the accumulator with the immediate data. If they are equal, the program proceeds with execution. Otherwise, a jump to the specified address will be executed. This is a short jump instruction, which means that the address of a new location must be relatively near the current one (-128 to +127 locations relative to the first following instruction).

      EXAMPLE:
      CJNE A,Rx,rel
      Before execution: PC=0445h
      After execution: If A≠33: PC=0423h
      If A=33: PC=0446h

      CJNE Rn,#data,rel - Compares immediate data to the register Rn and jumps if not equal
      Rn: Any R register (R0-R7)
       Data: Constant in the range of 0 - 255 (0-FFh)
       addr: Jump address
      Description: Instruction first compares immediate data to the register Rn. If they are equal, the program proceeds with execution. Otherwise, a jump to the specified address will be executed. This is a short jump instruction, which means that the address of a new location must be relatively near the current one (-128 to + 127 locations relative to the first following instruction).

      EXAMPLE:
      CJNE Rn,#X,rel
      Before execution: PC=0345h
      After execution: If R5≠44h: PC=0323h
      If R5=44h: PC=0346h

      CJNE @Ri,#data,rel - Compares immediate data to indirectly addressed register and jumps if not equal
      Ri: Register R0 or R1
       Data: Constant in the range of 0 - 255 (0-FFh)
      Description: This instruction first compares immediate data to indirectly addressed register. If they are equal, the program proceeds with execution. Otherwise, a jump to the specified address in the program will be executed. This is a short jump instruction, which means that the address of a new location must be relatively near the current one (-128 to +127 locations relative to the next instruction).

      EXAMPLE:
      CJNE @Ri,#X,rel
      Before execution: Register Address SUM=F3h
      PC=0345h R0=F3h
      After execution: If SUM≠44h: PC=0323h
      If SUM=44h: PC=0346h

      DJNZ direct,rel - Decrements direct byte by 1 and jumps if not 0
      Direct: arbitrary register with address 0-255 (0-FFh)
       addr: Jump address
      Description: This instruction first decrements value in the register. If the result is 0, the program proceeds with execution. Otherwise, a jump to the specified address in the program will be executed. As it is direct addressing, the register must be within the first 255 locations of RAM. This is a short jump instruction, which means that the address of a new location must be relatively near the current one (-128 to +127 locations relative to the first following instruction).

      EXAMPLE:
      DJNZ Rx,rel
      Before execution: PC=0445h
      After execution: If CNT≠0: PC=0423h
      If CNT=0: PC=0446h

      DJNZ Rn,rel - Decrements the Rn register by 1 and jumps if not 0
      Rn: any R register (R0-R7)
       addr: jump address
      Description: This instruction first decrements the value in the Rn register. If the result is 0, the program proceeds with execution. Otherwise, a jump to the specified address in the program will be executed. This is a short jump instruction, which means that the address of a new location must be relatively near the current one (- 128 to +127 locations relative to the first following instruction).

      EXAMPLE:
      DJNZ Rn,rel
      Before execution: PC=0445h
      After execution: If R1≠0: PC=0423h
      If R1=0: PC=0446h

      JB bit,rel - Jump if direct bit is set
      addr: Jump address
       Bit: any bit of RAM
      Description: If the bit is set, a jump to the specified address will be executed. Otherwise, if the value of bit is 0, the program proceeds with the next instruction. This is a short jump instruction, which means that the address of a new location must be relatively near the current one (-128 to + 127 locations relative to the first following instruction).

      EXAMPLE:
      JB bit,rel
      Before execution: PC=0323h
      After execution: If P0.5=0: PC=0324h
      If P0.5=1: PC=0345h

      JC rel - Jump if carry flag is set
      addr: Jump address
      Description: Instruction first checks if the carry flag is set. If set, a jump to the specified address is executed. Otherwise, the program proceeds with the next instruction. This is a short jump instruction, which means that the address of a new location must be relatively near the current one (-129 to + 127 locations relative to the first following instruction).

      EXAMPLE:
      JC [jump address]
      Before instruction: PC=0323h
      After instruction: If C=0: PC=0324h
      If C=1: PC=0345h

      JBC bit,rel - Jump if direct bit is set
      Bit: any bit of RAM
       addr: Jump Address
      Description: This instruction first checks if the bit is set. If set, a jump to the specified address is executed and the bit is cleared. Otherwise, the program proceeds with the first following instruction. This is a short jump instruction, which means that the address of a new location must be relatively near the current one (-129 to + 127 locations relative to the first following instruction).

      EXAMPLE:
      JBC bit,rel
      Before execution: PC=0323h
      After execution: If TEST0.4=1: PC=0345h, TEST0.4=0
      If TEST0.4=0: PC=0324h, TEST0,4=0

      JNB bit,rel - Jump if direct bit is not set
      addr: Jump address
       Bit: any bit of RAM
      Description: If the bit is cleared, a jump to the specified address will be executed. Otherwise, if the bit value is 1, the program proceeds with the first following instruction. This is a short jump instruction, which means that the address of a new location must be relatively near the current one (-129 to + 127 locations relative to the first following instruction).

      EXAMPLE:
      JNB bit,rel
      Before execution: PC=0323h
      After execution: If P0.5=1: PC=0324h
      If P0.5=0: PC=0345h

      JMP @A+DPTR - Jump indirect relative to the DPTR
      A: accumulator
       DPTR: Data Pointer
      Description: This instruction causes a jump to the address calculated by adding value stored in the accumulator to the 16-bit number in the DPTR Register. It is used with complex program branching where the accumulator affects jump address, for example when reading a table. Neither accumulator nor DPTR register are affected.

      EXAMPLE:
      JMP @A+DPTR
      Before execution: PC=223 DPTR=1400h
      After execution: PC = 1402h if A=2
      PC = 1404h if A=4
      PC = 1406h if A=6
      Note:
      As instructions AJMP LABELS occupy two locations each, the values in the accumulator specifying them must be different from each other by 2.

      JNZ rel - Jump if accumulator is not zero
      addr: Jump Address
      Description: This instruction checks if the value stored in the accumulator is 0. If not, a jump to the specified address will be executed. Otherwise, the program proceeds with the first following instruction. This is a short jump instruction, which means that the address of a new location must be relatively near the current one (-129 to + 127 locations relative to the first following instruction).

      EXAMPLE:
      JNZ rel
      Before execution: PC=0323h
      After execution: If A=0: PC=324h
      If A≠0: PC=283h

      JNC rel - Jump if carry flag is not set
      addr: Jump Address
      Description: This instruction first checks whether the carry flag is set. If not, a jump to the specified address will be executed. Otherwise, the program proceeds with the first following instruction. This is a short jump instruction, which means that the address of a new location must be relatively near the current one (-129 to + 127 locations relative to the first following instruction).

      EXAMPLE:
      JNC rel
      Before execution: PC=0323h
      After execution: If C=0: PC=360h
      If C=1: PC=324h

      LCALL addr16 - Long subroutine call
      addr16: Subroutine Address
      Description: This instruction unconditionally calls a subroutine located at the specified address. The current address and the start of the subroutine called can be located anywhere within the memory space of 64K.

      EXAMPLE:
      LCALL adr16
      Before execution: PC=0123h
      After execution: PC=1234h

      JZ rel - Jump if accumulator is zero
      addr: Jump Address
      Description: The instruction checks whether the value stored in the accumulator is 0. If yes, a jump to the specified address will be executed. Otherwise, the program proceeds with the following instruction. This is a short jump instruction, which means that the address of a new location must be relatively near the current one (-129 to + 127 locations relative to the first following instruction).

      EXAMPLE:
      JZ [jump address]
      Before execution: PC=0323h
      After execution: If A0: PC=324h
      If A=0: PC=283h

      LJMP addr16 - Long jump
      addr16: jump address
      Description: Instruction causes a jump to the specified 16-bit address.

      EXAMPLE:
      LJMP adr16
      Before execution: PC=0123h
      After execution: PC=1234h

      RET - Return from subroutine
      Description: This instruction ends every subroutine. After execution, the program proceeds with the instruction following an ACALL or LCALL.

      EXAMPLE:

      RET
      RETI - Return from interrupt
      Description: This instruction ends every interrupt routine and informs processor about it. After executing the instruction, the program proceeds from where it left off. The PSW is not automatically returned its pre-interrupt status.

      SJMP rel - Short Jump (relative address)
      addr: Jump Address
      Description: Instruction enables jump to the new address which should be in the range of -128 to +127 locations relative to the first following instruction.

      EXAMPLE:
      SJMP rel
      Before execution: PC=323
      After execution: PC=345



      Related Posts Plugin for WordPress, Blogger...
      Subscribe to RSS Feed Follow me on Twitter!