0% found this document useful (0 votes)
14 views

Topic 3.tools Used in ASL Programming

Microprocessor pdf

Uploaded by

Sarendah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Topic 3.tools Used in ASL Programming

Microprocessor pdf

Uploaded by

Sarendah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

COMPILED BY: I. E LIABAYA COMMUNICATION & NAVIGATION (AVIONICS) DEPARTMENT.

4.0 TOOLS USED IN ASSEMBLY LANGUAGE PROGRAMMING

1] THE ASSEMBLER
An assembly language program cannot be executed by a machine directly as it is not in binary form
[machine language]. Usually we refer to such a program as a source program. A program is needed
in order to translate an assembly language [source] program into the object code executable by the
machine. The program that does all this is called an assembler.
Several types of assemblers are available the most common are;
1] One-pass assemble
2] two-pass assemble
3] Macro assemble
4] Cross-assemble
5] Resident assemble
6] Meta assemble

One-pass assembler.
In one pass assembler the source code is processed only once. As the source code is processed, any
labels encountered are given an address and stored in a table. Therefore when the label is
encountered again the assembler may look backwards to find the address of the label. If the label
has not been defined yet the assembler issues an error message.
Since only one pass is used to translate the source code a one-pass assembler is very fast.

Two-Pass Assembler
The two-pass assembler is similar in operation to the one pass with one major difference i.e the first
pass made through the source code is specifically for the purpose of assigning an address to all
labels. When the labels have been stored in a table with the appropriate addresses a second pass is
made to actually translate the source code into machine code.

Macro-Assembler
A macro assembler is a type of two pass assembler that allows the programmer to write the source
code in a macro. Conditional assembly is also included in macro assemblers.

- 84 -
COMPILED BY: I. E LIABAYA COMMUNICATION & NAVIGATION (AVIONICS) DEPARTMENT.

Cross-Assembler
A cross assembler may be of any type already mentioned. The distinguishing feature of across
assembler is that it is not written in the same language used by the processor that will execute the
machine code generated by the assembler. Cross assemblers are usually written in high level
languages e.g. FORTRAN and then the assembler may be executed on another machine e.g.
Motorola 6800.

Resident-Assembler
Is almost the complete opposite of cross-assembler. It is written to run on the same machine that
will execute the source code.

Meta-Assembler
The most powerful assembler is the Meta assembler because it will support many micro-processors.
The programmer merely specifies at the start of the source code which microprocessor. The
assembler will translate the source code to the correct machine code.
NB
The output file from most assemblers is an object file is a code that may be confirmed to execute at
any address.

2] EDITOR
This is the program used to modify and create the files contain your own program and document A
good editor is display oriented i.e. a cursor that shows or marks your place in the file the editor has
commands to change ,delete or insert lines or character The two type of editors currently;

1] Line-Oriented editor
2] Character-Oriented editor

The main difference between the two is that line editor do not display any change in the file whereas
character editors will display the change. Character oriented editor are also called screen editor or
display editor.

- 85 -
COMPILED BY: I. E LIABAYA COMMUNICATION & NAVIGATION (AVIONICS) DEPARTMENT.

3] DEBUGGER
This is a program that removes the bugs/errors out of your program. The debugger provides an
interactive method of executing and debugging the program one or a few instructions at a time.
Debugging Techniques
Debugging a microprocessor based system may be divided into two categories:
(i) Software debugging
(ii) Hardware debugging
Both debugging processes are usually carried out separately from each other because software
debugging can be carried out on an emulator without having the final system hardware.
In a single-board microcomputer, techniques commonly used in debugging are:
i) Single-stepping technique
ii) Breakpoint technique
iii) Register examine/simulator program
a) Single step
A single-stepper facility makes use of a single-step key on a keyboard and allows the user to execute
the program being debugged one instruction at a time. Generally, a single step facility is built with a
hardwired logic circuit. As the single-step key is pushed, it is possible to observe addresses and
codes as they are executed. During debugging, it is usually helpful to examine the state of the data
bus, the address bus, the control bus and the status flags. By the single step technique, one can be
able to detect program faults such as;
i. Incorrect addresses
ii. Incorrect jumps
iii. Incorrect data
iv. Erroneous op-codes etc
The single step technique is useful for short programs.
b) Breakpoint
A breakpoint facility allows the user to execute a program in sections. The breakpoint can be set in a
program by using the RST instructions. When the execute key is pushed, the program is exeuted
until the breakpoint. The registers can then be examined for expected results. If that segment of the
program is found to be satisfactory, a second breakpoint can be set at another memory address to
debug the next segment of the program. With the breakpoint facility, you can isolate the segment of
the program with errors. Then that segment of the program can be debugged with single-step facility.

- 86 -
COMPILED BY: I. E LIABAYA COMMUNICATION & NAVIGATION (AVIONICS) DEPARTMENT.

There are two types of breakpoint systems:


(i) Hardware
(ii) Software
Hardware breakpoint
The hardware breakpoint uses hardware to monitor the system address bus and detect when the
system reaches the desired breakpoint location. When the breakpoint is detected, the hardware uses
the processor control lines to either halt the processor for inspection or cause the processor to
execute an interrupt to a breakpoint routine. Hardware breakpoints can be used to debug both ROM
and RAM based programs.
Software breakpoints
Software breakpoints only operate on a system with the program in RAM because the breakpoint
instruction must be inserted into the program that is to be executed.
Note
Most debuggers combine single-stepper and breakpoint facilities to provide a complete package. The
user may insert a breakpoint at a desired point and let the program execute until that point. When the
program stops at the breakpoint, the user may use a single stepper to examine it one instruction at a
time.
c) Register examine/simulator
A simulator is a program that allows the execution of a program while observing the contents of the
registers of the target processor. When appropriate keys are pressed, the contents of the registers can
be displayed. The simulator operates by taking one instruction at a time and then simulating all
actions that the target processor would perform for that instruction.
Simulators are usually very large programs which will include all the software debugging tools
(single-stepper, breakpoint etc) necessary in a complete software development program.

