Jump to content



0

File I/O in assembly language


11 replies to this topic

#1 retroclouds OFFLINE  

retroclouds

    Stargunner

  • 1,096 posts
  • Location:Germany

Posted Fri Jul 15, 2011 9:20 AM

I'm looking for some examples on how to do disk file access using TMS9900 assembly language
What I'm looking for is how to sequentially read a file, write a file, random access. Reading the catalog, etc.

What requirements are there in regards to VDP memory, scratch-pad memory, etc.
How to access the DSR.

Anyone ? :)


EDIT: hhmmm this is not related to the Tutankham project :)

#2 adamantyr OFFLINE  

adamantyr

    Moonsweeper

  • 424 posts

Posted Fri Jul 15, 2011 9:24 AM

View Postretroclouds, on Fri Jul 15, 2011 9:20 AM, said:

I'm looking for some examples on how to do disk file access using TMS9900 assembly language
What I'm looking for is how to sequentially read a file, write a file, random access. Reading the catalog, etc.

What requirements are there in regards to VDP memory, scratch-pad memory, etc.
How to access the DSR.

Anyone ? :)


EDIT: hhmmm this is not related to the Tutankham project :)

The TI Tech Page has good information for this; I've used it to create the file reading system for my CRPG. I call the "FILES" subroutine, for example, to reduce the number of active files to 1 and free up space in VDP, and do a lot of random access.

I'm going on vacation for the weekend, so I can't provide more details from my project, but when I get back I can do so.

Adamantyr

#3 Willsy OFFLINE  

Willsy

    Dragonstomper

  • 765 posts
  • Location:Uzbekistan (no, really!)

Posted Fri Jul 15, 2011 2:31 PM

You write a PAB in VDP memory, and set >8356 in pad to point to the length byte of your PAB.

It's actually fairly easy to do in assembly language. Reading a catalog is a bitch, because the numeric data comes back in Radix 100 format.

Doing things like relative file IO in assembly is quite simple once you get the hang of it. The trick is to write little subroutines that each do a little bit of work on the PAB. I generally 'work' on the PAB in normal CPU memory, then transfer it to VDP at the end, when I've finished setting it up.

Eg.
  BL @OPCODE       ; write an OPEN opcode to the opcode field 
  DATA OPEN,MYPAB  ; (byte 0) of the pab at address MYPAB

  LI R0,45         ; set record number 45
  BL @SETREC       ; call the 'set record' routine
  DATA MYPAB       ; update the PAB at address MYPAB in cpu memory

Once you have a little library of these helper routines, is very easy.

Attached is a PDF that I made for myself some time that summarises the layout of PABs. Hope you find it useful!

If you need to know anything, just go ahead and ask... Adam, Matthew, Tursi, Marc, myself etc will be happy to help.

Attached Files



#4 marc.hull ONLINE  

marc.hull

    Dragonstomper

  • 645 posts
  • Location:Oklahoma CIty.

Posted Fri Jul 15, 2011 2:58 PM

View PostWillsy, on Fri Jul 15, 2011 2:31 PM, said:

You write a PAB in VDP memory, and set >8356 in pad to point to the length byte of your PAB.

It's actually fairly easy to do in assembly language. Reading a catalog is a bitch, because the numeric data comes back in Radix 100 format.

Doing things like relative file IO in assembly is quite simple once you get the hang of it. The trick is to write little subroutines that each do a little bit of work on the PAB. I generally 'work' on the PAB in normal CPU memory, then transfer it to VDP at the end, when I've finished setting it up.

Eg.
  BL @OPCODE       ; write an OPEN opcode to the opcode field 
  DATA OPEN,MYPAB  ; (byte 0) of the pab at address MYPAB

  LI R0,45         ; set record number 45
  BL @SETREC       ; call the 'set record' routine
  DATA MYPAB       ; update the PAB at address MYPAB in cpu memory

Once you have a little library of these helper routines, is very easy.

Attached is a PDF that I made for myself some time that summarises the layout of PABs. Hope you find it useful!

If you need to know anything, just go ahead and ask... Adam, Matthew, Tursi, Marc, myself etc will be happy to help.


Thanks for the pat on the back but Marc knows absolutely dick about this mysterious file stuff. It is also outside my current scope (which is restricted to games, songs and beer.) I don't know if Ernie ever made it over here but I do know he is a file wizard. Tim also knows his way around that oldest of dark magics ;-).

