EASy68K  
It is currently Sat Mar 25, 2017 5:53 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Feb 26, 2014 12:21 am 
Offline

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
 Profile  
Reply with quote  
PostPosted: Fri Feb 28, 2014 11:28 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1035
Location: Monroe County Community College, Monroe Michigan, U.S.A.
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
 Profile  
Reply with quote  
PostPosted: Sun Mar 02, 2014 3:13 am 
Offline

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.

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


Top
 Profile  
Reply with quote  
PostPosted: Mon Mar 03, 2014 8:15 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1035
Location: Monroe County Community College, Monroe Michigan, U.S.A.
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

_________________
Prof. Kelly


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group