You are on page 1of 36

TK 2633:

Microprocessor & Interfacing

Lecture 7:
Assembly Language

Dr Masri Ayob
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.

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 2


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

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 3


Assembly Language

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 4


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.

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 5


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.

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 6


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.

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 7


Assembly Language

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 8


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.

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 9


Assembly Language

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 10


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.

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 11


Assembly Language

 Operand arithmetic operations.

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 12


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 :

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 13


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.

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 14


Assembly Language

 Define Byte (DB).


 Defines 8-bit memory data for a

programme.
 Multiple one byte data, comma ( , ) as a

separator.

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 15


Assembly Language : Example

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 16


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.

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 17


Assembly Language : Example

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 18


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.

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 19


Assembly Language : Example

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 20


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.

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 21


Assembly Language : Example

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 22


Assembly Language

 Equate (Equ).
 Equates a label to another label or

value.
 Note that the EQU statement label does

not contain a colon ( : ).

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 23


Assembly Language

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 24


How To Write Assembly Language

 Create one folder and save the following


files (MS DOS application):
 Assembler file : ASM85.COM

Communication software: PROCOMM.EXE

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 25


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.

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 26


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

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 27


How To Write Assembly Language
Compile the source code as follows (DOS
command):
ASM85 <filename> [options]
e.g. To compile file “test1.asm”
Causes the assembler to
output the code to the
ASM85 test1.asm –F -I -S '.HEX' file in INTEL hex
format (default is
MOTOROLA hex format).
Causes the assembler to
output a full source listing to Causes the assembler to
the '.LST' file. By default, display symbol table.
only lines containing errors
are written to the listing file. Other options can be
referred to XASM.DOC
Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 28
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”


Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 29
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.

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 30


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.

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 31


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.
Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 32
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.

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 33


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)

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 34


How To Upload File into Trainer Kit

 To view other command press?


 You can view register contents
 Trace instruction
 Change Memory, etc.

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 35


Thank you
Q&A

Tuesday, January 17, 2023 Prepared by: Dr Masri Ayob 36

You might also like