Bitte ich bin neue Assemblersprache und ich versuche, den Umriss einer Box zu drucken. Ich bin wirklich festgefahren. Ich habe alles versucht, was ich weiß, aber ich bekomme es einfach nicht, um den Entwurf zu drucken. Vielen Dank im Voraus für Ihre HilfeSo drucken Sie eine Rahmenkontur in Assemblersprache
INCLUDE Irvine32.inc
.data
prompt BYTE "This program draws a rectangle using the * character.", 0
len BYTE "How high would you like your box? ", 0
wid BYTE "How wide would you like your box?: ", 0
image BYTE "* ", 0
space BYTE " ", 0
leninput DWORD ?
widinput DWORD ?
h DWORD ?
w DWORD ?
count DWORD ?
.code
main proc
;;; Write the prompt to the screen
mov edx, OFFSET prompt
call WriteString
call Crlf
;;; Write the length request to the screen
mov edx, OFFSET len
call Crlf
call WriteString
;;; Obtain the length value(which will be in eax)
call ReadDec
mov leninput, eax
;;; Write the width request to the screen
mov edx, OFFSET wid
call Crlf
call WriteString
;;; Obtain the second value(which will be in eax)
call ReadDec
mov widinput, eax
;;; Draw rectangle on screen
mov eax, 0
mov ecx, leninput; set outer loop with length
L1 :
mov count, ecx; save outer loop count
mov ecx, widinput; set inner loop count with the width
L2 :
call ConditionCheck
loop L2; repeat the inner loop
call Crlf; Print line
mov ecx, count; restore outer loop(length)
loop L1; repeat outer loop 1
exit
main endp
; ----------------------------------------------------------------------
ConditionCheck PROC
mov eax, leninput
mov ebx, widinput
.IF eax == 1
mov edx, OFFSET image
call WriteString
.ELSEIF eax == leninput
mov edx, OFFSET image
call WriteString
.ELSEIF ebx == 1
mov edx, OFFSET image
call WriteString
.ELSEIF ebx == widinput
mov edx, OFFSET image
call WriteString
.ELSE
mov edx, OFFSET space
call WriteString
.ENDIF
ret
ConditionCheck ENDP
; ---------------------------------------------------------------------- -
end main
Ausgabe sollte wie folgt aussehen:
How high would you like your box? 5
How wide would you like your box? 6
******
* *
* *
* *
******
Aber ich habe die Box in anstatt
Ah .. MASM Makros oder Richtlinien, oder was das '.IF' ist ... das muss zu debuggen unbequem sein, um nicht die tatsächlichen Anweisungen zu sehen. BTW, haben Sie überlegt, was passieren würde, wenn Sie 'leninput - = 2;' machen würden, geben Sie immer eine ganze Zeile aus, dann 'leninput' loop mit "inneren" Zeilen, und after loop würde enden, geben Sie wieder eine volle Zeile aus ? (Aber Sie sollten wahrscheinlich die Eingabe bereinigen, um zu bestätigen, dass es 3+ war) .... und ähnlich kann der Code des inneren Teils nach 'widinput - = 2;' treatment einfacher sein. – Ped7g