Read and print string - Assembly -
i'm trying create program in assembly read character character, store in array , print character character. know can use interrupts read , print strings, want own code learn more.
the code read, not know why not printing:
buff dw 0,0,0,0,0,0 len equ 5 mov ah, 1 mov si, 0 read: mov al b.buff[si] int 21h inc si cmp si, len jl read jmp print mov si, 0 mov ah, 2 print: mov dl, b.buff [si] int 21h inc si cmp dl, 0 je end jmp print end:
you've done quite bit wrong. don't feel bad - nobody born knowing stuff.
1) don't tell assembler you're using. they're different! (looks maybe eric isaacson's a86?)
2) buffer declared "word"s, you're using "byte"s. won't harm.
3) buffer should in "data" section. you're going try execute buffer. mess quite badly.
4) in "read" loop, put 0 buffer al
, read character (into al
) , don't it! 1 of 2 "big" problems.
5) @ end of "read" loop, jump on 2 lines reset si
0 , load 2 ah
... you're still "reading", not printing (and in unintended place in buffer). other "big" problem.
6) "print" loop expects zero-terminated string. don't explicitly zero-terminate string @ end of "read" loop. since buffer pre-filled zeros, won't hurt, might want it.
7) don't exit cleanly dos (int 21h/4ch
)... unless "end" (depends on assembler?).
there may more, should closer.
Comments
Post a Comment