Ich mache ein Assembly-Labor für meine Schule und es auf dem Drucken von Nummern mit und ohne Vorzeichen. Es druckt unendlich viele "- /", aber es sollte eine Zahl gedruckt werden. Ist der Offset für die Nummer auf den ASCII-Wert 30h?Drucken von gesungenen und vorzeichenlosen Zahlen in Assembly
Display .EQU 04E9h
NumAddr .EQU 0050h
Main:
mov BX, NumAddr
mov DX, Display
mainLoop:
MOV AH,[BX]
cmp AH, 0h ; is number 0?
JE EndPrt ; if yes we are done
CMP AH,0h
JG posNum ; should jump to posNum if AH is positive
negNum:
mov AL, 2Dh
out DX,AL ; print a negative sign
NEG AH ; turn AH into a positive number
printPos:
MOV AL,[BX]
ADD AL, 30h ; should add required offset to convert to ASCII
out DX,AL
MOV AL, 0Dh
out DX,AL
MOV AL, 0Ah
out DX,AL
inc BX
jmp mainLoop
EndPrt:
HLT
.END Main