Presentation is loading. Please wait.

Presentation is loading. Please wait.

ASSEMBLY LANGUAGE.  Upon completing this topic, you should be able to: Classify the 8085A microprocessor instructions Explain the basic function of common.

Similar presentations


Presentation on theme: "ASSEMBLY LANGUAGE.  Upon completing this topic, you should be able to: Classify the 8085A microprocessor instructions Explain the basic function of common."— Presentation transcript:

1 ASSEMBLY LANGUAGE

2  Upon completing this topic, you should be able to: Classify the 8085A microprocessor instructions Explain the basic function of common use instruction. Write simple program using assembly language

3  Assembly language is used to program microprocessor.  Assembly language instructions can be classified into 5 distinct operational categories: a. Data transfer (copy) operations Data transfer (copy) operations b. Arithmetic operations Arithmetic operations c. Logical operations Logical operations d. Branching operations Branching operations e. Stack, I/O and machine control operations Stack, I/O and machine control operations

4  Data transfer instructions move (copy) :- Constant (immediate) data into register o MVIRegister, Constant (8 bit) o Register (A, B, C, D, E, H, L) o Constants ( any 8 bit number ) o Decimal  0 – 255  MVI B, 200 o Binary  00000000B – 11111111B  MVI B, 11001000B o Hexadecimal  00H – 0FFH  MVI B, 0C8H o LXIRegister pair, Constant (16 bit) o Register pair( B = BC, D = DE, H = HL, SP = stack pointer) o Constants ( any 16 bit number ) o Decimal  0 – 65535  LXI B, 16368 o Binary  0000000000000000B – 1111111111111111B  LXI B, 0011111111110000B o Hexadecimal  0000H – 0FFFFH  LXI B, 3FF0H

5  Data transfer instructions move (copy) :- Data between register o MOVDestination, Source o Copy data from source to destination o Destination and source is register (A, B, C, D, E, H, L) o Size of moving data is 8 bit (1 byte) o Example:MOVB,A o XCHG o Exchange the contents of HL register with DE register o The contents of register H are exchanged with register D and the contents of register L are exchanged with register E o Example:XCHG

6  Data transfer instructions move (copy) :- Data from accumulator to memory o STAAddress o Data from Accumulator are copied into specific memory location given by Address o The size of address is 16 – bit (2 byte) o Example:STA3200H o STAXRegister Pair o Data from Accumulator are copied into specific memory location given by Register Pair o Indirect data transfer o Register pair( B = BC, D = DE) o Example:STAXB

7  Data transfer instructions move (copy) :- Data from memory to accumulator o LDAAddress o Data from specific memory location given by Address are copied into Accumulator o The size of address is 16 – bit (2 byte) o Example:LDA3200H o LDAXRegister Pair o Data from specific memory location given by Register Pair are copied into Accumulator o Indirect data transfer o Register pair( B = BC, D = DE) o Example:LDAXD

8  Data transfer instructions move (copy) :- Data from memory to register o MOVRegister, M o Copy data from memory(source) into register (destination) o The memory location is specified by HL register o Register (A, B, C, D, E, H, L) o Example:MOVB, M o LHLD Address (Load H and L register Direct) o Data from memory location specified by Address is copied into register L o Data from memory location specified by Address + 1 is copied into register H o The size of address is 16 – bit (2 byte) o Example:SHLD2000H

9  Data transfer instructions move (copy) :- Data from register to memory o MOVM, Register o Copy data from register(source) into memory (destination) o The memory location is specified by HL register o Register (A, B, C, D, E, H, L) o Example:MOVM,D o SHLD Address (Store H and L register Direct) o Data from register L is stored into memory location specified by Address o Data from register H is stored into memory location specified by Address + 1 o The size of address is 16 – bit (2 byte) o Example:LHLD2000H

10  Arithmetic operations are perform by ALU and the result of operations will be stored in Accumulator (for instruction that involved Accumulator only).  All arithmetic instructions (except INX, DCX) will alter the Flag register.

