1. RE: Writing an assembler
- Posted by "mic _" <stabmaster_ at hotmail.com> Feb 21, 2007
- 454 views
Once you've finished the assembler part, have fun writing the linker. That is, if you plan to generate Windows executables (PE) and not just .com files or something like that. I wrote one (in Euphoria) a few years ago and iirc it got pretty ugly (though that could have something to do with the learn-as-you-code strategy I normally apply for my own projects). I couldn't find it in the archives, but it's available here http://www.cyd.liu.se/~micol972/site/nqar2.zip. For added goodness it's all one big source file, but the linker stuff is all the create_*_table and write_*_header/table procedures. >From: Pete Lomax <guest at RapidEuphoria.com> >Reply-To: EUforum at topica.com >To: EUforum at topica.com >Subject: Writing an assembler >Date: Tue, 20 Feb 2007 18:47:03 -0800 > > >posted by: Pete Lomax <petelomax at blueyonder.co.uk> > >Well, I got a mad idea about writing an assembler (one to create exe files) >in Eu. However, tricky stuff like mod r/m aside, there is one point I >really cannot wrap my head around. Suppose you have: > >jz l9 >... >jz l8 >.... >jz l1 >... >l1: >.... >l8: >... >l9: >... >jmp l5 > >Now l9,8,7... are forward references so you'd be wise to assume they will >need a 4-byte offset. Either at l1 or on a second pass, you figure the jz >l1 can be a one-byte offset, which may mean (3rd pass would be OK) that jz >l2 can too. > >My question is how do you keep track of where all these bytes are going to >be? >When you "shrink" jz l1 (or 6), how/when do you modify that final jmp l5? > >I think/hope this is a generic problem-solving question: >How do you 'move' multiple things like this at once? >Or, just being told exactly what info I really need to keep might make 1p >drop. > >I guess a similar question is that if I have say: >"some that some that some that" >and I have {6,16,26}, if I replace "that" with "x", somewhere I shall want >those indexes changed to {6,13,20}. [I may replace instances in any order >and consider that those numbers may be dispersed a bit more, and there may >well be literally many thousands of such inter/independent effects]. > >Hoping for a hint, >Pete > > > >
2. RE: Writing an assembler
- Posted by Robert Craig <rds at RapidEuphoria.com> Feb 21, 2007
- 480 views
- Last edited Feb 22, 2007
mic _ wrote: > Once you've finished the assembler part, have fun writing the linker. That > is, if you plan to generate Windows executables (PE) and not just .com files > > or something like that. I wrote one (in Euphoria) a few years ago and iirc > it got pretty ugly ... After developing the assembler, AES drafted me into fixing some bugs in their extremely complicated home-brew linker, written by a couple of other guys. Conceptually a linker is much simpler than an assembler, but I always recall the comment that I ran into, when I had to fix something in the Logical Section Handler... /* Welcome to the Logical Section Handler. Abandon Hope All Ye Who Enter Here. */ I later learned that "Abandon Hope..." was the inscription at the gates of Hell, according to Dante's Divine Comedy. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com