Você está na página 1de 24

CHAPTER 3

INSTRUCTION SET AND


ASSEMBLY LANGUAGE
PROGRAMMING

1
COURSE LEARNING OUTCOMES
(CLO3)
Upon completion of this course, students
should be able to:

write a simple program in


assembly language to perform
given tasks .

2
3.2 APPLY ASSEMBLY LANGUAGE

The program is
difficult to
understand

The program is slow


to key-in to the
computer due to the
input one bit by one
Limitations in bit at a time
programming
using machine
language

The program did not


specify the tasks we
perform require a
computer.
The program
is long and
arduous 3
3.2 APPLY ASSEMBLY LANGUAGE

To overcome these problems, the use of


easily remembered code (mnemonic)
was introduced.

It is apply with the use of Assembly


Language

4
3.2 APPLY ASSEMBLY LANGUAGE

Assembly Language
• consists of statements written with short mnemonics such
as ADD, MOV, SUB, and CALL.

• has a one to-one relationship with machine language


meaning that each assembly language instruction
corresponds to a single machine-language instruction.

• is not portable because it is designed for a specific


processor family

• There are a number of different assembly languages


widely used today, each based on a processor family
5
3.2 APPLY ASSEMBLY LANGUAGE

Assembly Language

• Some well-known processor families are Motorola 68x00, Intel


IA-32, SUN Sparc, Vax, and IBM-370.

• Assembly language instructions are processor specification


dependents. For example, a program written in the Intel
assembly language cannot be executed on the PowerPC
processor.

6
3.2 APPLY ASSEMBLY LANGUAGE

Assembly Language Instruction

labelsOpcode OperatorOpcode SourceOperand destinationOperand ; comment

Size Source Destination

MOVE.B D0, D1 ; comment


Opcode Operand

7
3.2 APPLY ASSEMBLY LANGUAGE

 Label – assign a name to an assembly language instruction

 Operator – mnemonic code that contains the two-seven letter


acronym for the instruction example MOVE, ADD, SUB, MULU, DIVU
 Operator size
Symbol Meaning Operator
# - decimal
.B Byte 00 MOVE.B #% - binary
.W Word 0000 MULU.W #@ - Octal
#$ - Hexadecimal
.L Longword 00000000 ADD.L

 Operand – tell assemble where to find the data it is operand on.

 Comment – describe statements in the source program to make the


program easy to understand. Command must precede a comment
with a semicolon 8
3.2 APPLY ASSEMBLY LANGUAGE

EXAMPLE ASSEMBLY LANGUAGE OPERATION

ORG #800 ; start Program Counter


MOVE.B #8,D0 ; load data 8 into data register D0 in byte size
MOVE.W #1,D1 ; load data 1 into data register D1 in word size
END ; end the program

14
3.2 APPLY ASSEMBLY LANGUAGE

EXERCISE ASSEMBLY LANGUAGE OPERATION

Write the correct instruction base in the statement below.

i. Move a binary data 101 into register D1 in byte size

ii. Move a hexadecimal data A into register D1 in word size

.B - byte # - decimal
.W- Word #% - binary
.L - Longword #@ - Octal
#$ - Hexadecimal
15
3.2 APPLY ASSEMBLY LANGUAGE

ARITHMETIC OPERATION

OPERATION SYNTAX EXAMPLE


ADDITION ADD ADD.B D1,D2

SUBSTRACTION SUB SUB.B D1,D2

MULTIPLE MULU MULU.B D1,D2

DIVIDE DIVU DIVU.B D1,D2

16
EXAMPLE FOR ADD OPERATOR

ADD.b #$08, d0

FP203 Computer Organisation 17


EXAMPLE FOR ADD OPERATOR

ADD.W #$1021, d0

FP203 Computer Organisation 18


3.2 APPLY ASSEMBLY LANGUAGE

EXAMPLE ARITHMETIC OPERATION

ORG #800 ; start Program Counter


MOVE.B #8,D0 ; load data 8 into data register D0 in byte size
MOVE.W #1,D1 ; load data 1 into data register D1 in word size
ADD.W D0,D1 ; add data D0 and D1 then store in D1 in word size
END ; end the program

19
3.2 APPLY ASSEMBLY LANGUAGE

EXERCISE ARITHMETIC OPERATION

20
3.2 APPLY ASSEMBLY LANGUAGE

LOGIC OPERATION

OPERATION SYNTAX EXAMPLE


AND AND AND.B D1,D2

OR OR OR.B D1,D2

NOT NOT NOT.B D1

21
3.2 APPLY ASSEMBLY LANGUAGE

EXAMPLE ARITHMETIC OPERATION

ORG #800 ; start Program Counter


MOVE.B #%111,D0 ; load data 111 into data register D0 in byte size
MOVE.B #%10,D1 ; load data 10 into data register D1 in byte size
AND.B D0,D1 ; use AND operation to data in D0 and D1 then store in D1 in byte size
NOT.B D1; use NOT operation to data in D1
END ; end the program

22
3.2 APPLY ASSEMBLY LANGUAGE

EXERCISE ARITHMETIC OPERATION

23
FP203 Computer Organisation 24

Você também pode gostar