0% found this document useful (0 votes)
13 views9 pages

SDQ ECE 445 Assignment

Bdbe

Uploaded by

adeniyijames176
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views9 pages

SDQ ECE 445 Assignment

Bdbe

Uploaded by

adeniyijames176
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

NAME: Ajayi Sodiq Ayobami

MATRIC NUMBER: 22D/67EC/1318

DEPARTMENT: ELECTRICAL AND COMPUTER ENGINEERING

CODE [COURSE]: ECE 445 [ ASSEMBLY LANGUAGE PROGRAMMING]

ASSIGNMENT 1: READ AND SUMMARIZE THE LECTURE NOTES FROM PAGE 1 TO


PAGE 50.
INTRODUCTION TO MICROCOMPUTER PROGRAMING LANGUAGES.

MICROCOMPUTER: Can be programmed using binary or hexadecimal number (Machine language),


Semi-English language statements (Assembly language) or a more understandable human-oriented
language called high-level language.

NOTE: The program written has to be converted into appropriate binary form, because microcomputer
understands only binary numbers.

Types of Microcomputer Programming Languages

(1) Machine language

(3) Assembly Language

(3)High level language.

1) MACHINE LANGUAGE: it consist of binary or hexadecimal code that specify action to be performed or
data element. A machine language Program for one microcomputer with not run on another
microcomputer due to aunique set of machine Instruction in each microcomputer.

2) ASSEMBLY LANGUAGE: is a Mnemonic representation of a natural or native language of a computer


called machine code. Its instructions are called MACROINSTRUCTION. Each macro- Instruction is
interpreted by means of priimitive actions called microinstructions.

*Micro instruction: is the smallest event that can take place within a computer.

*Macroinstruction: is the process of carrying out a series of microinstruction

*Interpretation: is the process of executing a macroinstruction.

Each Instruction in an assembly language. Program is composed of three or four field as follows.

(1) Label field

(2) Mnemonic field (OP code)


(3) Operand field

(4) Comment field (optional).

(3) HIGH LEVEL LANGUAGE: it comprises of english type statement designed to rectify the Problem in
assembly and machine language Programming. High level language aid a computer program to have a
direct control of the hardware and uses more memory than other computer languages.

ADVANTAGE

i. The Programmer does not need to be familiar with microprocessor Internal architecture or It
instruction set

ii. This language has a wider level of application

iii. Each statement of the program is equivalent to a member of assembly or machine language
Instruction.

DISADVANTAGE

i. High Level language requires greater expertise.

ii. The technology involve is complax

iii. It is very expersive to run and to maintain.

ASSEMBLY LANGUAGE PROGRAMMING CONCEPTS.

An instruction manipulates stored data and sequence of instruction makes up a Program.

An assembly language instruction has two Components.

1. Operation code (OP code) field

2. Operand or Address of operand field

1. The OP-Code field specifies how data is to be manipulated.

2. Address field is to indicate the location of a data item.

Where; Rl is the source register, Ro Is the destinatio register

*INSTRUCTION FORMATS

1. Zero-address instruction format

2. One-address instruction format

3. Two-address instruction format


4. Three-address instruction format

(1) Zero-address instruction format: An instruction that does not require any address is called a
zero-address Instruction format; Examples are STC (set carry flag), NOP (no oporation) RAL(rotate
accumulator left), RET (return from exception).

(2) ONE-address instruction format: an Instruction with a Single.

Format : addresse <op-code > Address1.

(3) Two address instruction format: Containing two addresses.

Format: • OP-code> Addr 1, Addr2

(4) Three address instruction formant: has three address

Format : <OP-Code>Addrl, Addr2, Addr 3

*ADDRESSING MODES

*Instruction Cycle: are sequence of operation that a microprocessor have to carry out while executing an
Instruction.

*Addressing mode: is the manner in which the microprocessor accomplishes the instruction cycle task. In
other manner words, addressing mode is the manner in which the microprocessor Calculates the
addresses of source & destination registers.

* Variations of addressing modes

1. Inherent/Implied Addressing Modes: The Instructions using this mode have no operands.Eg STC,
CMA, NOP, RET

2. Immediate Addressing Mode: Whenever an Instruction contains the operand valve. The symbol #
usually indientes that an instruction is in immediate Mode.

3. Direct Addressing Mode: Instruction using this mode specify the effective address of the Operand as
Part of the instruction. Instruction using this mode contain three bytes.First byte is the op-code and two
bytes represent the address of data

4. Register Addressing Mode: This mode specifies the register or register pair that contains data ie
operand valves are held in microprocessor registers.

5. Register Addressing Indirect Mode:. Whenever an instruction specifies a microprocessor register that
holds the address of an operands the resulting addressing mode is known as the register indirect mode.

