Jump to content

Photo

Which Assembly Language is descended from 6502?

6502 Assembler

19 replies to this topic

#1 SIO99 OFFLINE  

SIO99

    Chopper Commander

  • 157 posts
  • Location:London, UK

Posted Sat Aug 11, 2012 8:38 PM

I've been studying a bit of 6502 Assembly Language recently, but so far I can't get the type in ALPA Assembler to Assemble anything! I plan to somehow learn 6502 soon. I hope this will enable me to move on and apply this knowledge on some more advanced computer system, using a more advanced CPU.

The question is, which Assembly Language(s) is or are similar to or descended from 6502? Can someone point out the similarities? I've read that there were 16 bit versions of the 6502 produced, but these are no longer made. I've studied some Z80 and 68000 in the past, but forgotten most of it.

#2 Bryan ONLINE  

Bryan

    Quadrunner

  • 8,547 posts
  • Cruise Elroy = 4DB7
  • Location:Costa Rica

Posted Sat Aug 11, 2012 10:10 PM

The 65816 is the 16-bit version of the 6502 and it is still made:
http://www.westernde...5c816s-chip.cfm

#3 candle OFFLINE  

candle

    River Patroller

  • 2,762 posts
  • Location:Lublin, Poland

Posted Sun Aug 12, 2012 12:52 AM

first ARM cpu had similiar syntax, plus more registers to operate on
but i guess you can say that about just any assembler and processor

; hello world!
; a cool demo by eKid

;------------------------------------------
; vectors
;------------------------------------------

; um, reset vectors?

    section "VECTOR00",HOME[$00]
RST_00:
    jp    $100    ; $100 is program start in cartridge header.

    section    "VECTOR08",HOME[$08]
RST_08:
    jp    $100

    section    "VECTOR10",HOME[$10]
RST_10:
    jp    $100

    section    "VECTOR18",HOME[$18]
RST_18:
    jp    $100

    section    "VECTOR20",HOME[$20]
RST_20:
    jp    $100

    section    "VECTOR28",HOME[$28]
RST_28:
    jp    $100

    section    "VECTOR30",HOME[$30]
RST_30:
    jp    $100

    section    "VECTOR38",HOME[$38]
RST_38:
    jp    $100

; irq vectors
    
    section "VBLANK_VECTOR",HOME[$40]
VBL_VECT:
    reti    ; do nothing

    section "LCD_VECTOR",HOME[$48]
LCD_VECT:
    reti    ; do nothing

    section "TIMER_VECTOR",HOME[$50]
TIMER_VECT:
    reti    ; do nothing

    section "SERIAL_VECTOR",HOME[$58]
SERIAL_VECT:
    reti    ; do nothing

    section "JOYPAD_VECTOR",HOME[$60]
JOYPAD_VECT:
    reti    ; do nothing!

;---------------------------------------------------------
; cartridge header
;---------------------------------------------------------

    section "CHEADER",HOME[$100]
CARTRIDGE_HEADER:
    
    ; 0100-0103 Program Entry point
    jp    START
    nop
    
    ; 0104-0133 Nintendo logo, must be exact or gb will refuse to run program
    db    $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83,$00,$0C,$00,$0D
    db    $00,$08,$11,$1F,$88,$89,$00,$0E,$DC,$CC,$6E,$E6,$DD,$DD,$D9,$99
    db    $BB,$BB,$67,$63,$6E,$0E,$EC,$CC,$DD,$DC,$99,$9F,$BB,$B9,$33,$3E
    
    ; 0134-013E Game title 11 chars
    db    "HELLO WORLD"
    
    ; 013f-0142 Manufacturer code
    db    "    "
    
    ; 0143 CGB flag
    db    $C0    ; cgb only
    
    ; 0144-0145 License code
    db    $00, $00
    
    ; 0146 SGB flag
    db    $00
    
    ; 0147 Cartridge Type
    db    $19
    
    ; 0148 ROM size
    db    $00    ; 32kb ROM
    
    ; 0149 RAM size
    db    $00    ; no cartridge ram
    
    ; 014A destination code
    db    $01    ; non-japan
    
    ; 014B old licensee code
    db    $33    ; $33 fixed, required
    
    ; 014C mask ROM version - handled by RGBFIX
    db    $00
    
    ; 014d header checksum - handled by RGBFIX
    db    $00    ; required!
    
    ; 014e-014f global checksum - handled by RGBFIX
    dw    $0000    ; not required

;------------------------------------------
; graphics
;------------------------------------------

    section "GRAPHICS",DATA

scribbles:
    include "scribbles.inc"

;------------------------------------------
; vram memory definition
;------------------------------------------

    section "VRAM_A",VRAM

; 4-bit font data
; 16 bytes per tile

