模拟CPU运算小程序,可以加分 400分!

来源:百度知道 编辑:UC知道 时间:2024/06/06 20:30:27
模拟CPU的运算, 就像汇编的程序一样
支持16位整数, 指令最少要有MOV, ADD, SUB, MUL, DIV

输入:
用户想输入一个运算,比如 (( 3 + 2 ) × 8 ) ÷ 5
输入
MOV AX,3 AX <-3
ADD AX,2 AX <-AX + 2
MUL AX,8 AX:BX<- AX × 8
DIV AX,5 AX:BX <- AX ÷ 5
Process:
1. Instruction address calculation
2. Instruction fetch
3. Instruction operation decoding
4. Data operand address calculation (loading) (if applicable)
5. Data operand fetch (if applicable)
6. Data operation
7. Data operand address calculation (storing)
8. Data operand store
英文版作业

Input:
1. User will be given one mathematic equation such as (( 3 + 2 ) × 8 ) ÷ 5.
2. User then converts the equation into a set of instructions that the program can execute.
For example:
MOV AX,3 AX ß 3
ADD AX,2 AX ß AX + 2
MUL AX,8 AX:BX ß AX × 8
DIV AX,5 AX:BX ß AX ÷ 5
3. User then inputs th

给我留言

这么多鸟语 我怎么看得懂???再者这已经超出硬件范围了 你还是去程序或其他地方问吧

晕死你这不是编程么?!~怎么来硬件地方来玩了~去软件那边凉快去

又来

program lkkjzp;
var
y,s,st,str:string;
kx,n,kc,k,z:int64;
i,j:longint;
code:integer;
t:real;
begin
readln(s);
while s<>'' do
begin
for i:=1 to length(s) do
if s[i] in ['a'..'z'] then y:=s[i];
j:=1;
kx:=0;
kc:=0;
code:=0;
for i:=1 to pos('=',s) do
begin
if ((s[i]='+') or (s[i]='-') or (s[i]='=')) and(i<>1) then
begin
str:=copy(s,j,i-j);
val(str,k,code);
if code=0 then kc:=kc-k;
if code<>0 then
begin
delete(str,code,1);
if str='' then k:=1 else
val(str,k,code);
if code<>0 then
if str[1]='+' then k:=1 else if str[1]='-'