EASy68K
http://www.easy68k.com/EASy68Kforum/

reading more than a byte from file
http://www.easy68k.com/EASy68Kforum/viewtopic.php?f=5&t=1293
Page 1 of 1

Author:  smdirru22 [ Wed Feb 26, 2014 12:21 am ]
Post subject:  reading more than a byte from file

Is there a way to read more than only one byte when reading from a file ?
when i use task 53 each character is read as one byte
im trying to read a number with 2 digits or more
how can i do this ?
my problem occurs when i read a file that has something like
10 2 3
my buffer will have
31 30 20 32 20 33
so is there a way to read in the 10 as a 10 not as 1 and a 0 ?
thanks

Author:  profkelly [ Fri Feb 28, 2014 11:28 pm ]
Post subject:  Re: reading more than a byte from file

If the file contains a number written using ASCII text you will need to convert the ASCII number into binary. If the file contains binary numbers they may be read one byte at a time and saved to a variable.

Author:  smdirru22 [ Sun Mar 02, 2014 3:13 am ]
Post subject:  Re: reading more than a byte from file

profkelly wrote:
If the file contains a number written using ASCII text you will need to convert the ASCII number into binary. If the file contains binary numbers they may be read one byte at a time and saved to a variable.

Thank you for the reply.
how would you suggest converting the ASCII text to binary and load it into a data register ?

Author:  profkelly [ Mon Mar 03, 2014 8:15 pm ]
Post subject:  Re: reading more than a byte from file

Code:
num = 0
read char
while is digit
    num = num * 10    ; make room for next digit
    char = char - $30  ; convert from ASCII to binary
    num = num + char
    read char
endwhile

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/