Frant's Amiga 68K assembler adventures
Page 1 of 1
Frant
King's Bounty



Posts: 24433
Location: Your Mom
PostPosted: Fri, 16th Aug 2024 08:05    Post subject: Frant's Amiga 68K assembler adventures
Part 1:

So I felt the urge to really get back into 68K assembler on the Amiga and this time stick with it.

I haven't done any real programming on the Amiga since 1994. I've made 2-3 attempts to get into it again the last couple of years but then forgot about it (truth: gave up after an hour).

I really believed that it would all come back to me almost instantly as I started. Oh how wrong I was. I remember the basics of it but I soon realized I had forgotten a TON of important things like various addressing variations, advanced use of registers and a lot that's needed to actually write useful code.

I created a disk with AsmTwo, the best assembler for OG Amiga coding IMHO, this particular version based on AsmOne, focusing on pure A500 68000 OCS/ECS assembly for effectiveness and saving a lot of RAM for actual code.

So I downloaded a startup sample source code from an online assembler course to get me started. A startup routine sets up everything needed for demo coding including turning off most of the OS, system interrupts etc. which gives me full control of the system and RAM.

Let's just say that the sample startup source code is 75% gibberish to me. Granted, it was written by a very skilled and advanced demo coder from a group called Scoopex which explains the dense and complex (for me) code he wrote.
(link to the page: Coppershade

I started AsmTwo, reserved 100KB chipmem for code and data and loaded "PhotonsMiniStartup.S" and was presented with this:



It was mainly me going "huh? what's that? what's he doing? how..?". I recognized all the mnemonics like move.*, bne/bra, lea, add etc. but the addressing modes of registers, jumps and branching was just gibberish to me.

I realised I had to go simple and re-learn a lot of the basic stuff before being able to follow more advanced code. I guess that's what happens when you haven't programmed in ~30 years. So I decided to write the simplest program I could think of:

Code:

loop:
   add.w #$0001, $dff180   ; add 1 to the background color register
   btst #6, $bfe001            ; is the left mouse button tested?
   bne loop                        ; no? goto loop
   rts                                 ; otherwise return to assembler/os


That obviously worked since it's one of the most simple things you can do in assembler. No setup, no initialization of various system components (except for testing the mouse button), no calls to the operating system etc.

Now I have to take the next step re-learning my old hobby.


Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!

"Thank you to God for making me an Atheist" - Ricky Gervais
Back to top
iconized




Posts: 4059
Location: Pays-Bas
PostPosted: Fri, 16th Aug 2024 09:01    Post subject:
Good luck! Smile
Back to top
Ankh




Posts: 23226
Location: Trelleborg
PostPosted: Fri, 16th Aug 2024 09:43    Post subject:
Keep us updated!


shitloads of new stuff in my pc. Cant keep track of it all.
Back to top
LeoNatan
Banned



Posts: 73193
Location: Ramat Gan, Israel 🇮🇱
PostPosted: Fri, 16th Aug 2024 14:47    Post subject:
Any reason to go with direct assembly and not with C and something like https://github.com/bebbo/amiga-gcc ?

I understand if it’s for nostalgia purposes and you want to relive the experiences you had when your were writing the assembly yourself. But if the source of your hunger is making actual software, it is more than likely that a modern compiler will produce a more optimized binary than you would, and your velocity is likely to skyrocket.
Back to top
Frant
King's Bounty



Posts: 24433
Location: Your Mom
PostPosted: Fri, 16th Aug 2024 17:55    Post subject:
Nah, I'm only doing it for fun, not for productivity. It's partly because of nostalgia but also a way to stimulate my brain.

The goal is to make an intro or a demo at some point. Pure assembler is fun on Amiga. I have total control over everything in the machine and the mindset of programming in assembler on the Amiga is quite rewarding (at least when you get something to work).

Assembler on the Amiga is the most efficient language for games, demos, intros etc. Most games were written in 68K assembler for that very reason.


Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!

"Thank you to God for making me an Atheist" - Ricky Gervais
Back to top
Nalo
nothing



Posts: 13437

PostPosted: Fri, 6th Dec 2024 18:42    Post subject:
Bump. Update?
Back to top
Frant
King's Bounty



Posts: 24433
Location: Your Mom
PostPosted: Fri, 6th Dec 2024 19:45    Post subject:
Been slow going. I've been trying to find a good commented startup/init code example so I can write my own. I don't want to copy someone else's code, I want to understand every part of it.

Addressing modes are many and complex; the macro assembler I'm using have different syntaxes for various things that I have to learn to be able to code like I used back in the day when I used a different (and clunkier) assembler (SEKA).

I need to dig up my old Amiga Hardware Reference manual but I have no idea where it is. A proper startup/init routine can be quite complex with many hardware registers to manipulate in order to turn off the OS, take control of all interrupts etc. etc. etc.

I looked at Photon from Scoopex example but he's written a massive startup/init source that covers everything and is divided into a wrapper and the exhaustive init source.

The easiest thing would be to copy the startup/init code from one of my early 90'ies source codes but I often wrote spaghetti code back in the day to get to the actual meat of the project and thus they're sloppy, have low compatibility with expansions/later CPU's/later OS revisions and so on. In other words it's not really usable for what I want to do.

I need to sort out that initial speed bump, find my hardware reference manual, check out some of my old source codes to see how I did things.

"I'll be back!"


Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!

"Thank you to God for making me an Atheist" - Ricky Gervais
Back to top
Ankh




Posts: 23226
Location: Trelleborg
PostPosted: Fri, 6th Dec 2024 22:21    Post subject:
Frant wrote:
Been slow going. I've been trying to find a good commented startup/init code example so I can write my own. I don't want to copy someone else's code, I want to understand every part of it.

Addressing modes are many and complex; the macro assembler I'm using have different syntaxes for various things that I have to learn to be able to code like I used back in the day when I used a different (and clunkier) assembler (SEKA).

I need to dig up my old Amiga Hardware Reference manual but I have no idea where it is. A proper startup/init routine can be quite complex with many hardware registers to manipulate in order to turn off the OS, take control of all interrupts etc. etc. etc.

I looked at Photon from Scoopex example but he's written a massive startup/init source that covers everything and is divided into a wrapper and the exhaustive init source.

The easiest thing would be to copy the startup/init code from one of my early 90'ies source codes but I often wrote spaghetti code back in the day to get to the actual meat of the project and thus they're sloppy, have low compatibility with expansions/later CPU's/later OS revisions and so on. In other words it's not really usable for what I want to do.

I need to sort out that initial speed bump, find my hardware reference manual, check out some of my old source codes to see how I did things.

"I'll be back!"


https://archive.org/details/amiga-hardware-reference-manual-3rd-edition

Smile


shitloads of new stuff in my pc. Cant keep track of it all.
Back to top
Frant
King's Bounty



Posts: 24433
Location: Your Mom
PostPosted: Sat, 7th Dec 2024 22:16    Post subject:
Thanks. I prefer paper books that I can have next to me when I code. I'll find my HRM. I know in which room it is, I just have to look through stuff.


I think I've found a really good example of a startup routine. Every single line is commented which makes it a lot easier to understand.

https://bumbershootsoft.wordpress.com/2024/08/10/amiga-500-bare-metal-startup-code/


Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!

"Thank you to God for making me an Atheist" - Ricky Gervais
Back to top
Page 1 of 1 All times are GMT + 1 Hour
NFOHump.com Forum Index - Programmers Corner
Signature/Avatar nuking: none (can be changed in your profile)  


Display posts from previous:   

Jump to:  
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 vote in polls in this forum


Powered by phpBB 2.0.8 © 2001, 2002 phpBB Group