News for hackers. Stuff that matters.
Re:BATAS: 8086 assembler written in MSDOS batch by classichasclass on Friday December 07, 2018 @09:04PM (#18633407)
I think people are missing the forest for the trees here. He's trying to bootstrap a programming environment from the basic tools provided with a default MS-DOS install ( https://github.com/mniip/BOOTSTRA ) and build everything from the "cleanest" possible state.

That is mad as badgers. The batch file assembler is merely what will get him more years in the asylum. ;)

Re:BATAS: 8086 assembler written in MSDOS batch by userbinator on Friday December 07, 2018 @09:52PM (#18633587)
I think a lot more people have tried something similar when they first read about DEBUG (and the source code listings in PC magazines of the time would use it for assembling short programs)... including me.

At the start, the most powerful tool is undoubtedly DEBUG.EXE with its ability to assemble and create executable files. It has just one handicap though: there are no labels. One has to manually adjust jump and variable locations.

My solution, instead of writing an assembler with batch files, was to use DEBUG itself to write the label-understanding assembler. I think I still have it somewhere, in incomplete form --- never got around to finishing the whole thing, because real life got in the way. ;-)

Looking at the number of "bootstrap pilgrimage" projects that have become public, it's great to see many others trying the same thing; there was this one recently too: https://news.ycombinator.com/item?id=17851311

