360 likes | 632 Views
TK 2633: Microprocessor & Interfacing. Lecture 7: Assembly Language. Assembly Language. Assembly language: 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:
E N D
TK 2633:Microprocessor & Interfacing Lecture 7: Assembly Language
Assembly Language • Assembly language: • 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: • An assembler is a program that converts software written in symbolic machine language (the source programme) into hexadecimal machine language (object programme). • The primary reason to use assembler is because development and modification are always difficult in machine language. Prepared by: Dr Masri Ayob
Assembly Language • The Two-pass Assembler : • Read programme two times. • Generate a table of the labels/symbols within the source programme. • Develop hexadecimal version of the source programme. • Allow forward addressing (the software can jump ahead to an instruction in a program). Prepared by: Dr Masri Ayob
Assembly Language Prepared by: Dr Masri Ayob
Assembly Language • The assembler always assumes that the first instruction of the programme is stored at memory address 0000H unless otherwise directed by the ORG command. Prepared by: Dr Masri Ayob
Assembly Language • Pass One: • The assembler scans the source programme during the first pass and generates a table of the labels found within the source programme. • 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 internal programme counter 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
Assembly Language • Pass Two: • During the second pass of the source programme, the assembler forms the object programme. • This occurs by referring to the label table for any labels that appear in the programme and to an instruction table. • The instruction table contains all the opcodes in both symbolic and machine language forms. • The tables help convert the source programme into the object programme. Prepared by: Dr Masri Ayob
Assembly Language Prepared by: Dr Masri Ayob
Assembly Language • Assembly Language Statement: • Format : • Label Field. • Contains a symbolic memory address that refers to the statement in a programme. Labels are optional and must end with a colon in some Intel 8085A ( : ). • Labels are constructed from alphanumeric characters and must begin with any letter of the alphabet. Prepared by: Dr Masri Ayob
Assembly Language Prepared by: Dr Masri Ayob
Assembly Language • Opcode field: • This field must contain opcodes. • Operand field: • 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. • ASCII must appear as one of more letters surrounded by apostrophe. Prepared by: Dr Masri Ayob
Assembly Language • Operand arithmetic operations. Prepared by: Dr Masri Ayob
Assembly Language • Comment field. • Must begin with semicolon in most 8085 assemblers and may continue to the end of the line only. • Use asterisk * or semicolon ; if the comment should continue into the next line. • Example : Prepared by: Dr Masri Ayob
Assembly Language • Assembler pseudo operations. • Directives to the assembler programme that may or may not generate machine code. • Examples : • END, DB, DW, DS, ORG, EQU, IF, ENDIF, SET, GLB, EXT, TITLE, SPC. • All pseudo operations must appear in the opcode field of a statement. Prepared by: Dr Masri Ayob
Assembly Language • Define Byte (DB). • Defines 8-bit memory data for a programme. • Multiple one byte data, comma ( , ) as a separator. Prepared by: Dr Masri Ayob
Assembly Language : Example Prepared by: Dr Masri Ayob
Assembly Language • Origin (ORG). • Changes the starting location of the programme to another address besides 0000H. • Can be used at any place in a programme to change the location of the assembled machine language instructions or data. Prepared by: Dr Masri Ayob
Assembly Language : Example Prepared by: Dr Masri Ayob
Assembly Language • Define Word (DW). • Pseudo operation stores a 16-bit number in the memory for use by a programme. • Defines no only numeric data but also memory addresses and label. Prepared by: Dr Masri Ayob
Assembly Language : Example Prepared by: Dr Masri Ayob
Assembly Language • Define Storage (DS). • Reserves space in a programme for variable data. • Does not place any specific data into the reserved area of memory. Prepared by: Dr Masri Ayob
Assembly Language : Example Prepared by: Dr Masri Ayob
Assembly Language • Equate (Equ). • Equates a label to another label or value. • Note that the EQU statement label does not contain a colon ( : ). Prepared by: Dr Masri Ayob
Assembly Language Prepared by: Dr Masri Ayob
How To Write Assembly Language • Create one folder and save the following files (MS DOS application): • Assembler file : ASM85.COM • Communication software: PROCOMM.EXE Prepared by: Dr Masri Ayob
How To Write Assembly Language • Create one folder and save the following files (MS DOS application): • Assembler file : ASM85.COM • Communication software: PROCOMM.EXE • Write a source program in assembly language using any text editor, e.g. Notepad, WordPad etc. Prepared by: Dr Masri Ayob
How To Write Assembly Language Source code Example (test1.asm): ORG $9000 MVI A,$2A ADI $38 MVI B,$67 MOV D,B RST 7 Prepared by: Dr Masri Ayob
How To Write Assembly Language • Compile the source code as follows (DOS command): ASM85 <filename> [options] e.g. To compile file “test1.asm” ASM85 test1.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' file. By default, only lines containing errors are written to the listing file. Causes the assembler to display symbol table. Other options can be referred to XASM.DOC Prepared by: Dr Masri Ayob
How To Write Assembly Language • Compilation will produce object file (.HEX) and listing file (.LST). For example DUNFIELD 8085 ASSEMBLER: test1 PAGE: 1 0000 1 9000 2 ORG $9000 9000 3E 2A 3 MVI A,$2A 9002 C6 38 4 ADI $38 9004 06 67 5 MVI B,$67 9006 50 6 MOV D,B 9007 FF 7 RST 7 This is a listing file “test1.lst” Prepared by: Dr Masri Ayob
SETTING UP PROCOMM FOR USE WITH THE PRIMER • ProComm is a powerful full featured communication software package that is ideally suited for use with the trainer PRIMER kit. • ProComm 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. • This menu allows you to configure ProComm to match the settings on the PRIMER. • Normally options 11 or 12 would be selected from the LINE SETTINGS menu…choose 11. • Options 11 constitute 9600, no parity, and 1 stop bit. Prepared by: Dr Masri Ayob
SETTING UP PROCOMM FOR USE WITH THE PRIMER • Next, select which COM port will be used for communication with the PRIMER. • Normally option 20 (COM1) 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
SETTING UP PROCOMM FOR USE WITH THE PRIMER • typing <ALT> S at the same time to display the SETUP menu. • 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) Expand blank lines...... YES 3) Pace character.......... 0 4) Character pacing........ 15 5) Line pacing............. 10 6) CR translation.......... NONE 7) LF translation.......... STRIP 8) CR translation.......... NONE 9) LF translation.......... NONE. Prepared by: Dr Masri Ayob
SETTING UP PROCOMM FOR USE WITH THE PRIMER • After making the necessary selections press <ESC> to exit to the SETUP menu. • At the SETUP menu select option S for Save and ProComm will then save the selected options to disk. • Once saved, configuring ProComm 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
How To Upload File into Trainer Kit • Connect the PRIMER kit to your PC using COM1. • Switch ON the PRIMER kit. • On the PRIMER kit, press: <RESET><FUNC> <0> • HELP MENU will be displayed on the PC monitor. • On the PC, press: • Shift > • Type the starting address of your program: e.g. 9000 • PgUp • 7 (ASCII) • Filename.hex (e.g. test1.hex) • Shift L (to list the program) • 9000 (starting address of the program) • G 9000 (execute the program) Prepared by: Dr Masri Ayob
How To Upload File into Trainer Kit • To view other command press ? • You can view register contents • Trace instruction • Change Memory, etc. Prepared by: Dr Masri Ayob
Thank youQ&A Prepared by: Dr Masri Ayob