11  Add immediate (constant) with accumulator ADIConstant (8 bit) o [A]  [A] + Constant o Constants ( any 8 bit number ) o Decimal  0 – 255  ADI 200 o Binary  00000000B – 11111111B  ADI 11001000B o Hexadecimal  00H – 0FFH  ADI 0C8H o If the result of operation produce carry, CY flag is set o S, P, AC, Z will reflect to the result of operation (content of A) ACIConstant (8 bit) o [A]  [A] + Constant + CY o Constants ( any 8 bit number ) o Decimal  0 – 255  ACI 200 o Binary  00000000B – 11111111B  ACI 11001000B o Hexadecimal  00H – 0FFH  ACI 0C8H o If the result of operation produce carry, CY flag is set o S, P, AC, Z will reflect to the result of operation (content of A)

12  Add register with accumulator ADDRegister o [A]  [A] + [Register] o Register (A, B, C, D, E, H, L) o If the result of operation produce carry, CY flag is set o S, P, AC, Z will reflect to the result of operation (content of A) o Example:ADD B ADCRegister o [A]  [A] + [Register] + CY o Register (A, B, C, D, E, H, L) o If the result of operation produce carry, CY flag is set o S, P, AC, Z will reflect to the result of operation (content of A) o Example:ADCB

13  Add memory content with accumulator ADDM o [A]  [A] + [M] o The memory location is specified by HL register o If the result of operation produce carry, CY flag is set o S, P, AC, Z will reflect to the result of operation (content of A) o Example:ADD M ADCM o [A]  [A] + [M] + CY o The memory location is specified by HL register o If the result of operation produce carry, CY flag is set o S, P, AC, Z will reflect to the result of operation (content of A) o Example:ADC M

14  Subtract immediate (constant) from accumulator SUIConstant (8 bit) o [A]  [A] - Constant o Constants ( any 8 bit number ) o Decimal  0 – 255  SUI 200 o Binary  00000000B – 11111111B  SUI 11001000B o Hexadecimal  00H – 0FFH  SUI 0C8H o If the result of operation required borrow, CY flag is set o If CY = 1, the content of Acc is in 2’s complement form (Negative Number) o S, P, AC, Z will reflect to the result of operation (content of A) SBIConstant (8 bit) o [A]  [A] - Constant - CY o Constants ( any 8 bit number ) o Decimal  0 – 255  SBI 200 o Binary  00000000B – 11111111B  SBI 11001000B o Hexadecimal  00H – 0FFH  SBI 0C8H o If the result of operation required borrow, CY flag is set o If CY = 1, the content of Acc is in 2’s complement form (Negative Number) o S, P, AC, Z will reflect to the result of operation (content of A)

15  Subtract register from accumulator SUBRegister o [A]  [A] - [Register] o Register (A, B, C, D, E, H, L) o If the result of operation required borrow, CY flag is set o If CY = 1, the content of Acc is in 2’s complement form (Negative Number) o S, P, AC, Z will reflect to the result of operation (content of A) o Example:SUB B SBBRegister o [A]  [A] - [Register] - CY o Register (A, B, C, D, E, H, L) o If the result of operation required borrow, CY flag is set o If CY = 1, the content of Acc is in 2’s complement form (Negative Number) o S, P, AC, Z will reflect to the result of operation (content of A) o Example:SBBB

16  Subtract memory content from accumulator SUBM o [A]  [A] - [M] o The memory location is specified by HL register o If the result of operation required borrow, CY flag is set o If CY = 1, the content of Acc is in 2’s complement form (Negative Number) o S, P, AC, Z will reflect to the result of operation (content of A) o Example:SUB M SBBM o [A]  [A] - [M] - CY o The memory location is specified by HL register o If the result of operation required borrow, CY flag is set o If CY = 1, the content of Acc is in 2’s complement form (Negative Number) o S, P, AC, Z will reflect to the result of operation (content of A) o Example:SBB M

17  Increment register by 1 INRRegister o [Register]  [Register] + 1 o Register (A, B, C, D, E, H, L) o S, P, AC, Z will reflect to the result of operation (content of Register) o CY flag will remains o Example:INR B INXRegister Pair (Rp) o [Rp]  [Rp] + 1 o Register pair( B = BC, D = DE, H = HL, SP) o No flags are affected o Example:INXB

18  Increment memory content by 1 INRM o [M]  [M] + 1 o The memory location is specified by HL register o S, P, AC, Z will reflect to the result of operation (content of Register) o CY flag will remains o Example:INR M

