Jump to content
IGNORED

Atari DOS 1 Source Listing?


Recommended Posts

I like playing around with various versions of DOS.  I was thinking of tweaking DOS 1 to address a bug or two.  Did source listings ever come out for that?  I've made a first pass as disassembling it, but having the original comments would make it vastly easier to make sense of.  If not, then I should continue to work on making sense of the listings and make them available for anyone else also interested.

 

The code amounts to the boot sector (128 bytes) at $0700 and 8000 bytes of DOS.SYS loaded immediately after it at $0780.

 

[No wonder they marketed the 810 for the 800 and not the 400, as you couldn't even boot DOS 1 on an 8K 400.]

  • Like 1
Link to comment
Share on other sites

I found a bug from the listings!

 

On page 10 of the PDF at address 1778, there's a BNE instruction to optionally skip over a JSR instruction.  The coder decided instead of defining a label for the target, they just used an offset from the current address: *+3.  But that's three bytes from the start of the BNE instruction, not 3 bytes after the instruction, so it will branch past the JSR opcode into the target address.  By sheer luck, that hits a C2 byte which is not a documented opcode, but happens to be a two-byte NOP.  So on a regular 6502, the code will execute as intended.  If other changes in the code shift the addresses, it will break badly.  I believe it's still a 2-byte NOP on the 65C02.  On the 65816, it's the REP instruction, also two bytes, and should also have no bad effects.

 

So it's harmless, but using *+n in a branch target needs to include the two bytes of the branch instruction itself.

 

Meanwhile I'm generating a text file version of the listings, and obviously I'm up to page 10.  I'm using the results of my disassembly to save a ton of typing, which is working well, especially considering that it's often hard to read the old scans.

  • Like 5
Link to comment
Share on other sites

Remember DOS 2 and 2.5 sources are out there as well to help with anything.    And I wonder if there is a tool to scan PDFs to do OCR, or do we have to print and re-scan?  I wonder if we could ask some AI tool to covert it for us. 😄

Link to comment
Share on other sites

1 minute ago, kheller2 said:

Remember DOS 2 and 2.5 sources are out there as well to help with anything.  

Was DOS 2 a complete rewrite, or was it based on the DOS 1 code?  I was under the impression they were from different contractors.  I suppose looking at the code would answer that.  (I have the DOS 2 listings as published by COMPUTE! in my attic; I should pull it out.)

  • Like 1
Link to comment
Share on other sites

I saw that branch instruction noted above.

I have done a dissembly and can see some routines are the same, some altered  and some totally new.

I am puzzled with what $25BB to $25FF is for. Unfortunately, the listing on archive for that part is missing.

Link to comment
Share on other sites

3 hours ago, sup8pdct said:

I saw that branch instruction noted above.

I have done a dissembly and can see some routines are the same, some altered  and some totally new.

I am puzzled with what $25BB to $25FF is for. Unfortunately, the listing on archive for that part is missing.

Isn’t it at the top of page 42? 80 bytes for file spec and EOPEN routine. 

Link to comment
Share on other sites

  • 2 weeks later...

I've gone through the listing PDF from above, and converted my disassembly into the same format.  The PDF is a bit fuzzy, so I'm sure I misread it at points, so some labels may be wrong (though probably consistent).  There is only one macro, "HILO," which takes a 16-bit label and creates H and L labels for the high and low bytes of the address (for loading pointers into A and X for subroutines or into other pointers like in IOCBs).  The listings expanded the macros, so most of the time I did, too (though not at the end when I got lazy).  I've added comments in [square brackets] where I thought it appropriate.  I put in a ^L where there's a page break in the listings file to make it easier to compare.

 

I would like to assemble this and compare with my DOS.SYS file, but I'm not sure what assembler to use.  If there's a cross-assembler that's compatible on Linux, that would be awesome.  Otherwise I'm guessing I should try the Atari Macro Assembler.  I know the Assembler Editor cartridge doesn't do macros, but otherwise that might work as well (and it's what I started with originally).

 

At some point I should put this in my GitHub Atari stuff, but I want to also do the DOS portion.  Then I may want to put out some patches, because that was one of the points of all this.  I want to verify that it assembles first.

 

One interesting thing I found was that my DOS.SYS file has an extra 146 zeros at the end.  I expect there's a bug where the file is 

 

Another interesting point is the listings have one difference: Two instructions down from the GETFIL label, it has "LDA #10" but my disassembly has "LDA #$0B" instead.  I think this is the maximum number of characters to read for a file spec, so there may have been an off-by-one error when using a drive number, such as: D1:ABCD1234.EXT

dos1dup_source.asm

  • Like 5
