Apple ][
The bulk of this page will focus on the Enhanced IIe, both because it was the most popular of the line and because it is the model we have.
Memory layout
Despite the 6502's 64K address space, an Apple II could have significantly more RAM and ROM than that. The IIe came standard with 64K built into the motherboard, which could be doubled with an extended 80-column text card. Other peripheral cards tended to contain their own onboard RAM/ROM. All of this extra memory is accessible through bank switching.
-
\$0000–\$00FF: zero page
-
\$0100–\$01FF: stack, Applesoft temporary storage
-
\$0200–\$02FF: keyboard/diskette input buffer
-
\$0300–\$03CF: user assembly programs
-
\$03D0–\$03FF: subroutine vectors for DOS, Applesoft, and system monitor
-
\$0400–\$07FF: text/low-res page 1
-
\$0800–\$0BFF: text/low-res page 2; more commonly used for Applesoft program storage
-
\$0C00–\$1FFF: free for use
-
\$2000–\$3FFF: high-res page 1
-
\$4000–\$5FFF: high-res page 2
-
\$6000–\$BFFF: normally free for use; \$9600 and above is used by DOS
-
\$C000–\$C0FF: I/O
-
\$C100–\$C1FF: slot 1 ROM
-
\$C200–\$C2FF: slot 2 ROM
-
\$C300–\$C3FF: slot 3 ROM
-
\$C400–\$C4FF: slot 4 ROM
-
\$C500–\$C5FF: slot 5 ROM
-
\$C600–\$C6FF: slot 6 ROM
-
\$C700–\$C7FF: slot 7 ROM
Zero page
I/O
Video memory
Other locations
To determine the exact model and version, examine \$FBB3 and \$FBC0. If \$FBB3 contains \$06, the computer is a IIe or IIc. \$FBC0 can contain the following values: [2]
-
\$EA: IIe with original ROMs
-
\$E0: IIe with enhanced ROMs
-
\$00: IIc
Programming
Applesoft
Integer BASIC
System monitor
Operating systems
DOS 3.3
ProDOS 8
CP/M
In order to run CP/M, a Z80 soft card is required. While we do not currently possess one, it should be possible to find one online — or we may be able to assemble our own from scratch using available schematics [4].
Peripheral cards
As with the rest of this page, we will focus on cards our machine has installed.
The Apple IIe has eight expansion slots (7 regular and 1 auxiliary). This alone is indicative of a completely different era of Apple's history, one in which the engineering team held more sway than the marketing team.
Apple extended 80-column card
Disk II interface
Super Serial
Applied Engineering RAMFactor
A RAM disk/memory expansion. ProDOS automatically registers it as a volume named /RAMs
(where s
is the slot number where the card is installed), and AppleWorks appears to relocate some of itself onto the card. Because the card uses volatile RAM, anything saved to the card will be lost when the computer is switched off unless external power is applied to the card. Applied Engineering sold a device to do just that, but we do not have one, nor do we particularly wish to.
The particular revision we have contains a total of 1 MB of RAM.
Sample code
Determining current execution page
This snippet is particularly useful for writing peripheral card ROM, where the code needs to function irrespective of its installed slot. It works by calling a “subroutine” consisting entirely of an RTS
(\$FF58 is one of a handful of addresses that Apple guaranteed will contain an RTS
instruction). Upon returning, $100+S
contains the high byte of the return (calling) address.
If calling from a peripheral card, the slot number can be identified by ANDing the result with 0F.
; stores the high byte of the execution address in the A register
; clobbers: A, X
getpage:
JSR $FF58 ; push the return address to the stack
TSX ; use stack pointer as index to stack page
LDA $100,X ; get high byte of return address
RTS
Writing bytes as hexadecimal
We don't have to reinvent the wheel for this one — the system monitor includes a handy routine called PRBYTE
(\$FDDA) for just this task, shown below [5]:
PRBYTE: PHA
LSR A
LSR A
LSR A
LSR A
JSR PRHEXZ ; =$FDE5
PLA
PRHEX: AND #$0F
PRHEXZ: ORA #$B0
CMP #$BA
BCC COUT ; =$FDED
ADC #$06
COUT: JMP (CSWL) ; =$0036, user output routine
To make use of it from Applesoft, load the following anywhere into memory:
JSR $DEBE ; CHKCOM - skips comma in Applesoft parsing
JSR $DFE3 ; GETPNT - get pointer to variable data, put it in $83...$84
LDY #$00
LDA ($83),Y ; get high byte from VARPNT
JSR $FDDA ; PRBYTE
INY
LDA ($83),Y ; get low byte from VARPNT
JMP $FDDA ; PRBYTE (will RTS for us)
Then it can be called from Applesoft like so (assuming the program was loaded at \$0300):
10 LET X% = 69
20 CALL 768,X%
Generate the Mandelbrot set
Useful as a benchmark. The computer must be in 80-column mode for it to display properly.
10 FOR Y=-12 TO 12
20 FOR X=-39 TO 39
30 CA=X*0.0458
40 CB=Y*.08333
50 A=CA
60 B=CB
70 FOR I = 0 TO 15
80 T=A*A-B*B+CA
90 B=2*A*B+CB
100 A=T
110 IF(A*A+B*B)>4 GOTO 200
120 NEXT I
130 PRINT " ";
140 GOTO 210
200 IF I>9 THEN I=I+7
205 PRINT CHR$(48+I);
210 NEXT X
220 PRINT
230 NEXT Y