TASM выводятся данные из внешнего файла с кракозябрами

Всем привет. Большой код, в котором требуется счесть внешний файл и вывести его содержимое с последующей надписью, сообщающей о результате этой операции (Fail или It is Okay). У меня все выводится ,как нужно, но между текстом из файла и подтверждающей строкой появляется какое-то количество кракозябр. Пробовал использовать вместо 09h функцию вывода 40h, но стало только хуже и строка состояния вывода перестала работать.

введите сюда описание изображения

Чтение файла для вывода начинается со строки ReadFile PROC . За внешность кода сразу извиняюсь.

model small     ;Memory for EXE
.DATA   
    FileName db 'Open.txt',0h
    OnStr    db 10,13, "It is Okay $"
    OffStr   db 10,13, "Fail $"
.stack  100h    ;Stack segment 256 bytes
.CODE

Start:
    
    mov ax,@data    ; ???????? ????? ???????? ?????? ? ??????? ??,??????? ???????? ???????????????
                    ;(PLACES the address of the data segment in the registry AX, which is the identifier )
    mov ds,ax       ; ???????? ?????? (ax in ds)
    mov dx, offset FileName ; ????????? ???? ? ??? ????? ? DS:DX
                            ;(Place the path and file name in DS:DX.)
    
                        ;?????????? ?????????
    CALL OpenFile       ;????? ??????? ??????? ????????? ?????????,??????? ?? ????????
                        ;I call the real procedure, which is outside the limits 
                        ;of the parameters - the ending of the program
   
    jc Error            ; ??????? ??????? ? ?????? ??????(jump in case of error)
                        ; ?? ???? ???? ??????? ???? ?? ???? ????????? ? ???? ???????? (CF) = 1
                        ;(that is, if the function above has not been performed and carrier flag = 1)
;Read
    
    CALL ReadFile                    
    
    jc Error
    
    CALL CloseFile     
    
    mov dx,OFFSET OnStr 
    jmp Write
  
    
    Error:
    mov dx,OFFSET OffStr
    ;????? ??????? ??????? Write ? ?????? ??? ????? ?????? ??????
    ;Next follows the Write function and so it writes the error line
    
    Write:
    CALL OnWrite
    
    
    Exit:
    mov ah,04Ch     ;Well be closing down the program
    int 21h         ;close the program
    
    
    OnWrite    PROC   
        mov ah,09h      ;??????? ?????? ????????? ????? ??????? 
                        ;DOS (output status bar of our DOS function)     
        int 21h
        ret             ;??? ??????? ?????? ???? ? ????? ????????? ? ??? ?????? 
                        ;????????? ?????? ?? ??????, ??? ????????? ???? ???????
                        ;this command must be at the end of the procedure and it will return
                        ;the command indication to the address where the procedure was called
    OnWrite    ENDP
    
    OpenFile    PROC   
         ;Open
          mov ah,3dh      ; ??????? ???????? ????? (file opening function)
          mov al,0            ; ????? ??????? - ?????? (access mode - read)
          int 21h             ; ????????? ??????? ???????? ?????(Perform file opening function)
          ret
    OpenFile    ENDP
    
    ReadFile    PROC   
          mov bx,ax           ;???????? ?????????? ax ? bx, ??? ?????? ???????? ???????????????
                        ;Places the content of ax in bx, which is the Identification
    
          mov ah,3fh      ; функция чтения файла
          mov cx,0FFFFh   ; сколько читать
          mov dx,OFFSET buffer    ; буфер
          
          int 21h         ; выполнить  
          mov ah,09h       
          int 21h
          
          ret
    ReadFile    ENDP
    
    CloseFile    PROC   
          mov ah,3eh
          int 21h            ; ????????? ??????? ???????? ?????(Perform file opening function)
          ret
    CloseFile    ENDP

buffer  label   byte 
End Start


Ответы (0 шт):