vr_font:
    ds    27*16    ; reserve space

;------------------------------------------
; definitions
;------------------------------------------

DONUT_ISGOOD    EQU    $01

NR52        EQU    $FF26

LCDC        EQU    $FF40
STAT        EQU    $FF41
SCY        EQU    $FF42
SCX        EQU    $FF43
LY        EQU    $FF44
BCPS        EQU    $FF68
BCPD        EQU    $FF69
IE        EQU    $FFFF

;------------------------------------------
; program
;------------------------------------------

    section "HELLOWORLD",HOME[$150]
    
START::
    di    ; disable interrupts
    
    xor    a        ; disable sound (16% power saving)
    ld    [NR52], a
    
; wait for vblank

.dwait:
    ld    a, [LY]
    cp    a, 146        ; +2 <img src='http://www.atariage.com/forums/public/style_emoticons/<#EMO_DIR#>/icon_smile.gif' class='bbc_emoticon' alt=':)' />
    jr    nz, .dwait

; disable LCD
    
    xor    a
    ld    [LCDC], a
    
; load scribble font <img src='http://www.atariage.com/forums/public/style_emoticons/<#EMO_DIR#>/icon_mrgreen.gif' class='bbc_emoticon' alt=':D' />
    
    ld    bc, vr_font
    ld    hl, scribbles
    ld    de, 27*256 + 16
    
.copyfont:
    ld    a, [hl+]
    ld    [bc], a
    inc    bc
    dec    e
    jr    nz, .copyfont
    ld    e, 16
    dec    d
    jr    nz, .copyfont
    
    
; build a cool palette :]
    
    ld    a, $80        ; index 0, auto-inc
    ld    [BCPS], a
    
    ld    hl, BCPD
    ld    [hl], $ff    ; white
    ld    [hl], $7f
    ld    [hl], $1f    ; red
    ld    [hl], $00
    ld    [hl], $1f    ; red
    ld    [hl], $00
    ld    [hl], $1f    ; red
    ld    [hl], $00
    
; draw the text
; start by clearing the screen
    
    ld    hl, $9800
    xor    a
    ld    de, 1024

.clearscreen:
    ld    [hl], $00
    inc    hl
    dec    de
    jp    nz, .clearscreen
    
; write text
    
    ld    hl, str_message
    ld    bc, $9800-1
    
.writetext:
    ld    a, [hl+]
    cp    0
    jr    z, .endtext
    inc    bc
    sub    64
    jr    c, .writetext
    ld    [bc], a
    jr    .writetext
.endtext:

; center image

    ld    a, -68
    ld    [SCY], a
    ld    a, -36
    ld    [SCX], a
    
    ld    a, $91        ; enable lcd
    ld    [LCDC], a
    
    halt            ; crash program (low power consumption)
    ; rgbasm adds a NOP

str_message:
db    "HELLO@WORLD",0 ; the @ is a space <img src='http://www.atariage.com/forums/public/style_emoticons/<#EMO_DIR#>/icon_sad.gif' class='bbc_emoticon' alt=':(' />
 


#4 ProWizard OFFLINE  

ProWizard

    River Patroller

  • 3,345 posts
  • MyIDE 2 Conversions in Progress!
  • Location:$d500-$d57f

Posted Sun Aug 12, 2012 2:21 AM

I do not understand the question completely. But I would say try the Mac/65 assembler or the Synassembler if you want to do it on real Atari.


#5 sack-c0s OFFLINE  

sack-c0s

    Stargunner

  • 1,113 posts
  • Location:Kingston Upon Thames, UK

Posted Sun Aug 12, 2012 9:10 AM

ARM was designed to be easily learned by 6502 coders so you could say it is descended from it.

#6 JamesD OFFLINE  

JamesD

    River Patroller

  • 4,797 posts

Posted Sun Aug 12, 2012 10:21 AM

Of modern CPUs, the closest assembly to the 6502 would be ARM.
ARM has many similarities to the 6502 as far as mnemonics go, but there are also some very clear differences between the 6502 and ARM.
For example, if you take a look at the jump/branch instructions, the 6502 has mnemonics for each condition and ARM has a generic jump followed by the condition and address in the operand field.
ARM further simplifies mnemonics (opcodes) and moves differences to the operand field to reduce the number of instructions and simplify decoding.

FWIW, in spite of their similarities, I'm not sure you can truly attribute ARM assembly strictly to the 6502.
If you look at the PDP series of computers, I'm sure you'll find they heavily influenced most CPUs in those days.

#7 atari8warez OFFLINE  

atari8warez

    River Patroller

  • 2,376 posts
  • Location:Canada

Posted Sun Aug 12, 2012 11:41 AM

I do not understand the question completely. But I would say try the Mac/65 assembler or the Synassembler if you want to do it on real Atari.


