doc_20150805212116

3
j Nick Hampshire brings you a I detaile d look at the C-16 ! Operating System variables I and memory map. ANYONE WISHING TO DO EXTENS IVE machine code programming on the C-1 6 or Plus-4 will require two essential pieces of information . The first, is a list of the operating system variables, their location and function. This is essential if fatal interac- tion with the system software is not to occur. It is also important to k now where to place variables when us ing any of the system subroutines. The second essential piece of informa- tion is a memory map. This con tai ns the entry points to the operating system and Basic ROM routines. The use of . such routines within a program can save a considerable amount of time and program space, an important considera- tion with the C-16. I have included both these pieces of i nformation in this article. Unfortun ately, Commodore has not previous ly produced any of this data and it has therefore been necessary to use the experience gained with p reviou s Commodore machines to deduce the location and function of bot h variables and routines. All the locations discovered have been thoroughly checked and I have no reason to doubt that they are correct, I wou ld however be very interested to hear from any r eaders with additional information. The operating system variables are, in common with all Commodore machi nes , stored in the bottom area of memory extending from locati on $0000 up to the bottom of the screen colour memory at $0800, a total of 2K of memory. All , the . important variable locations are shown in Table 1. It should be noted that locations $00 and $01 are an 1/0 port located on the processor chip and cannot therefore be used for variable storage. A memory map of the ROM based operating system _and ·Basic routines is shown in Table 2. Many of these routines are usable to some degree, and some are extremely valuable. Most of the routines and var iab le s are similar, or even identical, in function , if not in location, to those on the C64. Readers wishing to gain an in depth knowle dge of the routines, functions and operations are recomm ended to consult 38 I one of the advanced books on the 64. The 11m11R, 64 Revealed series by Nick Hampshire, I published by Collin s is recommended , especiall y Advanced Com m odo re 64 Bas ic Revealed. OF THE · , ·· - ,:able:.1 ' ·· .. · · · ·. · _,,. ' ,< •. ~..... ' .,; •' ' I --====---==----------------------- 0001 - Cassette c:cit1trr:r l Bit 4 Cassette read (100A OOOD 0(10E OOOF (1(114-(1(115 - 0016 001 7-0(11 E: 0019-0021 0022-0025 0026-002A - 002B-002C 002D-002E - 002F-0030 0031-(HJ32 [1[133-00:::4 0035-(1(136 0037-(1038 0039-(1[ 1: 3A 003B - 003C 003D-003E - oo:::F-0040 - 0041 -(HJ42 - 004:::: - 0044 - 0045-0046 - 0047-(HJ4f: 0049 - 004A - 004E:-004C - 004D 004E-005:3 0054 - 0056 - 0057-0060 - 0061 0062-0065 0066 0067 :3 : Cassette motc•r ( O=on) 1 : Cassette 1 . ur i te 0=LOAD,1=VERIFY \o TY~e= FF=string,00=numeric 13 T·::1~=·e: f:O=inte ·~er., 00=-f k•~.tin-:.1 t '1 DATA scan- --'L I ST •::tuote.··'memm-··::1 + l- :<.-:.1 i )- I t-1te~er 1,_.1.a. luE' .i:.::. . c I F'r:r inter : tenn:•or.:(t-·'::1 str in~ st-:<.ck ·-~ -<. L.=<.St tern~=· str i t·r:.1 vector :,_: ~; - { · 1 Tem~=·or.:(t-·':::I strin~ :::ta.ck 2'~· · J3 Ut i l i t·::l PO int.er area. .5 1 1 S-;7 . ProodL~c:t area. fc•r rn1..,1 ltiP lic.:<.tion -1 2 Pointer : st-=<rt of B.:1.s i c i-; .3 Pointer : sta.rt of B.:G i c ._.1 .31-· 1-=<b li::..:=- L; ~- F'o inter: st .:1.rt of arr.:1.·::1s i-/ ? - :,. . ::. F'o inter: end of arra:::1s (1 ·J 5-0 Pointer: bo ttom of str i n:.-1s 5·; - -;;· 2.. t t · r ·, Pointer : curren s .r 1 n-:.1 .::, -_ ., cf . Pointer : top of B- :t:- i c n-1emor'::l 11:, - 5{ Current Ba.sic: line number -::- l · · :: CHAF.:GET PO int.er -S ~- :i (. c, _ Pointer: FOR/DO stack ti -- L2 /. Cw-rent DATA line number , ,<S · c. L; Ctwrent DATA address c: :;· -15 ( I nPt~t t_.1ector ( :7 - t.3 Cr_~rrent i...iar i . :1J:i le' name (. '. ~) · · > - ::; Cw-rent •._.1a.r i c1b le a.ddress · )'; · ; .:- V. :1.r i aJ:. le Pointer for FOP.~-l~D=:T j_ , · -Jt 1 I ·~· ==-·=<. '..Je.: o~=· sa.i. ..,e; Ba.sic m~·o1t~,t=t~· ;=·:_. : ..,e;. -{ { . I 1_.omPc<r 1.son s · ::1rnbo l accur11u l,=,.tut · -/ .:. ; Misc numeric work at-· ea } S -. ::; ~! · Jwf1P ,__.ector +or functions (;c ,. - j i::; Mis,:: work a.rea c:i -( - c" ' FAC#l exPonE-nt t - FAC# 1 m-:1rit i ssa. , :.i - 1 _; -~ FAC# 1 s i · :.WI ( '; · ::;;e t-· i es e•-..' - ::<. l1~at ion constant ~=·o inter · 7 I 11 ' 'I 'I (106f: FAC# 1 o• ,.1er+ low i O !.. -t 0069-006E - FAC#2 i o 5 - I / 'C.) 006F - FAC s i · :.w1 corn~=-ar i son // 1 0070 - FAC# 1 round i n-:.1 / / 2 0075 F:oom +or sw- .:<Phic:s screen J/ 7 ( O=not c1!...J-=•j l-=<b le) n . .- 007C-OO?D - F'o inter: GO::::f_l.f: st - :.'l.ck ·' tf -- / Z .5 !JO::\:: - F l- :<::.i +or 1.1.1 i ndo,.1.1 ( $40=w i nclow on .. /3 r $80=multicolour.,$C6~both 0090 0091 I:...,. '...t I('' · -. Status word ST J~~ J- - Ke-::1s1.1.1 itch CI A: :3TOP and F:V:; + la::.1s O= lo . :1.d .. 1 =• . ..1er if ·::l , i-1 '1 0093 0094 0095 - ::::et-· i ·=<.1 i:11_4t~=·ut : deferred char· + l-:<::.-1 1~ 8 - : ::er i 2. l def erred ch-:<r- -::i.cter i l--( 5 - # · ,:,pen f i les ! > ; . .c · 009::: I nr:·ut dei...11 ce I _) --- 0099 01.~t~=·1.~t CMD de 1 . ..1 ice i 5 .3 0097 009A - Di rect=:::O/r1_m=O 01...1t1=-ut control /5 c, 009D-009E - Tc<.Pe end - ::<.ddress/End of ~=· ro ·:. wc1If1 J5 .. - y,. OOAJ-OOA5 .Jiff·::1 clock J{:; J- / S [10A6 - Seri - ~- l bit cotmt/EO I f lasi 1 l OOAA - Cc,1_mtdown t.:IJ':·e wr i t.e/b it count I i, 0[1AB # chars in f i lename ; 1 I OOAC - Current lo·:.1 i C- ::<. l f i li? i .::; :::- - 00AD - C:1.wrent second - :<r-·.:1 a.ckk ·ess 1 :'; :1 OOAE - Cw--rE-nt de . ..1 ice ; (1 i OOAF-OOBO - Pointer to f i len.::<.ff,e /7 5 i -:Jt 1 I,- t +. .-1 J •7,,.,;; .J, .Jo 7 0•::.1I:2-00:B3 - ,·· u s .. :(!"-· .. a~,:~ress 1,:...; - 1 f :J 00B4-00f:5 Al! sta.rt. a. ddress ( !•=:iad., · \.ier i +·::1 > /. 7'5 om::6-(1(fE:7 - F'o 1 nter : ca.ss:E'tte buffer { f, / - OOC4-00C5 I m:·L~t cursc~r lo·:.1 ( r-01.1.1) e:r:r ltm1n) / :) £ 00C6 L · Jh 1 ch ke':::1 : t-4=no ke·.:1 f tj o i<2o 18<_ 1 37 00C7 I m=·ut. from screen/ke ·::1boar·d i C \ '5 OOC:::-OOC9 - Pointer tei screen line 2_ D ') _ 2 ;:, ; 00CA Pointer=c:ursor column 0 <: OOC:B - 01.rtt: ·ut ·= itwtes f l-:<. "21 2. 0 -:; Of1CD · Pointer : ct~rsor row - o - ~:, . OOCE 01_4t~:·1.4t ch.:1r- :1.cter (to scr e en > w t, OOCF # of i nsE't-·ts outst.:1r1d i n-:.1 '2...o 1- 00EA - OOEB Sc reen c:o lour p,:,intet-· 2.. ~<'.z: -- 2-1.>i OOEC-OOED Ve ·::clboar·d. t:oointer 2--.- ~>&, - 2:;-~1 _ 00EF # chars 1 n kE''::lbo.:<r-d bl 6 ffer '2... ,V'.) OOF8 T·::1~:·e of t-=<i=·e + i le 2... 'z1.. / i OOFF-010A F lo.a.tin·:.-1 to A:3CI I/ work n ar-e . ::<. 'J_";""';-· - J..b ( 0100-013E T.:1;: ,e error lo · :.1 1Sf ;, - :::, 1 u · . .-:-11•-:1.-:·1-•-::>lFF F't-------t- -+.-- 1 - ·- - - 2..- i c.-, , ~.:. t. t. •.:.I 'Lll_:l;:'::;.::;.1_1 . ::; .••. ;:f.1_:~·( ,:;:;<, "I;:',=!. ', l.) - J I 0200-025::: - R::1.s i c i rn:·ut bL4f fer ')'r 2 -: &c.... -u . 0259-(125A Pointer: line# +or COHT 6;.: , r {...-(: . 2. / 025f:-025C - F'o inter : B2.s i c st . .3-tement tor CC!r-HL~C: -> - 02F2-02F:;: F loa. t-f i :,-:: ed . ..1ector·· 1- jf + ·:.;~ 02F4-02F5 Fi::-::ed-f lo,;:1.t . ..1ectr:rr ·T-s- c, - ~s-7 0:300-0311 - Ba.sic . ..1ectors '') bS -- J -6 ( ·, - )

Upload: stefanmansier

Post on 28-Aug-2015

214 views

Category:

Documents


1 download

DESCRIPTION

Nuts and Bolts of the Commodore C16

TRANSCRIPT

  • j Nick Hampshire brings you a I detailed look at the C-16 ! Operating System variables I and memory map.

    ANYONE WISHING TO DO EXTENSIVE machine code programming on the C-1 6 or Plus-4 will require two essential pieces of information.

    The first, is a list of the operating system variables, their location and function. This is essential if fatal interac-tion with the system software is not to occur. It is also important to know where to place variables when using any of the system subroutines.

    The second essential piece of informa-tion is a memory map. This contains the entry points to the operating system and Basic ROM routines. The use of. such routines within a program can save a considerable amount of time and program space, an important considera-tion with the C-16.

    I have included both these pieces of information in this article.

    Unfortunately, Commodore has not previously produced any of this data and it has therefore been necessary to use the experience gained with p reviou s Commodore machines to deduce the location and function of both variables and routines. All the locations discovered have been thoroughly checked and I have no reason to doubt that they are correct, I wou ld however be very interested to hear from any readers with additional information.

    The operating system variables are, in common with all Commodore machines, stored in the bottom area of memory extending from location $0000 up to the bottom of the screen colour memory at $0800, a total of 2K of memory. All ,the . important variable locations are shown in Table 1. It should be noted that locations $00 and $01 are an 1/ 0 port located on the processor chip and cannot therefore be used for variable storage.

    A memory map of the ROM based operating system _and Basic routines is shown in Table 2. Many of these routines are usable to some degree, and some are extremely valuable. Most of the routines and variab les are similar, or even identical, in function, if not in location, to those on the C64.

    Readers wishing to gain an in depth knowledge of the routines, functions and operations are recommended to consult

    38 I one of the advanced books on the 64. The 11m11R, 64 Revealed series by N ick Hampshire,

    I published by Collins is recommended , especiall y Advanced Com m odore 64 Basic Revealed.

    OF THE

    , -,:able:.1 ' .. . : _,,. ' ,< . ~..... ' .,; ' ' I ~

    --====---==-----------------------

    0001 - Cassette c:cit1trr:r l Bit 4 Cassette read

    (100A OOOD 0(10E OOOF (1(114-(1(115 -0016 001 7-0(11 E: 0019-0021 0022-0025 0026-002A -002B-002C 002D-002E -002F-0030 0031-(HJ32 [1[133-00:::4 0035-(1(136 0037-(1038 0039-(1[1:3A 003B- 003C 003D-003E -oo:::F-0040 -0041 -(HJ42 -004:::: - 0044 -0045-0046 -0047-(HJ4f: 0049- 004A -004E:-004C -004D 004E-005:3 0054- 0056 -0057-0060 -0061 0062-0065 0066 0067

    :3 : Cassette motcr ( O=on) 1 : Cassette 1.ur i te

    0=LOAD,1=VERIFY \o TY~e= FF=string,00=numeric 13 T::1~=e: f:O=inte~er., 00=-f k~.tin-:.1 t '1 DATA scan---'L I ST ::tuote.'memm-::1 + l -: /. 7'5 om::6-(1(fE:7 - F'o 1 nter : ca.ss:E'tte buffer { f, / -OOC4-00C5 I m:L~t cursc~r lo:.1 ( r-01.1.1) e:r:r ltm1n) / :) 00C6 LJh 1 ch ke':::1 : t-4=no ke.:1 f tj o

    i

  • o:::: 16-031 7 031!::-(1319 0:31A-ft::::1f: 0:::: 1 C-(t31 D 031E-031F

    0:322-(1:32:3 0324-(1:325

    0:32A-0:32E: 032C-032D lt32E-0~32F 0:330-03:::: 1

    04FC/04FE 04FD/04FF i;.150:::: 0509-0512 1]513-051C 05111"'""(1526

    IF.:q ,._.1ector -for ke::::1sc-:.n/c locl~ ?-86 ''i1J1 Mc1.1 n I RC~ vector for tc9 -, 1-'2), OPEN vector }-~ '2. - ")-')3 ~LOS~ vector i,-:') 'i -~ r~S-:=,et 1 t1PUt ~..'ector ~ ~ 6 - "f '2:) 7 Set outt:ut . ..iector ~)& - ;fS Outt=-ut vector f!o'i- tlo')" Test-STOP ,.ector ,9d,- s - Current colour code1~~~

    Bit 7 : 1=-f la.sh 6-4 : lw11 i narice ( 0-7) 3-0 : colour (0-15)

    0547 07(H3-07E:0

    07F5 07F6 07FD 0800-0BFF OC00-(:JFEV 10f10-3FF5 1800-:3FF5 3FF6-3FFD

    Maxi mum size . o-f ke'::lboa.rd br_,f-fer V.2.h '.) Petoea.t st:eed cc,tn-1ter l 1 tt !' Re~=-eat de la'=' c:c,ur,ter l)

  • AB8D Perform ' REt4UMBER , ~ S c.) t 7- D965 - It-1toL~t unt i l carr i a~e ,returnss-6'r ADCA Perform FOR DB 11 - Read ke:::1boarcl 56 o 8 7 AE5A Perferrri, ,. DELETE _ . DC:49 - Outt: .. ~ L-c,41 P f.. ,r1...,c-A'.'E,. r .~ / - - er orm EF5:::: (lpen fi le ($0318) 0 L z_ ~ t

    C:951 - Per-form ,r1LOAD,. F04A - Load t=-ro& o

    C99C - Perform ,sci:.:ATCH'. -S- I bi 2 F265 - Test STOP ke':1 ($(1:3Z,6) 62.p '5':> C9CC Perform ,COLLECT,. F2A4 Power - reset entr:::1 Cf- I L b C9DA - Perform coP'r''. F2CE Set kerna l 1,..ectors 6,2..y~&r C9F 4 - Per-form ,. REHAME,. -S--1 ) 0-U F2D3 - Store kerna l vecj:ors b 2... I o .'.) CA0(1 - Perform ,. BACKUP F30B - Initialise I /0 6 2.....2. l C\ /

    - Get Par&c,ters tor disk c,ommands F::::52 - Initialise s'::lstem consf..:1.nt~.62..z. J - Read disk error .F 40C - Set f i lename deta; ls CZ... Lr f6 .

    CD32 - ,"ARE 'T'OU SUF=:s'T!J7J F423 - Set timeout &2..