Robert Munafo's Embryonic Peeks Pokes and Calls for the Apple II
This list of PEEKs, POKEs and CALLs differs from the other onesyou've seen in three important ways:
- All items are listed strictly in numerical order. This makes it possible to look something up by its number great if you're trying to figure out what an old program does.
- All items give both decimal and hex forms (and negative decimal if appropriate). For example: $C030 = 49200 = -16336.
- Anything that doesn't always work is labeled with a "restrictions" qualifier, telling what machines and/or setups will or will not produce the intended effect. This includes machine versions (][, ][+, //e, //c, IIgs, etc.) as well as DOS versions and things like whether integer BASIC is in RAM or in ROM.
The hex numbers are for those of you who use the monitor, disassembler and mini-assembler. You can learn all about these great tools from the Apple II Programming FAQ, which you can find by entering "apple2/programmerfaq/part1" into a search engine.
The decimal addresses are given in equivalent positive and negative values because some people have learned it one way and some have learned it the other. Addresses less than 32768 are only given in positive form, and addresses in the Integer BASIC ROM (or its equivalent when loaded into RAM) are only given in negative form because the positive form would give a *** >32767 ERR.$HEX Decimal negative Description $06 6 Free zero-page space to to $09 9 $18 24 Free zero-page space to to $1F 31 $36 lo Character output hook. $37 hi Normally points to 9EBD, the DOS output handler (OPUTINCP). $38 lo Character input hook. $39 hi Normally points to 9E81, the DOS input handler (INPTINCP). $48 72 Monitor: Value of P register (for break and single-step). DOS RWTS: scratch. If you call RWTS you should clear this location before using the Monitor single-step. $4E 78 lo Keyboard get idle counter. Changes whenever $4F 79 hi Apple is waiting for keyboard input. Often useful as a random number seed. $67 103 lo Beginning of Applesoft program $68 104 hi $AF 175 lo End of Applesoft programs $B0 176 hi $C9 201 Described by others as possible "random" to numbers. I cannot verify this. $CD 205 $CE 206 Free zero-page space $CF 207 $EB 235 Free zero-page space to to $EF 239 $F9 249 Free zero-page space to to $FF 255 $100 256 6502 stack page. to to $1FF 511 $3D9 985 Entry point for DOS 3.3 RWTS routine. Only usable to from assembly because it requires A:Y to point to $3DB an RWTS I/O Block specifying all the parameters. From Basic you can call RWTS with the following relocatable 7-byte glue routine: LDA #$hi ; A9 hi 169 lo LDY #$lo ; A0 lo 160 hi JMP $03D9 ; 4C D9 03 76 217 3 Or, if you want to use DOS 3.3's own I/O block at $B7E8, use this 6-byte glue code: JSR $03E3 ; 20 E3 03 32 227 3 JMP $03D9 ; 4C D9 03 76 217 3 Finally, here's a 10-byte glue routine that also lets you find out if there was an error: JSR $03E3 ; 20 E3 03 32 227 3 JSR $03D9 ; 20 D9 03 32 217 3 ROR $B7F5 ; 6E F5 B7 110 245 183 RTS ; 60 96 It rotates the carry bit into the high bit of the result code in $B7F5 = 47093. If there was an error on the RWTS operation the high bit will be set (in Basic, PEEK(47093) > 127) and the lower bits will tell you what error you got as follows: $00-$7F = 0-127 = no error $84 = 132 = error during initialization $88 = 136 = write protect error $90 = 144 = volume mismatch error $A0 = 160 = drive error $C0 = 192 = read error (obsolete) The I/O block is 17 bytes, the format is described in the entry for $B7E8. RWTS trashes location $48 = 72, so you should clear $48 if before going to the Monitor. (See $48 for explanation) $3E3 995 Entry point: loads address of DOS standard RWTS I/O to to block into A:Y. For DOS 3.3 this address is $B7E8. $3E9 1001 $3EA 1002 Entry point: Install a character input hook. It takes parameters in $36-$39 = 54-57; if you haven't changed these locations since booting DOS then CALL 1002 will "reconnect" DOS $2000 8192 HGR graphics memory to $3FFF 16383 $4000 16384 HGR2 graphics memory to $5FFF 24575 $9600 38400 -27136 Beginning of area used by DOS (ends at $BFFF/49151) $9E81 40577 -24959 DOS character input handler (INPTINCP) $9EBD 40637 -24899 DOS character output handler (OPUTINCP) $B685 46725 -18811 This location can be tested to find out what version of DOS 3.3 you're running (only works for unhacked Apple official DOS 3.3's :-). The values are: $A5 = 165 = oldest $BA = 186 = better $B6 = 182 = latest $B7B5 47029 -18507 DOS 3.3 RWTS code and its subroutines. This to to includes most of the physical disk I/O functionality $BFFF 49151 -16385 of DOS such as reading and writing blocks, and formatting an entire disk. $B7E8 47080 -18456 The parameter block used by DOS 3.3 for its internal to to calls to RWTS. You can use this block for your own $B7F8 47096 -18440 calls to RWTS, but you have to make A:Y point to it before calling (LDA $B7 ; LDY $E8; JSR $3D9). The individual bytes of this block follow. See also the description of RWTS at $3D9 = 985. $B7E8 47080 -18456 Table type (always 1) $B7E9 47081 -18455 Slot * 16 ($60 = 96 for slot 6, $50 = 80 for slot 5) $B7EA 47082 -18454 Drive number (1 or 2) $B7EB 47083 -18453 Volume Number (usually 0 to specify "any") $B7EC 47084 -18452 Track (from $00 to $22, 0 to 34) $B7ED 47085 -18451 Sector (from $00 to $0F, 0 to 15) $B7EE 47086 -18450 lo Address of the Device Characteristics Table $B7EF 47087 -18449 hi Address of the Device Characteristics Table $B7F0 47088 -18448 lo Address of Read/Write data buffer $B7F1 47089 -18447 hi Address of Read/Write data buffer $B7F2 47090 -18446 Unused (should be 0) $B7F3 47091 -18445 Portion of Sector to read (to read all 256 bytes, set to 0) $B7F4 47092 -18444 Command code: 0 = Seek 1 = Read 2 = Write 3 = Format $B7F5 47093 -18443 Return value. If carry bit is clear when RWTS returns, there was no error and this location can be ignored (if the operation was a read, this will be the last byte read). If carry is set, the result code is: $00 = 0 = no errors $08 = 8 = error during initialization $10 = 16 = write protect error $20 = 32 = volume mismatch error $40 = 64 = drive error $80 = 128 = read error (obsolete) $B7F6 47094 -18442 Volume number of last access $B7F7 47095 -18441 Slot * 16 of last access ($60 = 96 for slot 6, $50 = 80 for slot 5) $B7F8 47096 -18440 Drive number of last access $BFFF 49151 -16385 Top of RAM on a 48K system. $C000 49152 -16384 Beginning of hardware and ROM memory area. Language card gives 16K of RAM in this area, which can be used to replace the ROMs $C030 49200 -16336 Speaker. Any PEEK or POKE will make a click to to to (each access toggles from low to high) All $C037 49207 -16329 8 addresses are equivalent. $F666 n/a -2458 Entry point for the awesome 371-byte Mini-Assembler built into the earlier (Integer BASIC) ROMs on the Apple ][. Since it is part of Integer BASIC, most //c, //e and IIgs users need to use the following steps to get into the mini-assembler: - Load Integer BASIC from disk into the language card or equivalent "shadow RAM" - Type INT to switch to Integer BASIC - Type CALL -2458 to enter the Mini-Assembler directly, OR - CALL -151 and then "F666G" at the Monitor prompt. n/a -958 Clear text screen from cursor to bottom. n/a -936 Clear the screen and move cursor to top-left (same as Applesoft "HOME" statement). n/a -868 Clear text from cursor to end of line. n/a -756 Wait until a key is pressed (you can then PEEK (-16384) to find out the character) $FDDA 64986 -550 Display A in hexadecimal.
This page was written in the "embarrassingly readable" markup language RHTF, and was last updated on 2017 Feb 02. s.11