当前位置:文档之家› 计算机组成与体系结构Ch4_ECOA (2)

计算机组成与体系结构Ch4_ECOA (2)

• Assemblers create an object program file from mnemonic source code in two passes. • During the first pass, the assembler assembles as much of the program is it can, while it builds a symbol table that contains memory references for all symbols in the program. • During the second pass, the instructions are completed using the values from the symbol table.
• During the first pass, we have a symbol table and the partial instructions shown at the bottom.
9
4.5 A Discussion on Assemblers
• After the second pass, the assembly is complete.
25
4.7 A Discussion on Decoding
• Disadvantage: all instructions must go through an additional level of interpretation, slowing down the program execution. There is a cost of the actual development, because appropriate tools are required.
19
4.7 A Discussion on Decoding
• There are two general ways in which a control unit can be implemented: hardwired control and microprogrammed control.
4.7 A Discussion on Decoding
• Microprogramming: uses software for control.
23
4.7 A Discussion on Decoding
Microprogramming: • Machine instructions are input into a special program, the microprogram, to convert the instruction into the appropriate control signals. • essentially an interpreter written in microcode. • converts machine instructions of ―0‖ and ―1‖ into control signals. • There is one subroutine for each machine instruction.
– We note the distinction between an assembler and a compiler: In assembly language, there is a one-to-one correspondence between a mnemonic instruction and its machine code. With compilers, this is not usually the case.
EXAMPLE 4.2 if/else construct :
Skipcond 400
if X = Y then X := X * 2; else Y := Y - X;
17
4.6 Extending Our Instruction Set
EXAMPLE 4.3 double any number:
8
4.5 A Discussion on Assemblers
• Consider our example program (top).
– Note that we have included two directives HEX and DEC that specify the radix of the constants.
18
4.7 A Discussion on Decoding
• A computer’s control unit keeps things synchronized, making sure that bits flow to the correct components as the components are needed. • There must be control signals to assert lines on various digital components to make things happen as described.
Microprogramming is flexible, simple in design, and lends itself to very powerful instruction sets. Microprogramming allows for convenient hardware/software tradeoffs.
– If you have ever used pointers in a program, you are already familiar with indirect addressing.
13
4.6 Extending Our Instruction Set
• JnS X
MBR ← PC MAR ← X M[MAR] ← MBR MBR ← X AC ← 1 AC ← AC + MBR PC ← AC
6
4.5 A Discussion on Assemblers
• We can also substitute labels (simple names) to identify or name particular memory addresses,
7
4.5 A Discussion on Assemblers
21
4.7 A Discussion on Decoding
hardwired control • Advantage: very fast • Disadvantage: circuits are complex, difficult to design or modify expensive

– With microprogrammed control, a small program is placed into read-only memory in the microcontroller. – Hardwired controllers implement this program using digital logic components.
2
4.4 A Simple Program
• This is the LOAD 104 instruction:
3
4.4 A Simple Program
• Our second instruction is ADD 105:
4
4.4 A Simple Program
• Our second instruction is STORE 106:
24
4.7 A Discussion on Decoding
• Advantage: If the instruction set requires modification, the microprogram is simply updated to match—no change is required in the actual hardware.
• The jump-and-store instruction, JNS, gives us limited subroutine functionality.
• JumpI X
MAR ← X MBR ← M[MAR] PC ← MBR
16
4.6 Extending Our Instruction Set
In Fetch, PC PC+1
14
4.6 Extending Our Instruction Set
• Clear
AC ← 0
• ADDI X
MAR X MBR M[MAR] MAR MBR MBR M[MAR] AC AC + MBR
15
4.6 Extending Our Instruction Set
Chapter 4
MARIE: An Introduction to a Simple Computer
4.4 A Simple Program
• Consider the simple MARIE program given below. We show a set of mnemonic instructions stored at addresses 100 - 106 (hex):
11
4.6 Extending Our Instruction Set
extended instruction set.
12
4.6 Extending Our Instruction Set
• So far, all of the MARIE instructions that we have discussed use a direct addressing mode. • This means that the address of the operand is explicitly stated in the instruction. • It is often useful to employ a indirect addressing, where the address of the address of the operand is given in the instruction.
相关主题