19  Decrement register by 1 DCRRegister o [Register]  [Register] - 1 o Register (A, B, C, D, E, H, L) o S, P, AC, Z will reflect to the result of operation (content of Register) o CY flag will remains o Example:DCR B DCXRegister Pair (Rp) o [Rp]  [Rp] - 1 o Register pair( B = BC, D = DE, H = HL, SP) o No flags are affected o Example:DCXB

20  Decrement memory content by 1 DCRM o [M]  [M] - 1 o The memory location is specified by HL register o S, P, AC, Z will reflect to the result of operation (content of Register) o CY flag will remains o Example:DCR M

21  Other Arithmetic Instruction DADRegister Pair (Rp) o [HL]  [HL] + [Rp] o Register pair( B = BC, D = DE) o S, P, AC, Z are not affected o CY flag will set if results of operation is larger than 16 bit o Example:DCR B DAA o Convert contents of Accumulator from binary value into two 4 digit BCD value o If value of lower order 4-bits > 9, or AC = 1, then [A] = [A] + 06H o If value of high order 4-bits > 9, or CY = 1, then [A] = [A] + 60H o S, P, Z, AC, CY flags are altered to reflect the result of operation o Example:DAA

22  Logic operations are perform by ALU and most of the result of operations will be stored in Accumulator.  Most of the arithmetic instructions will alter the Flag register.

23  ANDing data with Accumulator ANIConstant (8 bit) o [A]  [A] ^ Constant o Constants ( any 8 bit number ) o Decimal  0 – 255  ANI 200 o Binary  00000000B – 11111111B  ANI 11001000B o Hexadecimal  00H – 0FFH  ANI 0C8H o S, P, Z will reflect to the result of operation (content of A) o CY flag is Reset, AC is Set ANARegister o [A]  [A] ^ [Register] o Register (A, B, C, D, E, H, L) o S, P, Z will reflect to the result of operation (content of A) o CY flag is Reset, AC is Set o Example:ANA B

24  ANDing data with Accumulator ANAM o [A]  [A] ^ [M] o The memory location is specified by HL register o S, P, Z will reflect to the result of operation (content of A) o CY flag is Reset, AC is Set o Example:ANA M

25  ORing data with Accumulator ORIConstant (8 bit) o [A]  [A] v Constant o Constants ( any 8 bit number ) o Decimal  0 – 255  ORI 200 o Binary  00000000B – 11111111B  ORI 11001000B o Hexadecimal  00H – 0FFH  ORI 0C8H o S, P, Z will reflect to the result of operation (content of A) o CY and AC flags are Reset ORARegister o [A]  [A] v [Register] o Register (A, B, C, D, E, H, L) o S, P, Z will reflect to the result of operation (content of A) o CY and AC flags are Reset o Example:ORA B

26  ORing data with Accumulator ORAM o [A]  [A] v [M] o The memory location is specified by HL register o S, P, Z will reflect to the result of operation (content of A) o CY and AC flags are Reset o Example:ORA M

27  XORing data with Accumulator XRIConstant (8 bit) o [A]  [A] Constant o Constants ( any 8 bit number ) o Decimal  0 – 255  XRI 200 o Binary  00000000B – 11111111B  XRI 11001000B o Hexadecimal  00H – 0FFH  XRI 0C8H o S, P, Z will reflect to the result of operation (content of A) o CY and AC flags are Reset XRARegister o [A]  [A] [Register] o Register (A, B, C, D, E, H, L) o S, P, Z will reflect to the result of operation (content of A) o CY and AC flags are Reset o Example:XRA B

28  XORing data with Accumulator XRAM o [A]  [A] [M] o The memory location is specified by HL register o S, P, Z will reflect to the result of operation (content of A) o CY and AC flags are Reset o Example:XRA M

29  Compare data with Accumulator CPIConstant (8 bit) o [A] – Constant >>>>> Flag Register o Constants ( any 8 bit number ) o Decimal  0 – 255  CPI 200 o Binary  00000000B – 11111111B  CPI 11001000B o Hexadecimal  00H – 0FFH  CPI 0C8H o If [A] < Constant, then CY = 1, Z = 0 o If [A] = Constant, then CY = 0, Z = 1 o If [A] > Constant, then CY = 0, Z = 0 o S, P, AC are affected by the result of subtraction