He wanted to know which CPU(s) is more advanced, but syntacticaly similar to 6502 so that he can learn to program them easily knowing how to program a 6502.

#8 atari8warez OFFLINE  

atari8warez

    River Patroller

  • 2,376 posts
  • Location:Canada

Posted Sun Aug 12, 2012 12:07 PM

ARM was designed to be easily learned by 6502 coders so you could say it is descended from it.


ARM takes some design queues from 6502 (like memory access architecture and lack of microcode) and have familiar looking opcodes but it's an advanced RISC processor and uses load/store architecture vs. the register-memory architecture of 6502. So it's not really a descendent of 6502 and the programmer would still need to learn a lot of new concepts, opcodes and ways of doing things...

#9 russg OFFLINE  

russg

    Stargunner

  • 1,229 posts
  • Location:Cleveland, Ohio

Posted Sun Aug 12, 2012 12:19 PM

I've been studying a bit of 6502 Assembly Language recently, but so far I can't get the type in ALPA Assembler to Assemble anything! I plan to somehow learn 6502 soon. I hope this will enable me to move on and apply this knowledge on some more advanced computer system, using a more advanced CPU.

The question is, which Assembly Language(s) is or are similar to or descended from 6502? Can someone point out the similarities? I've read that there were 16 bit versions of the 6502 produced, but these are no longer made. I've studied some Z80 and 68000 in the past, but forgotten most of it.


Atari BASIC you can learn programming. The assembler for Atari does some things that aren't available in BASIC, except by USR calls. If you want to code for a modern machine, meaning a Windows PC, you can get Microsoft
Visual BASIC 2010 and Visual Studio for free. Visual BASIC is hard to get all the thousands of 'reserved words'. If you want to do something, say input a variable from the screen, in Atari BASIC it is 'INPUT #1,A$"
and DIM A$(10) or for a real number INPUT X, don't have to dimension the X. Atari BASIC only has real numbers, numbers up to billions +/- 9.9999999 E +97 to nine significant digits (actually only up to 1 billion).

To input a real number called 'cfreq' in VB 2010:

Dim cfreq as double

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Try
If Len(TextBox1.Text) > 0 Then
cfreq = Double.Parse(TextBox1.Text)
Label7.Text = cfreq
End If
Catch ex As Exception
MsgBox("non-number error")
TextBox1.Clear()
End Try
End Sub

Textbox1 and label7 you created when you created your 'form'. VB starts with a form, a windows box you add textbox and label to, then set parameters for them.
Then enter the code that happens when something changes in your form box.

The VB 2010 Express coding environment does most of the hard stuff automatically, the 'Private sub Textbox1....' and the end try end sub. Only the middle part with the
'cfreq = Double.Parse(TextBox1.Text)' do you enter. And that is also mostly prompted with many, many options. You just enter 'cfreq= ' then VB prompts you for the rest.

What I'm saying is you learn basic programming with Atari BASIC, init variables, loops, if then, gosub, but VB 2010 you Google what you want to do, eg.
enter variable in Visual BASIC and get a youtube video on how to do it. There's not so much of the tough parts you have to code, VB prompts you
for what you're trying to do. OH, the best part. VB 2010 Express is free, at least for 60 days or something. I developed my two VB 'apps' and haven't
seen the end of trial period yet. Youtube has tutorials on graphics too.

Here's a link to my VB programs.
http://www.russgilb.net


I'd say real Windows programmers use C#. Theres a C for Visual Studio 2012. I don't even know an assembler for 64 bit PC. I think 32 bit PC there was Eric Isaacsons A86 assembler. I did
some X86 coding many years ago.

Edited by russg, Sun Aug 12, 2012 1:16 PM.


#10 JamesD OFFLINE  

JamesD

    River Patroller

  • 4,797 posts

Posted Sun Aug 12, 2012 8:58 PM

I'd say real Windows programmers use C#. Theres a C for Visual Studio 2012. I don't even know an assembler for 64 bit PC. I think 32 bit PC there was Eric Isaacsons A86 assembler. I did
some X86 coding many years ago.

So what your saying is, you use C#? :D

#11 ZylonBane OFFLINE  

ZylonBane

    River Patroller

  • 3,376 posts
  • Location:KC, KS, USA

Posted Sun Aug 12, 2012 9:29 PM

I think he has no comprehension what this thread is about, so he decided to pretend it was about BASIC.

#12 DamageX OFFLINE  

DamageX

    Chopper Commander

  • 243 posts

Posted Sun Aug 12, 2012 9:43 PM

Freescale (formerly Motorola) 68HC08 microcontrollers are still around and they are as similar to 6502 as anything.

I don't even know an assembler for 64 bit PC.

NASM supports AMD64 instruction set.

#13 russg OFFLINE  