Re:BATAS: 8086 assembler written in MSDOS batch by cardiffspaceman on Saturday December 08, 2018 @01:24AM (#18634187)
As others have said, "Start with a floppy and a magnetized needle..."
Re:BATAS: 8086 assembler written in MSDOS batch by mniip on Saturday December 08, 2018 @07:46AM (#18634978)
I had initially considered doing it that way but deemed it too tedious. I really can't stand calculating and correcting offsets all the time.
Re:BATAS: 8086 assembler written in MSDOS batch by Someone on Saturday December 08, 2018 @08:20AM (#18635070)
I think I would get a Forth up and running ASAP, and write the assembler, if one still is needed, in that Forth.

looking at https://github.com/nornagon/jonesforth/blob/master/jonesfort... for a simple example, that needs assembler labels and macros, but I think a few batch files can give you rough approximations of those (example of rough approximation: assume every function is 64 bytes long, and every jump needs a 2-byte offset. That makes address calculations a bit easier. Wasteful, but that can be fixed later, once you have a better assembler written in your Forth.

Re:BATAS: 8086 assembler written in MSDOS batch by userbinator on Saturday December 08, 2018 @02:03PM (#18636872)
I wrote my initial version on lined paper, using labels, and didn't calculate the offsets until I was ready to enter it in. The planning/design was also done on paper, away from a computer.

The state of mind required to do that is something I can safely say is foreign to the majority of developers today, who will write code they're not completely sure of and test/debug/modify later; but when each "cycle" of debugging may take many minutes instead of seconds, one learns to think very very carefully about what the code is doing. Code that works perfectly on the first run is not unusual when you have this mindset.

Re:BATAS: 8086 assembler written in MSDOS batch by Narishma on Saturday December 08, 2018 @06:11AM (#18634777)
Why DEBUG.EXE and not the BASICs that came with MS-DOS? Wouldn't that be much easier?
Re:BATAS: 8086 assembler written in MSDOS batch by Someone on Saturday December 08, 2018 @01:09PM (#18636537)
Those required the presence of a version of Basic in ROM (I guess to keep the size of the executable down, not primarily as a license-checking scheme), so they didn’t run on all hardware.

(Source: https://en.wikipedia.org/wiki/IBM_BASIC#IBM_Disk_BASIC, https://en.wikipedia.org/wiki/IBM_BASIC#IBM_Advanced_BASIC)

Re:BATAS: 8086 assembler written in MSDOS batch by hakfoo on Saturday December 08, 2018 @01:49PM (#18636768)
The IBM BASIC/BASICA used the ROM stuff to an extent, but the free-standing GWBASIC included in MS-DOS didn't.
Re:BATAS: 8086 assembler written in MSDOS batch by Narishma on Sunday December 09, 2018 @07:38AM (#18640588)
That's PC-DOS though, not MS-DOS. AFAIK MS-DOS always came with a disk BASIC that didn't require anything in ROM.
Re:BATAS: 8086 assembler written in MSDOS batch by tempodox on Saturday December 08, 2018 @02:54AM (#18634346)
Using that cursed parody of an interpreter to write an assembler definitely merits extra hero points. :)
Re:BATAS: 8086 assembler written in MSDOS batch by curlypaul924 on Saturday December 08, 2018 @04:31AM (#18634588)
If that's the goal, then why write it in batch instead of BASIC?
Re:BATAS: 8086 assembler written in MSDOS batch by userbinator on Friday December 07, 2018 @07:45PM (#18633048)
Appears to be based on a very similar design to https://news.ycombinator.com/item?id=7882066 , except that batch files are far more limited than bash.

Also, may I suggest a small optimisation to APPFB.COM : there is no need for push cs/pop ds at the beginning, because in a .COM format executable all the segment registers are initially set to the same value. You can eliminate two unnecessary bytes ;-)

Re:BATAS: 8086 assembler written in MSDOS batch by sqldba on Saturday December 08, 2018 @04:36AM (#18634595)
Sorry I think you’re very slightly wrong.

There was a bug in either some revision of MSDOS or a compatible version that needed it. That’s why it’s common (though agreed technically unnecessary as it’s unlikely to ever be run on those...)

Re:BATAS: 8086 assembler written in MSDOS batch by zygotic12 on Friday December 07, 2018 @07:52PM (#18633084)
Both of you are mad as badgers. I'd love to buy you a beer.
Re:BATAS: 8086 assembler written in MSDOS batch by 171243 on Friday December 07, 2018 @07:15PM (#18632863)
Wow, this is a blast from the past. I got started "programming" by writing batch files to do all sorts of interesting and crazy things. Stuff like sleeping for a second by printing a predefined number of spaces because the sleep construct didn't exist. There was some guys homepage (think 1996/7) that I remember had an incredible amount of scripts to do things like grabbing the logged in users name, etc all through batch files. In the process of researching possible commands to use in the scripts I came upon "debug" which seemed to be its own language but was far too advanced for me as a 9/10 year old. Glad to see someone finally found a use for it! Good times.
Re:BATAS: 8086 assembler written in MSDOS batch by contingencies on Friday December 07, 2018 @07:54PM (#18633095)
I once wrote a batch file virus... it was mostly a proof of concept because the only programming documentation I had access to was an MSDOS 5 manual. It was a great manual!
Re:BATAS: 8086 assembler written in MSDOS batch by 171243 on Friday December 07, 2018 @08:16PM (#18633193)
I showed off the "net send" flood in my school which was a batch file that looked like this:

    :label
    net send username
    goto label
Someone then substituted * for username and flooded the network. I got to spend a week in in school suspension for that!!!
Re:BATAS: 8086 assembler written in MSDOS batch by maxxxxx on Friday December 07, 2018 @08:24PM (#18633238)
Ouch! The author must have incredible pain tolerance doing this in batch.
Re:BATAS: 8086 assembler written in MSDOS batch by RcouF1uZ4gsC on Friday December 07, 2018 @11:13PM (#18633883)
>He's trying to bootstrap a programming environment from the basic tools provided with a default MS-DOS install

Wasn’t some version of BASIC provided with every version of MSDOS?

Re:BATAS: 8086 assembler written in MSDOS batch by pan69 on Friday December 07, 2018 @11:21PM (#18633916)
Up until MSDOS version 5, MSDOS was shipped with GW-BASIC. From MSDOS 5 onward it shipped with QBasic.

If you can create an assembler with batch files it should certainly be possible to create one with BASIC. :)

Hmm, interesting idea...

Re:BATAS: 8086 assembler written in MSDOS batch by pjmlp on Saturday December 08, 2018 @05:16AM (#18634672)
I don't remember any longer, did PC-DOS, DR-DOS and all other DOS compatible variants also ship GW-BASIC?
Re:BATAS: 8086 assembler written in MSDOS batch by pan69 on Saturday December 08, 2018 @03:01PM (#18637202)
I don't believe that is the case, Those versions of DOS might ship with some version of BASIC though. GW-BASIC was/is a Microsoft product. If I'm not mistaken (or as lore tells us), the GW-B stands for Gates William Bill. :)
Re:BATAS: 8086 assembler written in MSDOS batch by zoom6628 on Friday December 07, 2018 @08:23PM (#18633231)
This is glorious for its clever use of batch. Like another poster says "mad as badgers".

If you have spare time can you recreate the .Net ILR from batch scripts? :-J

Re:BATAS: 8086 assembler written in MSDOS batch by zamalek on Friday December 07, 2018 @08:13PM (#18633183)
Now we need an LLVM target for this.
Re:BATAS: 8086 assembler written in MSDOS batch by LocalH on Sunday December 09, 2018 @11:19AM (#18641558)
Nice. A more period-accurate name, I think, would have been “BatAss” lmao
Re:BATAS: 8086 assembler written in MSDOS batch by pjmlp on Saturday December 08, 2018 @05:16AM (#18634673)
I would say it is quite ingenious.
Re:BATAS: 8086 assembler written in MSDOS batch by wiz21c on Saturday December 08, 2018 @05:57AM (#18634736)
Obligatory FSF idea : why not start from a blank disk ?
Re:BATAS: 8086 assembler written in MSDOS batch by IcePic on Monday December 10, 2018 @03:03AM (#18646083)
blank as in "no bootblock on it written as a binary blob from a non-free tool" then?
Re:BATAS: 8086 assembler written in MSDOS batch by wiz21c on Tuesday December 18, 2018 @04:25AM (#18705431)
Yeah, I know the limits of the FSF reasoning. Well, what about starting from Silicium and Carbon molecules ? :-)