0% found this document useful (0 votes)
51 views53 pages

Chapter 3.1.1 3.1.2

The document discusses instruction set and assembly language programming. It defines instruction set, machine language, and assembly language. Machine language uses binary codes to represent instructions in a computer-dependent format. Assembly language uses mnemonics to represent machine instructions in a human-readable format. It then describes the instruction format and addressing modes in assembly language programming.

Uploaded by

zainlemonade
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)
51 views53 pages

Chapter 3.1.1 3.1.2

The document discusses instruction set and assembly language programming. It defines instruction set, machine language, and assembly language. Machine language uses binary codes to represent instructions in a computer-dependent format. Assembly language uses mnemonics to represent machine instructions in a human-readable format. It then describes the instruction format and addressing modes in assembly language programming.

Uploaded by

zainlemonade
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/ 53

Chapter 3

INSTRUCTION SET AND ASSEMBLY


LANGUAGE PROGRAMMING
Learning outcomes
• EXPLAIN INSTRUCTION SET IN ASSEMBLY
LANGUAGE.
• Define Instruction set, machine and assembly
language.
• Describe the addressing modes using proper
instruction format
• Describe various types of addressing modes with
example.
Explain the instruction set and assembly
language.
• Message sent by programmers (program instructions)
understood by the computer and vice versa.
• Language that friendly to human also understandable to
computer systems.
• Three level of language:
• Low level – machine language
• Middle level – assembly language
• High level – high-level language
Define Instruction set, machine and
assembly language
Instruction Set
•The complete collection of instructions that are
understood by a CPU
• Known also as Machine Code/Machine Instruction
• Binary representation
• Usually represented by assembly codes
Machine language

• a binary program (or binary code).


• a sequence of instruction and operand in
binary that list the exact representation
instruction as they appear in computer
memory.
• Natural language of a particular computer
system.
• Strings of numbers or binary codes (0 or 1).
Machine language (cont…)

