Jump to content
IGNORED

Going from x86 ASM to 6502 ASM?


Recommended Posts

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?

846685[/snapback]

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...