Showing posts with label microprocessors. Show all posts
Showing posts with label microprocessors. Show all posts

Sunday, September 17, 2023

Microcomputing systems

Micro computing Systems

Content Link
Module 1 Module 1- 8086 Notes
Module 1 8086 -Memory management -notes
Module 1 8086 Architecture -Power point
Module 1 8086 Instruction set and addressing mode -PPT
Module 1 ARM processor PPT
Module 1 ARM processor PPT
Module 2 8051 Controller ppt
Module 2 8051 Controller ppt
Queastion Bank Question bank CIA 1
Queastion Bank Question bank CIA 1 Part A Answer

Friday, September 1, 2023

Assending order of ALP model of 8086 processor


  ORG 100h        ; Origin at 100h

MOV SI, OFFSET NUMBERS ; SI points to the array of numbers
MOV CX, 5       ; Number of elements to sort (change as needed)

SORT_LOOP:
    MOV BX, CX      ; Inner loop counter
    DEC BX          ; Decrement BX since we compare BX with BX+1

INNER_LOOP:
    MOV AX, [SI]    ; Load the value at SI into AX
    CMP AX, [SI+2]  ; Compare with the next value
    JLE NO_SWAP     ; Jump if less than or equal (no swap needed)

    ; Swap the values
    XCHG AX, [SI+2]
    MOV [SI], AX

NO_SWAP:
    ADD SI, 2       ; Move to the next element
    LOOP INNER_LOOP ; Repeat for all elements

    DEC CX          ; Decrement outer loop counter
    LOOP SORT_LOOP  ; Repeat for all elements

   

NUMBERS DB 23, 11, 56, 7, 34 ; Array of numbers to sort

END
  

Monday, August 14, 2023

Microprocessor -8086

Microprocessor 8086

Content Link
Notes Assembler Directives
Notes 8086 Introdcution, pin configuration, Minimum mode, maximum mode, addressing mode

Sunday, October 6, 2013

ADDRESSING MODES OF 8086




ADDRESSING MODES OF 8086



Addressing mode indicates a way of locating data or operands. Depending upon the data types used in the instruction and the memory addressing modes, any instruction may belong to one or more addressing modes, or some instruction may not belong to any of the addressing modes. Thus the addressing modes describe the types of operands and the way they are accessed for executing an instruction. Here, we will present the addressing modes of the instructions depending upon their types.
 According to the flow of instruction execution, the instructions may be categorized as
(i)                 Sequential control flow instructions and
(ii)               Control transfer instructions.


Sequential control flow instructions are the instructions, which after execution, transfer control to the next instruction appearing immediately after it (in the sequence) in the program. For example, the arithmetic, logical, data transfer and processor control instructions are sequential control flow instructions.


  1. Immediate: In this type of addressing, immediate data is a part of instruction, and appears in the form of successive byte or bytes.
Example: MOV AX, 0005H
In the above example, 0005H is the immediate data. The immediate data may be 8-bit or 16-bit in size.

  1. Direct: In the direct addressing mode, a 16-bit memory address (offset) is directly specified in the instruction as a part of it.
Example: MOV AX, [5000H]
Here, data resides in a memory location in the data segment, whose Physical address may be computed using 5000H as the offset address and content of DS as segment address. The Physical address, here, is 10H*DS+5000H.

  1. Register: In register addressing mode, the data is stored in a register and it is referred using the particular register. All the registers, except IP, may be used in this mode.
Example: MOV BX, AX.

  1. Register Indirect: Sometimes, the address of the memory location, which contains data or operand, is determined in an indirect way, using the offset registers. This mode of addressing is known as register indirect mode.
In this addressing mode, the offset address of data is in either BX or SI or DI registers. The default segment is either DS or ES. The data is supposed to be available at the address pointed to by the content of any of the above registers in the default data segment.
Example: MOV AX, [BX]
Here, data is present in a memory location in DS whose offset address is in BX. The Physical address of the data is given as 10H*DS+ [BX].

  1. Indexed: In this addressing mode, offset of the operand is stored in one of the index registers. DS and ES are the default segments for index registers SI and DI respectively. This mode is a special case of the above discussed register indirect addressing mode.
Example: MOV AX, [SI]
Here, data is available at an offset address stored in SI in DS. The Physical address, in this case, is computed as 10H*DS+ [SI].

  1. Register Relative: In this addressing mode, the data is available at an Physical address formed by adding an 8-bit or 16-bit displacement with the content of any one of the registers BX, BP, SI and DI in the default (either DS or ES) segment. The example given before explains this mode.
       Example: MOV Ax, 50H [BX]
       Here, Physical address is given as 10H*DS+50H+ [BX].

  1. Based Indexed: The Physical address of data is formed, in this addressing mode, by adding content of a base register (any one of BX or BP) to the content of an index register (any one of SI or DI). The default segment register may be ES or DS.
