How to compile .MAC files and command line options

Por mtini

Master (142)

imagem de mtini

31-07-2019, 00:57

Can anyone tell me if with the program "sjasmplus" I can compile files with the extension .MAC?

And if so, what would be the command line to perform the compilation?


Entrar ou registrar-se para comentar

Por alexito

Paladin (761)

imagem de alexito

31-07-2019, 12:29

I have included my work adapting .MAC and SIC.ROM (COLECOVISION GAME ROM) to compile successfully via my old Z80 compiler from PSYQ (that mean you'll need to work with DOSBOX on Modern PC computers)

Good Luck.

PS: Just be careful using U.BAT before you understand the whole thing.

Por Ped7g

Expert (67)

imagem de Ped7g

30-01-2020, 10:35

(disclaimer: I know nothing about MAC files, and Colecovision ROM requirements, but it seems like regular Z80 CPU with simple ROM+RAM, i.e. sjasmplus should be enough to write SW for Colecovision, but I would need to learn about specifics to provide some working example ... and if you are after porting Colecovision ROM to MSX, then this should be still similar case from the assembling point of view, but may involve more effort on the source to do the conversion - but that's not assembler-specific part of the task)

Is .MAC Z80 assembler source?

If yes, then the command line is `sjasmplus your_file.mac`, but that will probably not store the output anywhere if the source file is not aware of sjasmplus directives for output control.

Also this may or may not work depending on the Z80 assembler syntax dialect, as I believe the MAC files are designed for different assembler, but most of the Z80 dialects are very similar (sjasmplus has medium-relaxed syntax and may work with MAC files). Whatever assembler-specific directives are used in the source, those may need complete rewrite to achieve the same task with sjasmplus directives (unless they are compatible, like for example "incbin" or "org").

About output: If the source does produce raw binary stream of machine code, then you can do even without any modification `sjasmplus x.mac --raw=output.bin`. If the source does do some `org` things and position things in memory and you want to store specific region of memory into final binary (like creating ROM file), you may try one of `device` options, even if your device is not directly supported, if it's for example regular Z80 address space without any banking, using `DEVICE ZXSPECTRUM48` at beginning of source is enough to have full 64kiB address space available. Then you position any machine code in the virtual device memory as needed (by ORG), and finally dump any region of memory with `savebin` into some binary file.

About command line options for sjasmplus - see docs for all options for z00m's branch of sjasmplus (v1.14.5 to be released today), by default for my own projects I prefer to use: --syntax=abfw --msg=war --lst --lstlab --nologo --fullpath
I usually use Makefile and GNU make to build my projects, so once I settle down on the particular options for the project, I have the build rules stored in the Makefile (and execute make from the Kate editor with build-plugin).

If you are new to this, and you have someones project with MAC files, there's very likely suggested way of building the project (probably using different assembler) - in ideal case make sure you are able to follow the original path first and everything works. Then you can try to experiment with sjasmplus and see if it leads somewhere (if you get eventually binary from sjasmplus, you can binary-compare it with the original working file to be sure the result is identical - this way I did help with one MSX project to migrate from tniasm to sjasmplus, the binary comparison helping me to catch subtle syntax differences where sjasmplus in default config was producing somewhat different machine code)

Without showing the particular project files it is difficult to be more specific with the help, sjasmplus is assembler, so hypothetically you can produce any binary file with it, even x86 win32/pe executable (if you use only "db" statements and write whole file byte by byte in the "source" - does not make any sense, and is highly impractical, but *possible*), so it's not about if it's possible, but whether it makes sense and is practical, and how much extra effort it will take.

Por Dolphin101546015

Champion (336)

imagem de Dolphin101546015

16-02-2020, 06:17

.MAC is extention what mean z80 MASM


Enlighted (6067)

imagem de NYYRIKKI

16-02-2020, 13:15

.MAC files are meant to be compiled with Microsoft M80 macro assembler. If the source is not very big and complex, you can edit it to compile also on sjasmplus, but it definitely takes some manual work since the macros, compiler definitions and such work quite differently...

You can run M80 also on modern PC's by using some commandline CP/M emulator. Although M80 is really great assembler with many advanced features (especially considering how old it is!), it is not the most intuitive to use. You also have to use L80 linker to produce the final binary due to oldskool ideology that you can put together single binary using routines from different programming languages.

For some practical tips about how to setup the compiler environment, please see the posts end of this page forward:

Por TomXP411

Supporter (8)

imagem de TomXP411

24-02-2020, 21:18

Just as a note - you don't compile assembly code. You assemble it.

Unlike C and other languages, converting Assembly to machine code is a 1:1 process, with one line of assembly producing one opcode and its operators. Where a prints() call will generate 5 or so lines of assembly output, one line of assembly generates exactly one opcode (plus its operands) of machine code output.

So compiling is actually the process of turning high level language (ie: prints("hello")) into assembly code, which is then turned into machine code by assembling it. While some compilers skip the discrete assembly step and go direct to machine code, many of the compilers - especially ones from the Z80 days - actually produce an assembly file, which is then piped through an assembler as a separate step. In fact, at least one compiler I use actually requires a separate assembler, or it can't generate object files.

I know it's a fine point, but as you delve into the world of programming, those fine points can make a huge difference at times. =)