Link to comment
Share on other sites

I've cleaned it up to correct inconsistent labels and a few other typos.  I haven't found an assembler that matches the syntax, but with some hacks (piping the source through sed for some substitutions), it will assemble without errors.  Now I need to look for binary differences to find any other errors, but it should be close.

dos1dup_source.asm

  • Like 5
Link to comment
Share on other sites

I managed to assemble it.  I hacked it up with sed (Unix tool for regular expression search/replace and such), and was able to get xa to assemble it.  I then did a hexdump of the result along with a hexdump of the same portion of a DOS 1 binary I have (starting at $1300), and there were a ton of differences.  Working through them, I found several typos, and with those corrected, it now is a perfect match except for variables that are zero (uninitialized) when assembling, but have whatever was in memory when written back out by DOS.  It would be a little interesting to find an original factory DOS 1 disk and see if those variables are zero there, but I suspect even those were created from DOS saving itself in development.

 

I've attached the latest good version.

 

Since this now assembles to the correct binary, the only bugs are likely typos in comments or consistent typos in labels.  Several letters look the same in the low-quality scan of the original sources, but I was usually able to figure out from the context what the correct letters were, so I hope the mistakes are minimal.

 

From the formatting, it looks like they were using tabs, so my file uses tabs consistently.  Bytes mattered back then, so that would make sense.

dos1dup_source.asm

  • Like 4
  • Thanks 1
Link to comment
Share on other sites

Keep up the good work!  I'm following along.  This is very interesting to me to take such old source code and rebuild proper binaries.   I know there are a few different assemblers out there, I  used CC65 to assemble the sources for the OS, and that or another to do 1050 ROM and DOS3 DUP.  I would be nice to have an Atari mainframe compatible assembler instead of hacking with sed/awk.

  • Like 3
Link to comment
Share on other sites

Fairly sure a lot of Atari dev work was done on PDP-11.

There's a bit of an emulation scene for them so possibly the environment could be replicated.

 

My experience on those - last 2 years of school we remoted in... which was probably being done by something like a 9.6k modem, maybe less.

  • Like 1
Link to comment
Share on other sites

2 hours ago, Rybags said:

Fairly sure a lot of Atari dev work was done on PDP-11.

Yup.  That's been widely reported.  But with the OS, BASIC, and DOS being contracted out, it's hard to be sure what environment they all used.

 

The sources look like they would assemble with the Atari Assembler Editor cartridge with two changes: Eliminate the macros, and add line numbers.

 

But another problem is that they created variables with "VAR *=*+2" to create a 2-byte variable, VAR, so the assembler just skips two bytes of output.

 

At this point, I should create a GitHub repository with the PDF, my true-to-the-original assembly file, and my hacked-to-assemble version of the file.

 

I've been thinking that what I would like to see is a 6502 assembler that is extremely forgiving on syntax with the goal of supporting any source that other assemblers support.  I don't think I'm the one to do that, through.

Link to comment
Share on other sites

13 minutes ago, pcrow said:

I've been thinking that what I would like to see is a 6502 assembler that is extremely forgiving on syntax with the goal of supporting any source that other assemblers support.  I don't think I'm the one to do that, through.

