首页 > 解决方案 > MARIE 计算器未按预期工作

问题描述

我需要在 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

标签: assemblymarie

解决方案


回答:

我发现结果中减去 48(十进制)将匹配代表所述数字的相应 ASCII 码的答案。


推荐阅读