TK 2633 Microprocessor Interfacing Lecture 7 Assembly Language
TK 2633: Microprocessor & Interfacing Lecture 7: Assembly Language Dr Masri Ayob Prepared by: Dr Masri Ayob
Assembly Language n n Assembly language: n Assembly language is used for most programming because it is extremely difficult to program a microprocessor in its native, that is hexadecimal machine language. Assembler: n An assembler is a program that converts software written in symbolic machine language (the source programme ) into hexadecimal machine language (object programme ). n The primary reason to use assembler is because development and modification are always difficult in machine language. 12/7/2020 Prepared by: Dr Masri Ayob 2
Assembly Language n 12/7/2020 The Two-pass Assembler : n Read programmetwo times. 1. Generate a table of the labels/symbols within the sourceprogramme. 2. Develop hexadecimal version of the source programme. n Allow forward addressing (the software can jump ahead to an instruction in a program). Prepared by: Dr Masri Ayob 3
Assembly Language 12/7/2020 Prepared by: Dr Masri Ayob 4
Assembly Language n 12/7/2020 The assembler always assumes that the first instruction of the programme is stored at memory address 0000 H unless otherwise directed by the ORG command. Prepared by: Dr Masri Ayob 5
Assembly Language n Pass One: n n n 12/7/2020 The assembler scans the source programmeduring the first pass and generates a table of the labels found within the sourceprogramme. Each entry in the label table contains the label and the address where the label appears in the programme. During the first pass the assembler determines the length of each instruction by updating an internal programme counter. This internalprogrammecounter allows the assembler to complete the label table by equating each label with the counter. Once the label table is complete the second pass begin. Prepared by: Dr Masri Ayob 6
Assembly Language n Pass Two: n During the second pass of the source programme , the assembler forms the object programme. n This occurs by referring to the label table for any labels that appear in the programmeand to an instruction table. n The instruction table contains all the opcodesin both symbolic and machine language forms. n The tables help convert the source programmeinto the objectprogramme. 12/7/2020 Prepared by: Dr Masri Ayob 7
Assembly Language 12/7/2020 Prepared by: Dr Masri Ayob 8
Assembly Language n n 12/7/2020 Assembly Language Statement: n Format : Label Field. n Contains a symbolic memory address that refers to the statement in aprogramme. Labels are optional and must end with a colon in some Intel 8085 A : ). ( n Labels are constructed from alphanumeric characters and must begin with any letter of the alphabet. Prepared by: Dr Masri Ayob 9
Assembly Language 12/7/2020 Prepared by: Dr Masri Ayob 10
Assembly Language n Opcodefield: n n Operand field: n n 12/7/2020 This field must contain opcodes. May contain register name, data or labels. If more than one of these is present, they must be separated with comma. Data must be encoded as decimal, binary, octal, hexadecimal, or ASCII must appear as one of more letters surrounded by apostrophe. Prepared by: Dr Masri Ayob 11
Assembly Language n 12/7/2020 Operand arithmetic operations. Prepared by: Dr Masri Ayob 12
Assembly Language n 12/7/2020 Comment field. n Must begin with semicolon in most 8085 assemblers and may continue to the end of the line only. n Use asterisk * or semicolon ; if the comment should continue into the next line. n Example : Prepared by: Dr Masri Ayob 13
Assembly Language n Assembler pseudo operations. n Directives to the assembler programmethat may or may not generate machine code. n Examples : n END, DB, DW, DS, ORG, EQU, IF, ENDIF, SET, GLB, EXT, TITLE, SPC. n All pseudo operations must appear in the opcodefield of a statement. 12/7/2020 Prepared by: Dr Masri Ayob 14
Assembly Language n 12/7/2020 Define Byte (DB). n Defines 8 -bit memory data forprogramme a. n Multiple one byte data, comma ( , ) as a separator. Prepared by: Dr Masri Ayob 15
Assembly Language : Example 12/7/2020 Prepared by: Dr Masri Ayob 16
Assembly Language n 12/7/2020 Origin (ORG). n Changes the starting location of the programmeto another address besides 0000 H n Can be used at any place in programme a to change the location of the assembled machin language instructions or data. Prepared by: Dr Masri Ayob 17
Assembly Language : Example 12/7/2020 Prepared by: Dr Masri Ayob 18
Assembly Language n 12/7/2020 Define Word (DW). n Pseudo operation stores a 16 -bit number in the memory for use by programme a. n Defines no only numeric data but also memory addresses and label. Prepared by: Dr Masri Ayob 19
Assembly Language : Example 12/7/2020 Prepared by: Dr Masri Ayob 20
Assembly Language n 12/7/2020 Define Storage (DS). n Reserves space in a programmefor variable data. n Does not place any specific data into the reserved area of memory. Prepared by: Dr Masri Ayob 21
Assembly Language : Example 12/7/2020 Prepared by: Dr Masri Ayob 22
Assembly Language n 12/7/2020 Equate (Equ). n Equates a label to another label or value. n Note that the EQU statement label does not contain a colon ( : ). Prepared by: Dr Masri Ayob 23
Assembly Language 12/7/2020 Prepared by: Dr Masri Ayob 24
How To Write Assembly Language n 12/7/2020 Create one folder and save the following files (MS DOS application): n Assembler file : ASM 85. COM n Communication software: PROCOMM. EXE Prepared by: Dr Masri Ayob 25
How To Write Assembly Language n n 12/7/2020 Create one folder and save the following files (MS DOS application): n Assembler file : ASM 85. COM n Communication software: PROCOMM. EXE Write a source program in assembly language using any text editor, e. g. Notepad, Word. Pad etc. Prepared by: Dr Masri Ayob 26
How To Write Assembly Language Source code Example (test 1. asm): ORG $9000 MVI A, $2 A ADI $38 MVI B, $67 MOV D, B RST 7 12/7/2020 Prepared by: Dr Masri Ayob 27
How To Write Assembly Language Compile the source code as follows (DOS command): ASM 85<filename> [options] n e. g. To compile file “test 1. asm” ASM 85 test 1. asm –F -I -S Causes the assembler to output the code to the '. HEX' file in INTEL hex format (default is MOTOROLA hex format). Causes the assembler to output a full source listing to the '. LST' Causes the assembler to file. By default, only lines display symbol table. containing errors are written to the listing file. Other options can be referred to XASM. DOC 12/7/2020 Prepared by: Dr Masri Ayob 28
How To Write Assembly Language n Compilation will produce object file (. HEX) and listing file (. LST). For example DUNFIELD 8085 ASSEMBLER: test 1 PAGE: 1 0000 9000 9002 9004 9006 9007 3 E 2 A C 6 38 06 67 50 FF 1 2 3 4 5 6 7 ORG $9000 MVI A, $2 A ADI $38 MVI B, $67 MOV D, B RST 7 This is a listing file “test 1. lst” 12/7/2020 Prepared by: Dr Masri Ayob 29
SETTING UP PROCOMM FOR USE WITH THE PRIMER n n n Pro. Comm is a powerful full featured communication software package that is ideally suited for use with the trainer PRIMER kit. Pro. Comm runs on IBM PCs and compatibles, using COM ports 1 - 4 at baud rates of up 19, 200 baud. Setup PROCOMM: type PROCOMM (using DOS prompt) LINE SETTINGS menu: type <ALT> P at the same time. n This menu allows you to configure Pro. Comm to match the settings on the PRIMER. n Normally options 11 or 12 would be selected from the LINE SETTINGS menu…choose 11. n 12/7/2020 Options 11 constitute 9600, no parity, and 1 stop bit. Prepared by: Dr Masri Ayob 30
SETTING UP PROCOMM FOR USE WITH THE PRIMER n Next, select which COM port will be used for communication with the PRIMER. n n 12/7/2020 Normally option 20 (COM 1) would be selected. The COM port chosen must be the COM port that the PRIMER is connected to. Save the setting. After selecting the COM port, press <ESC> to exit the LINE SETTINGS menu. Prepared by: Dr Masri Ayob 31
SETTING UP PROCOMM FOR USE WITH THE PRIMER n typing <ALT> S at the same time to display the SETUP menu. n n n select option 6 (ASCII TRANSFER SETUP). Selecting option 6 will take you to the ASCII TRANSFER SETUP menu. This menu is correct for PRIMER communication in its default settings. The default settings should be as follows: 1) Echo locally. . . NO 2) 3) 4) 5) 6) 7) 8) 9) 12/7/2020 Expand blank lines. . . YES Pace character. . 0 Character pacing. . . . 15 Line pacing. . . 10 CR translation. . NONE LF translation. . STRIP CR translation. . NONE LF translation. . NONE. Prepared by: Dr Masri Ayob 32
SETTING UP PROCOMM FOR USE WITH THE PRIMER n n 12/7/2020 After making the necessary selections press <ESC> to exit to the SETUP menu. At the SETUP menu select option S for Save and Pro. Comm will then save the selected options to disk. Once saved, configuring Pro. Comm will no longer be required for future communication sessions. After saving press <ESC> to exit to the terminal mode of operation. Prepared by: Dr Masri Ayob 33
How To Upload File into Trainer Kit n n n Connect the PRIMER kit to your PC using COM 1. Switch ON the PRIMER kit. On the PRIMER kit, press: <RESET><FUNC> <0> n n On the PC, press: n n n n 12/7/2020 HELP MENU will be displayed on the PC monitor. Shift > Type the starting address of your program: e. g. 9000 Pg. Up 7 (ASCII) Filename. hex (e. g. test 1. hex) Shift L (to list the program) 9000 (starting address of the program) G 9000 (execute the program) Prepared by: Dr Masri Ayob 34
How To Upload File into Trainer Kit n n 12/7/2020 To view other command press? You can view register contents Trace instruction Change Memory, etc. Prepared by: Dr Masri Ayob 35
Thank you Q&A 12/7/2020 Prepared by: Dr Masri Ayob 36
- Slides: 36