在从变量加载值之前清除累加器

时间:2014-09-30 01:37:54

标签: assembly subtraction mano-machine

我一直在编写一个执行此操作的程序:

Suppose we have the following program:
  DF1 = A - B
  SUM = DF1 + C
  DF1 = 1
  SUM = SUM + DF1 + C
Write a (Mano) assembly program that does what the pseudo-code program does.  
Assume that each variable is translated to a labelled memory address.

我认为它在大多数情况下是正确的,但不幸的是,没有一个非常可靠的mano汇编编译器来测试我的代码。无论如何,我唯一担心的是我在第17行有 CLA 指令。我这样做是为了将DF1设置为零,因为我们想在 1 中加载一个新值。这是正确的做法吗?

如果有人对我可能错过的错误或改进有任何其他批评或建议,请提供您的意见。

非常感谢任何和所有的帮助/输入。感谢。

ORG 100   /Program loaded into address 100 (hex)
CLA       /Clear accumulator....DF1 = 0
STA DF1   /Save DF1
LDA DF1   /Load current DF1
LDA B       /Load B to accumulator
CMA       /Create 2's complement
INC
ADD A       /Subtract B from A  
STA DF1   /Save DFI

LDA SUM   /Load current SUM
ADD DF1   /Add DF1 to SUM
ADD C       /Add C to SUM
STA SUM   /Save SUM

CLA       /Clear accumulator....DF1 = 0 
LDA DF1   /Load current DF1
ADD 1       /Add 1 to DF1
STA DF1   /Save DF1

ADD SUM   /Add SUM to DF1
ADD C       /Add C to DF1
STA SUM   /Save SUM 

DF1 -
SUM -
A   -
B   -
C   -

0 个答案:

没有答案