It is currently Wed Dec 11, 2019 11:22 pm

 All times are UTC

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: reading more than a byte from filePosted: Wed Feb 26, 2014 12:21 am

Joined: Wed Feb 26, 2014 12:17 am
Posts: 2
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

Top

 Post subject: Re: reading more than a byte from filePosted: Fri Feb 28, 2014 11:28 pm

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1109
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.

_________________
Prof. Kelly

Top

 Post subject: Re: reading more than a byte from filePosted: Sun Mar 02, 2014 3:13 am

Joined: Wed Feb 26, 2014 12:17 am
Posts: 2
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.

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

Top

 Post subject: Re: reading more than a byte from filePosted: Mon Mar 03, 2014 8:15 pm

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1109
Code:
num = 0
while is digit
num = num * 10    ; make room for next digit
char = char - \$30  ; convert from ASCII to binary
num = num + char
endwhile

_________________
Prof. Kelly

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 4 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ EASy68K Forum    FAQ    Latest Features    EASy68K Questions    68000 Programming Questions    Wish List    Wishes Granted    Undocumented Features    Documented Features    General Discussion    EASy68K Projects