Jump to content



0

Going from x86 ASM to 6502 ASM?


3 replies to this topic

#1 Luigi301 OFFLINE  

Luigi301

    Chopper Commander

  • 242 posts

Posted Fri Apr 29, 2005 6:34 PM

I want to make games for the 2600. I know some x86 ASM, but 6502 ASM is a bit more confusing (somehow) than x86. Any tips on going from x86 to 6502 or PC arch to 2600 arch other than memory is gold?

#2 batari OFFLINE  

batari

    )66]U('=I;B$*

  • 6,237 posts
  • begin 644 contest

Posted Fri Apr 29, 2005 8:49 PM

Luigi301, on Fri Apr 29, 2005 7:34 PM, said:

I want to make games for the 2600. I know some x86 ASM, but 6502 ASM is a bit more confusing (somehow) than x86. Any tips on going from x86 to 6502 or PC arch to 2600 arch other than memory is gold?

View Post

First, let's assume 8086 for simplicity. This is what I know, or at least think. I could be wrong, so others feel free to correct me.

The 6502 has only three registers while 8086 has a bunch (I forget how many exactly.)
The 6502 has one interrupt, the 6507 has zero, the 8086 has 256 (?).
The 6502 can only move data 8 bits at a time. The 8086 can do 8 or 16 bit operations.
The 6502's hardware registers are memory mapped. The 8086's are not.
The 6502 has a flat memory model. The 8086 (IIRC) can do segemted memory, or maybe it was relocatable memory for code+data or something of that sort.
The 6502 has 16-bit addressing, the 8086=24 bit.
Flags are similar.
Both have stacks.
Both have interrupt/reset/NMI vectors.

Here's a few 8086 instructions and their closest 6502 analog. Not all 6502 instructions are represented.

8086 6502
____________

adc adc
add none
and and
call jsr
cbw none
cli cli
cwd none
cmp cmp
dec dec
div none
idiv none
imul none
in none
inc inc
int brk
iret rti
ja none
jae bcc
jb bcs
jbe none
je beq
jne bne
jg none
jge bpl
jl bmi
jle none
jmp jmp
lea none (?)
mov lda, ldx, ldy, sta, stx, sty, tax, tay, txa, tya
mul none
neg none
nop nop
not none
or ora
out none
pop pla
popf plp
push pha
pushf php
ret rts
sal asl (?)
sar lsr (?)
shl rol (?)
shr ror (?)
sbb sbc
sti sei
sub none
test bit
xor eor

This should get you started. Once you have the instructions down. it's time to learn addressing modes. Try reading some existing 6502 code first, then view the various modes on a website somewhere (google is your friend.)

Edited by batari, Fri Apr 29, 2005 9:11 PM.


#3 Tom OFFLINE  

Tom

    Moonsweeper

  • 449 posts
  • Location:Switzerland

Posted Sat Apr 30, 2005 2:26 AM

batari, on Fri Apr 29, 2005 9:49 PM, said:

The 6502 has a flat memory model.  The 8086 (IIRC) can do segemted memory, or maybe it was relocatable memory for code+data or something of that sort.

Relocatable code (as long as you don't use far calls/jumps) was just a lame excuse to have a memory model as braindead as the 8086's :)


Actually, if you do know your way around assembly programming, you should be fine with these tutorials on the 6502: http://www.6502.org/tutorials

#4 danwinslow OFFLINE  

danwinslow

    Stargunner

  • 1,748 posts

Posted Sat Apr 30, 2005 7:16 AM

At first I thought the 6502 was brain dead due to lack of registers. Then I realized that the entire page 0 ( first 256 bytes of ram ) is nothing *but* registers.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users