Академический Документы
Профессиональный Документы
Культура Документы
Architecture
Programming Techniques
on Set
Machine Language
Memories Instructio
Assemble Language
Assembler
Programming Step
mming
Data Transfer & Arithmetic Operations
p
Program
Data Manipulation
Decision Making
Back
Machine Language
The actual binary instruction for a microprocessor is called
machine code
Machine code = op code & operand(s)
Assembly Language
A word like abbreviation of the instruction’s function are called
instruction mnemonics
Mnemonics => > LD = LOAD = MOV = MOVE
An example of Z80-CPU Instruction Set
Machine Code Mnemonic T-States Description
80 ADD A, B 4 A← A + B
A0 AND A, B 4 A← A ^ B
3D DEC A 4 A← A – 1
3C INC A 4 A← A + 1
C2 nn JP NZ , nn 10/7 If Z=0 then PC = nn
CA nn JP Z, nn 10/7 If Z=1 then PC = nn
78 LD A, B 4 A← B
79 LD A
A, C 4 A← C
32 nn LD (nn), A 13 (nn) ← A
Assembler
Mnemonics must be interpreted into machine language by
human or by computer programming
The computer program which converts mnemonics into machine
executable instructions is called an assembler.
Start
Decision
Process
Output
p
Display
Programming Step
3. Design Code (mnemonics)
• Using Microprocessor Instruction Set - come out the series
instruction needed.
4. Implementation
• Assemble mnemonics into machine code (binary code)
• Apply the code.
Data Transfer
Special
Copy A into C LD C, A
Copy H into B LD B, H
HALT HALT
END
Step 4 – Implementation
LD
LD
LD
LD
LD
Data Manipulation Instructions
Data Manipulations
RESTART (RST)
Status of a CPU is kept in Flag Register or Status Register
Examples Applications (1)
1
1. Add 10 bbytes
t off ddata
t in
i memory
e.g. Find the Total sum of numbers in memory address 1820H until 1829H.
ORG 1800H
LD HL, 1820H ; set memory pointer
LD B, 0AH ; set counter
LD A, 00H ; clear acc.
LOOP LD C, (HL) ; fetch no.
ADD A, C ; add up
INC HL ; adjust pointer location
DJNZ LOOP ; if not finished, continue
RST 38H