EASy68K  
It is currently Sun Apr 05, 2020 9:37 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: FileIO question
PostPosted: Mon Mar 18, 2013 3:21 am 
Offline

Joined: Sat Mar 09, 2013 3:44 am
Posts: 1
Hello,
So I've searched for a solution everywhere but for the life of me cannot print the numbers of the file I read on display. All I get is either an addressing error or my output displaying '65535'. Any clue how to print the string of numbers out from a file?

Thank, here is my code so far..
Code:
ORG      $800
START
    ; CREATING THE FILE
   lea      filename,a1
   move   #52,d0         open new file
   trap   #15
    ; WRITING IN THE FILE
   lea      data,a1         data to write
   move   #datasize,d2   # bytes to write
   move   #54,d0         write to file
   trap   #15
    ; POSITIONING THE FILE TO READ
   move   #0,d2         file position
   move   #55,d0
   trap   #15
    ; READING THE FILE
   lea      buffer,A0        file read and stored into buffer
   move    #datasize,d2
   move    #53,d0
   trap    #15
   ; PLACING READ FILE INTO STACK
   
    move.w   #2,A0
    move.w  (A0),d1
    move    #3,d0
    trap    #15
      
   SIMHALT               Halt Simulator

filename   dc.b   'test1.txt',0
data      dc.w   9,8,7,6,5,4,3,2,1,0,5,4,3
datasize   equ       100
buffer      ds.w   10


   END      START






Top
 Profile  
 
 Post subject: Re: FileIO question
PostPosted: Mon Mar 18, 2013 1:03 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1118
In your code.
    ; READING THE FILE
    lea buffer,A0
should be
    lea buffer,A1

    ; PLACING READ FILE INTO STACK

    move.w #2,A0
    move.w (A0),d1
    move #3,d0
    trap #15
This code reads the word data from memory location $000002 and displays it as a decimal number. That is not what the comment suggests. What was the intended outcome of this code?

_________________
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 6 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