簡體   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