flashjazzcat #1 Posted January 10, 2010 I realize I might as well say "I'm going to write a program to do the job", but I though I'd ask anyway: are there any utilities which will convert, say, an ATASM source file to MADS, taking care of all the subtle pseudo-op differences, double/single quotes, etc? Such a thing would be intensely useful for someone like myself who has 400K of ATASM source code which needs converting to MADS. Search/replace a possibility but time consuming, fiddly, and prone to errors. Quote Share this post Link to post Share on other sites
Sub(Function(:)) #2 Posted January 10, 2010 I realize I might as well say "I'm going to write a program to do the job", but I though I'd ask anyway: are there any utilities which will convert, say, an ATASM source file to MADS, taking care of all the subtle pseudo-op differences, double/single quotes, etc? Such a thing would be intensely useful for someone like myself who has 400K of ATASM source code which needs converting to MADS. Search/replace a possibility but time consuming, fiddly, and prone to errors. I don't actually know if there is a tool to do this conversion, for these two assemblers anyway. BUT... I had to do something similar way back when I started programming. Converting to Z80 from a previous processor (8088? too long ago). I was introduced to the MS-DOS version of 'sed' by a co-worker. You can find a win32 cli version of this tool in the UnxUtils package on sourceforge. This is basically a text search and replace tool on steroids, and scriptable. If you have not used the tool before and need some help drop me a PM. Quote Share this post Link to post Share on other sites
flashjazzcat #3 Posted January 10, 2010 [quote name=Sub(Function()' date='Sun Jan 10, 2010 7:38 PM' timestamp='1263152305' post='1917160] I don't actually know if there is a tool to do this conversion, for these two assemblers anyway. BUT... I had to do something similar way back when I started programming. Converting to Z80 from a previous processor (8088? too long ago). I was introduced to the MS-DOS version of 'sed' by a co-worker. You can find a win32 cli version of this tool in the UnxUtils package on sourceforge. This is basically a text search and replace tool on steroids, and scriptable. If you have not used the tool before and need some help drop me a PM. Fantastic - thanks for that. It looks as close to what I'm looking for as I'll get. I'll check it out properly tomorrow, and the offer of help is surely appreciated. Quote Share this post Link to post Share on other sites
Urchlay #4 Posted January 10, 2010 (edited) A while back I wrote a messy perl script to convert dasm source code to something atasm, mac65, and/or ca65 can use. Script and man page included in zip file: dasm2atasm.zip It's not really a shining example of great coding style, and it's not 100% perfect, but it does mostly work... I never did get around to converting the other way around (to dasm), and I've never looked at mads at all other than to notice its syntax is pretty weird-looking for someone who learned on mac65 and switched to dasm. Edited January 10, 2010 by Urchlay Quote Share this post Link to post Share on other sites
ivop #5 Posted January 10, 2010 I realize I might as well say "I'm going to write a program to do the job", but I though I'd ask anyway: are there any utilities which will convert, say, an ATASM source file to MADS, taking care of all the subtle pseudo-op differences, double/single quotes, etc? Such a thing would be intensely useful for someone like myself who has 400K of ATASM source code which needs converting to MADS. Search/replace a possibility but time consuming, fiddly, and prone to errors. Once upon a time, in the early nineties, there was this idea to create some sort of meta-assembler format that could represent all the capabilities of all other assemblers around at the time. The idea was to write to- and from-this-format-converters, to minimize the amount of converters needed. For example, there being 10 assemblers, you would need 20 converters, instead of 90, to be able to convert any format to any other format. The from-converters would warn if the target format could not handle a certain feature of the metaformat. I am not exactly sure, but I think there was an article about this on one of the Mega Megazines. The format was called AIF (assembler interchange format). Quote Share this post Link to post Share on other sites
+Allan #6 Posted January 11, 2010 It would be nice if you could add Atari's two assemblers so present source code plus any future source code found could be converted to the other assemblers. Allan Quote Share this post Link to post Share on other sites
flashjazzcat #7 Posted January 11, 2010 A while back I wrote a messy perl script to convert dasm source code to something atasm, mac65, and/or ca65 can use. Script and man page included in zip file: dasm2atasm.zip It's not really a shining example of great coding style, and it's not 100% perfect, but it does mostly work... I never did get around to converting the other way around (to dasm), and I've never looked at mads at all other than to notice its syntax is pretty weird-looking for someone who learned on mac65 and switched to dasm. Great - I'll mess around with this and see if I can adapt it. Thanks. When I wrote my MA65 assembler, I had little experience of MAC/65 and none whatsoever of cross-assemblers. I tried to make the thing as flexible as possible (so that it would accept ".BYTE" as well as "BYTE", etc), but some of the flexibility caused problems later on because I had allowed things like periods in label names, which eventually had to be removed when I ported the code. But it's a shame conventions regarding single/double quotes, periods before pseudo-ops, etc, can't be arrived at. Obviously the extended capabilities of one assembler (especially MADS) won't appear in another, but it's too bad that basic source code using no assembler-specific features can still require a lot of work to translate. Hopefully some of these scripts/tools will partly or wholly solve the problem. Quote Share this post Link to post Share on other sites
Urchlay #8 Posted January 12, 2010 When I wrote my MA65 assembler, I had little experience of MAC/65 and none whatsoever of cross-assemblers. I tried to make the thing as flexible as possible (so that it would accept ".BYTE" as well as "BYTE", etc), but some of the flexibility caused problems later on because I had allowed things like periods in label names, which eventually had to be removed when I ported the code. But it's a shame conventions regarding single/double quotes, periods before pseudo-ops, etc, can't be arrived at. Obviously the extended capabilities of one assembler (especially MADS) won't appear in another, but it's too bad that basic source code using no assembler-specific features can still require a lot of work to translate. For even more fun, look at some ancient KIM or SYM assembly... some of that stuff requires an asterisk to indicate zero page mode (e.g. "LDA *$00" is zero page, "LDA $00" would get assembled as a 3-byte absolute instruction). Really ancient KIM assembly uses LDAZ and STAZ for zero page, LDAI for immediate... Maybe the One True Assembler shouldn't try to automagically support everything... maybe it just needs to be configurable (insane amount of command-line switches, plus a GUI front-end that shows checkboxes). Let's see... Labels can be case-sensitive or not, can optionally be followed by a colon when they're being defined, can contain various weird characters (Atari used to use an assembler that allowed question marks, BOOT? was valid)... ROL/ROR/LSR/ASL accumulator mode can be "ROL A" or just "ROL"... and I suppose in assemblers that don't require the A, someone might use A as a label. The old Compute! "Simple Assembler" didn't allow commas in indexed modes: "LDA 80X" instead of "LDA $80,X"... come to that, it only allowed hex, so the $ wasn't required (or allowed). .BYTE vs. BYTE (also byte, lowercase, and some people like to write stuff like Byte). DASM allows a dot in an expression to mean "current address" (same as asterisk in most other assemblers, lot of 2600 code was written using dot though). Also uses square brackets for grouping: [1+2]*3 Completely incompatible macro systems. Different keywords used to start/end a macro, different capabilities: some are variadic (take variable number of arguments, defaulting missing args to zero), some allow overloading (multiple macros with same name, but different number of arguments), some do neither. Some automatically make labels used inside macros local, some make you start local labels with a dot or something, some don't support local labels at all... Different syntax used for accessing arguments ($1, %1, {1}, but are they 0-based or 1-based, and if 1-based, does the 0th argument indicate the number of args?) I've seen both \ and % used for the modulus operator. As mentioned, single vs. double quotes. Also, do you use "LDA #'A" or "LDA #'A'" to load the ASCII value of the letter A? I've seen one assembler that uses each syntax, plus one that allows either. ATASM supports an "SBYTE" operator, very Atari-specific: it takes a string and assembles it into Atari screen codes instead of ASCII. No easy way to mimic this one on other assemblers, most (all?) macro assemblers don't let you pick apart a string argument and do stuff to the individual characters. *= vs. ORG Also, using either *= or ORG, does the assembler emit an Atari binary load header? MAC/65 and ATASM do, DASM doesn't, not sure about ASM/ED cartridge. CA65 doesn't, but what it does spit out is a funky object file that needs to be linked with LD65 (which will add the binary load header, but IIRC only one of them per file). A vast and bewildering array of pseudo-ops, including .OPT, which does completely different things in different assemblers... Hopefully some of these scripts/tools will partly or wholly solve the problem. Depends on how you define the problem. If the problem is just "I need to be able to assemble this code written for Assembler X, but I only have Assembler Y", scripts can handle most of it (though the scripts haven't all been written yet), plus a bit of manual editing/cleanup. If the problem is "I need to be able to use the same assembler to assemble all code I get from anywhere", that's obviously the harder task (but if you manage to get it working, it'll be impressive). If the problem is "I need a utility that can convert from any 6502 asm syntax to any other", that'd probably be the hardest (actually impossible to make it work 100% of the time: different assemblers have different feature sets). Quote Share this post Link to post Share on other sites
flashjazzcat #9 Posted January 12, 2010 In reality, it's probably a "once only" job, to convert a batch of MA65 and ATASM code across to MADS. None of the code has any macros or opts to worry about: the main job is the basic legwork of getting the quotes, pseudo-ops and label formats right. The most painstaking conversion I ever did was the then 300K of Atari-based MA65 source code for The Last Word. Converting those thousands of lines was done pretty much by hand. The source code was full of inverse characters, label names with periods buried in them, paired single quotes around characters (which ATASM didn't like). It took about two days to get it to compile again. Now, of course, I want to move from ATASM to MADS, although I imagine the process may be less painful than trying to accomplish the reverse. As well as The Last Word, there's a lot of old library code for SpartaDOS X, which might even find its way into CC65 one day. That said, I'm managing OK with ATASM for now. It's surely too big an ask to come up with a converter which parses macro definitions, etc, and pragmatically reconstructs the definitions using the syntax of the new assembler. But a utility which manages to convert all the .BYTEs to BYTE and strips all the "A"s off the implied addressing instructions, etc (or whatever's necessary) would be pretty indispensable for a task like this. I haven't really played with the scripts yet, but I will. The task may not be as involved as I thought, of course. I just converted the source code for a VBXE demo from MADS to ATASM, and as I mentioned already, I think find and replace will have an easier time doing it the other way around. Quote Share this post Link to post Share on other sites