I think the title really says most of it already. I have been working on 8086 assembly stuff for a class. We are using DOS and MASM a lot. My friend Kyle and I wanted to share the source for our project but neither of us had a good idea how to do it. We both have google docs accounts so for this last project we just shared a collection with two folder OLDARCHE and NEWEST. To check a file out we just moved it to OLDARCHIVE. Then to check it in we just copied it back up. Since you can download whole collections as a zip file this worked pretty well.
Then I decided it would be cool if we could edit the files online. So I wrote a .bat that would rename all the asm files to .txt file extensions and do a basic “clean” of the folder to kill obj and exe files. I called this batch file gd_pack. That stood for google docs pack. Well now that they are all .txt files google is happy to convert them to editable documents. The batch files can be uploaded with the source.
All the source files can be downloaded at once as a collection and I always choose “convert docs to txt format” in the collection download options.
I wrote another script to change all the filenames back once I downloaded a collection and unzipped it. I called that one gd_unpack. The one thing that was a pain in the butt was that google docs ads a correctly formated UTF BOM which is a two bite code you would normally be ok with having at the front of your bit stream. Except that beaks the file as far as MASM is concerned. See my google docs help question for more info: http://www.google.com/support/forum/p/Google+Docs/thread?tid=053b786244ab3398&hl=en
All that had to be done now was to strip out the first 4 bytes of each txt file. Unfortunately I’m not the illest assembly programmer yet. I have not done anything with writing files to disk or reading command tails. Well, I was feeling lazy so I just used GNU tail. But yes I was in windows so that means keeping tail.exe with my files (and two libraries). Very dirty I admit but I just wan to try this out you know. So I wrote a for loop so that dos runs tail on each file and strips out the first four bytes. DONE except I had to rename tail.exe to tail.com and that’s what its getting called for the rest of its life (dos does not care) so that it dodge clean which I do every once in a while even when I’m not about to upload it (yes,everything is living hodge podge in the same folder for now).
As part of the gd_pack tail.com is renamed to tail.bin to dodge the google file type filters, and back when I retrieve it… because google docs hates com and exe files.
The end result is I can edit my source online and download it with a few clicks and unpack it. One click cleans it and prepares it for upload, then I drag and drop to my google docs page for safe keeping. Oh I forgot to mention there are a few .txt files in my folder that are actually for real txt files. I just rename those back to txt at the last minute …
I did some “things” with the file extensions that basically go like this:
1. the files are stripped of leading 4 bytes and end up copied to filename.txt.tmp
2. then I delete all *.txt files
3. strip off .tmp file extensions from filename.txt.tmp files
4. rename .txt to .asm
If it was bash I could have combined steps but , DOS I really an happy with just getting something to work with less investment of time. So that should explain the bash file. The others are real simple.
here are the scripts:
rename *.asm *.txt
rename tail.com tail.bin
rename tail.bin tail.com
for /f %%a IN ('dir /b *.txt') do tail --bytes=+4 %%a > %%a".tmp"
rename *.tmp *.
rename *.txt *.asm
rename *answers.asm *.txt
rename *verification.asm *.txt