Skip to content
Game 0 Unit 5 of 19 1 hr learning time

A Vast Street of Memory

Meet the 68000's enormous address space — millions of numbered boxes, each holding a byte. Store a colour out in memory and read it back, the same round-trip you ran through registers, now through RAM.

26% of Meet The Machine

Sixteen registers is roomy, but it's still sixteen. Everything else a program works with lives in memory — and on the 68000, memory is vast.

Picture the same street of numbered boxes you'd meet on any machine, each box holding a byte, each with an address. The difference is the length of the street. An 8-bit chip could name 65,536 boxes — 64 KB, the ceiling its whole world ran into. The 68000 names addresses with 24 bits, reaching sixteen megabytes — and the Amiga fills a good stretch of it: chip RAM the custom chips can see, fast RAM for the CPU alone. You will not run out of street the way an 8-bit programmer did.

Reaching a box is the MOVE you already know, pointed at an address instead of a register.

What you'll see by the end

The Amiga screen filled with cyan.
Cyan, proving a round trip: the colour stored out to a box in memory, then read back from it before reaching the screen.

A cyan screen. As when we passed values between registers, the colour isn't the point — the journey is. The colour went out to a box in memory, then came back from it, and only then to the screen. The box held it faithfully in between.

Store and read, by address

;──────────────────────────────────────────────────────────────
; Meet the Machine (Amiga) - Unit 5: A Vast Street of Memory
;
; The 68000 can address a vast street of memory. You store a value at an address
; and read it back, exactly as you'd expect. Here a colour goes out to a spare
; word of memory and comes back before it reaches the screen.
;──────────────────────────────────────────────────────────────

CUSTOM      equ $dff000
DMACON      equ $096
INTENA      equ $09a
INTREQ      equ $09c
COP1LC      equ $080
COPJMP1     equ $088
BPLCON0     equ $100
COLOR00     equ $180

            section code,code_c

start:
            lea     CUSTOM,a5
            move.w  #$7fff,INTENA(a5)
            move.w  #$7fff,INTREQ(a5)
            move.w  #$7fff,DMACON(a5)
            lea     copperlist,a0
            move.l  a0,COP1LC(a5)
            move.w  d0,COPJMP1(a5)
            move.w  #$8280,DMACON(a5)

            ; ----------------------------------------------- YOUR CODE START
            move.w  #$00ff,scratch      ; store a cyan at the address 'scratch'
            move.w  scratch,d0          ; read it back from memory into d0
            move.w  d0,colourval        ; show it
            ; ------------------------------------------------- YOUR CODE END

forever:
            bra.s   forever

scratch:    dc.w    $0000               ; a spare word of memory to borrow

copperlist:
            dc.w    BPLCON0,$0200
            dc.w    COLOR00
colourval:
            dc.w    $0000
            dc.w    $ffff,$fffe
move.w  #$00ff,scratch      ; store a cyan at the address 'scratch'
move.w  scratch,d0          ; read it back from memory into d0
move.w  d0,colourval        ; show it

scratch is a label, and a label is just an address — a particular box in memory, set aside with scratch: dc.w $0000. The first MOVE writes the colour into that box; the second reads it back out into d0. Same instruction, addresses instead of registers. (Notice there are no brackets here: naming the label means "the box at this address." Brackets — (a0) — mean something more, and we get to them in Unit 10.)

The round trip proves the box holds the value: the colour only reaches the screen because it survived the journey out to memory and back.

Assemble, master, and run

make

A cyan screen — stored to a box and fetched back.

Try this: any free box

Point scratch somewhere else. Add a second spare word, scratch2: dc.w 0, and store to it instead. Same cyan — any free box of RAM holds your colour just as well. Nothing is special about the first one; it's the address that names the box, and there are millions to choose from.

Try this: two boxes don't interfere

Store one colour to scratch and a different one to a second box, then read just one back:

    move.w  #$00ff,scratch      ; cyan in box one
    move.w  #$0f00,scratch2     ; red in box two
    move.w  scratch,d0          ; read box one back
    move.w  d0,colourval        ; -> cyan

The screen is cyan — you read box one, and the red you put in box two sat untouched. Change the read to scratch2 and it turns red. Two addresses, two independent boxes.

If it doesn't work

  • The screen is black. The read didn't find your value — check the same label is used for both the store and the read.
  • vasm errors. A borrowed box needs declaring: scratch: dc.w $0000 somewhere in the program (we put it just after forever).
  • The colour is wrong. Make sure you stored a .w (a colour is a word) — a .b store would write only half of it.

What you've learnt

Memory is a vast street of numbered boxes — millions of them on the 68000's 24-bit address space — each holding a byte. move to an address stores; move from an address reads; a label is just the address of a box. The value survives out in memory exactly as it did in a register.

What's next

That's the whole of what the machine is on the CPU side — registers and memory, moved around with MOVE. Now we turn to the part that makes it an Amiga: the screen itself. Next — The Screen Is a Bitmap — we find out the picture is a map of bits in memory, and put the first one there ourselves.