4] LINKER, RELOCATORS AND LOADER.


Large programs are best broken down into „modules‟ i.e. separate parts that can be edited ,assembled
or compiled and debugged separately. A linker is a program that gets together all the modules
contained in a program. Once the modules are put together a program called a relocator assigns a
location in memory to each module and then a loader gets it into memory.

- 87 -
COMPILED BY: I. E LIABAYA COMMUNICATION & NAVIGATION (AVIONICS) DEPARTMENT.

5] LABLES
When a programmer is writing a program containing jump instruction, he does not always know the
absolute address in memory where the instruction is stored. Therefore it is usual for a programmer to
use „symbolic address name‟ or „labels‟ to indicate the intended addresses of the destination
instruction and it is only during the translation process that these are converted to absolute addresses
as shown below.

ADDRESSES: SYMBOLIC INSTRUCTION


(Assigned during translation process)
LAB 1:Destination Instruction
JMP LAB 1 ; Branch to instruction with
; address (symbolic) LAB 1
JMP LAB 2 ; Branch to instruct with
; Symbolic address LAB 2
LAB 2: Destination instruction

Normally the symbolic names used for labels are a mix of alpha – numeric names by the
programmer e.g. REPEAT, START, RESULT, BEGIN, LOOP, SUM, NUM etc

6] ASSEMBLY DIRECTIVES (Pseudo instructions)


An assembly language program can‟t be executed by a machine directly as it is not in binary form.
Usually we refer to an assembly language program as a source program. An assembler is needed in
order to translate an assembly language program into the object code executable by the machine.
Pseudo instructions (pseudo codes) are instructions which are not directly translated into machine
language (object code) but are used as special instructions to the assembler (directives) to perform
special function.
The assembler will recognize pseudo instructions that assign memory space, assign addresses to
labels, format the pages of the source code etc. The pseudo instruction is usually placed in the op-
code field. If any label or data are required by the pseudo instruction, they are placed in the label or
operand field as necessary.

- 88 -
COMPILED BY: I. E LIABAYA COMMUNICATION & NAVIGATION (AVIONICS) DEPARTMENT.

Common pseudo instructions


a) Origin (ORG)
The ORG instruction is used by the programmer when it is necessary to place the program in a
particular location in memory. It informs the assembler about the start address or origin of the
program.
For example, if it is desired to have a subroutine at a particular location in memory such as 2000H,
the ORG statement would be placed immediately before the subroutine to direct the assembler to
alter the program counter.
ORG 2000H ; set program counter to 2000H.
SUB: MVI A, 05H ; subroutine puts 05H in A.
RET ; return to caller.
Note
Most assemblers will assume a starting address of 0000H if no ORG statement is given in the source
code.
b) Equate (EQU)
The EQU instruction is used to assign the data value or address in the operand field to the label in
the label field. The EQU instruction is important because it allows the programmer to write the
source code in symbolic form and be concerned with the numeric value needed. In some cases, the
programmer develops a program without knowing the actual address or data required by the
hardware. The program may be written and debugged in symbolic form and the actual data added at
a later time.
Using the EQU instruction is also helpful when a data value is used several times in a program. If for
example a counter value was loaded at ten different locations in a program, a symbolic label (such as
„COUNT‟) could be used and the label „COUNT‟ defined at the end of the program.
Example.
PORT A: EQU 00 ; assign a dummy value
PORT B: EQU 00 ; another dummy value
MVI A, FFH ; data to be sent to output
OUT PORT A ; send data to port A
OUT PORT B ; and port B too
NOTE: In the above example, the programmer does not know the hardware address of output ports
A and B, but may still write the program. When the port addresses are known, they may be used to
replace 00 in the EQU instruction.

- 89 -
COMPILED BY: I. E LIABAYA COMMUNICATION & NAVIGATION (AVIONICS) DEPARTMENT.

c) Define byte (DB)


The DB instruction is used to set a memory location to a specific data value. The DB instruction is
usually used to create data tables or to presser a flag value used in the program. As the name implies,
the DB instruction is used to create an 8-bit value
For example, if a table of four values 45H, 34H, 25H and D3H is to be created at address 2000H, the
following code could be written.
ORG 2000H ; set table address
TABLE: DB 44H, 34H, 25H, D3H ; preset table values

NOTE
The commas are necessary for the assembler to differentiate between data values. When the code is
assembled, the machine code would appear as follows;
2000…….44
2001…….34
2002…….25
2003…….D3
d) Define storage (DS)
This instruction reserves or allocates memory locations for storage of temporary data
e.g. ORG 1800H
TEMP1: DS 2
This reserves 2 bytes of memory at locations starting from 1800H

7] MACRO
A macro is a sequence of instruction that the programmer gives a name. Whenever the programmer
wishes to duplicate the sequence of instruction, the macro name is inserted in the source code. The
macro routine is not the same as a subroutine „call‟ in assembly language. An assembly language
call is a function of the microprocessor. When a macro is used it is a function of the assembler and
not the micro-processor. Every time the macro name is encountered in the source file a block of
instructions (macro) is assembled.

- 90 -

You might also like