【发布时间】:2021-02-21 07:47:45
【问题描述】:
我正在看这个作业:
编写一个程序,接受三个输入并按升序输出它们。
我使用了以下 LMC 模拟器:https://www.101computing.net/LMC/#
这就是我到目前为止所做的:
INP 901 Input num1
STA 318 Store num1 in address 18
INP 901 Input num2
STA 319 Store num2 in address 19
INP 901 Input num3
STA 320 Store num3 in address 20
SUB 219 Subtract num2 from num3
BRP 810 Jump to address 10 if it is zero or positive (J1)
LDA 519 Load num2 from address 19
STA 320 Store num3 in address 20
LDA 520 Load num3 from address 20 (J1)
SUB 218 Subtract num1 from num3
BRP 815 Jump to address 18 if it is zero or positive (J2)
LDA 518 Load num1 from address 18
STA 320 Store num3 in address 20
LDA 520 Load num3 from address 20 (J2)
OUT 902 Output result
HLT 000 Stop program
DAT Data num1
DAT Data num2
DAT Data num3
我只实现了找到最大的数字,但我不知道如何将它们按升序排列。
我怎样才能以正确的顺序输出其他两个值?
【问题讨论】:
标签: computer-science little-man-computer