Assembly Language continue 2192021 1 Assembly Language Format
Assembly Language (continue) 2/19/2021 1
Assembly Language Format Label • Start : • • Delimiter Colon Space Comma Semicolon 2/19/2021 Opcode LXI Operand SP, 3 FF 0 H Comment ; Initialize stack pointer Placement After label Between an opcode and an operan Between two operand Before beginning of a comment 2
Assembler Directive ORG (Origin) END EQU DFB (define byte) DFW (define Word) DFS (define Storage) 2/19/2021 Example Description ORG 2000 H The next block of instructions should store in memory starting at 2000 H END End of assembly PORTA: EQU 80 H The value of term PORTA is equal to 80 H DATA: DFB 10 H, 30 H Initializes an area byte by byte DATA: DFW 2020 H Initializes an area two byte at time DATA: DFS 10 Reserves a specified number of memory 3
Flowchart : Program Assembly & Execution Start Write /Edit Source Program Assemble Source File Yes Expected Result? No Troubleshot/Debug Yes Errors? Go Back to Edit Errors No Generate Hex / List File End Download Hex File into Target System & Execute Program 2/19/2021 4
Example (Sample Source Code) NUM 1: NUM 2: CPU “ 8085. TBL” ORG 2000 H EQU 55 H EQU 78 H LXI SP, 3 FF 0 H ; Initialize Stack pointer MVI A, NUM 1 ; load first number MOV B, A ; save it to B register MVI A, NUM 2 ; load second number ADD B ; add register A & B STA RESULT ; store to 2050 H RST 1 ORG 2050 H RESULT: DFS 1 ; reserve 1 byte location in END ; memory (Note: write your source code using any text editor) 2/19/2021 5
Manual assembly *Please Refer to 8085 Assembly Code Summary 8085 Assembly Codes INSTRUCT LOGICAL MOV B, A (B) (A) 47 1 4 LXI SP, data 16 (SP) (byte 3) (SP) (byte 2) 31 3 10 2/19/2021 OP-CODE BYTE T-STATE FLAGS _ S Z P CY AC 6
Manual assembly Address (Hex) 2000 2003 2005 2006 2008 2009 200 C 2/19/2021 Program Code Machine Code (Hex) LXI SP, 3 FF 0 H 31 F 0 3 F MVI A, NUM 1 3 E 55 MOV B, A 47 MVI A, NUM 2 3 E 78 ADD B 80 STA RESULT 32 50 20 RST 1 CF 7
Exercise PORTA: LOOP: DELAY: LOOP 1: 2/19/2021 CPU “ 8085. TBL” ORG 2000 H EQU 80 H LXI SP, 3 FF 0 H XRA A CMA OUT PORTA CALL DELAY JMP LOOP ; Initialize Stack pointer MVI B, 255 DCR B JNZ LOOP 1 RET END 8
Manual assembly Address (Hex) Program Code Machine Code (Hex) LXI SP, 3 FF 0 H XRA A CMA OUT PORTA CALL DELAY JMP LOOP MVI B, 255 DCR B JNZ LOOP 1 RET 2/19/2021 9
Assembler The Assembler is a program that translates source code or mnemonics into the binary code (machine code). In addition to translating mnemonics, the Assembler performs various functions, such as error checking and memory allocations. 2/19/2021 10
Source File (Example. ASM) Assembler (Translator) HEX File Listing File (Example. HEX) (Example. LST) 2/19/2021 11
Example of Listing File 00000 CPU "8085. TBL" 02000 00000055 00000078 ORG 2000 H EQU = = NUM 1: NUM 2: 02000 31 F 03 F 02003 3 E 55 02005 47 02006 3 E 78 02008 80 02009 325020 0200 C CF 02050 RESULT: 00000055 NUM 1 00000078 NUM 2 00002050 RESULT 2/19/2021 LXI SP, 3 FF 0 H MVI A, NUM 1 MOV B, A MVI A, NUM 2 ADD B STA RESULT RST 1 ORG 2050 H DFS END 55 H 78 H ; Initialize Stack pointer ; load first number ; save it to B register ; load second number ; add register A & B ; store to 2050 H 1 ; reserve 1 byte location in ; memory 12
Example of Hex File : 020000 FC : 0 D 20000031 F 03 F 3 E 55473 E 7880325020 CFF 2 : 00000001 FF : 0 D 20000031 F 03 F 3 E 55473 E 7880325020 CFF 2 Byte Count Record Type Address 2/19/2021 Data Byte (Program Code) Checksum 13
• Byte Count The number of data bytes in the record • Address of the first data byte in the record. Address in End of File record is 0000 • Record Type The record type for a data record is 00. The record type for an End of File record is 01 • Data Byte Data byte in HEX ASCII. Two character per byte. • Checksum Two’s complement byte of binary sum of preceding byte in record; Including byte count, address and data byte 2/19/2021 14
Testing & Debugging • Download Hex File into Target System & Execute Program 8085 Development System is communicated with PC through serial port (RS 232). RS 232 PC 2/19/2021 8085 Development Board 15
- Slides: 15