Example: MOV AX, [BX] [SI]
Here, BX is the base register and SI is the index register. The Physical address is computed as 10H*DS+ [BX] + [SI].

  1. Relative Based Indexed: The Physical address is formed by adding an 8-bit or 16-bit displacement with the sum of contents of any one of the bases registers (BX or BP) and any one of the index registers, in a default segment.
Example: MOV AX, 50H [BX] [SI]
Here, 50H is an immediate displacement, BX is a base register and SI is an index register. The Physical address of data is computed as 160H*DS+ [BX] + [SI] + 50H.


The control transfer instructions:

 The addressing modes depend upon whether the destination location is within the same segment or a different one. It also depends upon the method of passing the destination address to the processor.
Basically, there are two addressing modes for the control transfer instructions, viz. inter-segment and intra-segment addressing modes.

If the location to which the control is to be transferred lies in a different segment other than the current one, the mode is called inter-segment mode. If the destination location lies in the same segment, the mode is called intra-segment.

Inter-segment Direct
                                         
                                                         Inter-segment

                                                                                               Inter-segment
                                                                                                Indirect

Modes for control
Transfer instructions

                                                                                               Intra-segment
                                                        Intra-segment                 Direct
                                                                 
                                                                                                     Intra-segment
                                                                                                      Indirect                      

Addressing Modes for Control Transfer Instruction



9.      Intra-segment direct mode:

In this mode, the address to which the control is to be transferred lies in the same segment in which the control transfer instruction lies and appears directly in the instruction as an immediate displacement value. In this addressing mode, the displacement is computed relative to the content of the instruction pointer IP.
The Physical address to which the control will be transferred is given by the sum of 8 or 16 bit displacement and current content of IP. In case of jump instruction, if the signed displacement (d) is of 8 bits (i.e. –128<d<+128), we term it as short jump and if it is of
16     its (i.e. –32768<+32768), it is termed as long jump.
 In this mode, the displacement to which the control is to be transferred, is in the same segment in which the control transfer instruction lies, but it is passed to the instruction indirectly. Here, the branch address is found as the content of a register or a memory location. This addressing mode may be used in unconditional branch instructions.

11. Inter-segment Direct Mode:

In this mode, the address to which the control is to be transferred is in a different segment. This addressing mode provides a means of branching from one code segment to another code segment. Here, the CS and IP of the destination address are specified directly in the instruction.

12.Inter-segment Indirect Mode:

In this mode, the address to which the control is to be transferred lies in a different segment and it is passed to the instruction indirectly, i.e. contents of a memory block containing four bytes, i.e. IP (LSB), IP (MSB), CS (LSB) and CS (MSB) sequentially. The starting address of the memory block may be referred using any of the addressing modes, except immediate mode.


Courtesy : internet sources 

Thursday, October 3, 2013

INSTRUCTION SET OF INTEL 8085


INSTRUCTION SET OF INTEL 8085

An Instruction is a command given to the computer to perform a specified operation on given data. The instruction set of a microprocessor is the collection of the instructions that the microprocessor is designed to execute. The instructions described here are of Intel 8085. These instructions are of Intel Corporation. They cannot be used by other microprocessor manufactures. The programmer can write a program in assembly language using these instructions. These instructions have been classified into the following groups:
1.      Data Transfer Group
2.      Arithmetic Group
3.      Logical Group
4.      Branch Control Group
5.      I/O and Machine Control Group

Data Transfer Group:
 Instructions, which are used to transfer data from one register to another register, from memory to register or register to memory, come under this group.

 Examples are: MOV, MVI, LXI, LDA, STA etc. When an instruction of data transfer group is executed, data is transferred from the source to the destination without altering the contents of the source. For example, when MOV A, B is executed the content of the register B is copied into the register A, and the content of register B remains unaltered. Similarly, when LDA 2500 is executed the content of the memory location 2500 is loaded into the accumulator. But the content of the memory location 2500 remains unaltered.

Arithmetic Group: 
The instructions of this group perform arithmetic operations such as addition, subtraction; increment or decrement of the content of a register or memory. Examples are: ADD, SUB, INR, DAD etc.

Logical Group
The Instructions under this group perform logical operation such as AND, OR, compare, rotate etc. Examples are: ANA, XRA, ORA, CMP, and RAL etc.
Branch Control Group
This group includes the instructions for conditional and unconditional jump, subroutine call and return, and restart. Examples are: JMP, JC, JZ, CALL, CZ, RST etc.
I/O and Machine Control Group:
 This group includes the instructions for input/output ports, stack and machine control. Examples are: IN, OUT, PUSH, POP, and HLT etc.

