assemblymarie

MARIE calculator not working as intended


I need to write a code in MARIE for a calculator that takes 2 numbers x and y, prints > x + y = z. The calculator isn't intended to calculate double digit answers. The problem I'm having is everything works, except the result will be a random ASCII character instead of the wanted result.

for example, 5 + 4 = i and 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

Solution

  • ANSWER:

    I found out that substracting 48 (dec) to the result would match the answer to the corresponding ASCII code that represents said number.