TK 2633: Microprocessor & Interfacing

36
Dr Masri Ayob Dr Masri Ayob TK 2633: Microprocessor & Interfacing Lecture 7: Assembly Language

description

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: - PowerPoint PPT Presentation

Transcript of TK 2633: Microprocessor & Interfacing

Page 1: TK 2633: Microprocessor & Interfacing

Dr Masri AyobDr Masri Ayob

TK 2633:Microprocessor & Interfacing

Lecture 7: Assembly Language

Page 2: TK 2633: Microprocessor & Interfacing

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.

Page 3: TK 2633: Microprocessor & Interfacing

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).

Page 4: TK 2633: Microprocessor & Interfacing

April 20, 2023 Prepared by: Dr Masri Ayob 4

Assembly Language

Page 5: TK 2633: Microprocessor & Interfacing

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

Page 6: TK 2633: Microprocessor & Interfacing

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

Page 7: TK 2633: Microprocessor & Interfacing

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

Page 8: TK 2633: Microprocessor & Interfacing

April 20, 2023 Prepared by: Dr Masri Ayob 8

Assembly Language

Page 9: TK 2633: Microprocessor & Interfacing

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

Page 10: TK 2633: Microprocessor & Interfacing

April 20, 2023 Prepared by: Dr Masri Ayob 10

Assembly Language

Page 11: TK 2633: Microprocessor & Interfacing

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

Page 12: TK 2633: Microprocessor & Interfacing

April 20, 2023 Prepared by: Dr Masri Ayob 12

Operand arithmetic operations.

Assembly Language

Page 13: TK 2633: Microprocessor & Interfacing

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

Page 14: TK 2633: Microprocessor & Interfacing

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

Page 15: TK 2633: Microprocessor & Interfacing

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

Page 16: TK 2633: Microprocessor & Interfacing

April 20, 2023 Prepared by: Dr Masri Ayob 16

Assembly Language : Example

Page 17: TK 2633: Microprocessor & Interfacing

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

Page 18: TK 2633: Microprocessor & Interfacing

April 20, 2023 Prepared by: Dr Masri Ayob 18

Assembly Language : Example

Page 19: TK 2633: Microprocessor & Interfacing

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

Page 20: TK 2633: Microprocessor & Interfacing

April 20, 2023 Prepared by: Dr Masri Ayob 20

Assembly Language : Example

Page 21: TK 2633: Microprocessor & Interfacing

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

Page 22: TK 2633: Microprocessor & Interfacing

April 20, 2023 Prepared by: Dr Masri Ayob 22

Assembly Language : Example

Page 23: TK 2633: Microprocessor & Interfacing

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

Page 24: TK 2633: Microprocessor & Interfacing

April 20, 2023 Prepared by: Dr Masri Ayob 24

Assembly Language

Page 25: TK 2633: Microprocessor & Interfacing

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

Page 26: TK 2633: Microprocessor & Interfacing

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

Page 27: TK 2633: Microprocessor & Interfacing

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

Page 28: TK 2633: Microprocessor & Interfacing

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.

Page 29: TK 2633: Microprocessor & Interfacing

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”

Page 30: TK 2633: Microprocessor & Interfacing

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.

Page 31: TK 2633: Microprocessor & Interfacing

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.

Page 32: TK 2633: Microprocessor & Interfacing

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.

Page 33: TK 2633: Microprocessor & Interfacing

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.

Page 34: TK 2633: Microprocessor & Interfacing

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)

Page 35: TK 2633: Microprocessor & Interfacing

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.

Page 36: TK 2633: Microprocessor & Interfacing

April 20, 2023 Prepared by: Dr Masri Ayob 36

Thank youQ&A