EASy68K  
It is currently Sun Apr 05, 2020 11:13 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: File I/O
PostPosted: Mon Mar 04, 2013 7:03 am 
Offline

Joined: Mon Mar 04, 2013 6:50 am
Posts: 1
I am totally new to 68k, so please forgive my ignorance.
In fact, my main goal is to read an array from .txt file, make some manipulations with it, and then write it back.
I started to learn file i/o with the fileio.x68 from examples, however, this program doesn't write the array properly - but the program seems correct. When I write the array as a string, everything is fine. However, how to get numbers from the string or turn them to string is somewhat mysterious. The example which I'm talking about:

Code:
*-----------------------------------------------------------
* Title         : FileIO
* Written by    : Chuck Kelly
* Date Created  : December-2-2004
* Description   : Demonstrate file I/O in EASy68K
* Modification  : Oct-18-2008 by CK
* Dec-25-2012 by CK, Uses SIMHALT
*-----------------------------------------------------------
   ORG      $800
START
   lea      filename,a1
   move   #52,d0         open new file
   trap   #15

   lea      data,a1         data to write
   move   #datasize,d2   # bytes to write
   move   #54,d0         write to file
   trap   #15

   move   #0,d2         file position
   move   #55,d0
   trap   #15

   lea      buffer,a1
   move   #datasize,d2   # bytes to read
   move   #53,d0         read from file
   trap   #15

   move   #50,d0
   trap   #15            close all files

   lea      filename,a1
   move   #57,d0         delete file
   trap   #15

   SIMHALT               Halt Simulator

filename   dc.b   'test1.txt',0
data      dc.b   'this is a test'
         dc.b   1,2,3,4,5,6,7,8,9,0
datasize   equ      *-data
buffer      ds.b   80

   END      START


Top
 Profile  
 
 Post subject: Re: File I/O
PostPosted: Mon Mar 04, 2013 9:45 am 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1118
The data is being written to the file. Here is the contents of the file
74 68 69 73 20 69 73 20 61 20 74 65 73 74 01 02 03 04 05 06 07 08 09 00

_________________
Prof. Kelly


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 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:  
Powered by phpBB® Forum Software © phpBB Group