1 / 30

Lecture 12 Assembly Language 1

Lecture 12 Assembly Language 1. All Instructions. If the operand is a memory location, its location is specified by the contents of the HL registers. All flags are modified to reflect the result of the operation. Move Immediate 8-bit.

sydney
Download Presentation

Lecture 12 Assembly Language 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 12Assembly Language 1

  2. All Instructions • If the operand is a memory location, its location is specified by the contents of the HL registers. • All flags are modified to reflect the result of the operation.

  3. Move Immediate 8-bit The 8-bit data in the instruction is stored in the destination register or memory. MVI Rd, data MVI M, data Example: MVI B, 57 or MVI M, 57

  4. Copy from source to destination Copies the contents of the source into the destination. MOV Rd, Rs MOV M, Rs MOV Rd, M Example: MOV B, C or MOV B, M

  5. Add register or memory to accumulator The contents of the operand are added to the contents of the accumulator and the result is stored in the accumulator. ADD R ADD M Example: ADD B or ADD M

  6. Halt and enter wait state The CPU finishes executing the current instruction and halts any further execution. An interrupt or reset is necessary to exit from the halt state. HLT <empty>

  7. Example 1 Write the instructions to add two numbers, 50 and 72, and save the answer in register C.

  8. Example 1 Write the instructions to add two numbers, 50 and 72, and save the answer in register C. MVI A, 50 MVI B, 72 ADD B MOV C, A HLT

  9. 8085 Assembler Directives • Assembler directives are instructions to the assembler concerning the program being assembled. • They are not translated into machine code or assigned any memory locations in the object file.

  10. 8085 Assembler Directives ORG Define start location END End of file EQU Equate DB Define byte DW Define word DS Define Storage

  11. Load Register Pair Immediate Loads 16-bit data in the register pair designated in the operand. LXI Reg pair, data Example: LXI H, 2034 orLXI H, XYZ

  12. Example 2 Write the instructions to add two numbers, 50 and 72, and save the answer in a memory location called result. Use the assembler to name a constant, cnst, for 50 and to use a memory location, called xyz, for 72.

  13. Example 2 org 0 cnst equ 50 xyz: db 72 result: ds 1 start: mvi a, cnst lxi h, xyz add m lxi h, result mov M, A hlt end start

  14. Load Accumulator The contents of a memory location, specified by a 16-bit address in the operand, are copied to the accumulator. LDA 16-bit address Example: LDA 2034 or LDA XYZ

  15. Store Accumulator The contents of the accumulator are copied into the memory location specified by the operand. This is a 3-byte instruction, the second byte specifies the low-order address and the third byte specifies the high-order address. STA 16-bit address Example: STA 2034 or STA XYZ

  16. Add Immediate to Accumulator The 8-bit data (operand) is added to the con-tents of the accumulator and the result is stored in the accumulator. All flags are mod-ified to reflect the result of the addition. ADI 8-bit data Example: ADI 45

  17. Example 3 Write the instructions to add two numbers, 50 and 72, and save the answer in a memory location called result. Use the assembler to name a constant, cnst, for 50 and to use a memory location called, xyz, for 72.

  18. Example 3 org 0 cnst equ 50 xyz: db 72 result: ds 1 start: lda xyz adi cnst sta result hlt end start ;

  19. Output Accumulator to a port The contents of the accumulator are copied into the I/O port specified by the operand. OUT 8-bit port address Example: OUT 99

  20. Input Accumulator from port The contents of the input port designated in the operand are read and loaded into the accumulator. IN 8-bit port address Example: IN 80

  21. Compare Immediate The second byte (8-bit data) is compared to the contents of the accumulator. The values being compared remain unchanged. CPI 8-bit data Example: CPI 89

  22. Compare Register or Memory The contents of the operand (register or memory) are compared to the contents of the accumulator. Both contents are preserved. The result of the com-parison is shown by setting the flags of the PSW as follows: CMP R M Example: CMP B or CMP M

  23. PSW Flag A < R A = R A > R Z 0 1 0 S 1 0 0 C 1 0 0 Some Notes on Comparisons The comparison is performed by a subtract- ion, followed by setting the bits in the PSW. The accumulator is not affected. (ACC) - (R) or (M) or I

  24. Jump Unconditionally The program sequence is transferred to the memory location specified by the 16-bit address given in the operand. JMP 16-bit address Example: JMP 2034 or JMP XYZ

  25. Jump Conditionally The program sequence is transferred to the memory location specified by the 16-bit address given in the operand based on the specified flag of the PSW as described below. Example: JZ 2034 or JNZ XYZ

  26. Jump Conditionally Opcode Description Flag Status JC Jump on Carry C = 1 JNC Jump on no Carry C = 0 JP Jump on positive S = 0 JM Jump on minus S = 1 JZ Jump on zero Z = 1, S = 0 JNZ Jump on not zero Z = 0 JPE Jump on even parity P = 1 JPO Jump on odd parity P = 0

  27. Example 4 Write the instructions to continually read a value on an input port whose address is 100. If the number represented by the data on the input port is greater than 128, turn on a light attached to bit 7 of an output port whose address is 101. If the number is less than 128, turn off the light.

  28. Example 4 org 0 ; inport equ 100 ; Input port outport equ 101 ; Output port setpt equ 128 ; Set point off equ 00H ; all bits zero on equ 80H ; bit 7 on start: mvi A, off ; Turn off to start. out outport loop: in inport ; Read the input port cpi setpt ; Compare jz loop ; Continue if the same jp seton ; Jump if greater jm setoff ; Jump smaller hlt ; Should never get here

  29. Example 4 (continued) seton: mvi A, on ; bit 7 on out outport ; output to port jmp loop ; continue setoff: mvi A, off ; bit 7 off out outport ; output to port jmp loop ; continue end start ; End of assembly

  30. Next Lecture Assembly Language 2

More Related