Mein Proggie ist zum Resultat einer Endlosschleife geworden, HILFE!
-
Hallo,
ich wollte ein kleines Programm schreiben, mit dem ich ein wenig mit Strings hantiere:- eine String einlesen, aber nur Sterne statt Buchstaben ausgeben und bei Return mit dem Einlese aufhören,
- String1 in String2 kopieren,
- und zum Schluss noch String2 lesbar ausgeben.
INCLUDE macro.bib IDEAL MODEL small STACK 128 ;--- DATA SEGMENT ------------------------------------------------------------- DATASEG string1 db 80 dup ( '.' ) ; reserve memory for 80 Byte, initial with '.' string2 db 80 dup ( '.' ) ; reserve memory for 80 Byte, initial with '.' ;--- CODE SEGMENT ------------------------------------------------------------- CODESEG Start: STARTUPCODE mov ax, ds ; initil DATASEG mov es, ax ;********** Userinput --> string1 ********** mov cx, 80 ; max 80 letters mov di, OFFSET string1 ; set aim register L0: mov ah, 08h ; key in AL int 21h stosb ; save input( letter ) in string1( byte 0 ) ... mov dl, al ; al --> dl push dx mov dl, '*' ; dl = '*' mov ah, 02h ; dl output int 21h pop dx cmp dl, 13 ; userinput == Return jump "L1" je L1 loop L0 ; loop it, till cx == 0 ;********** copy string1 --> string2 ********** L1: mov cx, 80 ; max 80 letters mov si, OFFSET string1 ; source = string1 mov di, OFFSET string2 ; aim = string2 L2: movsb ; string1 --> string2 loop L2 ; loop it, till cx == 0 ;********** show string2 ********** NEW_LINE NEW_LINE mov cx, 80 ; max 80 letters mov si, OFFSET string2 ; source = string2 L3: lodsb ; load byte --> al ... mov dl, al ; move al --> dl mov ah, 02h ; show dl int 21h SLEEP 5000 ; Slow it loop L3 ; loop it, till cx == 0 ;********** End here ********** L4: mov ah, 01h ; wait till user press any key int 21h mov ah, 4ch ; last word :) int 21h EXITCODE End Start ;--- EXIT ---------------------------------------------------------------------
Aber irgendwie werden in einer Endlosschleife nur P’s ausgegeben. Kann mir da mal jemand helfen? Danke.
Gruß Tobi.
-
Schreib mal so
string1 db 81 dup ( '$' ) ; reserve memory for 81 Byte, initial with '$' string2 db 81 dup ( '$' ) ; reserve memory for 81 Byte, initial with '$'
-
PS: Grund, DOS-Interrups zur Textausgabe erwarten am Ende des Textes das Dollarzeichen '$'!
-
Statt "Display Character"(Funktion 02H)
mov cx, 80 ; max 80 letters mov si, OFFSET string2 ; source = string2 L3: lodsb ; load byte --> al ... mov dl, al ; move al --> dl mov ah, 02h ; show dl int 21h SLEEP 5000 ; Slow it loop L3 ; loop it, till cx == 0
solltest Du dann besser "Display String" (Funktion 09H) nehmen.
mov dx, offset string2 mov ah, 09h int 21h