6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Apr 27, 2024 12:53 pm

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Sun Dec 03, 2023 3:05 am 
Offline

Joined: Sat Oct 09, 2021 11:21 am
Posts: 703
Location: Texas
Well, I won't say it's the best thing ever but here's something new (for me):

First is the Assembler.cpp. What is it? It's an assembler for the '816, but with my own flavor added I guess. I am not following a lot of standard conventions here, but it works pretty well and has some cool features that I find helpful. It's not 100% tested out and probably has a bug or two, but as of now it seems to be working great!

Second is an example code for it, my Bootloader + Mini-Monitor. It fits in 512 bytes, and includes all that's necessarily for booting from a PIC + SD card, and in case that doesn't work, a 'rescue' mini-monitor that barely is usable at all. This would actually work with any of my current boards, given that I'm using a VIA for the PS/2 Keyboard and have bitmap style graphics somewhere directly accessible in memory. The 512 bytes contains all of the character bitmap data along with PS/2 to "hex" conversion tables. The monitor itself only displays zero page, but you can navigate around it using space, backspace, and return.

The C++ code isn't well commented, but the ASM code is pretty heavily commented. I'm also adding a screenshot of what my mini-monitor looks like from my old Acolyte Simulator. The characters are SUPER tiny so that I can fit everything in memory. The inverted character is where your 'cursor' is, and you can either alter it or move the cursor. You can run the code from the top of zero page by pressing escape.

An odd little thing indeed. It was this, or text-based Tetris. :/ What do you use as a 'rescue' monitor? A last ditch effort in case all else fails?

I went looking through the lists of '816 assemblers, but have been unimpressed. Maybe I didn't look into them well enough. What '816 assembler do you use? What do you like about it? What do you not like about it?

Thanks everyone!

Chad


Attachments:
MiniMonitorScreenshot.png
MiniMonitorScreenshot.png [ 2.4 KiB | Viewed 1711 times ]
Assembler.cpp [30.74 KiB]
Downloaded 23 times
MiniMonitor.asm [8.8 KiB]
Downloaded 23 times
Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 03, 2023 4:31 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8428
Location: Southern California
sburrow wrote:
I went looking through the lists of '816 assemblers, but have been unimpressed. Maybe I didn't look into them well enough. What '816 assembler do you use? What do you like about it? What do you not like about it?

Did you look at the list of assemblers on my links page? http://wilsonminesco.com/links.html#assem

I use Cross-32 (C32 for short), originally from Universal Cross Assemblers in Canada, later sold by Data Sync Engineering and MPE Forth, but now Data Sync Engineering's site is gone and MPE Forth no longer has C32 on their site and I've been trying to get a response about where someone can get it, or whether I can distribute it myself, not to make any money but just to keep a good thing going.