• Machine-dependent (differ from one µP to


other µP.
• Program written in any other language must be
translated to binary representation of
instruction before they can be executed by
computer.
• Programmers need to know specifically the
architecture of CPU.
Machine language (cont…)
Limitations in programming using
machine language

long
difficult to
and understand
difficult
did not
specify the slow to key-in to
tasks we the computer
due to the input
perform one bit by one
require a bit at a time
computer.
To overcome these problems, easily remembered
code (mnemonic) was introduced.
It is apply with the use of Assembly Language
Assembly language (cont…)
• Assembly language is a symbolic representation of a machine
language of specific processor.

• Assembly language is a form that is very dependent on the


underlying architecture.

• Using english-like abbreviations (MUL), ( ADD), (SUB)

• Assembler as translator.

• Assembler - Translate ordinary mnemonics such as MOVE


Data, Acc, into their corresponding machine language (the only
form of instruction that computer can executed)
Assembly language (cont…)

• Assembly Process - Process of translating an assembly


language programs into a machine language programs.
The assembly process is straightforward (one-to-one
mapping of assembly languages statements to their
machine language counterpart) and rather simple

• Programmer need to know the basic architecture.


Why assembly language study is
important?

• It clarifies the execution of instruction.


• It shows how the data represent in memory.
• It show how a program interacts with the operating
system (OS), processor and, input and output (I/O)
system.
• It clarify how a program access external devices
• Sometimes difficult to access hardware drive and
system tool if using (register transfer languages) RTL
Advantages using assembly languages

• Easy to make compilers, debuggers and other


device tools.
• Allow accessing information that is not accessible
(restricted) from high level languages.
• More function library that can be used in
programming development.
• Possibility to make library function that compatible
with different compiler and operating system
Disadvantages using assembly languages

• (Development) Requires longer development time


• (Reliability & Security) Easy to makes error
• (Debug) More possibility for errors
• (Maintain) Difficult to modify because it allows
unstructured code.
• (Portability) Difficult to porting / migrate to different
platforms.
Structured code C, C++, Java, PHP
Unstructured code
High level language (HLL)

• Using everyday English and common mathematical notation.


(x = I + j)
• Overcome problems : assembly language require many
instruction to accomplish a simple task.
• Single instruction in HLL = several AL instructions.
• Compiler as translator.
• Programmers do not need to know the architecture of CPU.
Three Different Levels Of Language
Comparison Of Instructions Of Three Different Languages
32
Data sizes
BIT
binary digit
hold only two values: 0 or 1
Smallest unit of data
 1 bit : the smallest.
 4 bit : nibble.
 8 bit : byte; indicated (.B) notation
 16 bit : word; indicated (.W) notation
 32 bit : long word; indicated (.L) notation
Data sizes
• For the data which has more bits, it is divided into
dual-half portions
• upper (MSD section)
• lower portions (LSB section).

• 1 Byte consists of two nibbles;


• upper nibble
• lower nibble.
• 1 Word consists of two bytes;
• upper byte
• lower byte.
• 1 Long Word consists of two word;
• upper word
• lower word.
Data sizes
• Can store either
Longword

1 0 0 1 1 0 0 1 1 1 0101110101011101000101

Word

0101011101000101

Byte

01000101
Notations for Information Representation
DATA SIZE
• A single cell sized 1 bit can store either logic-0 or logic-
1.
• Thus the range of data is 0 – 1.
Data size: n = 1
Data capacity : 2n = 21 = 2
Range : 0 – 1

• A single cell sized 4 bit (Nibble) can store 16 possible


situations
Data size: n = 4
Data capacity : 2n = 24 = 16
Range : 0 - 15
DATA SIZE
Data size Data type Data capacity Range
N 2n
( in bit)

1 Bit 2 0–1

4 Nibble 16 0 - 15
8 Byte 256 0 – 255
16 Word 65536 0 – 65535
32 Long Word 4,294,967,296 0 - 4,294,967,295
REGISTER SET of MC68000
Internal Register – the
working element of µp.
MC68000 – an internal
32-bit processor
Register Set
 8 data register (D0-D7)
 7address register(A0-A6)
 2 stack pointer(USP&SSP)
 1 program counter (PC)
 1 status register (SR)
DATA REGISTERS
• Consists of 8 general purpose registers
• D0 to D7
• Can used as SOURCE / DESTINATION in a instruction
• Can access as BYTE, WORD, LONGWORD
• Data manipulation can be done here
31 16 15 87
• E.g. add, subtract, multiply, divide 0
D0
D1
• Used to store 32-bit data D2
• Bit 0 is the smallest (LSB) D3
• Bit 31 is the largest (MSB) D4
D5

• Divided into 16 or 8 bits D6


D7
• 16 bits – bit 0 to bit 15 (word)
• 8 bits – bit 0 to bit 7 (byte)
ADDRESS REGISTER

• Consists of 7 general purpose registers :


• A0 to A6
• Can be used as SOURCE / DESTINATION in an
instruction
• Can access as BYTE, WORD, LONGWORD
68000 Data Type

• Binary
• Octal
• Hexadecimal
• Decimal
• Character
Data type : binary
Data type : octal
Data type : hexadecimal
Data type : decimal
ASCII character
Data Type

% binary number
@ octal number
$ hexadecimal number
No sign decimal number
‘ ‘ ASCII code
Describe Addressing Modes Using
Proper Instruction Format
INSTRUCTION FORMAT

• There are many MC68000 instructions. However,


theses instructions comply to a standard
instruction format:
INSTRUCTION FORMAT

<Label> <Operator> <Operand> Comments

<Label> <Opcode> <Operand> Comments

<Label> <Mnemomic> <Operand> Comments


Instruction Format
• LABEL – pointer to the instruction’s memory location
• OPERATOR -operation code ( ie; MOVE,ADD…)
• OPERAND – Depends on the operator, may has more than one
operand.
• COMMENT – Explanation about the execution of instruction.
• Data format - Byte | Word | Longword | Sign-extended
Instruction Format
Label
• Label are optional
• Label – a user-defined symbol representing
the address associated with the instruction.
• Up to 8 alphanumeric, begin with letter,
terminated by a space.
Opcode/operation code / Mnemonic
• Opcode is an operation code that will be executed by
microprocessor
• It is abbreviation of English-like word for an operation
• For example
• MOVE – Transfer data from source to destination
• ADD – Add two binary numbers stored in registers
• Associates with the size of data to be execute
• Can be either
• Byte: .B
• Word: .W
• Longword: .L
Operands
Comment
• Comment is optional
• Comment provide readability for future reference
• Explain the operation of each instruction
• Any line beginning with an * is a comment.
• Any line beginning with a ; (semi-colon) is a
comment.
• Example ;
org $1000 ; set the location counter to $1000
DATA Format

• mnemonics are postfixed with symbol ".B", ".W", ".L".


DATA Format
DATA Format
DATA Format
DATA Format
DATA Format

You might also like