30  Compare data with Accumulator CMPRegister o [A] - [Register] >>>>> Flag Register o Register (A, B, C, D, E, H, L) o If [A] < [Register], then CY = 1, Z = 0 o If [A] = [Register], then CY = 0, Z = 1 o If [A] > [Register], then CY = 0, Z = 0 o S, P, AC are affected by the result of subtraction o Example:CMP B

31  Compare data with Accumulator CMPM o [A] - [M] >>>> Flag register o The memory location is specified by HL register o If [A] < [M], then CY = 1, Z = 0 o If [A] = [M], then CY = 0, Z = 1 o If [A] > [M], then CY = 0, Z = 0 o S, P, AC are affected by the result of subtraction o Example:CMP M

32  Rotate Accumulator Right 1 bit RRC  Rotate Accumulator Right o [A 0 ]  CY o [A 0 ]  [A 7 ] o [A n+1 ]  [A n ] o CY is modified according to A 0 o S, P, Z, AC are not affected

33  Rotate Accumulator Right 1 bit RAR  Rotate Accumulator Right through Carry o [A 0 ]  CY o CY  [A 7 ] o [A n+1 ]  [A n ] o CY is modified according to A 0 o S, P, Z, AC are not affected

34  Rotate Accumulator Left 1 bit RLC  Rotate Accumulator Left o [A 7 ]  CY o [A 7 ]  [A 0 ] o [A n ]  [A n+1 ] o CY is modified according to A 7 o S, P, Z, AC are not affected

35  Rotate Accumulator Left 1 bit RAL  Rotate Accumulator Left through Carry o [A 7 ]  CY o CY  [A 0 ] o [A n ]  [A n+1 ] o CY is modified according to A 7 o S, P, Z, AC are not affected

36  Complement Accumulator CMA o [A] = [A] o No Flag are affected  Complement Carry Flag CMC o CY= CY o Other Flag are not affected  Set Carry Flag STC o CY= 1 o Other Flag are not affected

37  Branch operations allow the microprocessor to change a sequence of a program, either unconditionally or under certain test condition.  The branch instructions are classified into 3 categories: Jump instruction Call and Return instruction Restart instruction

38  Jump instruction Unconditional Jump o JMPAddress (Label) o Jump to specific address location provided by Address o The size of address is 16 – bit (2 byte) o [byte 3][byte 2]  [PC] o Suitable for continuous loop o Example:JMP3000H JMPLOOP Conditional Jump o J ConditionAddress (Label) o Jump to specific address location provided by Address if the condition is true o The size of address is 16 – bit (2 byte) o [byte 3][byte 2]  [PC] o The condition is base on the S, P, CY, Z

39  Jump instruction Conditional Jump OpcodeDescriptionCondition JNZJump if no ZeroZ = 0 JZJump if ZeroZ = 1 JNCJump if no CarryC = 0 JCJump if CarryC = 1 JPJump if PositiveS = 0 JMJump if MinusS = 1 JPOJump if Parity OddP = 0 JPEJump if Parity EvenP = 1

40  Call and Return instruction Subroutine is a group of instructions written separately from the main program to perform function that occurs rapidly in the main program. To implement subroutine, 8085 provide two instructions: 1.CALL – Call a subroutine 2.RET – Return from subroutine to main program

41  Call and Return instruction Unconditional Call and Return o CALLAddress of subroutine (Label) o Jump to specific address location provided by Address of subroutine o The size of address is 16 – bit (2 byte) o [PCH]  [SP – 1] o [PCL]  [SP – 2] o SP – 2  SP o [byte 3][byte 2]  [PC] o Example:CALL3000H CALLDELAY

42  Call and Return instruction Unconditional Call and Return o RET o Return to main program o [SP]  [PCL] o [SP + 1]  [PCH] o SP + 2  SP o Example:RET

43  Call and Return instruction Conditional Call and Return o C ConditionAddress of subroutine (Label) o Jump to specific address location provided by Address of subroutine if specific condition is true o The size of address is 16 – bit (2 byte) o If (condition = true) o [PCH]  [SP – 1] o [PCL]  [SP – 2] o SP – 2  SP o [byte 3][byte 2]  [PC]