Intel 8085 Instructions


1.      Data Transfer Group
a.   MOV r1, r2
           (Move Data; Move the content of the one register to another).
            [r1] ß [r2].
        
     b. MOV r, m (Move the content of memory register). r ß [M]

     c. MOV M, r. (Move the content of register to memory). M ß [r]

     d. MVI r, data. (Move immediate data to register). [r] ß data.

     e. MVI M, data. (Move immediate data to memory). M ß data.

     f. LXI rp, data 16. (Load register pair immediate). [rp] ß data 16  
        bits,    [rh] ß 8 LSBs of data.

     g. LDA addr. (Load Accumulator direct). [A] ß [addr].

     h. STA addr. (Store accumulator direct). [addr] ß [A].

     i.LHLD addr. (Load H-L pair direct). [L] ß [addr], [H] ß [addr+1].

     j. SHLD addr. (Store H-L pair direct) [addr] ß [L], [addr+1] ß [H].

     k. LDAX rp. (LOAD accumulator indirect) [A] ß [[rp]]

     l. STAX rp. (Store accumulator indirect) [[rp]] ß [A].

     m. XCHG. (Exchange the contents of H-L with D-E pair) [H-L] <--> 
          [D-E].

2.      Arithmetic Group

i.                    ADD r. (Add register to accumulator) [A] ß [A] + [r].
ii.                 ADD M. (Add memory to accumulator) [A] ß [A] + [[H-L]].
iii.               ADC r. (Add register with carry to accumulator). [A] ß [A] + [r] + [CS].
iv.               ADC M. (Add memory with carry to accumulator) [A] ß [A] + [[H-L]] [CS].
v.                  ADI data (Add immediate data to accumulator) [A] ß [A] + data.
vi.               ACI data (Add with carry immediate data to accumulator). [A] ß [A] + data + [CS].
vii.             DAD rp. (Add register paid to H-L pair). [H-L] ß [H-L] + [rp].
viii.          SUB r. (Subtract register from accumulator). [A] ß [A] – [r].
ix.               SUB M. (Subtract memory from accumulator). [A] ß [A] – [[H-L]].
x.                  SBB r. (Subtract register from accumulator with borrow). [A] ß [A] – [r] – [CS].
xi.               SBB M. (Subtract memory from accumulator with borrow). [A] ß [A] – [[H-L]] – [CS].
xii.             SUI data. (Subtract immediate data from accumulator) [A] ß [A] – data.
xiii.          SBI data. (Subtract immediate data from accumulator with borrow).
[A] ß [A] – data – [CS].
               xiv.      INR r (Increment register content) [r] ß [r] +1.
               xv.       INR M. (Increment memory content) [[H-L]] ß [[H-L]] + 1.
xvi.           DCR r. (Decrement register content). [r] ß [r] – 1.
xvii.        DCR M. (Decrement memory content) [[H-L]] ß [[H-L]] – 1.
xviii.      INX rp. (Increment register pair) [rp] ß [rp] – 1.
xix.           DCX rp (Decrement register pair) [rp] ß [rp] -1.
xx.             DAA (Decimal adjust accumulator) .

The instruction DAA is used in the program after ADD, ADI, ACI, ADC, etc instructions. After the execution of ADD, ADC, etc instructions the result is in hexadecimal and it is placed in the accumulator. The DAA instruction operates on this result and gives the final result in the decimal system. It uses carry and auxiliary carry for decimal adjustment. 6 is added to 4 LSBs of the content of the accumulator if their value lies in between A and F or the AC flag is set to 1. Similarly, 6 is also added to 4 MSBs of the content of the accumulator if their value lies in between A and F or the CS flag is set to 1. All status flags are affected. When DAA is used data should be in decimal numbers.

3.      Logical Group

i.                    ANA r. (AND register with accumulator) [A] ß [A] ^ [r].
ii.                 ANA M. (AND memory with accumulator). [A] ß [A] ^ [[H-L]].
iii.               ANI data. (AND immediate data with accumulator) [A] ß [A] ^ data.
iv.               ORA r. (OR register with accumulator) [A] ß [A] v [r].
v.                  ORA M. (OR memory with accumulator) [A] ß [A] v [[H-L]]
vi.               ORI data. (OR immediate data with accumulator) [A] ß [A] v data.                                                                                            
vii.             XRA r. (EXCLUSIVE – OR register with accumulator) [A] ß [A] v   [r]                                                                                                                     
viii.          XRA M. (EXCLUSIVE-OR memory with accumulator) [A] ß [A] v  [[H-L]]
ix.               XRI data. (EXCLUSIVE-OR immediate data with accumulator) [A] ß                    
            [A]  v  data.                                                       
