TK 2633: Microprocessor & Interfacing
-
Upload
hiram-hurley -
Category
Documents
-
view
42 -
download
0
description
Transcript of TK 2633: Microprocessor & Interfacing
Dr Masri AyobDr Masri Ayob
TK 2633:Microprocessor & Interfacing
Lecture 7: Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 2
Assembly LanguageAssembly 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.
April 20, 2023 Prepared by: Dr Masri Ayob 3
Assembly LanguageAssembly Language
The Two-pass Assembler : Read programme two times.
1. Generate a table of the labels/symbols within the source programme.
2. Develop hexadecimal version of the source programme.
Allow forward addressing (the software can jump ahead to an instruction in a program).
April 20, 2023 Prepared by: Dr Masri Ayob 4
Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 5
The assembler always assumes that the first instruction of the programme is stored at memory address 0000H unless otherwise directed by the ORG command.
Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 6
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.
Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 7
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.
Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 8
Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 9
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.
Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 10
Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 11
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.
Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 12
Operand arithmetic operations.
Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 13
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 :
Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 14
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.
Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 15
Define Byte (DB). Defines 8-bit memory data for a
programme. Multiple one byte data, comma ( , ) as
a separator.
Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 16
Assembly Language : Example
April 20, 2023 Prepared by: Dr Masri Ayob 17
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.
Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 18
Assembly Language : Example
April 20, 2023 Prepared by: Dr Masri Ayob 19
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.
Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 20
Assembly Language : Example
April 20, 2023 Prepared by: Dr Masri Ayob 21
Define Storage (DS). Reserves space in a programme
for variable data. Does not place any specific data
into the reserved area of memory.
Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 22
Assembly Language : Example
April 20, 2023 Prepared by: Dr Masri Ayob 23
Equate (Equ). Equates a label to another label or
value. Note that the EQU statement label
does not contain a colon ( : ).
Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 24
Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 25
Create one folder and save the following files (MS DOS application): Assembler file : ASM85.COM
Communication software: PROCOMM.EXE
How To Write Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 26
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.
How To Write Assembly Language
April 20, 2023 Prepared by: Dr Masri Ayob 27
How To Write Assembly Language
Source code Example (test1.asm):
ORG $9000MVI A,$2AADI $38MVI B,$67MOV D,BRST 7
April 20, 2023 Prepared by: Dr Masri Ayob 28
Compile the source code as follows (DOS command):
ASM85 <filename> [options]
e.g. To compile file “test1.asm”
ASM85 test1.asm –F -I -S
How To Write Assembly Language
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.
Other options can be referred to XASM.DOC
Causes the assembler to display symbol table.
April 20, 2023 Prepared by: Dr Masri Ayob 29
How To Write Assembly Language
DUNFIELD 8085 ASSEMBLER: test1 PAGE: 1
0000 1 9000 2 ORG $90009000 3E 2A 3 MVI A,$2A9002 C6 38 4 ADI $389004 06 67 5 MVI B,$679006 50 6 MOV D,B9007 FF 7 RST 7
Compilation will produce object file (.HEX) and listing file (.LST). For example
This is a listing file “test1.lst”
April 20, 2023 Prepared by: Dr Masri Ayob 30
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.
April 20, 2023 Prepared by: Dr Masri Ayob 31
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.
April 20, 2023 Prepared by: Dr Masri Ayob 32
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.
April 20, 2023 Prepared by: Dr Masri Ayob 33
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.
April 20, 2023 Prepared by: Dr Masri Ayob 34
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)
April 20, 2023 Prepared by: Dr Masri Ayob 35
How To Upload File into Trainer Kit
To view other command press ? You can view register contents Trace instruction Change Memory, etc.
April 20, 2023 Prepared by: Dr Masri Ayob 36
Thank youQ&A