【发布时间】:2018-06-09 23:23:12
【问题描述】:
我需要在 MARIE 中为一个计算器编写代码,该计算器需要 2 个数字 x 和 y,打印 > x + y = z。计算器不打算计算两位数的答案。我遇到的问题是一切正常,除了结果将是一个随机的 ASCII 字符而不是想要的结果。
例如,5 + 4 = i 和 3 + 2 = e
ORG 100
load a
output / prints ">"
input
store x / takes input and stores into x
load x
output / loads x into AC and output
input
store y / takes input and stores into y
load b
output / prints "+"
load y
output / prints y
load c
output / prints "="
load x
add y
store z / adds x and y, stores into z
load z
output / prints z (the result)
halt
a, hex 3E
b, hex 2B
c, hex 3D
x, hex 0
y, hex 0
z, hex 0
【问题讨论】:
-
您正在添加 ascii 代码。因此
5+4变为0x35+0x34=0x69,实际上是i。 -
哦!我想我明白了。所以我只需要用 30 代替这些值,应该没问题吧?