x.          CMA. (Complement the accumulator) [A] ß [A]
                                                                                                                                                                        
x.                  CMC. (Complement the carry status) [CS] ß [CS]
xi.               STC. (Set carry status) [CS] ß 1.
xii.             CMP r. (Compare register with accumulator) [A] – [r]
xiii.          CMP M. (Compare memory with accumulator) [A] – [[H-L]]
xiv.           CPI data. (Compare immediate data with accumulator) [A] – data.
The 2nd byte of the instruction is data, and it is subtracted from the content of the accumulator. The status flags are set according to the result of subtraction. But the result is discarded. The content of the accumulator remains unchanged.
xv.             RLC (Rotate accumulator left) [An+1] ß [An], [A0] ß [A7],
            [CS] ß [A7].
             The content of the accumulator is rotated left by one bit. The seventh bit of the accumulator is moved to carry bit as well as to the zero bit of the accumulator. Only CS flag is affected.
  A7






A0
CS  
 
Carry Status                              Accumulator

                      Schematic diagram for RLC        
      
xvi.           RRC. (Rotate accumulator right) [A7] ß [A0], [CS] ß [A0], [An] ß [An+1].
The content of the accumulator is rotated right by one bit. The zero bit of the accumulator is moved to the seventh bit as well as to carry bit. Only CS flag is affected.

A7






A0
  CS
 

            
Carry Status                                                   Accumulator

                                      Schematic Diagram for RRC

xvii.        RAL. (Rotate accumulator left through carry) [An+1] ß [An], [CS] ß [A7], [A0] ß [CS].
xviii.      RAR. (Rotate accumulator right through carry) [An] ß [An+1], [CS] ß [A0], [A7] ß [CS]

4.      Branch Group

i.                    JMP addr (label). (Unconditional jump: jump to the instruction specified by the address). [PC] ß Label.
ii.                 Conditional Jump addr (label): After the execution of the conditional jump instruction the program jumps to the instruction specified by the address (label) if the specified condition is fulfilled. The program proceeds further in the normal sequence if the specified condition is not fulfilled. If the condition is true and program jumps to the specified label, the execution of a conditional jump takes 3 machine cycles: 10 states. If condition is not true, only 2 machine cycles; 7 states are required for the execution of the instruction.
a.      JZ addr (label). (Jump if the result is zero)
b.      JNZ addr (label) (Jump if the result is not zero)
c.      JC addr (label). (Jump if there is a carry)
d.      JNC addr (label). (Jump if there is no carry)
e.      JP addr (label). (Jump if the result is plus)
f.       JM addr (label). (Jump if the result is minus)
g.      JPE addr (label) (Jump if even parity)
h.      JPO addr (label) (Jump if odd parity)
iii.               CALL addr (label) (Unconditional CALL: call the subroutine identified by the operand)
CALL instruction is used to call a subroutine. Before the control is transferred to the subroutine, the address of the next instruction of the main program is saved in the stack. The content of the stack pointer is decremented by two to indicate the new stack top. Then the program jumps to subroutine starting at address specified by the label.
iv.               RET (Return from subroutine)
v.                  RST n (Restart) Restart is a one-word CALL instruction. The content of the program counter is saved in the stack. The program jumps to the instruction starting at restart location.

5. Stack, I/O and Machine Control Group

i.                    IN port-address. (Input to accumulator from I/O port) [A] ß [Port]
ii.                 OUT port-address (Output from accumulator to I/O port) [Port] ß [A]
iii.               PUSH rp (Push the content of register pair to stack)
iv.               PUSH PSW (PUSH Processor Status Word)
v.                  POP rp (Pop the content of register pair, which was saved, from the stack)
vi.               POP PSW (Pop Processor Status Word)
vii.             HLT (Halt)
viii.          XTHL (Exchange stack-top with H-L)
ix.               SPHL (Move the contents of H-L pair to stack pointer)
x.                  EI (Enable Interrupts)
xi.               DI (Disable Interrupts)
xii.             SIM (Set Interrupt Masks)
xiii.          RIM (Read Interrupt Masks)
xiv.           NOP (No Operation)



                 

ADDRESSING MODES

            Each instruction requires certain data on which it has to operate. There are various techniques to specify data for instructions.  These techniques are called addressing modes.  Intel 8085 uses the following addressing modes:

i.                    Direct addressing
ii.                 Register addressing
iii.               Register indirect addressing
iv.               Immediate addressing

Immediate Addressing

            In immediate addressing mode the operand is specified within the instruction itself, examples are:
            i. MVI A,05     { Move 05 in register A }
           ii. ADI 06          { Add 06 to the content of the accumulator }