Beginner 6502 Assembly Stuff

Post Reply
gavinhaslehurst
Posts: 47
Joined: Thu Jan 07, 2021 11:37 am

Beginner 6502 Assembly Stuff

Post by gavinhaslehurst »


*** THIS FILE IS ALSO NOW IN THE DEMO SECTION TO ENABLE THE "TRY IT NOW" FEATURE ***




This may be of interest to absolute 6502 assembly beginners like me, although advanced 6502 programmers may cringe at the way I've done things here! This program does very little, but it is a repository of useful assembly routines for things like printing different bytes of memory (useful for debugging) as well as some basic math operations. I will keep adding to this as I progress through my assembly journey (I'm aiming to write my fractal BASIC programs in assembly).




Thanks to the following YouTubers for their excellent tutorials on all things 6502: 




Ben Eater - YouTube




Matt Heffernan - YouTube




ChibiAkumas - YouTube (and also his excellent website: Assembly Tutorials: Learn 6502 Assembly Programming... With ChibiAkumas!)




Function usage: (notation for cc65 assembler)




   jsr print

.byte (list of PETSCII character codes to print, ending in a $0 byte)




   jsr println

.byte (list of PETSCII character codes to print, ending in a $0 byte)




   jsr print_mem

.word (start address of memory dump)




Set MEMDUMPLEN to the number of addresses you wish print_mem to display. 



Updated to include 16-bit data handling, including: 




   jsr neg_16




Negate a 16 bit number stored in the zero page at Z_H (for the high byte) and Z_L (for the low byte) 




   jsr print_mem_16

.word (addr)




Print the contents of memory addresses starting from (addr) for MEMDUMPLEN bytes. The bytes are paired up and displayed as they are in the memory, and then also displayed by swapping them from the native little endian format to a more human-readable table of hex, binary and signed decimal values. 


Attachments
Beginner 6502 Assembly Stuff
Beginner 6502 Assembly Stuff
mathasm.png (190.36 KiB) Viewed 5239 times
MATH16.PRG
Beginner 6502 Assembly Stuff
(1.06 KiB) Downloaded 344 times
math16.asm
Beginner 6502 Assembly Stuff
(13.37 KiB) Downloaded 405 times
Post Reply