r/adventofcode • u/Vijfhoek • Dec 09 '20
Upping the Ante [2020 Day 1 (Part 1)] [C64 Assembly] I implemented day 1 part 1 for the Commodore 64!
28
Upvotes
r/adventofcode • u/Vijfhoek • Dec 09 '20
6
u/Vijfhoek Dec 09 '20
As an exercise I implemented AoC day 1, part 1 for the Commodore 64, in Assembly!
I wanted to implement the display and math routines myself, instead of relying on the ones provided by BASIC (which is in fact banked out). While the multiplication routines are currently stolen from a C64 wiki and the divmod routine handcompiled from C code found online, I implemented things like converting the ASCII, decimal input to integers and vice versa for the output, and of course the solution to AoC, myself.
Currently it takes about a second to run, which I'm sure can be much faster but for now I'm really happy that it works at all. Next up is part 2, which will require me to implement 32-bit multiplication to have any hope of calculating the answer...
Code (spoilers, of course), specifically day01.asm.
Should you want to run it, you'll need the entire c64 folder, and the input in rust/inputs/ (yeah, I should move the inputs folder..). It compiles with KickAssembler, and can then be run in VICE. I use the following command line:
kickass main.asm -showmem && x64 main.prg.4
u/daggerdragon Dec 09 '20
Have you seen this year's community fun Gettin' Crafty With It yet? A Commodore 64 definitely counts as "playing with your toys"...
Also, I want pics of said Commodore 64!
2
u/CrazyA99 Dec 15 '20
Mad props! I don't understand how I missed this post for so long. Just did day 1 part 1 in BASIC in Vice. But this is anohter level! Awesome!
2
u/ConfusedSimon Dec 15 '20
Why do I still remember 'JSR $FFD2' to print.
0
u/[deleted] Dec 15 '20
[deleted] — view deleted comment