Professional Documents
Culture Documents
DFT 1113
COMPUTER
ORGANISATION
NOR ZAMIRA
BINTI OTHMAN
JTMK
LEARNING OUTCOMES
3.1
UNDERSTAND INSTRUCTION SET AND ASSEMBLY
LANGUAGE.
3.1.1 Define Instruction set, machine and assembly language.
3.1.2 Describe the addressing modes using proper instruction
format
3.1.3 Describe various types of addressing modes with example.
3.2
APPLY ASSEMBLY LANGUAGE.
3.2.1 Write a simple program in assembly language for:
a. arithmetic operation
b. logic operation
3.2.2 Use tools in analyzing and debugging assembly language
programs
INTRODUCTION
Capability of processor determine the capability of the
computer system. Therefore, processor is the key
element or heart of a computer system.
Other than PC, microprocessors are used in various
computerized system such as industrial automation.
MACHINE LANGUAGE:
Machine language is a binary program (or binary code).
Binary code is a sequence of instruction and operand in
binary that list the exact representation instruction as
they appear in computer memory.
Programmers
need
architecture of CPU.
to
know
specifically
the
MACHINE LANGUAGE:
The
program is
difficult to
understan
d
The
program did
not specify
the tasks
we perform
require a
computer.
The program
is slow to keyin to the
computer due
to the input
one bit by one
bit at a time
ASSEMBLY LANGUAGE
Assembly language is a symbolic representation of a
machine language of specific processor. Assembly language
Assembler as translator.
Assembler - Translate ordinary mnemonics such as MOVE
Data, Acc, into their corresponding machine language
development.
Possibility to make library function that compatible with
different compiler and operating system
platforms.
COMPARISON OF INSTRUCTIONS OF
THREE DIFFERENT LANGUAGES
COMPARISON OF INSTRUCTIONS OF
THREE DIFFERENT LANGUAGES
MICROPROCESSOR OVERVIEW
The term microprocessor typically refers to the central processing unit
(CPU) of a microcomputer, containing the arithmetic logic unit (ALU)
DATA SIZES
BIT
binary digit
hold only two values: 0 or 1
Smallest unit of data
DATA SIZES
For the data which has more bits, it is divided into dual half portions
upper (MSD section)
lower portions (LSB section).
DATA SIZES
Can store either
Longword
1 0 0 1 1 0 0 1 1 1 0101110101011101000101
Word
0 1 0 1 0 1 1 1 0 1 0 0 0 1 0 1
Byte
01000101
9 6 2 1 7 6 6
Most Significant Digit (MSD)
0 1 2 3 4 5 6
6 5 4 3 2 1 0 Little End-ian Numbering
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
N
( in bit)
Data type
Data capacity
2n
Range
Bit
01
Nibble
16
0 - 15
Byte
256
0 255
16
Word
65536
0 65535
32
Long Word
4,294,967,296
04,294,967,295
bit processor
Register Set
8 data register (D0-D7)
7address register(A0-A6)
2 stack pointer(USP&SSP)
ASCII CHARACTER
DATA T YPE
% binary number
@ octal number
$ hexadecimal number
No sign decimal number
Character ASCI code
3.1.2 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
INSTRUCTION FORMAT
LABEL pointer to the instructions 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.
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 ;
DATA FORMAT
mnemonics are postfixed with symbol ".B", ".W", ".L".
DATA FORMAT
DATA FORMAT
DATA FORMAT
DATA FORMAT
DATA FORMAT
3.1.3 DESCRIBE
VARIOUS TYPES OF
ADDRESSING MODES
WITH EXAMPLE.
Arithmetic Group
Logical Group
memory to register
register to memory
register to register
memory to memory
# indicate actual
value
$ indicate
hexadecimal value
Example 2:
MOVE.B D0,D1
Before : D1 = $00200500 , D0 = $00002222
After : D1 = $00200522 , D0 = $00002222
Example 3:
MOVE.W $3000,D1
Before : D1 = $00200500 ,
After : D1 = $00203243 ,
$3000
32
$3001
43
$3002
98
before $4000
MOVE.W D6,$4000
Before: D6 = $AB206541 ,
After : D6 = $AB206541
After
Example 5:
MOVE.W D2,(A1)
Before : D2 = $AB206541 ,
A1 = $00000501
After : D2 = $AB206541 ,
A1 = $00000501
3254
$4000
32
$4002
4377
$4001
54
$4004
9868
$4002
43
$4000
6541
$4000
65
$4002
4377
$4001
41
$4004
9868
$4002
43
After
Before
$501
FF
$501
65
$502
FF
$502
41
$503
FF
$503
FF
MOVEA.W D6,A2
Before : D6 = $AB206541 , A2 = $ABCD1234
After : D6 = $AB206541 , A2 = $00006541
Example 7:
MOVEA.W D6,A2
Before : D6 = $AB20A541 , A2 = $ABCD1234
After : D6 = $AB20A541 , A2 = $FFFFA541
Example 8:
MOVEA.L D6,A2
Before : D6 = $AB206541 , A2 = $ABCD1234
After : D6 = $AB206541 , A2 = $AB206541
Example 2:
MOVEQ #$80,D3
Before : D3 = $AB206541
After : D3 = $FFFFFF80
Example 3:
MOVEQ #-3,D2
Before : D2 = $AB206541
After : D2 = $FFFFFFFD
Example 1:
MOVEM.W D2/D5/D0,$200
Before : D0 = $11112222 , $200 6541
D2 = $33334444 , $202 4377
D5 = $55556666 , $204 9868
After : D0 = $11112222 , $200 4444
D2 = $33334444 $202
,
6666
D5 = $55556666 $204
,
2222
Example 2 :
MOVEM.L D2/D5/D0,-(A4)
$500
Before : D0 = $11112222 , D2 = $33334444 ,$504
D5 = $55556666 , A4 = $0000050C$508
$50C
After : D0 = $11112222 ,
$500 33334444
D2 = $33334444 ,
$504 55556666
D5 = $55556666 ,
$508 11112222
A4 = $00000500
451287A4
54A2F221
846AC1DD
45123211
MOVEM.W $200,D2/D5/D0
Before : D0 = $11112222 ,
D2 = $33334444 ,
D5 = $55556666 ,
After : D0 = $FFFF9868 ,$200
D2 = $00006541 $202
,
D5 = $00004377 $204
,
Example 4 :
$200
6541
$202
4377
$204
9868
6541
4377
9868
MOVEM.L (A4)+,D2/D5/D0
$500
Before : D0 = $1111222 , D2 = $33334444 , $504
D5 = $55556666 , A4 = $00000500$508
$50C
After : D0 = $846AC1DD ,
$500 451287A4
D2 = $451287A4 , $504 54A2F221
D5 = $54A2F221 , $508 846AC1DD
A4 = $0000050C
451287A4
54A2F221
846AC1DD
45123211
EXG (EXCHANGE)
EXG interchanges the contents of two
registers.
operand size for EXG is longword
Example 1:
EXG D1,D5
Before : D1 = $11223344 , D5 = $66778899
After : D1 = $66778899 , D5 = $11223344
SWAP
SWAP exchanges the lower word of the specified
data register with its upper word.
the operand size for SWAP is word.
Example 1
SWAP D1
Before : D1 = $11223344
After : D1 = $33441122
Example 2
SWAP D1
Before : D1 = $1234567
After : D1 = $45670123
CLR
ARITHMETIC GROUP
Similarly as the operation of mathematic,
addition (+), subtraction (-), multiplication (x),
division ()
Binary arithmetic instructions performs signed
and unsigned operations.
ARITHMETIC GROUP
ADD (ADDITION)
68000 MP allows addition of 3 data size i.e 8 bit (.B),
16 bit (.W), and 32 bit (.L)
Data is accessed via register (D0 to D7), memory,
absolute data and I/O port.
< Destination> + <Source>
<Destination>
ADD (ADDITION)
$3000
32
$3001
43
$3002
ADD.L D0,D1
Before : D1 = $00200500 , D0 = $00002222
After : D1 = $00202722 , D0 = $00002222
98
Example 1:
Example 2:
ADD.W $3000,D1
Before : D1 = $00200500 ,
After : D1 = $00203743 ,
ADD (ADDITION)
Example 3:
ADD.B D0, D1
.B
HH
22
+ 44
66
ADD (ADDITION
Example 4:
ADD.W D6,$4000
Before: D6 = $AB206541 ,
After : D6 = $AB206541 ,
$4000
3254
$4000
32
$4002
4377
$4001
54
$4004
9868
$4002
43
$4000
9795
$4000
97
$4002
4377
$4001
95
$4004
9868
$4002
43
Example 1:
ADDI.W
#$72,D1 and
ADDI.W #$72,D1
ADD.W #$72,D1
Before : D1 = $00200500 are equivalent
After : D1 = $00200572
But ADDI # can add to a
memory location
ADDA (ADDITION)
ADDA destination of add is an address register
Example 1:
ADDA.W D6,A2
Before : D6 = $AB206541 , A2 = $ABCD1234
After : D6 = $AB206541 , A2 = $ABCD7775
Example 2:
ADDA.L D6,A2
Before : D6 = $AB20A541 , A2 = $ABCD1234
After : D6 = $AB206541 , A2 = $56EDB775 , C = 1
Example 3:
ADDA.W #$8122,A0
Before : A0 = $FFFFFFFF
After : A0 = $FFFF8122
ADDQ (ADDITION
1 until 8
ADD #4, D1
Example 1:
ADDQ.B #$04,D3 (ADDQ #XXX,Dn)
Before : D3 = $AB206541
After : D3 = $AB206545
SUB (SUBTRACTION)
< Destination> - <Source>
<Destination>
SUB
Example 2:
SUBI.L #10,D2
Before : D2 = $AB206541
After : D2 = $AB206537
Example 3:
SUBQ.W #@11,D3 (SUBQ #XXX,Dn)
Before : D3 = $AB206541
-128 (80) until 127 (7F)
After : D3 = $AB200038
MULU
Example 1:
MULU #2,D2 ;16 bit x 16 bit = 32 bit
Before : D2 = $AB206541
After : D2 = $0000CA82
@ octal no.
Example 2:
MULU #2,D2
Before : D2 = $AB20FFFF
After : D2 = $0001FFFE
% binary no.
No signdecimal no.
DIVU
Example 1:
DIVU #2,D3
Example 2:
DIVU #$1234,D0 ;32 bit / 16 bit = 16 bit lower(result)
16 bit upper ( remainder)
Before : D0= $00005678
After : D0 = $0DA80004
NEG
NEG = 2s complement
$41
Invert
$BF
01000001
10111110
+
1
10111111
LOGICAL GROUP
LOGICAL GROUP
AND
Example 1:
AND.B #$3E, D3
[D3(B) AND $3E D3 (B) ]
(8 bit data in data register D3 is AND-ed with 8 bit
absolute data, and the product is stored in D3)
OR
Example 1:
OR.B D0, D1
D1(B) ]
NOT
Example 1:
NOT.B D1
[D1(B) NOT D1 ]
(content in D1 is NOT, and the product is stored back
to D1)