6. Memory Indirect Addressing Mode: Sometimes, it is possible that an instruction may contain the
address of an operand.
7. Address Made Base on Address Modification: effective (EA) of an operand is expressed as a Sum of
two parameters known as Modifier M the displacement the offset or and the reference address . EA=
RA + M

Thare are four addressing mode based on this concept

-Indexed Register

Base Register Mode

Base Index Register Mode

Relative Addressing Mode

*PROGRAM CONTROL INSTRUCTION

A program can select a particular segive instructions to execute based on the results of computation. In
assembly language programming, the instruction that could be used to realize this idea are Called
program Control Instructions.

- uncondition Branch Instructio

- Condition Branch Instruction

- Subroutine Call & Rature

INTRODUCTION TO ASSEMBAY LANGUAGE PROGRAMMING.

Mhemomies are self-evident Symbolic name that refers to an operation

e.g ADD donates addition operation

SUB donates subtraction operation

BRA donates branching operation

MOVE donates copy operation

consider a typical assembly language instruction given below

SUB.B Number, D3

These means; Subtract 8-bit number Stored in memory location named number from the contents of a
data register D3.

- B means size of source data that the instruction will work on


- D3 means data Storage

- Number refers to memory location of the source operad

*ASSEMBLER: Is a program that translates symbolically written programs in assembly language into
machine language.

One-Pass Assember: This assembler scans through the assembly language program once and translates
the assembly language program into a machine Language Program.

Two-Pass Assember: This assembler scans the assembly language program twice.

Macro assembler: This type of assembler translates a program written in macrolanguage into the
machine language.

Resident Assembler: This type of assemblen a assembles programs for a microprocess or in which it is
resident.

Cross Assembler: The cross assembler program is written in a high level language, so that it can run on
different types of processors that understand the same high-level language

Meta-Assembler: This type of asser bler can assemble programs for many different types of
microprocessor, The programmer usually defines the particular proessor being used.

ASSEMBLER SYNTAX -Label field Mnemonic/OP-Code field Operand field Comment field

ASSEMBLER DIRECTIVE The Pseudo-Instructions are not directly translated into machine language
instruction. Assemble uses pseudo-instruction or directives to make the formatting of the edited text
easier.

Typical Pseudo-Instructions are

- ORIGIN (ORG)

- EQUATE (EQU)

- DEFINE BYTE (DB)

- DEFINE CONSTANT (DC)

-TITTLE (TTL)

ORIGIN (ORG): The pseudo instruction ORG lets the programmer place the programs any where in the
memory. ORG address tells the assemble to load the program into memory Starting at the Specified
address. Similarly the ORG pseudo-instruction causes the assembler to Place a new value in the address
counter.
EQUATE (EQV): assign a value in Its operand field to an address in. Its label field. This allows the user to
assign a numeric value to a Symbolic name.

This Pseudo cada instruction assiges the valve 0200 in bexadecimal to the abel START.

DEFINE BYTE (DB): The Pseudo instruction DB is usually used to set a memory location to a certain byte
value.

DEFINE CONSTANT (DC) is a rective to the assembler to set up one or more data values as constant in
memory.

*MOTOROLA MC68000 MICROPROCESSOR

MC68000 can be operated in two modes; user modes and Supervisor mode.

- The user mode is used to execute user programs while the supervisor made is used to Implement
operating system and protection features by the microprocessor.

DATA TYPES, INSTRUCTION SET AND ADDRESSING MODE

*MC 68000 supports tive different data types 1-bit 4-bit BCD digits B-bits (byte) -16-bits (word) a C
32-bits (long word)

- Its instruction set includes 56 basic instruction types, 14 addressing mates and over 1000 op-codes.

It has no input 8 output instruction, hence, all input & output are memory mapped

It has eight data registers and nine address registers including the supervisor stack pointer.

*PROGRAMMING MODEL

The programming model of a microprocessor describes in detail all registers that are available in
microprocessor to a programmer, which can be manipulated, MC68000 has adequate registers for
various manipulations.

*Data Registers: The Processor has eight 32bit data registers (Do-D7). Data registers hold artithmetic
valves and data item in form of 1-bit, 8-bit (byte), 16-bit word, 32 bit long word and 4-bit BCD numbers.

