Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Please help with problem

I'm trying to open, read, and output a text file to the screen. It works, and I can read the file onscreen, but numerous symbols follow. I think it has to do with the top part of my code, but I'm not sure. Could someone please look it over? I welcome any suggestions. I'll paste the top part of my code first, then the output to the screen. Thanks. P.S. If you need more info, just let me know.
(Top part of code)

DATA SEGMENT
;directive to define byte data
;string data definition
;20 unassigned bytes and prints out buffer when done
;
TITLE1 DB 'Hello world',13,10,'$' ;pg. 82
FILENAME BYTE 'D:DATA.TXT',0 ;(0 terminates string)
INHANDLE WORD ?
BYTESREAD WORD ?
BUFFER BYTE ? ;buffer size indicated in other part of code
DATA ENDS
;*************
STACK SEGMENT STACK
;generates a repeated storage allocation, using constant expression as counter
DB 32 DUP ('STACK ') ;pg. 83
STACK ENDS
;***********

(output to screen)

Hello world

Hey Paul, do you understand how we did this?
Yo Kira, how does this look now? (end of file)
STACK STACK STACK STACK STACK STACK STACK STACK STACK STACK
STACK STACK STACK STACK STACK STACK STACK STACK STACK P
? + ? ? ?? n?^?V ??2 ?-?+n?+?+ ??-? -!+lq+ ? +? -!r3
? ??? + ? -!r ? ?+ ??-? ? -!r
>?? -!r + L-!NNB08`? CV?
Tenth10.obj?
? ? ? ? ?Tenth10.obj6 ? ?? /Microsoft (R) Macro
Assembler Version 6.15.8803?6-??-?? K?
M?? O?+h??+F+?-x?% =? ?s?x?
j?? ?p??t??h???P+p%+L+?+dJ-!X?+ ?+ ? [?+O?- +-?, ?+t??
d?FX?+?-!+?
3+?+!++ ?+!3-6+!?+ ?+!=u?T = tKVP=? u86+!;t.:? t)< t:?l?u?FV?:
? t :?+ d?ZZT??ZZT( X^-F-?Fdnd>!?!u?du>!?!u?d>!Press any key to
continue . . .
!


Comments

  • anthrax11anthrax11 Member Posts: 511
    : I'm trying to open, read, and output a text file to the screen. It works, and I can read the file onscreen, but numerous symbols follow. I think it has to do with the top part of my code, but I'm not sure. Could someone please look it over? I welcome any suggestions. I'll paste the top part of my code first, then the output to the screen. Thanks. P.S. If you need more info, just let me know.
    : (Top part of code)
    :
    : DATA SEGMENT
    : ;directive to define byte data
    : ;string data definition
    : ;20 unassigned bytes and prints out buffer when done
    : ;
    : TITLE1 DB 'Hello world',13,10,'$' ;pg. 82
    : FILENAME BYTE 'D:DATA.TXT',0 ;(0 terminates string)
    : INHANDLE WORD ?
    : BYTESREAD WORD ?
    : BUFFER BYTE ? ;buffer size indicated in other part of code
    : DATA ENDS
    : ;*************
    : STACK SEGMENT STACK
    : ;generates a repeated storage allocation, using constant expression as counter
    : DB 32 DUP ('STACK ') ;pg. 83
    : STACK ENDS
    : ;***********
    :
    : (output to screen)
    :
    : Hello world
    :
    : Hey Paul, do you understand how we did this?
    : Yo Kira, how does this look now? (end of file)
    : STACK STACK STACK STACK STACK STACK STACK STACK STACK STACK
    : STACK STACK STACK STACK STACK STACK STACK STACK STACK P
    : ? + ? ? ?? n?^?V ??2 ?-?+n?+?+ ??-? -!+lq+ ? +? -!r3
    : ? ??? + ? -!r ? ?+ ??-? ? -!r
    : >?? -!r + L-!NNB08`? CV?
    : Tenth10.obj?
    : ? ? ? ? ?Tenth10.obj6 ? ?? /Microsoft (R) Macro
    : Assembler Version 6.15.8803?6-??-?? K?
    : M?? O?+h??+F+?-x?% =? ?s?x?
    : j?? ?p??t??h???P+p%+L+?+dJ-!X?+ ?+ ? [?+O?- +-?, ?+t??
    : d?FX?+?-!+?
    : 3+?+!++ ?+!3-6+!?+ ?+!=u?T = tKVP=? u86+!;t.:? t)< t:?l?u?FV?:
    : ? t :?+ d?ZZT??ZZT( X^-F-?Fdnd>!?!u?du>!?!u?d>!Press any key to
    : continue . . .
    : !
    :
    :
    :
    It probably has to do with the other part of the code.
    Interrupt 21h function 40h returns the number of bytes read. Before printing out the file, make sure you put a "$" character at the end of the message. I hope you don't mind tasm syntax:
    [code]
    mov ah,40h
    mov dx,offset BUFFER
    mov cx,sizeof BUFFER
    mov bx,INHANDLE
    int 21h

    mov di, offset BUFFER
    add di,ax
    mov [di],"$"

    mov ah,9
    mov di,offset BUFFER
    int 21h
    [/code]
  • oldandtiredoldandtired Member Posts: 10
    Thanks. I'll look it over now.


    : : I'm trying to open, read, and output a text file to the screen. It works, and I can read the file onscreen, but numerous symbols follow. I think it has to do with the top part of my code, but I'm not sure. Could someone please look it over? I welcome any suggestions. I'll paste the top part of my code first, then the output to the screen. Thanks. P.S. If you need more info, just let me know.
    : : (Top part of code)
    : :
    : : DATA SEGMENT
    : : ;directive to define byte data
    : : ;string data definition
    : : ;20 unassigned bytes and prints out buffer when done
    : : ;
    : : TITLE1 DB 'Hello world',13,10,'$' ;pg. 82
    : : FILENAME BYTE 'D:DATA.TXT',0 ;(0 terminates string)
    : : INHANDLE WORD ?
    : : BYTESREAD WORD ?
    : : BUFFER BYTE ? ;buffer size indicated in other part of code
    : : DATA ENDS
    : : ;*************
    : : STACK SEGMENT STACK
    : : ;generates a repeated storage allocation, using constant expression as counter
    : : DB 32 DUP ('STACK ') ;pg. 83
    : : STACK ENDS
    : : ;***********
    : :
    : : (output to screen)
    : :
    : : Hello world
    : :
    : : Hey Paul, do you understand how we did this?
    : : Yo Kira, how does this look now? (end of file)
    : : STACK STACK STACK STACK STACK STACK STACK STACK STACK STACK
    : : STACK STACK STACK STACK STACK STACK STACK STACK STACK P
    : : ? + ? ? ?? n?^?V ??2 ?-?+n?+?+ ??-? -!+lq+ ? +? -!r3
    : : ? ??? + ? -!r ? ?+ ??-? ? -!r
    : : >?? -!r + L-!NNB08`? CV?
    : : Tenth10.obj?
    : : ? ? ? ? ?Tenth10.obj6 ? ?? /Microsoft (R) Macro
    : : Assembler Version 6.15.8803?6-??-?? K?
    : : M?? O?+h??+F+?-x?% =? ?s?x?
    : : j?? ?p??t??h???P+p%+L+?+dJ-!X?+ ?+ ? [?+O?- +-?, ?+t??
    : : d?FX?+?-!+?
    : : 3+?+!++ ?+!3-6+!?+ ?+!=u?T = tKVP=? u86+!;t.:? t)< t:?l?u?FV?:
    : : ? t :?+ d?ZZT??ZZT( X^-F-?Fdnd>!?!u?du>!?!u?d>!Press any key to
    : : continue . . .
    : : !
    : :
    : :
    : :
    : It probably has to do with the other part of the code.
    : Interrupt 21h function 40h returns the number of bytes read. Before printing out the file, make sure you put a "$" character at the end of the message. I hope you don't mind tasm syntax:
    : [code]
    : mov ah,40h
    : mov dx,offset BUFFER
    : mov cx,sizeof BUFFER
    : mov bx,INHANDLE
    : int 21h
    :
    : mov di, offset BUFFER
    : add di,ax
    : mov [di],"$"
    :
    : mov ah,9
    : mov di,offset BUFFER
    : int 21h
    : [/code]
    :

Sign In or Register to comment.