44  Jump instruction Conditional Call and Return OpcodeDescriptionCondition CNZCall on no ZeroZ = 0 CZCall on ZeroZ = 1 CNCCall on no CarryC = 0 CCCall on CarryC = 1 CPCall on PositiveS = 0 CMCall on MinusS = 1 CPOCall on Parity OddP = 0 CPECall on Parity EvenP = 1

45  Call and Return instruction Conditional Call and Return o R Condition o Return to main program if specific condition is true o If (condition = true) o [SP]  [PCL] o [SP + 1]  [PCH] o SP + 2  SP

46  Jump instruction Conditional Call and Return OpcodeDescriptionCondition RNZReturn on no ZeroZ = 0 RZReturn on ZeroZ = 1 RNCReturn on no CarryC = 0 RCReturn on CarryC = 1 RPReturn on PositiveS = 0 RMReturn on MinusS = 1 RPOReturn on Parity OddP = 0 RPEReturn on Parity EvenP = 1

47  Restart instruction Use to transfer program execution to one of eight memory locations depending upon the number. Generally used in conjunction with interrupts and inserted using external hardware Can also be used in software. Memory location can be calculated using the following formula; Memory Location = n * 08H where n is a restart number

48  Restart instruction RSTN o N  number of address locations o No Flag are affected  Other instruction PCHL o Copy contents of register HL to Program Counter o [H]  [PCH] o [L]  [PCL] InstructionAddress RST 000H RST 108H RST 210H RST 318H RST 420H RST 528H RST 630H RST 738H

49  Stack can be described as a set of memory locations in the R/W memory specified by a programmer in the main program.  It used to store binary information temporarily during the execution of a program.  The beginning of stack is define in the program using LXISP, Stack Address  Storing data bytes at the stack location is begin at memory address that is one less than the address in the stack pointer and continue in reverse numerical order.  Therefore, the stack is initialized at the highest available memory location to prevent the program from being destroyed by the stack information.

50  Stack Instructions PUSHRegister Pair (Rp) o Store register pair on Stack o Register pair( B = BC, D = DE, H = HL, PSW = A and Flag) o [RpL]  [SP - 1] o [RpH]  [SP - 2] o SP – 2  SP o Example:PUSHPSW POPRegister Pair (Rp) o Retrieve register pair from Stack o Register pair( B = BC, D = DE, H = HL, PSW = A and Flag) o [SP ]  [RpH] o [SP + 1]  [RpL] o SP + 2  SP o Example:POPPSW

51  I/O devices can be interfaced with the 8085 microprocessor either as peripheral I/O or memory-mapped I/O.  In the peripheral I/O, the instructions IN/OUT are used as data transfer, and the device is identified by an 8-bit address.  In memory-mapped I/O, memory related instructions are used for data transfer, and the device is identified by a 16-bit address

52  I/O Instructions IN8-bit port address o The contents of the input port specified by 8-bit port address is read and loaded into the Accumulator o Example:IN81H OUT8-bit port address o Transfer data from the Accumulator to the output device specified by 8-bit port address o Example:OUT80H

53  Machine Control Instructions NOP o No operation is performed o Use to increase processing time or substitute in place of an instruction o Example:NOP HLT o The CPU finishes executing the current instruction and halt any further execution o The address and data bus are placed in high impedance state o No register contents are affected o Reset or interrupt is necessary to exit from halt state o Example:HLT

54  Machine Control Instructions DI o Disable Interrupt o Use to disable all interrupt o Example:DI EI o Enable Interrupt o Use to turn on all interrupt (Except mask interrupt) o Example:EI

55  Machine Control Instructions SIM o Set interrupt mask o Use to enable and disable maskable interrupt o Bit D 7 is use to send serial data out o Example:SIM RIM o Read Interrupt mask o Use to read current status of maskable interrupt o Bit D 7 is use to read serial data in o Example:RIM


Download ppt "ASSEMBLY LANGUAGE.  Upon completing this topic, you should be able to: Classify the 8085A microprocessor instructions Explain the basic function of common."

Similar presentations


Ads by Google