6502 Assembler Help

Basic and Machine Language

Moderator: Moderators

Post Reply
tonyrocks
Vic 20 Hobbyist
Posts: 118
Joined: Mon Jan 04, 2016 10:17 pm
Website: http://www.tonyrocks.com
Location: Pittsburgh
Occupation: IBM Watson Engr

6502 Assembler Help

Post by tonyrocks »

Hey guys,
I'm in the process of "re-learning" assembler and found some generic 6502 assembler code. I'm trying to find the equivilant commands for commodore 64 or vic-20. I'm a little confused on what sta $200,y does and how to convert to vic-20 asm.

Here is an example of soemthing I grab from online:

Code: Select all

start:
 inx ;increment x register
 txa ;transfer X to a
 sta $200, y 
 sta $300, y
 sta $400, y
 sta $500, y
 iny
 tya
 cmp 16
 bne do
 iny
 jmp start
do:
 iny
 iny
 iny
 iny
jmp start
Thanks!
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: 6502 Assembler Help

Post by Mike »

tonyrocks wrote:I'm a little confused on what sta $200,y does and how to convert to vic-20 asm.
STA $0200,Y writes the value of the accumulator A into the address defined by adding the Y index register to $0200. In BASIC, the command POKE 512+Y,A (with A,Y = 0..255) would be the direct equivalent. Whether thrashing bytes in the range $0200..$02FF on the VIC-20 is a good idea, is altogether another matter - but that's what the instruction also does on the VIC-20's 6502, regardless.

Your example endlessly writes to $0200..$05FF ever increasing values (derived from the X register by TXA) to every second byte, leaving a gap of 4 bytes should the low byte of the addresses become equal to either 16 (with an implied # in the CMP instruction), or the value in address 16 (if the instruction CMP 16 is meant as is). As complicated as this sounds, this routine IMO serves no conceivable use. You might be better off looking for routines, that have been written with an actual (machine independent) use for the 65xx series in mind. http://6502.org might serve as a useful start point.

If you find compelling examples of 6502 routines written for the VIC-20, we can of course also discuss them here in Denial. :mrgreen:
Kakemoms
Vic 20 Nerd
Posts: 740
Joined: Sun Feb 15, 2015 8:45 am

Re: 6502 Assembler Help

Post by Kakemoms »

Since both machines use a 6502-based core, all the assembler instructions are the same. The only difference is what different memory locations do, and for that you can look at the Vic-20 & C64 memory map here:

http://www.commodore.ca/manuals/pdfs/co ... ry_map.pdf

If you want to do something graphics related, C64 code can't immediately be translated to the Vic-20 since the two machines have quite different graphics processors (the C64 having double the resolution for horizontal axis compared to the Vic-20).
tonyrocks
Vic 20 Hobbyist
Posts: 118
Joined: Mon Jan 04, 2016 10:17 pm
Website: http://www.tonyrocks.com
Location: Pittsburgh
Occupation: IBM Watson Engr

Re: 6502 Assembler Help

Post by tonyrocks »

thank you! that chart is very useful.
Bobbi
Vic 20 Afficionado
Posts: 355
Joined: Thu Oct 13, 2016 11:35 am
Location: Toronto
Occupation: Programmer

Re: 6502 Assembler Help

Post by Bobbi »

I find this one helpful too:
http://www.zimmers.net/cbmpics/cbm/vic/memorymap.txt
(same info, different format.)
Post Reply