C32 is a great macro assembler that comes with the files to work for dozens of different processors, and the manual tells you how to write the files for a processor of your own design.  It says it's about a 40-hour job to adapt it to a new processor.  For the '816, something I really like about it is that for immediate operands, you specify the size, whether 8- or 16-bit (like LDA #foobar for 16-bit, or LDA #<foobar for 8-bit), which has two advantages:  1.) it keeps you mindful of what size you're dealing with, and 2.) you can write a routine knowing it will always be called with the accumulator and the index registers a certain size, and not waste unnecessary REP and SEP instructions like other assemblers require just so the assembler knows how big an operand to lay down.  One bug I have found in it, after decades of use, is that a comma in a quoted string in a macro parameter line makes it think it's a delimiter to the next macro parameter, even though the closing quote mark has not been reached yet.  Another is that INCLude files in a macro's definition don't get included until the macro is finished.  Hopefully these bugs were fixed after I got the version I'm using.  One feature I liked in the 2500AD assembler that I wish were also in C32 is that 2500AD allowed you have a varying number of macro parameters, and then in the conditional assembly in the macro, use the directive IFMA followed by a number, which says, in essence, "If a 4th parameter exists, do this with it...If a 5th macro parameter exists, do this with it..."  A nice C32 feature that 2500AD lacked was a bit-wise OR of a couple of values and put the result in the operand for an LDA # for example.

Edit, after others' comments below about linkers:  The 2500AD assembler used a linker.  The other engineer in the company, who chose the assembler and put in the requisition for it, had a lot of trouble getting the linker working.  Myself, I never understood it either, and only used commands he came up with with the help of 2500AD's technical-help people, and then I used those as a template and only changed file names in those commands for later applications.  C32 doesn't have that complication.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 03, 2023 7:19 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8144
Location: Midwestern USA
sburrow wrote:
The C++ code isn’t well commented...

Understatement of the month...and it’s only December 3.  :D

Quote:
What do you use as a ’rescue’ monitor?  A last ditch effort in case all else fails?

All my POC units have Supermon 816 embedded in the firmware.  If mass storage can’t be accessed or if an OS can’t be loaded from the boot disk, control automatically drops into the monitor.

Quote:
I went looking through the lists of ’816 assemblers, but have been unimpressed.  Maybe I didn’t look into them well enough.

For which operating system?

Quote:
What ’816 assembler do you use?

I use the Kowalski editor/assembler as modified by Daryl Rictor to handle 65C816 assembly language.

Quote:
What do you like about it?

It works well, has a good macro language, programs can be assembled from within the editor and assembly is fast.  It can assemble my partition editor program, which has over 30,000 lines of source, in about one second, running on my rickety Windows XP box.

Quote:
What do you not like about it?

It runs on Windows.  :evil:

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 03, 2023 7:31 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
I have in mind to assemble some tiny snippets of '816 code, and I plan to use BBC Basic as a native assembler - I believe the version for the Acorn Communicator should be usable, as disassembled by dominicbeesley.

I haven't used either of these, but two '816 assemblers are tagged on github: Rsar in Rust, and HIEPA in python.


Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 03, 2023 9:29 am 
Offline

Joined: Thu Mar 03, 2011 5:56 pm
Posts: 277
BigEd wrote:
I have in mind to assemble some tiny snippets of '816 code, and I plan to use BBC Basic as a native assembler - I believe the version for the Acorn Communicator should be usable, as disassembled by dominicbeesley.

I haven't used either of these, but two '816 assemblers are tagged on github: Rsar in Rust, and HIEPA in python.


The C256Foenix project uses 64tass (https://github.com/irmen/64tass) for the 65816 variants (and possibly also the 65c02 versions).

Communicator Basic has been on my radar for a while; I've been thinking about porting it to the C256Foenix (FMX), but I'm too easily distracted by other shiny things.


Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 03, 2023 11:58 am 
Offline

Joined: Sat Oct 09, 2021 11:21 am
Posts: 703
Location: Texas
GARTHWILSON wrote:
Did you look at the list of assemblers on my links page? http://wilsonminesco.com/links.html#assem


I did not, I looked at the list on this 6502.org website. I see a lot of the same ones mentioned, but I'll look again, thank you.

GARTHWILSON wrote:
(like LDA #foobar for 16-bit, or LDA #<foobar for 8-bit)


Oh that is easy to implement! Cool, I like it. Thanks for the idea. Right now my assembler only works in 8-bit mode, though native/emulator is supported (I believe?).

BigDumbDinosaur wrote:
Quote:
sburrow wrote:
The C++ code isn’t well commented...

Understatement of the month...and it’s only December 3. :D


Haha! Well, I did essentially write it all from scratch in one day. This was my third attempt, and I find it easier to just start over than try to modify older junk. This one is MUCH improved over my previous versions. But because I code so fast I don't often leave comments.

BigDumbDinosaur wrote:
For which operating system?


Linux of course. I opened the file you posted, and saw an .exe in there and stopped... "Uh, BDD, what the heck?" Then I scrolled down and, "Oh! He *said* it was for Windows. Haha!"

BigEd wrote:
and HIEPA in python.


I like that one so far. Thank you!

rwiker wrote:
The C256Foenix project uses 64tass


I looked at that, and the set of files is overwhelming. I'm sure it's super fancy, but wow, I feel like mine is working fine so jumping into a huge thing like that isn't worth my time to learn it. Still, thank you.

By the way, I'm planning on using a PIC + SD card bootloader configuration, similar to Garth's: viewtopic.php?p=91876#p91876 The difference between Garth's and mine would be he is using the I2C module for mass storage while I'm using an SD card, aside from that it's pretty similar in concept. I think he is also planning on using the PIC to 'spoon feed' the '816 with whatever memory it needs, while I will 'spoon feed' this 512 bytes and then wait for the '816 to ask for SD card memory.

Thanks everyone!

Chad


Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 03, 2023 2:28 pm 
Offline

Joined: Tue Jul 05, 2005 7:08 pm
Posts: 990
Location: near Heidelberg, Germany
Let me add xa65 to the mix of 816 cross assemblers.

_________________
Author of the GeckOS multitasking operating system, the usb65 stack, designer of the Micro-PET and many more 6502 content: http://6502.org/users/andre/


Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 03, 2023 3:04 pm 
Offline
User avatar

Joined: Fri Aug 03, 2018 8:52 am
Posts: 745
Location: Germany
kinda surprised the C256Foenix doesn't use Calypsi C's Assembler as the compiler suite has a built-in target for the C256Foenix, so i thought they would just fully switch to that.

anyways, skimming through the code i notice a few things.

you already mentioned the lack of comments but i've also spotted some consistently inconsistent whitespace between operators. what i mean is that specifically in for loop initiations you don't place any whitespace characters between operators (example: "i=0") but almost everywhere else you do add whitespace (example: "value = 0"). personally i would always recommend having whitespace characters between operators for readability sake.

I'm also somewhat questioning the choice of using a giant 16MB array to hold the generated code instead of either a tmporary file or a dynamic array that is only roughly as large as it needs to be.

besides that and some long if-else chains that could be replaced by switch statements, and other more minor details, it looks pretty clean.

sburrow wrote:
Linux of course

i mean that's what MSYS2 is for nowadays. as long as someone doesn't use functions that are too POSIX-y or too Windows-y, a program will very likely compile and run fine on both OSes. especially true for programs that don't go far beyond the standard C libraries.


Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 03, 2023 4:29 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1398
Location: Scotland
sburrow wrote:

I went looking through the lists of '816 assemblers, but have been unimpressed. Maybe I didn't look into them well enough. What '816 assembler do you use? What do you like about it? What do you not like about it?

Thanks everyone!

Chad


I use ca65 from the cc65 suite to assembler 6502, 65C02 and 65C816 stuff. I like the way it works with separate modules & linker as that's the same as i've been using for a good few decades now (under Unix/Linux). It supports good, flexible macros and I can drive it from the command-line and use my own editors/Makefiles...

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 03, 2023 6:23 pm 
Offline

Joined: Tue Dec 03, 2019 11:39 am
Posts: 8
sburrow wrote:
I went looking through the lists of '816 assemblers, but have been unimpressed. Maybe I didn't look into them well enough. What '816 assembler do you use? What do you like about it? What do you not like about it?

I use a homemade assembler with the concept from Table Assembler (external CPU instruction definitions) and basic assembly directives from 64tass and ca65. It's slower than most assemblers but it works.


Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 03, 2023 8:14 pm 
Offline

Joined: Sat Oct 09, 2021 11:21 am
Posts: 703
Location: Texas
Proxy wrote:
you already mentioned the lack of comments but i've also spotted some consistently inconsistent whitespace between operators. what i mean is that specifically in for loop initiations you don't place any whitespace characters between operators (example: "i=0") but almost everywhere else you do add whitespace (example: "value = 0"). personally i would always recommend having whitespace characters between operators for readability sake.

I'm also somewhat questioning the choice of using a giant 16MB array to hold the generated code instead of either a tmporary file or a dynamic array that is only roughly as large as it needs to be.

besides that and some long if-else chains that could be replaced by switch statements, and other more minor details, it looks pretty clean.


It's clean because it was written in a single day :) I like to use whitespace normally, but inside for-loop constraints I do not. Sometimes I keep things without whitespace to show 'togetherness', like (var1 * var2 * (var3+1)), it kind of 'groups' things better in my eyes. The 16MB of RAM was super easy to use, and all PC's I know of have that much to spare so to me it's a huge waste but perfectly fine. Lastly, I do use switch statements but only sparingly. I actually dislike them for general use because of the blocking { } and the 'break's needed. I'm ok with blocking, and I'm ok with 'break'ing from a loop, but I don't like blocking and 'break'ing when not in a loop. Switch statements have their uses, but just not here apparently.

Off topic, I find programming like art. It's like I'm painting a picture. Sometimes I want to use this particular stroke, this particular brush, this particular pigment, this particular oil-base. My last two versions were more 'modular' with a lot of sub-functions. This one was like 2 functions outside of main(), which is just hilarious but totally fine. When I program with data at work, I use classes (read: fancy structs) all the time, but only because it's easy to use pointers as records.

Thanks for the programming analysis! :D

fachat wrote:
Let me add xa65 to the mix of 816 cross assemblers.


drogon wrote:
I use ca65 from the cc65 suite to assembler 6502, 65C02 and 65C816 stuff.


Thank you for the suggestions.

beethead wrote:
I use a homemade assembler with the concept from Table Assembler


Sweet! That makes 1.5 of us (I'm only 0.5 at this point I suppose).

Thanks everyone.

Chad


Top
 Profile  
Reply with quote  
PostPosted: Wed Dec 27, 2023 6:21 pm 
Offline

Joined: Wed Nov 04, 2015 11:10 am
Posts: 51
Hi folks, I used CA65 myself a while ago. I'm programming for a VIC 20. I have to figure it out again, it's been so long. I will figure it out again. I can assemble but I can link going by my notes. It's a good assembler.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: