Home
Admin | Edit

Atari 8 bits code setup

Contents

Introduction


Just a small quick-start / reminder to low-level (6502 assembly) programming for the Atari 8 bits computers.

Focus is on Atari 800 XL but should works for other models.

See this for other Atari 8 bits codegolf resources and AtariAge board.

Atari System Reference Manual

Assembly language programming for the Atari computers

Also see this for a course on Atari 8 bits graphics and this or this for a course on assembly language for Atari computers (this is also handy as a 6502 reference), there is plenty other resources on Atari archives or Atari mania.

I like the De Re manual also "All About Atari" which can be found here.

The way to go to generally learn this platform is to get a reference of the memory map (available on links above), try to make sens of it and poke it.

Note :

Quick-start tooling


Download an emulator such as Atari800 and the assembler, i personally like ATMAS II (the file can be found in the list of that link), ATMAS pretty much act like a regular text editor and it doesn't have line numbering.

Put the downloaded assembler .atr file into e.g. ~/atari and also create ~/atari/data which will store the binaries produced by the assembler or saved sources.

Here is a quick command that i use to launch the assembler (note that it uses XL and the above setup, see this for the emulator usage) : atari800 -xl -no-bilinear-filter -H1 ~/atari/data -hreadwrite -ntsc -nobasic "~/atari/Atmas II Macroassembler A.atr"

ATMAS II with the demo program loaded

Disassembler

ATMAS II has an easy disassembler but the load binary + disassemble can be tedious so i prefer a disassembler which run in the browser, it support easy drag and drop of multiple Atari 8 bits binary files. (doesn't have undocumented instructions though)

ATMAS Quick-start


ATMAS II is a straightforward and powerful macro assembler for the Atari 8 bits computer.

ATMAS II manual can be found here or just translate the German manual. (the reference card at the end of the manual might be handy to get a quick grasp)

Assemble and run the demo program

This is a quick way to get all the clues needed to assemble and run a program (taken from the manual, where <esc> means pressing escape key, <start> means F5) :

<esc>RD:DEMO<esc><esc> (load demo program)
<ctrl>-Y (assemble program)
<esc> (back to the editor)
<esc>U<esc><esc> (start program)
<start> (end program)

Save program binary

Example saving a program from A800 to A8F9 (so 256 bytes program, see this for a description of the Atari 8 bits executable format)

<ctrl>-P (go to monitor screen)
<s> (SAVE)
A800
A8F9
<enter>
H1:mybinary.xex
<e> (quit monitor screen)

With the above tooling setup the H1 device will point to e.g. ~/atari/data folder so the saved executable file MYBINARY.XEX will be located in this folder.

Save/load source code

Save a text buffer content to MYSOURCE.SRC, replace WH1 by RH1 to load a file instead, if you load a new file you might need to delete current buffer content by doing : <esc>k<esc><esc>

Note : Don't forget to <ctrl>-E before saving!

<ctrl>-E (this put the cursor position at the beginning, required before saving since saving is from the current cursor position)
<esc>WH1:mysource<esc><esc>

Source code can be created / edited from Linux as well then loaded up from the Atari. (to some extents)

ATMAS sample code


Here are some sample code which are actually taken from the demo routines in the ATMAS manual but stripped of the macros. (not optimized, this can be shorter)

See also this for some re-implementation of BASIC routines in assembly.

Plot to screen

An example of changing screen mode and plotting an orange pixel at 0,0.

ICCOM EQU $342
ICBAL EQU $344
ICBAH EQU $345
ICBLL EQU $348
ICBLH EQU $349
ICAX1 EQU $34A
ICAX2 EQU $34B
CIOV  EQU $E456
COPEN EQU 3
CCLSE EQU 12
CPBIN EQU 11
ATACHR EQU $2FB
ROWCRS EQU $54
COLCRS EQU $55

    ORG $A800

* SET SCREEN MODE
    LDX #$60
    LDA #CCLSE
    STA ICCOM,X
    JSR CIOV
    LDA #7 * SCREEN MODE (here mode 7 160x80)
    STA ICAX2,X
    AND #$F0
    EOR #$10
    ORA #$0C
    STA ICAX1,X
    LDA #COPEN
    STA ICCOM,X
    LDA #DEV@
    STA ICBAL,X
    LDA #DEV@/256
    STA ICBAH,X
    JSR CIOV

* SET COLOR
    LDA #1 * orange
    STA ATACHR

* SET CURSOR POSITION
    LDA #0 * X
    STA COLCRS
    LDA #0/256 * X
    STA COLCRS+1
    LDA #0 * Y
    STA ROWCRS

* PLOT
    LDX #$60
    LDA #CPBIN
    STA ICCOM,X
    LDA #0
    STA ICBLL,X
    STA ICBLH,X
    LDA ATACHR
    JSR CIOV

LOOP@    JMP LOOP@

DEV@ ASC 'S:'

Text output

ICCOM EQU $342
ICBAL EQU $344
ICBAH EQU $345
ICBLL EQU $348
ICBLH EQU $349
ICAX1 EQU $34A
ICAX2 EQU $34B
CIOV  EQU $E456
COPEN EQU 3
CCLSE EQU 12
CPTXT EQU 9
CPBIN EQU 11
ATACHR EQU $2FB
ROWCRS EQU $54
COLCRS EQU $55

    ORG $A800

* SET CANAL
    LDA #0 * CANAL
    ASL
    ASL
    ASL
    ASL
    TAX

* PRINT STRING
    LDA #CPTXT
    STA ICCOM,X
    LDA #STRING
    STA ICBAL,X
    LDA #STRING/256
    STA ICBAH,X
    LDA #4 * STRING LENGTH
    STA ICBLL,X
    LDA #0
    STA ICBLH,X
    JSR CIOV

STRING ASC "TEST"

ATASCII control characters can be sent to move the cursor, clear the screen etc.

back to topLicence Creative Commons