File based Assembler

User avatar
desertfish
Posts: 1096
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

File based Assembler

Post by desertfish »

A file based assembler: it assembles from source files on the disk and saves the resulting program to disk as well.
This allows to assemble large files that can be conveniently edited too as normal text files, and allows to assemble to memory locations that would be problematic otherwise as well. (such as when it would overwrite the assembler program itself)

The source code and a description of the features is on github.

To run the internal self-test you'll need to copy the two TEST-* files from the 'test' directory on github to the x16 disk drive as well.

Screenshot_20230119_000257.png
Screenshot_20230119_000257.png (92.24 KiB) Viewed 21182 times
Attachments
assembler.prg
(16.27 KiB) Downloaded 329 times
Last edited by desertfish on Tue Apr 02, 2024 8:38 pm, edited 5 times in total.
voidstar
Posts: 494
Joined: Thu Apr 15, 2021 8:05 am

Re: File based Assembler

Post by voidstar »

Hey this is pretty neat and still seems to work on R44.

What would we call the assembler syntax that this supports? (same as 64tasm?)

The sample all-opcodes program created the PRG, but running it quickly just dumps into the monitor - maybe that's expected at the end of its run time?

Can I get a smaller example - like, just increment/count a memory region, show the content, and loop?
User avatar
desertfish
Posts: 1096
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Re: File based Assembler

Post by desertfish »

Yeah I guess it is turboassembler inspired syntax indeed.

It is correct that yhe test all opcodes assembly file is not meant to produce a runnable program, it simply is a sequence of all instructions.

Finally here is an example hello world program that you can type into the editor and assemble:

* = $9000 CHROUT = $FFD2 START JSR PRINTMESSAGE RTS PRINTMESSAGE: LDY #$00 LOOP: LDA MESSAGE,Y BEQ EXIT JSR CHROUT INY BNE LOOP EXIT: RTS MESSAGE: .STRZ "hELLO wORLD!"


Notice that the assembler was already capable to detect a rom-based X16Edit, so when you run a very recent rom.bin you can profit from this even without having to build your own rom.
voidstar
Posts: 494
Joined: Thu Apr 15, 2021 8:05 am

Re: File based Assembler

Post by voidstar »

Excellent!!!

Thank You

(ah you updated screen shot already)
User avatar
desertfish
Posts: 1096
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Re: File based Assembler

Post by desertfish »

Updated the ASSEMBLER.PRG with a non-ancient version.
Christophlex
Posts: 2
Joined: Wed Nov 01, 2023 2:43 pm

Re: File based Assembler

Post by Christophlex »

Fantastic. I just got back into x86 assembly after decades away, and this has been perfect.

One question: Is it possible to declare a bunch of bytes easily? As it is now, if I wanted to declare 4 bytes, I could do:

.BYTE $01,$02,$03,$04

Are there any directives that will do a .BYTE(x) = 0. That is, create x number of bytes, and initialize them to zero? Or not even initialize them at all.

Thanks!
User avatar
desertfish
Posts: 1096
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Re: File based Assembler

Post by desertfish »

Christophlex
Posts: 2
Joined: Wed Nov 01, 2023 2:43 pm

Re: File based Assembler

Post by Christophlex »

Thanks for getting back to me. Yes, I'm using .byte just fine, but let's say I wanted to create 64 bytes, but I don't have values immediately to populate them with. I could .byte $00,$00,$00,$00,$00... 64, but I wanted to know if there was a way to use it to create 64 bytes (or any number) without having to populate them.

Thanks!
User avatar
desertfish
Posts: 1096
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Re: File based Assembler

Post by desertfish »

Oh, I see what you mean. No there's no .fill (or something like that) yet. I could add that pretty easily I think.
User avatar
desertfish
Posts: 1096
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Re: File based Assembler

Post by desertfish »

Updated with a fix for the X16Edit character set issue , and now recognises ".org $xxxx" as an alternative to "* = $xxxx" to change the program counter.
Post Reply