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

Instruction Set and Assembly Language Programming

This document discusses instruction set and assembly language programming. It defines instruction set as a collection of machine instructions, and the instruction set architecture (ISA) as the collection of instruction sets and functional units visible to the programmer. Assembly language uses symbolic names instead of numbers for instructions and variables. Key points made include: - Machine language consists of numbers and is difficult for humans, while assembly language uses names; - Assembly language has the same structure and commands as machine language but is easier for humans; - Assembly provides advantages like performance but disadvantages like longer development time.

Uploaded by

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

Instruction Set and Assembly Language Programming

This document discusses instruction set and assembly language programming. It defines instruction set as a collection of machine instructions, and the instruction set architecture (ISA) as the collection of instruction sets and functional units visible to the programmer. Assembly language uses symbolic names instead of numbers for instructions and variables. Key points made include: - Machine language consists of numbers and is difficult for humans, while assembly language uses names; - Assembly language has the same structure and commands as machine language but is easier for humans; - Assembly provides advantages like performance but disadvantages like longer development time.

Uploaded by

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

INSTRUCTION SET AND ASSEMBLY

TOPIC 3:
LANGUAGE PROGRAMMING

OUTLINE:
 Understand instruction set and assembly language

 Assembly language
3.1 Understand instruction set and assembly language

Instruction Set
 A collection of machine instruction for a given machine

The Instruction Set Architecture (ISA)


 ISA is a collection of instruction sets (assembly language) and functional units of a machine.
The instruction set architecture (ISA) is made visible to the programmer, who is responsible
for handling register usage and subroutine linkage.
Machine Language

Figure 3.1: Hierarchy of programming language


• The lowest-level programming language (except for computers that
utilize programmable microcode) Machine languages are the only
languages understood by computers.
• While easily understood by computers, machine languages are almost
impossible for human to use because they consist entirely of numbers.
• Programmers, therefore, use either a high-level programming
language or an assembly language.
• An assembly language contains the same instructions as a machine
language, but the instructions and variables have names instead of being
just numbers.
• Programs written in high-level languages are translated into assembly
language or machine language by a compiler. Assembly language
programs are translated into machine language by a program called
an assembler.
Assembly language

• Assembly languages have the same structure and set of commands as


machine languages, however assembly languages enable a programmer
to use names instead of numbers.
• Machine languages consist entirely of numbers and are almost impossible for
human to read and write.
• Each type of CPU has its own machine language and assembly language, so
an assembly language program written for one type of CPU won't run on
another.
Advantages of assembly language Disadvantages of assembly language
 Easy to make compilers, debuggers and  Requires longer development time
other device tools  Easy to make error
 Allow accessing information that is not  More possibility for errors
accessible from high level languages  Difficult to modify because it allows
 More function library that can be used in unstructured code
programming development  Difficult to porting to different platforms.
 Possibility to make library function that is
compatible with different compiler and
operating system.
The Importance of Assembly Language

• Clarifies the execution of instruction


• Shows how the data represents in
memory
• Shows how a program interacts with
the Operating System (OS),
processor and input/output system.
• Clarifies how a program access
external devices
Addressing Mode

• The term addressing modes refers to the way in which the operand of an
instruction is specified.
• Information contained in the instruction code is the value of the operand
or the address of the result/operand.
• Types of addressing mode
1 Immediate

 The operand is an immediate value which is stored explicitly in the instruction.


 The operand is a number that follows the opcode
 For example: #1000, #$AB23
2 Direct

 The effective address is equal to address part of the instruction.


 The operand resides in memory and its address is given directly by the address
field of the instruction.
 Example: D0, D1
3 Indirect

-The address field of the instruction where the effective address is stored in memory.
-An address is specified in a register (pointer) and the MPU looks up the address
in that register
-Example: (A1), D1

o Register
o Register Indirect
o Displacement (Indexed)
o Stack
3.2 Assembly language

Assembly language instruction

• Label is used to assign a name to an assembly language instruction such as LOOP,


BUFFER and COUNTER.
1 Opcode

 Opcode is mnemonic code that contains the two-to-seven letter


acronym for the instruction for example MOVE, ADD, SUB, MULU,
DIVU, OR, AND and NOT.
 Opcode data size

Symbol Meaning Example of Opcode

.B Byte MOVE.B

.W Word MULU.W

.L Longword ADD.L
2 Opcode data format

 One digit of hexadecimal is represented by 4 bits


 1 digit of hexadecimal, is labeled as ‘H’

4 bit =   H = nibble

8 bit =   HH = byte

16 bit =   HHHH = word

32 bit = HHHH HHHH = long word


3 Operand use to tell assemble where to find the data it is operand on

 Types of source operand are decimal number, hexadecimal number, binary


number or octal number and it represent by some symbol.
 Operand symbols are

Symbol Description Example of Operand


# Decimal number #500
#$ Hexadecimal number #$ 64BA
#% Binary number #%1010
#o Octal number #o327
Arithmetic operation
The basic arithmetic operation are adding, subtracting, multiplying and
dividing.
• Addition operation
o The Opcode is ADD
o The operation is source + destination destination

o Examples of instruction

Opcode Operands Comment

ADD. B D1, D2 Add data in register D1 with data in D2

ADD. W D0, (A1) Add data in register D0 with data in address A1


Subtract or minus operation
 The Opcode is SUB
 The operation is destination - source destination

 Examples of instruction

 Examples of assembly language program


Multiple operation
 The Opcode is MULU
o The operation is source * destination destination

o Examples of instruction

Opcode Operands Comment

MULU. B D1, D2 Multiple data in register D1 with data in D2

MULU. W #$ABCD, D1 Multiple data ABCD with data in register D1

o Examples of assembly language program


Division operation

 The Opcode is DIVU


o The operation is destination / source destination

o Examples of instruction

Opcode Operands Comment

DIVU. B #100, D1 Divide data in register D1 with data 100


DIVU. W (A1),D2 Divide data in register D2 with data in address A1
o Examples of assembly language program
Logic Operation
1

 AND logic operation


o The Opcode is AND
o The operation is source ^ destination destination

o Examples of instruction

Opcode Operands Comment


AND. B D1, D2 AND data in register D1 with data in D2
AND. W #%1111, (A1) AND data 1111 with data in address A1
Continue

o Examples of assembly language


program
 OR logic operation 2
o The Opcode is OR
o The operation is source v destination destination

o Examples of instruction

Opcode Operands Comment


OR. B D1, D2 OR data in register D1 with data in D2
OR. W #%1111, (A1) OR data 1111 with data in address A1

o Examples of assembly language program


3
 NOT logic operation
o The Opcode is NOT
o The operation is destination destination

o Examples of instruction

Opcode Operands Comment


NOT. W D1 NOT data in register D1

o Examples of assembly language program


Continue
Thank You

You might also like