Address Registers: There are nine, 32 bit address registers, (A0 through A7 Plus A7') address registers are
used to hold memory pointers (addresses) and index values of an operand.
Program Counter: The Program Counter PC keeps track of the address of next Instruction to be executed.
It alway contains the address of the next In memory to be Instruction to be executed. PC is a 32-bit long
register.

Status Register are the user byte and system byte.

The user byte includes the condition code flags such as

- Carry (C): Carry flag can either be set (1) or Cleared (0). It is set it arithmetic and logical operation
carried out results in a carry or borrow bit from bit 7 to bit 8 in a destination data register.

Overflow (V): flag is level of one if the set to logical result of manipulation is larger than the destination
register, that is the result is no longer reliable

-zero (2): 2 flag is set (1), if result of arithmetic and logical operations is equal to numerical value -
zero.otherwise, the z flag is Clear.

-Extend (x): is similar to carry flag be cause they are always affected the same way as carry flag but
extend flag is used in multi-precision instructions such as ADDX & SUBX.

-Negative (N) is set (1) if result of arithmetic & logical operations. is equal to negative numerical Value

- Supervisor Flag: is set to one the System operate in the supervisory mode, otherwise, the user mode
operation is assumed.

ADDRESSING MODE

- MC68000 microprocessor's addressing mode can be divided into six basic groups:

i. Register Direct

ii. Address register indirect

iii. Immediate Address

iv. Absolute Address

v. Program counter relative

vi. Implied Address.

*INSTRUCTION SET

- MC68000 contains 56 basic instructions. The Instruction set repertoire is very versatile and allows an
efficient means to handle HLL structures like linked lists and array . ALL MC68000 Imstruction may be
classified into eight groups.

DATA MOVEMENT INSTRUCTIONS


ARITHMET IC INSTRUCTIONS

LOGICAL INSTRUCTIONS

SHIFT AND ROTATE INSTRUCTIONS

BIT MANIPULATION INSTRUCTIONS

BINARY CODED DECIMAL INSTRUCTIONS

PROGRAM CONTROL INSTRUCTIONS

SYSTEM CONTROL INSTRUCTIONS

DATA MOVEMENT INSTRUCTIONS E G (DMI): allow: data transfers from register to memory, memory to
register memory to memory. to register, There are eleven data movement Instructions in MC68000.
-MOVE, MOVEM, MOVED, MOVEQ, MOVEA, EXG, SWAP, LEA, PEA, LINK and UNLINK. P MOVE
INSTRUCTIONS

(1) MOVE: Move or Copy data from Soura to destination.

Format for basic move instruction MOVE. S(EA), (EA)

(2) MOVEA: The instruction moves data from the effective address of source operand to an address
register. The assemble Syntax is MOVEA S (EA), A

(3) MOVEM: When data are pushed the stack pointer is decremarit led by the data size and incremented
by the data size when data are pushed onto the stack.

(4) MOVE Q : instruction moves the Immediate 8-bit data in the instruction into the specified data
register. Assembler Syntax: MOVEQ#data,Dn

(5) MOVED Instruction transfers data between data register (Dn) and alternate byte of memory
locations, Starting at the location Specifica by "d (Ay)" and incremented by the operand size. Syntax:
MOVEP Dn,d(Ay) or MOVEP Pd (AY), Dn

(6) EXG and SWAP INSTRUCTIONS

EXG: instruction exchanges the 32- Bit contents of two registers. SYNTAX: EXG Rx,Ry

SWAP: instruction exchanges 16-bit halves of a data register. SYNTAX: SWAP Dn

(7) LEA AND PEA INSTRUCTIONS LEA:

Load Effective Address [LEA] Instruction moves an effective address (EA) from source operand Into a
specified address.register CAN). SYNTAX: LEA (EA), An
PEA: instruction computes an effective address and then pushes it (32-bit address) onto the Stack.
SYNTAX: PEA (EA)

(9) LINK AND UNLNK INSTRUCTIONS:

LINK: is usually used at the beginning of a subroutine to allocate stack space for stering local variables
and parameters for nested subroutine calls. SYNTAX! LINK An, # - displacement

UNLNK: is used at the end of - Subroutine before the RETURN Instruction to release the reserved local
area & restore the Stack - Pointer contents. SYNTAX: UNLK An An —> SP; (SP) + An

(2) ARITHMETIC INSTRUCTIONS are used to manipulate data. "It allows the following

A. To Perform 8-bit, 16-bit, and 32-bit additions & subtractions.

B. To Perform 16-bit by 16-bit multiplication and 32-bit by 16-bit division

C. Compare clear & negate Operations

D. Extended arithmetic instructions for performing multiprecision arithmetic

E. Test instruction for comparing operand with zero

F. Test & set instruction which can be used for synchronization In a multiprocessor System.

ADDITION AND SUBTRACTION INSTRUCTION.

ADDITION:There are various types of addition instructions depending on the state of source operand.

* ADD: add the content of source register to the destination register.

ADD(EA), (EA); EA <—— (EA)+(EA)

* ADDI instruction adds immediate data to a register of memory location.

ADDI #data, (EA); (EA) <—— (EA) + data

* ADDQ instruction adds Immediate Integer data between 0 & 7 to the register or memory location in
the destination operand.

ADDQ #dx (EA); (EA) <—— (EA) +dx

where dx is an integer between 0 & 7.

You might also like