Im Grunde habe ich eine Eingabe, die ein Ergebnis ausgibt und zurück zum Anfang springt, das Problem ist, dass es auf der aktuellen Zeile druckt, anstatt das Ergebnis auf der neuen Zeile zu drucken ... was könnte ich tun, um das zu beheben?Wie wird ein neues Zeilenzeichen in LC-3 gedruckt?
Ich denke, ich habe 2 Stunden damit verbracht, herauszufinden, wie. Ive versuchte alles von .fill zu .stringz und gedankenlos mit Puts überall mit zufälligen Sachen in R0
Tatsächliches Problem: Ich bin nicht sicher, ob es ein logischer Fehler im Code, der auch das vorherige, was gedruckt wurde, druckt ... im Grunde, was passiert ist meine Ausgabe lautet:
Please enter digit: 1 <---- assume thats input
Please enter a digit: 0001
Please enter a digit: Please enter a digit 4
Please enter a digit: 0100
Please enter a digit: Please enter a digit: <wait for user input>
Wenn es sein sollte:
Please enter digit: 1 <---- assume thats input
0001
Please enter a digit 4
0100
Please enter a digit <wait for user input>
Code:
.orig x3000
start AND R0, R0, #0
AND R1, R1, #0
AND R2, R2, #0
AND R3, R3, #0
AND R4, R4, #0
AND R5, R5, #0
AND R6, R6, #0
AND R7, R7, #0
lea r0, prompt
puts
lea r1, input
char getc
putc
str r0, r1, #0
add r1, r1, #1
add r2, r0, #0
ld r3, check1 ;first check
add r2, r2, r3
add r4, r0, #0
add r5, r2, #0
and r2, r2, #0
getc
add r2, r0 #-10
brz cont
cont and r0, r0, #0
and r2, r2, #0
add r0, r4, #0
add r2, r5, #0
brn incorrect
and r2, r2, #0
add r2, r0, #0
and r3, r3, #0
ld r3, check2 ;second check
add r2, r2, r3
brzp incorrect
add r4, r0, #0
and r0, r0, #0
and r2, r0, #0
add r2, r2, #10
body and r0, r0 #0
add r0, r4, #0
and r2, r2, #0 ;numbers 0-9 that make it pass checks
and r3, r3, #0
ld r3, test0
add r2, r0, r3
brz case0
and r2, r2, #0
and r3, r3, #0
ld r3, test1
add r2, r0, r3
brz case1
and r2, r2, #0
and r3, r3, #0
ld r3, test2
add r2, r0, r3
brz case2
and r2, r2, #0
and r3, r3, #0
ld r3, test3
add r2, r0, r3
brz case3
and r2, r2, #0
and r3, r3, #0
ld r3, test4
add r2, r0, r3
brz case4
and r2, r2, #0
and r3, r3, #0
ld r3, test5
add r2, r0, r3
brz case5
and r2, r2, #0
and r3, r3, #0
ld r3, test6
add r2, r0, r3
brz case6
and r2, r2, #0
and r3, r3, #0
ld r3, test7
add r2, r0, r3
brz case7
and r2, r2, #0
and r3, r3, #0
ld r3, test8
add r2, r0, r3
brz case8
and r2, r2, #0
and r3, r3, #0
ld r3, test9
add r2, r0, r3
brz case9
test0 .fill -48
case0 lea r0, empty
puts
lea r0, eol
puts
lea r0, string0
puts
lea r0, eol
puts
brnzp start
test1 .fill -49
case1 lea r0, eol
puts
lea r0, string1
puts
lea r0, eol
puts
brnzp start
test2 .fill -50
case2 lea r0, eol
puts
lea r0, string2
puts
lea r0, eol
puts
brnzp start
test3 .fill -51
case3 lea r0, eol
puts
lea r0, string3
puts
lea r0, eol
puts
brnzp start
test4 .fill -52
case4 lea r0, eol
puts
lea r0, string4
puts
lea r0, eol
puts
brnzp start
test5 .fill -53
case5 lea r0, eol
puts
lea r0, string5
puts
lea r0, eol
puts
brnzp start
test6 .fill -54
case6 lea r0, eol
puts
lea r0, string6
puts
lea r0, eol
puts
brnzp start
test7 .fill -55
case7 lea r0, eol
puts
lea r0, string7
puts
lea r0, eol
puts
brnzp start
test8 .fill -56
case8 lea r0, eol
puts
lea r0, string8
puts
lea r0, eol
puts
brnzp start
test9 .fill -57
case9 lea r0, eol
puts
lea r0, string9
puts
lea r0, eol
puts
brnzp start
string0 .stringz "0000"
string1 .stringz "0001"
string2 .stringz "0010"
string3 .stringz "0101"
string4 .stringz "0100"
string5 .stringz "0101"
string6 .stringz "0110"
string7 .stringz "0111"
string8 .stringz "1000"
string9 .stringz "1001"
empty .fill 0
eol .fill 10
prompt .stringz "Enter a digit: "
check1 .fill -48
check2 .fill -58
incorrect halt
input .blkw 10
.end
Suchen Sie den Newline-Hexcode des Betriebssystems und drucken Sie das? –
Durch das Entfernen des Codes wird die Antwort ungültig. Das ist verpönt. Bitte tu das nicht. – rene
Rene, ich habe meinen Code absichtlich entfernt, wäre es möglich, wenn Sie es ebenso wie Chris Antwort, die meinen Code enthält, freundlicherweise abnehmen könnten? oder zumindest Fragmente davon, ich könnte in ernsthafte Schwierigkeiten mit der Universität geraten, ich wollte nur winzige Hilfe mit einem Druckfehler, aber das Posten meines Codes kann ein ernsthafter Verstoß sein. –