Not promising anything here, but could you be kind enough to mention some of the pain points on syntax? (context: I do maintain an assembler that has 6502 mode: https://rmac.is-slick.com)

Link to comment
Share on other sites

There's source available for Atari Basic, the original OS and Dos 2.0s - so the original assembler used might be deducable.

There's also plenty of documentation surrounding development (though also plenty of gaps) which could also help.

Edited by Rybags
Link to comment
Share on other sites

14 minutes ago, ggn said:

Not promising anything here, but could you be kind enough to mention some of the pain points on syntax? (context: I do maintain an assembler that has 6502 mode: https://rmac.is-slick.com)

The number one thing is implicit comments.

 

A quirk was the use of "PER" as a label, which triggered a bug in 'xa' where 65816 opcodes are reserved words even when not in that mode.  I reported that, and they may fix it.

 

Some assemblers expect colons after labels, but that didn't impact me.

 

The code expects to do character constants as #'0 or even expressions like #'A-'0+10 in hex conversion.  The assembler I was using expected #"A" instead.

 

Macro syntax is obviously going to be different on different assemblers.  Fortunately this only used one, though I would have used a ton more for a bunch of things it was doing all the time.

 

The syntax for .IF/.END and .TITLE wasn't supported by the assembler I was using.

 

For reference, here's the line I was using to assemble the source:

xa -E -XMASM -P dos1dup.lst -o dos1dup.bin <(cat dos1dup_source.asm | sed -e 's/;.*//' -e 's/\t...*\t.*\t/&;/' -e 's/\t=*\t[^.].*\t/&;/' -e 's/\t[*]=.*\t/&;/' -e 's/HILO/;&/' -e 's/[.]IF/;&/' -e 's/[.]END/;&/' -e 's/[.]TITLE/;&/' -e 's/^&/;&/' -e '104,107s/^/;/' -e "s/#'\(.\)/#"'"\1"/' -e "s/'0/"'"0"/' -e 's/[.]BYTE/.byt/' -e 's/ASL\tA/ASL/' -e s/^PER/PEER/g -e 's/\tPER/\tPEER/g' -e '100,$s/[*]=[*]+1/.BYTE 0/' -e '100,$s/[*]=[*]+2/.WORD 0/' -e '100,$s/[*]=[*]+5/.BYTE 0,0,0,0,0 /' -e '100,$s/[*]=[*]+40/.WORD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /' -e '100,$s/[*]=[*]+80/.WORD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /' -e '100,$s/[*]=[*]+[$]100/.WORD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /')

 

  • Like 2
Link to comment
Share on other sites

If it helps any, here is a list of equates i figured out for dos1 based on dos 2 listing.

 

        11E5 DFDPFN
        11E3 DFDSSN
        11E1 DFDCNT
        11E0 FILDIR
        116E FCBCNT
        116C FCBSSN
        116A FCBLSN
        1168 FCBCSN
        1167 FCBBUF
        1166 FCBDLN
        1165 FCBMLN
        1164 FCBFLG
        1161 FCBOTC
        1160 FCBFNO
        113F FNAME
        113E FNAME-1
        1137 SECTBL
        112E DBUFAL
        112D TEMP4
        112C TEMP3
        112B TEMP2
        112A TEMP1
        1129 SVDBYTE
        1128 SFNUM
        1127 CDIRS
        1126 CDIRD
        1125 DHFNUM
        1124 DHOLED
        1123 DHOLES
        1122 CURFCB
        1121 ENTSTK
        111D ERREOF
        1119 GREAT
        1116 FGREAT
        1111 ERRIO
        10FF RETURN
        10FB ERRDNO
        10F9 ERRNSB
        10F7 ERRNSA
        10F5 ERRSYS
        10F3 ERFNMM
        10F1 ERRFN
        10EF ERRPDL
        10ED ERFLOCK
        10EB ERDVDC
        10E9 ERDFULL
        10E7 ERFNF
        10E5 ERRPOT
        10D9 DFN
        10D8 TDFR
        10CD TDF1
        10CB TSTDOS
        10CA WD4
        10C4 WD3
        10A4 WD2
        10A2 WD1
        109A WD0
        1090 SETDSO
        107B DD1
        1079 DELDOS
        106A WRTDOS
        1069 FSBR
        105B FRESBUF
        1058 SSBA
        104D GSB4
        1042 GSB1
        1010 DSIO
        0FC1 DERR1
        0F89 SETUP
        0F86 GSERR
        0F6D GS4
        0F59 GS3
        0F52 GS2
        0F2D GS1
        0F2B GETSECTOR
        0F05 FS3
        0EFD FS2
        0EF1 FS1
        0EED FRESECT
        0EEA DEAD
        0EE3 DSIOER
        0EDD BSIOR
        0EDC DSYSIO
        0ECD VTIO
        0EC6 WRVTOC
        0EC3 RDVGO
        0EBA RDVTOC
        0EA1 DIRIO
        0EA0 WRTDIR
        0E9D RDDIR
        0E9B RDDELE
        0E91 RDFNMM
        0E8E RDIOER
        0E82 RDNS2
        0E5A RDNS1
        0E52 RDNXTS
        0E45 MVLSN
        0E3C RWCSIO
        0E3B WRCSIO
        0E19 WRTN6
        0DE6 WRTN5
        0DC9 WRNERR
        0DAF WRTN2
        0DA6 WRTLS1
        0D9E WRTN1
        0D9B WRU1
        0D8A WRTNXS
        0D86 SDRTN
        0D80 SFDSH1
        0D69 SFDSH
        0D60 SFD4
        0D54 SFD3
        0D47 SFD2
        0D42 SFD1
        0D2B CSFDIR
        0D1B SFDIR
        0D15 FDSC2
        0D0F FDSC1
        0D04 FDSCHAR
        0D01 FNDERR
        0CFD FDEND
        0CF7 FD6
        0CEB FD5
        0CDF FD4
        0CCF FD3
        0CC4 FD2
        0CBD FD1
        0CB2 FD0
        0CAE FNDCNX
        0CA4 FD0A
        0C98 FNDCODE
        0C87 STDIGIT
        0C70 CVD1
        0C6B CVDIGIT
        0C61 CVDY
        0C51 CVDX
        0C35 LD2
        0C2F LD1
        0C1B FDENT
        0C18 LDDONE
        0BFB LDCNT
        0BF5 LDENT1
        0BEB LDENT
        0BE8 GDCRTN
        0BCB GDCHAR
        0BBF LISTDIR
        0BB1 XF4
        0BA6 XF3
        0B88 XF2
        0B67 XF1
        0B55 XFORMAT
        0B40 NOTE
        0B3D PERR1
        0B37 XP3
        0B2A XP2
        0B18 XP1
        0B03 POINT
        0B00 TLF
        0AF5 TSTLOCK
        0ADC XLC1
        0AD1 XLCOM
        0ACC UNLOCK
        0AC5 LOCK
        0AC2 XDELY
        0AAF XDEL4
        0AA9 XDEL2A
        0AA4 XDEL2
        0A76 DELETE
        0A5F XRN3
        0A55 XRN2
        0A50 XRN1B
        0A36 XRN1A
        0A2B XRN1
        0A1D RENAME
        0A1A XFV
        0A17 DVDCER
        0A0A DVDCVT+1
        0A09 DVDCVT
        09EB SPECIAL
        09C3 RRDIR
        09BD CLUPDT
        09B5 FNSHF2
        09B3 FNSHF1
        09B1 FNSHFT
        09A9 CLDONE
        098F CLOSE
        098C SFNF
        097B STATUS
        0978 GET3
        0959 GET2
        0949 GET1
        093C GETBYTE
        0929 PUT1
        090E PUTBYTE
        08EF SETFCB
        08EC DHFOX3
        0888 DHFOX2
        0885 OPNER2
        0882 OPNER1
        0860 OPN2A
        0857 OPN2
        0839 OPN1A
        0813 OPN1
        07FD OPEN
        07DD ADI2
        07CC ADI1
        0788 FMINIT
        0780 DFLADR
        077C DFMSDH
        076F DSIO2
        0763 BSIO
        074F INCBA
        0712 XBCONT
        0710 DFLINK
        070E DFSFLG
        070C SASA
        070B SAFBFW
        070A DRVBYT
        0709 SABYTE
        0700 FMSORG

  • Like 3
Link to comment
Share on other sites

21 hours ago, sup8pdct said:

If it helps any, here is a list of equates i figured out for dos1 based on dos 2 listing.

That helps a lot!  I had done the same thing, but there was one where you had a different address for the label, and looking again, you were correct.  And there were a bunch I hadn't gotten.  I've updated my files on GitHub to use the new labels.

  • Like 2
Link to comment
Share on other sites

So one bug found and fixed:

 

The end of DOS is set to $2680.  That's in SASA at $070C, which is part of the DOS file.  The DUP sources are separate, so it can't just reference an automatically generated symbol.  Since it was manual, they didn't adjust it for the final build.  The correct value is $262E.  If you do a POKE 1804,46, then write new a new DOS file, it will be 1 sector shorter and BASIC will have 82 more bytes free.  I did a quick test to verify this.  I also verified that the DOS.SYS file still contains the same last RTS instruction that it is supposed to end with, so I didn't cut anything off.

 

I'm more annoyed by the wasted sector from this bug than the wasted memory, but 45 years later it's fixed.

  • Like 3
  • Haha 1
Link to comment
Share on other sites

I've updated things on the GitHub page for this.  I now have the as-close-to-original-as-possible sources, cleaned up sources with more modern syntax that I can actually assemble, a combined single source file, and a modified source file.  For now, the modified file takes all the buffers for both DOS and DUP and moves them to the end.  This means it doesn't have to save them as part of DOS.SYS, so it's now 56 sectors instead of 64 sectors.  I also eliminated a little bit of padding so the overall free memory is up slightly.

  • Like 2
Link to comment
Share on other sites

And I've found and fixed the DOS 1 bug that annoyed me in the first place and inspired this project:  If you create a file with 256 or more sectors, the directory listing only shows the low-byte of the sector count.  It took a while to find because I was looking in the wrong place.  All the code that manages the file sector counts was right (except for an initialization bug that I also fixed, but appeared to be harmless).  I finally looked at the directory sector in a debugger and saw that the count was right there, too.  The bug was in reading the directory.  They left off a ",X" on the instruction to read the high byte of the sector count, which seems to have caused it to always get a zero (fortunately).  That's fixed, and now directory listings are correct.

 

Of course, the DOS 2 listings have these bugs fixed, but now DOS 1 has it, too.

  • Like 3
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...