close_1_file:
mov bx, handle
mov ah, 3eh
int 21h
loop:
lodsb
mov dl,al
call charget
cmp si, 0
jmp ending
jmp loop
First of all, you really shouldn't name a lable like an instruction.
Second, where is si
initialized?
Third, why do you compare it against 0?
Fourth, why two jumps?
jmp ending ; you want this to be je
jmp loop
And the function charget
writes a character, but is named as if it were reading it?
But even if you would have the je
to branch, where would the 0
come from? You said in your file is abc
, so there will be no 0
in your buffer, unless you explitcitly put it there.
update
What you must do is the following:
- open the file. done
- read the file. done
- preserve the number of bytes you just read.
- close the file. done
- point to the buffer where you read it into.
- loop through that buffer until you have printed N characters, where N is the number of bytes you preserved from the read.
update 2
You still have one problem left. Of course you store each character in a row, otherwoise you read each single character in the same place.
mov ax, counter
mov dx, offset buffer
add dx, ax
inc counter