assembly - 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
解决方案
回答:
我发现结果中减去 48(十进制)将匹配代表所述数字的相应 ASCII 码的答案。
推荐阅读
- python - 如何在不使用切片和打印功能的情况下对字符串进行子串化?
- mysql - 错误 1062 键 'primary' 的重复条目 '0'
- r - 如何获得每个主成分解释的总方差
- powerbi - Power BI - 如何从原始源创建另一个表
- mvvm - Xamarin 在列表中形成列表(使用 prism 导航)
- python - pyodbc执行sqlserver存储过程——如何为用户定义表传入DEFAULT参数
- python - 如何在 HMTL/Bootstrap4 中使用变量作为选择器?
- c++ - 多线程中的工作池内存泄漏
- ios - 用原点阻止了一个框架
- java - 为什么下面代码的输出是这个映射:{1=[Dd,Ff], 2=[Dd,Ff], 3=[Dd,Ff], 4=[Dd,Ff]}?