1. Program with machine language according to the following c.
int_8 a = 1;
int_8 c = a + 3;
(1)Write your assembly code & machine code
(2)Explain machine code execution with the fetch-decode-execute cycle
(3)Explain functions about IR, PC, ACC registers in a CPU
(4)Explain physical meaning about vars a & c in a machine
1.(1) LOD # 1–>STO X –> LOD X –> ADD#3 –> STO Y –> HLT
1.(2)
Main memory –> fetch instruction –> Decode instruction –>Registers –>Get data –>Execute the instruction –> Main memory
1.(3)
IR:指令寄存器,用来保存当前正在执行的一条指令
PC:程序计数器,存放下一条指令在内存中的地址
ACC:累加寄存器,功能是当运算器的算术逻辑单元(ALU)执行全部算术和逻辑运算时,为ALU提供一个工作区,暂时存放ALU运算结果
1(4)
2. 简答题
(1)What are stored in memory?
(2)Can a data or a instruction stored in the same place?
(3)Explain Instruction Format with example instructions.
2(1) 指令和数据
2(2) 可以
2(3)
例:ADD X :00000000 10000000
前八位称命令指示,第四位为寻址模式,例子中为0,表示操作数是该地址的内容;后八位称为操作数,表示数值或地址,例子中表示内存中地址128。整个例子表示加上将内存地址128中的数据
3. 解释以下词汇
(1)汇编语言(Assembly Language)
(2)编译(Compiler)
(3)命令式语言(Imperative programming)
(4)函数编程语言(Functional programming)
(5)过程式编程(Procedural programming)
3(1)
A language that uses mnemonic codes(助记忆符号) to represent machinelanguage
instructions
3(2)
A program that translates a high-level language program
into machine code
3(3)
Imperative programming is a programming paradigm that uses statements that change a program’s state
3(4)
Functional programming is a programming paradigm–a style of building the structure and elements of computer programs–that treats computation as the evaluation of mathematical functions and avoid changing-state and mutable data
3(5)
A programming paradigm, derived from structured programming, based upon the concept of the procedure call