This would be a good subject for a tell all type of manuscript. Provided it was dumbed down for us mere mortals.

#5 Tony Knerr OFFLINE  

Tony Knerr

    Star Raider

  • 73 posts

Posted Fri Jul 15, 2011 4:42 PM

Here's some code that loads image files. reads the header, and places them in the correct area.
It's for the HSGPL card, but shows basic concepts. I've got some code to save and restore ramdisk sectors to a single I/F 128 file also, if you're interested. I'll have to transfer that from my Geneve and will take a little work, though.


Tony

Attached Files



#6 Willsy OFFLINE  

Willsy

    Dragonstomper

  • 765 posts
  • Location:Uzbekistan (no, really!)

Posted Fri Jul 15, 2011 4:52 PM

I'll see if I can put some sort of document together if adamantyr doesn't beat me to it. Iirc its covered quite well in one of the assembly books. I'll look it up tomorrow .

#7 retroclouds OFFLINE  

retroclouds

    Stargunner

  • 1,096 posts
  • Location:Germany

Posted Sat Jul 16, 2011 2:08 AM

View PostWillsy, on Fri Jul 15, 2011 4:52 PM, said:

I'll see if I can put some sort of document together if adamantyr doesn't beat me to it. Iirc its covered quite well in one of the assembly books. I'll look it up tomorrow .

Thanks. I appreciate it a lot. The info I got in this thread is a good starting point.

I'm kinda hoping that InsaneMultitasker chimes in. This morning I recalled that he was working on exact such document about a year ago.
Dunno how far he got, but perhaps forces can be bundled :)

At this time I'm starting collecting the information, unfortunately no time for hacking.
I have some (oracle) business to take care off next week and most likely I won't be having internet access.
So I'll be silent for a while :ponder:

#8 Willsy OFFLINE  

Willsy

    Dragonstomper

  • 765 posts
  • Location:Uzbekistan (no, really!)

Posted Sat Jul 16, 2011 8:15 AM

Chapter 5, section 5.6, page 162 is the start of the Assembly File IO in the attached book "Simplified 99/4 Assembly Language" by Ken Kulp. This is a brilliant book.

I think you'll find it explains everything you need to know. It doesn't explain reading the disk catalog, but don't make that your first File IO project, choose something simpler to start with! Like, writing "hello mother" to a file, and then reading it back etc!

Hope you like the attached.

Mark

Attached Files



#9 Ksarul OFFLINE  

Ksarul

    Star Raider

  • 68 posts

Posted Sat Jul 16, 2011 11:38 AM

Thanks Willsy, I don't think I've ever seen that book. . .

#10 retroclouds OFFLINE  

retroclouds

    Stargunner

  • 1,096 posts
  • Location:Germany

Posted Sun Jul 17, 2011 1:45 AM

wow, that's a very good book! Too bad TI didn't supply it together with the Editor/Assembler cartridge.

Yeah I'm gonna start with some trivial tasks and see how far I get :)

Thanks willsy.

#11 adamantyr OFFLINE  

adamantyr

    Moonsweeper

  • 424 posts

Posted Mon Jul 18, 2011 2:16 PM

I'm back from vacation... did you figure out how to do files in my absence?

One thing that isn't documented with relative files is WHEN to actually populate the PAB with the record you want. I've found the best time to do this is on the read/write operation. I initially had the record placed with the open operation, but I found that while that worked with the TI Disk Controller, the Myarc HDFC actually ignored it.

Adamantyr

#12 retroclouds OFFLINE  

retroclouds

    Stargunner

  • 1,096 posts
  • Location:Germany

Posted Tue Jul 19, 2011 10:04 AM

View Postadamantyr, on Mon Jul 18, 2011 2:16 PM, said:

I'm back from vacation... did you figure out how to do files in my absence?

One thing that isn't documented with relative files is WHEN to actually populate the PAB with the record you want. I've found the best time to do this is on the read/write operation. I initially had the record placed with the open operation, but I found that while that worked with the TI Disk Controller, the Myarc HDFC actually ignored it.

Adamantyr

I'm out of town. The hotel I'm in doesn't have WIFI. So I downloaded a few things in advance, still collecting infos at this time. Expecting to dig into it the next week. Thanks




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users