russg

    Stargunner

  • 1,229 posts
  • Location:Cleveland, Ohio

Posted Mon Aug 13, 2012 4:21 AM


I'd say real Windows programmers use C#. Theres a C for Visual Studio 2012. I don't even know an assembler for 64 bit PC. I think 32 bit PC there was Eric Isaacsons A86 assembler. I did
some X86 coding many years ago.

So what your saying is, you use C#? :D

No, I'm not a real programmer, I'm a duffer. I think the OP wanted to know what a real programmer for PC uses, especially an assembler, which I don't know, but as usual, I have something to say,
even if it doesn't make a whole lot of sense. :o)

(Hey! I made an emoticon.)

Edited by russg, Mon Aug 13, 2012 4:31 AM.


#14 russg OFFLINE  

russg

    Stargunner

  • 1,229 posts
  • Location:Cleveland, Ohio

Posted Mon Aug 13, 2012 4:30 AM

I think he has no comprehension what this thread is about, so he decided to pretend it was about BASIC.

Let us know your answer.

#15 russg OFFLINE  

russg

    Stargunner

  • 1,229 posts
  • Location:Cleveland, Ohio

Posted Mon Aug 13, 2012 6:19 AM


I'd say real Windows programmers use C#. Theres a C for Visual Studio 2012. I don't even know an assembler for 64 bit PC. I think 32 bit PC there was Eric Isaacsons A86 assembler. I did
some X86 coding many years ago.

So what your saying is, you use C#? :D

Real programmers do use MS Visual Studio. Visual C++ and Visual C# and even Visual BASIC. C#, C++ you can embed inline machine code, probably from assembled code.

Here's a pretty complete list of assemblers.

http://en.wikipedia....#ARM_assemblers

Edited by russg, Mon Aug 13, 2012 6:43 AM.


#16 rdea6 OFFLINE  

rdea6

    Stargunner

  • 1,671 posts
  • Location:Arizona USA

Posted Mon Aug 13, 2012 7:14 AM

That is a nice list,,,, should satisfy the OP.

#17 Gury OFFLINE  

Gury

    Stargunner

  • 1,009 posts

Posted Tue Aug 14, 2012 9:08 AM

And many real programmers also use Delphi and Lazarus.

#18 wesmond OFFLINE  

wesmond

    Space Invader

  • 46 posts
  • Location:London, UK

Posted Tue Aug 14, 2012 9:32 AM

To OP - you said you want to learn 6502 "somehow" - the book you've mentioned elsewhere (130xe assembly language) is a pretty good reference - although I've not typed in ALPA. I learned the simple basics with Atari's Assembler Editor, but it was hard work and as a kid I didn't get that far. I've got into it more recently, and with much more success, with this combination:- 1. Eclipse (you'll need Java), 2. MADS assembler/compiler, 3. Altirra to run/debug/disassemble/step through... I'm sure there are alternatives to all three, but having an Eclipse/Java background I found that combination worked really well. Google or search these pages for all three.

To write something nice, you'll also need open in a webpage, if not on paper, Mapping the Atari, or De Re Atari probably, to tell you what memory addresses are for which bit of Atari's hardware - that's when the fun starts, as 6502 assembler on its own is really not that much - just reads/writes with memory, a bit of maths and logic, comparisons and branches... not much more.

Good luck...

#19 russg OFFLINE  

russg

    Stargunner

  • 1,229 posts
  • Location:Cleveland, Ohio

Posted Tue Aug 14, 2012 12:53 PM



I'd say real Windows programmers use C#. Theres a C for Visual Studio 2012. I don't even know an assembler for 64 bit PC. I think 32 bit PC there was Eric Isaacsons A86 assembler. I did
some X86 coding many years ago.

So what your saying is, you use C#? :D

Real programmers do use MS Visual Studio. Visual C++ and Visual C# and even Visual BASIC. C#, C++ you can embed inline machine code, probably from assembled code.

Here's a pretty complete list of assemblers.

http://en.wikipedia....#ARM_assemblers


There's also John Harris (a REAL programmer) MAE, another macro 6502 assembler for A8.
Then there's a 'cross assembler' I think it is called, do 6502 assembly coding on a PC, called cc65.

Edited by russg, Tue Aug 14, 2012 1:46 PM.


#20 flashjazzcat OFFLINE  

flashjazzcat

    Quadrunner

  • 8,589 posts
  • Location:United Kingdom

Posted Tue Aug 14, 2012 1:18 PM

There's also John Harris MAE, another macro 6502 assembler.
Then there's a 'cross assembler' I think it is called, do 6502 assembly coding on a PC, called cc65.


MAE looks excellent. CC65 is a C compiler, but it has an assembler which can be used as a stand-alone tool, called CA65.




0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users