Hallo Besucher, der Thread wurde 11k mal aufgerufen und enthält 95 Antworten

letzter Beitrag von KSimcomal am

Mega Assembler is live on file host

  • Hi Mega65 programmers,


    I uploaded a very first version of Mega Assembler to the file host. If you want a native assembler for experimentation on the Mega65, you might want to give it a try. For now it's a very simple assembler, with only 6502 support plus all instructions that are needed for mapping on the Mega65. Please be aware that I am sure it will contain lots of bugs. Very little testing has happened so far. You've been warned :D


    And yes, it is written in Basic and therefor not the fastest assembler.


    If you find annoying bugs (and you will!) you can post them here. If you include a description of how to reproduce the bug, maybe I'll fix it :whistling:




  • grubi : I've just been playing around with your assembler and I think it's really well done. :thumbup:


    I do have one question: Is it already possible to use assembler programs outside the $1600 range?


    I can compile this tiny test program to $1600 without any problems,




    but not to $4000, for example.





    To illustrate what I mean, here is the short example in BASIC 65.EX:





    Is that not possible in principle, because your BASIC program is in that range, or am I missing something here?


    Is it yet possible to compile the code to bank 4 or 5?

  • Hi Snoopy, thanks for the feedback. You are right, it is not possible yet, but just because the assembler does not switch banks. So in its default mode, it would Poke everything to Bank 128, which is why it works fine in the first 8KB.


    As a workaround, you could just enter BANK 0 (or any other bank) before starting Mega Assembler.


    Long term it might be a good idea if I include a .BANK directive to the assembler so it can be put in the source code.


    To be homest, I haven't thought about this yet because I was so focused to get the assembly part running, so your input is more than welcome.


    But in order to assemble programs into bank 0 where the assembler itself is stored, I have already a few solutions in mind. One would be to assemble to disk, and then being able to load with ,8,1. Another would be to automatically create a Basic header with a sys command. A third option would be to assemble to a different bank, and then program some kind of Swapper that safes Basic, copies the machine code, runs it and then restores the basic program. So many things still to do...

  • I implemented a .BANK assembler directive to set the destination bank for assembly. Default bank is 128, and it can be changed as needed, even several times during assembly, so you can output different parts of the program to different banks and memory locations. When running the program with Mega-R, the bank and adress of the first byte that was written will be used as entry point.


    So for example:

    .BANK 4

    *=$2000

    LDA #1

    STA $800

    RTS


    BANK 4:SYS 8192


    works now.


    I will release this version along with a couple of other changes that I have in mind, probably in a couple of days, depending on how much time I find. You know, I have family, a job and other hobbies as well... ;)

  • I uploaded version 0.1.2 of Mega Assembler to the file host. It adds the .BANK directive so you can now use any memory bank of the Mega65 for your programs (see comment above), plus the ability to write the machine code output to a file, so you can load and run your programs later without having to assemble them again (set your bank, then load with ,8,1 or use the new BLOAD command).


    The new .BASIC directive automatically saves a Basic version of your assembler program to disk, so you can just load and run it like you would any Basic program.


    Documentation is included in the built-in help feature, plus I created some examples how to use the new features. They are included on the disk.

  • Documentation is included in the built-in help feature, plus I created some examples how to use the new features. They are included on the disk.

    Just a hint for the docs: E.g. in the BANK example you can also use a shorter SYS $44000 for running the assembled program from BASIC instead of BANK 4:SYS $4000. But of course both versions work! ;)

  • Just a hint for the docs: E.g. in the BANK example you can also use a shorter SYS $44000 for running the assembled program from BASIC instead of BANK 4:SYS $4000. But of course both versions work! ;)

    Thanks, I didn't know this :thumbup:

    Learning new things every day. Love it :D


    Edit: I assume I can't run a program in Bank 0 in the same way with SYS $0xxxx, right?

    Edit2: Just tried it out, indeed I can't. For bank 0 I need to issue a BANK 0 command first. So the SYS method is not universal.


    Updated the docs accordingly, will upload with the next version of MA.

  • I assume I can't run a program in Bank 0 in the same way with SYS $0xxxx, right?

    No, that doesn't work, I assume for compatibility reasons.


    If you use an address <= $FFFF the SYS command used the value which was set with a former BANK command.



    So a SYS $04000 doesn't start the program at $4000 in bank 0, but the program at $4000 in the last set bank.

  • Yeah, reding the docs helps. While looking at this, it seems it would be a good idea to update the default assembly destination adress from $1600 to $1800 :whistling:


    I use defaults for everything because I had the idea that Mega Assembler should be super accessible, i.e. you can simply start typing in assembler instructions and then assemble and run the program, to experiment and try out little things. No need to save your file either. If you want to get more sophisticated, your can then use your own values for bank, adress, filename etc.


    So for example, run Mega Assembler, type in: (with at least one leading space per line)

    Code
    1. INC $D020
    2. RTS

    Press Mega-A, any key, Mega-R, and.... Voila!

  • I agree that would be nice. However it's low on my priority list, since you simply can DIR the disk before you run Mega Assembler, then you have to remember only the name of the one file you want to load.


    On the other hand, it would be a nice opportunity to put the contents of our recent community book "65000 ways to display the directory on your MEGA65" to action :D


    Update: Alright, since it was so easy to do, it's already implemented. It will be out with the next version. Press Mega-D to display a directory with all .ASM files. :D

    I mean, it was simply a DIR "*.ASM",W then wait for a key...

    Now please don't tell me you want to browse the directory and select the file to load :argue

  • I uploaded a new version of Mega Assembler to the file host. Here is the changelog:


    5.6.2022 New Version 0.2.0 with full support for 4510 CPU of C65!


    For changes see CHANGELOG.ASM (open in Mega Assembler):

    - Default destination adress for assembly has been changed to $1800

    - Press Mega-D to display a directory of all .ASM files on disk

    - Explicit accumulator adressing mode can now be used optionally, e.g. "ASL" and "ASL A" are equivalent

    - Target CPU output can now be specified with the new .6502, .4510 and .45GS02 directives

    - All 4510 CPU instructions and adressing modes have been added

    - Allow to force 16 bit branches using "!", e.g. "BEQ !<label>". Note: 16 bit branches will not be used automatically by the assembler, but you will get an error if an 8 bit branch is out of range

    - Maximum number of lines in editor increased to 2000

    - Added the ability to return to the editor from Basic with "GOTO 99", in case CONT is not available

    - Assembly can now be aborted by pressing ESC

    - Added the ability to pause or abort assembly when errors occur, so error messages from longer programs can be read

    - The save function is now unavailable when the editor is empty, to prevent accidentally overwriting a program by mixing up Mega-L with Mega-S on startup

    - Added "4510.ASM" to demo the new 4510 instructions

  • Version 1.0.0 is now available and ready to download. Now supports full instruction set of the 45GS02 CPU of the MEGA65, including 32-bit virtual register and flat memory access to the ATTIC RAM!


    Changes in version 1.0.0 Released 11 JUN 2022


    - This is the first "complete" version of Mega Assembler! Please report any bugs you discover

    - Added full support for 45GS02 processor of the MEGA65

    - Implemented .45GS02 target mode directive

    - 45GS02 CPU target is now default

    - Added 45GS02 style flat-memory access for z-indexed adressing using square brackets, e.g. LDA [$80],Z

    - Added support for 45GS02 virtual 32 bit register (Q pseudo register)

    - Q pseudo register adressing mode can now be explicitly specified, for example "ASLQ Q" and "ASLQ" are equivalent

    - Added ESC-Q to editor to delete all characters from cursor to end of line

    - Added the .PAUSE directive, so you can pause assembly during pass 2 at specific lines to take a look at the listing

    - Added the ability to highlight comments in the listing by using ;;

    - Added the ability to run a program immediately after successful assembly by pressing R without having to return to the editor first

    - Added "45GS02.ASM" to demo the new 45GS02 instructions


    Have fun :D