繁体   English   中英

LC-3有条件的

[英]LC-3 Conditionals

我必须根据R0的值打印字符串“ POSITIVE”,“ NEGATIVE”或“ ZERO”。 您如何在LC-3中表示多个条件? 我当时想我可以将其自身加上值以检查R0是正,负还是零,但是我不知道如何检查所有这三种情况。

printCC ADD R1,R0,R0
BRp printPOS
printPOS LEA R0, StringPOS
PUTS
RET

StringNEG   .STRINGZ "NEGATIVE\n"
StringZERO  .STRINGZ "ZERO\n"
StringPOS   .STRINGZ "POSITIVE\n"
.orig x3000

ADD R0, R0, #0      ; ensure that branch is dependent
                    ; on R0 (the last result)
BRp printPOS
BRn printNEG
LEA R0, StringZERO
BR DONE
printNEG LEA R0, StringNEG
BR DONE
printPOS LEA R0, StringPOS
DONE PUTS
HALT

StringNEG   .STRINGZ "NEGATIVE\n"
StringZERO  .STRINGZ "ZERO\n"
StringPOS   .STRINGZ "POSITIVE\n"

.end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM