************************** STOP PRESS ********************************** OS 1.2 ADDRESSES COMING SOON , some here already. ( More coming when I've finished exams, i.e. after 10th june ) ************************************************************************ XXXX XXXXXX XXXXXXXX XXXXX XXXXX XXXX XXXXXXXX XX XX XX XX XX XX XXXXXXXX XX XX XX XX XX XXXXX XXXXX XX XXXXXXXXXX XX XX XX XX XX XXXXXXXXXX XX XX XX XX XX XX XXXXXXXX XXXXX XXXXX XXXX XXXXXX XXX XX XXXXXXX XXXX BBC Memory Map ~~~~~~~~~~~~~~~ PAGE USAGE SUMMARY: Page use &00 zero page &01 processor stack &02 OS use &03 OS use &04 0400-0480 system integer variables 0481-04FF variables catalogue &05 FOR/REPEAT/GOSUB stack &06 string buffer &07 line input &08 sound,envelopes &09 RS423 transmit buffer &0A RS423 recieve buffer &0B soft key buffer } &0C character definitions } May be used for machine code etc &0D disk workspace } &0E start of Basic program buffer &0E-3F Model A Basic/user RAM &0E-7F Model B Basic/user RAM &80-BF language ROM &C0-FD OS ROM &FC-FD Fred & Jim expansion buses &FE memory mapped I/O &FF OS ROM ZERO PAGE: ~~~~~~~~~ Location Function 00-01 LOMEM lo-hi 02-03 VARTOP (top of variables) 04-05 Basic stack pointer 06-07 HIMEM lo-hi 08-09 ERL lo-hi 0A offset for text pointer 0B-0C text pointer 0D-11 RND store 12-13 TOP lo-hi 14 Number of chars in PRINT field 15 flag:Bit 7 set => hex o/p for PRINT 16-17 ERROR vector default to &B443 18 PAGE hi byte 19-1A secondary text pointer 1B offset for secondary text pointer 1C-1D ptr - restet to PAGE 1E COUNT 1F LISTO option 20 flag:&FF => TRACE ON 21-22 maximum TRACE line number 23 WIDTH 24 number of REPEATs left 25 number of GOSUBs left 26 15 * number of FORs left 27 variable type:&00=string &40=integer &05=floating point &A4=FN &F2=PROC 28 OPT value for assembler 29-2B assembled code buffer 2A-2D IAC (integer accumulator) 2A-2B pointer to variable 2C variable type 2E FAC#1 sign/POINT parameter 2F FAC#1 over/underflow byte 30 FAC#1 exponent 31-34 FAC#1 mantissa 35 FAC#1 rounding byte 36 length of string 37-38 object loc in assembler RENUMBER pointer pointer for variable name in DIM line crunching pointer action address JMP vector 39 length of variable name 39-3A number of bytes into array that variable is,ptr to keyword table RENUMBER/DELETE line number 3B-3C ptr for RENUMBER / number of inserted spaces in LISTO 3B FAC#2 sign 3C FAC#2 over/underflow 3D FAC#2 exponent 3E-41 FAC#2 mantissa 42 FAC#2 rounding byte 3C-3D ptr used in DEF 3D-3E ptr used in search for line / crunching 3F array type:&05=floating point &04=string 3F-47 hex o/p nibbles 42-47 numeric work area 43 temporary store used in calculating exponents 48 counter in series evaluation 48-49 adjustments factor for ASCII/f-point conversion 4A temporary store used in calculating exponents 4B-4C ptr to current variable 4D file number temp store 4D-4E LISTO pointer / INPUT flags 4F 50-6F not used in basic model A 70-8F guaranteed empty 90-9F allocated for Econet system A0-A7 used by current NMI (mostly disc and network filing) A8-AF used for OS commands when executing B0-BF filing system scratch space C0-CF allocated to current active filing system D0-E1 allocated to VDU driver E2 cassette filing system status E3 cassette filing system options E4-E6 OS workspace E7 auto repeat countdown timer E8-E9 pointer to OSWORD &01 input buffer EA RS423 timeout counter EB cassette filing system flag EC internal number of last key pressed ED as above ,but for key still being pressed EE internal number of key to ignore ,set by OSBYTE &79 EF accumulator value of most recent OSBYTE/OSWORD F0 X register value of most recent OSBYTE/OSWORD or stack pointer value of last BRK F1 Y register value of most recent OSBYTE/OSWORD F2-F3 text pointer F4 RAM copy number of currently selected paged ROM F5 current PHROM or ROM filing system ROM number F6-F7 address pointer to paged ROM F8-F9 not used FA-FB general workspace for OS FC user IRQ routine slave slot for register FD-FE pointer to byte after last BRK FF Escape flag ZERO PAGE LOAD/SAVE BLOCK: 37-38 pointer to file name 39-3A load address: 4 bytes,least to most significant 3B set to &FF 3D-40 execution address: 4 bytes,as above 41-44 program save,lower limit: 4 bytes,as above 45-48 program save,upper limit: 4 bytes,as above PAGE 1: ~~~~~~ 00-FF used by 6502 stack and some service paged ROMs PAGE 2: ~~~~~~ 00-35 indirection vectors: 00-01 USERV reserved 02-03 BRKV break vector 04-05 IRQ1V all IRQ vector 06-07 IRQ2V unrecognised IRQ 08-09 CLIV interpret command line given 0A-0B BYTEV miscellaneous OS operations (register parameters) 0C-0D WORDV miscellaneous OS operations (control block parameters) 0E-0F WRCHV write character to screen from A 10-11 RDCHV read character to A from keyboard 12-13 FILEV load or save file 14-15 ARGSV load or save data on file 16-17 BGETV load byte to A from file 18-19 BPUTV save byte to file from A 1A-1B GBPBV load or save block of memory to file 1C-1D FINDV open or close file 1E-1F FSCV file system control entry 20-21 EVNTV event interrupt 22-23 UPTV user print routine 24-35 ? 36-8F main system variables accessed by OSBYTE &A6-FF 90 VDU vertical adjust set by *TV 91 interlace toggle flag as set by *TV 92-96 stored value of system clock 97-9B stored value of system clock 9C-A0 countdown interval timer A1-B0 paged ROM type table B1-B2 INKEY countdown timer B3-B5 used as work locations by OSWORD 1 B6-B9 lower bytes of most recent analogue convertor values BA-BD higher bytes of most recent analogue convertor values BE analogue system flag BF-C8 event enable flags C9 soft key expansion pointer CA first auto repeat count CB-CD workspace for two key rollover CE sound semaphore CF-D7 buffer busy flags D8-E0 buffer start indices E1-E9 buffer end indices EA-EB block size of current cassette input file EC block flag of current cassette input file ED last character of current cassette input file EE-FF used to build OSFILE control blocks PAGE 3: ~~~~~~ 00-01 X co-ord of right of graphics window 02-03 Y co-ord of bottom of graphics window 04-05 X co-ord of left of graphics window 06-07 Y co-ord of top of graphics window 08 X co-ord of left of text window 09 Y co-ord of bottom of text window 0A X co-ord of right of text window 0B Y co-ord of top of text window 0C-0D X co-ord of graphics origin 0E-0F Y co-ord of graphics origin 10-17 ? 18 text cursor X position 19 text cursor Y position 1A-40 ? 4A-4B text cursor address 4C-4D ? 4E MSB screen memory start ( LSB not stored, assumed = 0 ) 4F bytes per character 50-51 address of top left of screen 52-53 bytes per line 54 screen memory length 55 MODE 56-57 ? 58 CLS/scroll filler byte 59 graphics foreground mask 5A graphics background mask 5B graphics foreground modifier 5C graphics background modifier 5D-5F ? 60 number of colours available 61 pixels per byte 62-6E ? 6F-7E pallette 7F-FF ? PAGE 4: ~~~~~~ 00-80 system integer varbiables 81-FF variables catalogue PAGE 5: ~~~~~~ 00-FF FOR/REPEAT/GOSUB stack PAGE 6: ~~~~~~ 00-FF string buffer PAGE 7: ~~~~~~ 00-FF line input PAGE 8: ~~~~~~ 00-FF sound ,envelopes PAGE 9: ~~~~~~ 00-FF RS423 transmit ,cassette ,sound and speech workspace PAGE A: ~~~~~~ 00-FF RS423 recieve and cassette workspace PAGE B: ~~~~~~ 00-FF user defined function key definitions PAGE C: ~~~~~~ 00-FF user defined character definitions PAGE D: ~~~~~~ 00-FF used by NMI routines ,disc workspace PAGES E-7F: ~~~~~~~~~~ Basic/user RAM PAGES 80-BF: ~~~~~~~~~~~ current language ROM PAGES C0-FD: ~~~~~~~~~~~ operating system ROM, entry points: Reset and BRK handling routines: D9CD RESET entry point DBB8 set up language DBE7 OSBYTE 8E - enter language ROM DC08 switch ROM page, read byte, return to original ROM DC16 save ROM identity and switch paged ROM DC1C maskable interrupt entry point DC54 BRKV - default BRK routine IRQ handling routines: DC68 check buffer status, receive IRQ, set ACIA DC7D transfer received serial data to input buffer DC93 IRQ1V - high priority IRQ routine enrty point DCA2 poll 6850 ACIA for IRQ, service it if required DCB3 generate RS423 event error DCBF output character from RS423 buffer DCD6 transmit serial data from output buffer DCDE check for RS423 error DCF3 offer IRQ to paged ROMs, then low priority IRQ handler DD06 poll MOS VIA for IRQ, service it if required DD13 check for vertical sync IRQ, service it if required DD47 poll USR VIA for IRQ, service it if required DD69 check for further MOS VIA IRQs DD6F process MOS VIA timer 2 IRQ DD79 transfer data from speech buffer to processor DDCA check MOS timer 1 timeout IRQ, service it if required DE47 check for ADC IRQ, service it if required DE6E set MOS VIA interrupt flag register DE72 check for key-pressed IRQ, service it if required DE89 IRQ2 - low priority IRQ handler routine Analogue to digital convertor routines: DE8C OSBYTE 11 - force A-D conversion DE8F set up ADC channel ROM embedded message printing routines: DEA9 set BRK address = C300, PRINT embedded message DEAB set BRK address, PRINT embedded message DEB1 PRINT embedded message Character input routines DEBB set INKEY countdown timer, read character to A register DEC5 RDCHV - read character from A register DED2 read character from EXEC file OS * command handler and printer output routines DF0C-DF0F copyright symbol lookup table DF10-DF88 command keywork and vector lookup table DF89 CLIV - interrupt command line routine DFB6 process */ command DFF2 push command entry address on stack then execute command E004 move pointers to next command vector E009 check command against commands from lookup table E00D transfer command line pointers to X,Y registers E018 *BASIC command E031 *RUN command E031 *CAT command E039 increment index (Y) and ... E03A flush MOS command buffer to non-blank, check for CR E043 flush line to non-blank, check for "," or CR E045 flush to non-blank, check for "," or CR E04E flush line to non-blank, convert ASCII to HEX, clear carry E07C convert ASCII numeral input to hex E07D increment index (Y) and ... E08A flush input line to non-blank, clear carry E08F if hex numeral remove ASCII offset E0A4 WRCHV entry point - write character from A register E114 if permitted, PRINT character E11E insert character into buffer and PRINT it E13A PRINT character via appropriate routine E143 parallel printer output E168 serial printer output E170 set buffer flag busy, if no space free, reset ACIA control reg E173 if no buffer space free, reset ACIA control reg E17A reset ACIA control reg E17C OSBYTE 9C - r/w 6845 ACIA control reg E189 write to ACIA control reg, save setting to page 2 E191 PRINT character via econet or user print routine E197 OSBYTE 7B - inform OS, printer going dormant E19B if printer buffer occupied, output character E1A2 select printer buffer and output character E1A4 PRINT character via econet or user printer routine E1AD flush specific buffer E1AE flush buffer E1D1 CNPV entry point - count or purge buffer E1F8 attempt to insert character into buffer E20E initialise parameter block 02EE,X-02FA,X E21F pack character into OSFILE control block E227 *KEY command E23C *LOAD command E267 "bad address" error message, error code FC E275 OSBYTE 77 - close any SPOOL or EXEC files E281 *SPOOL command E28F close SPOOL file E2AD construct OSFILE parameter block from OS command line buffer E310 "bad command" error message, error code FE E310 USERV default entry point E31D "bad key" error message, error code FB E33E *SAVE command E342 *FX command E348 *TAPE command ? *TV command ? *ROM command ? *OPT command ? *MOTOR command ? *CODE command User defined key routines: ? calculate length of key string E3D1 set up soft key definition E3E9 "key in use" error message, error code FA Buffer housekeeping routines: <<< watch this space >>> PAGE FC: ~~~~~~~ 00-FF external memory mapped I/O FRED 00-0F used by dealers test equipment (PET) 10-13 teletext 14-17 prestel 80-8F used by dealers test equipment C0-FE reserved for user applications FF ROM paging register PAGE FD: ~~~~~~~ 00-FF external memory mapped I/O JIM intended for external paged ROM/RAM (up to 64K) PAGE FE: ~~~~~~~ 00-FF internal memory mapped I/O SHEILA: REG IC WRITE READ ~~~ ~~ ~~~~~ ~~~~ 00 6845 CRTC address register 01 6845 CRTC register file 08 6850 ACIA control register status register 09 6850 ACIA transmit data register receive data register 10 serial ULA control register 20 video ULA 21 video ULA 30 74LS161 paged ROM identity 40 internal 6522 MOS input/output 60 ORB/IRB 6522 VIA output register B input register B 61 ORA/IRA 6522 VIA output register A input register A 62 DDRB 6522 VIA data direction B 63 DDRA 6522 VIA data direction A 64 T1C-L 6522 VIA T1 low order latches T1 low order counter 65 T1C-H 6522 VIA T1 high order counter 66 T1L-L 6522 VIA T1 low order latches 67 T1L-H 6522 VIA T1 high order latches 68 T2C-L 6522 VIA T2 low order latches T2 low order counter 69 T2C-H 6522 VIA T2 high order counter 6A SR 6522 VIA shift register 6B ACR 6522 VIA auxiliary control reg. 6C PCR 6522 VIA peripheral control reg. 6D IFR 6522 VIA interrupt flag reg. 6E IER 6522 VIA interrupt enable reg. 6F ORA/IRA 6522 VIA as reg 1 but no handshake 80 8271 FDC command register status register 81 8271 FDC parameter register result register 82 8271 FDC reset register 83 8271 FDC illegal illegal 84 8271 FDC write data read data A0 CR1/SR1 68B54 ADLC control register 1 status register 1 A1 CR2/SR2 68B54 ADLC control register 2/3 status register 2 A2 TxFIFO 68B54 ADLC transmit FIFO ,continue RxFIFO receive FIFO A3 TxFIFO 68B54 ADLC transmit FIFO ,terminate RxFIFO recieve FIFO C0 uPD7002 data latch ,A/D start status C1 ADC high byte of result C2 PAGE FF: ~~~~~~~ operating system ROM ============================================================================== Note - The following applies to BASIC 1 BASIC ROM ROUTINES: ~~~~~~~~~~~~~~~~~~ 8000 Jump to language initialisation 8003 Jump to cold start 8007 ROM titles 801F Language initialisation 806D Table of keywords and tokens 835A Action addresses - lo bytes 83CB Action addresses - hi bytes 84AE Assembler tables 84ED Assembler entry point 856A Output hex of AC then a space 8570 Output hex of AC 87E4 Get byte from ASCII 87ED Crunch one word 88AB Test char in AC : C=1 if alphanumeric 88CA Get char from line 88D3 Crunch entire line of text 88D9 Crunch part of text 8A13 Get byte from basic text, pointed to by (&19),&1B 8A1E Get byte from basic text, pointed to by (&0B),&0A 8A35 Check presence of "," and move text ptr to it 8A80 Warm start 8B14 Evaluate next statement 8B7E 'Type mismatch error' 8BAA Deal with "=" on start of line (in DEFFN) 8BC3 Deal with "*" 8BD0 Allocate value to string variable 8C36 Perform $xxxx = string 8C4B 'No room' error 8C5B Pull string off stack into buffer 8CCD Perform PRINT# 8E3E Output message pointed to by (&19),Y within quotes 91D7 Increment IAC 91EB (&2A,2B)=(&2A,2B)*(&3F,40) 928C Evaluate expression , result in IAC 9292 Get integer parameter from Basic text 941B Search for FN/PROC 9429 Search for variable pointed to by (&37,38),length of name in &39 94AD Set up FN/PROC references 94BC Set up new variable name 94F7 Clear newly created variable 9548 Set up variable references,(&2A,2B) points to variable 95A9 Set up variable references 967B Set up string variable references 96AB Set up array references 9789 Check array subscript size 97E2 Check "=" then evaluate RHS of expression 97F4 Check next char is "=" 9810 Skip rest of statement testing escape 9826 Move past code 9834 Test escape key 9839 Syntax error 9851 Move to next statement , with TRACE output if necessary 9893 Copy pointers then evaluate expression 98D6 Do TRACE output if required 98C2 Search for ELSE and execute it 98F1 Output decimal for number in &2A,2B , lo-hi 9942 Search Basic for given line number , C=1 if not found 9B03 Evaluate expression (main entry point) 9BEF Concatenate strings 9DFD Evaluate expression and get non-space char into XR 9ED0 Assemble PRINT output string 9E81 Assemble hex output string for PRINT 9EB9 Assemble floating point output string A04B Convert AC to dec ASCII and store in string buffer A057 Store char in string buffer,incrementing pointers A06C Get floating-point number from ASCII A188 FAC#1 = FAC#1 * 10 (acting on mantissa only),preserving AC A1CB Get sign of FAC#1 A20F Copy FAC#1 to FAC#2 A23E FAC#1 = FAC#1 / 10 A2AF Convert fixed-point to floating-point A2F4 Normalise FAC#1 A33F Unpack variable into FAC#2 A37E Pack FAC#1 to memory A3A3 Unpack &046C onwards to FAC#1 A3A6 Unpack variable to FAC#1 - pointed to by (&4B,4C) A3D8 Round FAC#1 A3F2 Convert floating-point to fixed-point A463 Clear FAC#2 A476 Convert sign in &2E and mantissa in &31-4 to signed integer in &31-4 A4C4 Increment mantissa of FAC#1 A4DE Swap variable and FAC#1 A61E FAC#1 = FAC#1 * FAC#2 A68B Test for under/overflow A691 Clear FAC#1 A6A4 FAC#1 = 1 A6B0 FAC#1 = 1 / FAC#1 A6B8 FAC#1 = variable / FAC#1 A6F2 FAC#1 = FAC#1 / variable A889 Power series evaluation AC5A Calculate VAL of string in buffer and store in FAC#1 ACFA IAC = NOT (IAC) AD94 Make IAC positive ADA0 FAC#1 = -FAC#1 ADB5 Complement IAC ADDC Scan input line ADF8 Scan string AE1B Evaluate single part of expression - final destination of Evaluate Expression subroutines AE85 Check ")" present after evaluating expression AE9C Get IAC value from hex in text AF07 Convert byte in AC to fixed-point in IAC AF19 Put AC,YR lo-hi in IAC (clearing higher bytes) AF85 Move &00XR - &00XR+3 into IAC B141 Search for DEF in Basic program B25F Pull processor stack off Basic stack B27C Transfer variables into FN/PROC B35B Unpack variable specified (type & location) by IAC into IAC/FAC#1/string buffer ,depending on variable type B433 Entry to error handling routine B443 Default error vector for ON ERROR contains:'REPORT:IF ERL <> 0 THEN PRINT"at line";ERL; PRINT:END' B4DD Evaluate expression and then... B4E0 Get variable desciption from Basic stack then... B4E3 Assign value to numeric variable B4F2 Store value of IAC in variable B53A Output character in AC , decrunching if token B571 Output any character , updating COUNT B57B Output space , updating COUNT B911 Deal with ON ERROR B9ED INPUT# BC17 Input string into buffer BC1D Input line of text printing AC as prompt BC42 Output clearing COUNT BC4A Remove line from Basic program (specified by line No in IAC) C=1 if line not found BCAA insert line into Basic program BCE9 Cold start BD38 Reset basic pointers BD69 Pack FAC#1 onto Basic stack BD96 Increment Basic stack pointer and point (&4A,B) to floating-point variable now below it BD8A Push value of variable onto Basic stack type specified by AC: 00 = string,floating point &40= fixed point BDAC Push IAC onto Basic stack BDCA Push string (&0600 to ) onto Basic stack BE02 Pull IAC from Basic stack BE23 Pull variable description off Basic stack BE42 Lower Basic stack pointer , checking memory available BE5C Store IAC in &00XR to &00XR+3 BE7A Load program then... BE88 Re-link Basic program BEAB TOP = TOP + YR BEDE Get parameters for LOAD/SAVE BFAE GET file# (for PRINT# , INPUT# ,etc) into AC and YR BASIC ACTION ADDRESSES: ~~~~~~~~~~~~~~~~~~~~~~ token address keyword token address keyword 80 9B54 AND C2 B01D MID$( 81 9DE7 DIV C3 B0C3 RIGHT$( 82 9B2F EOR C4 B01F STR$ 83 9DDE MOD C5 ACDE STRING$ 84 9B14 OR C6 905F EOF 85 -- ERROR C7 8ECE AUTO 86 -- LINE C8 BF2D DELETE 87 -- OFF C9 B5B5 LOAD 88 -- STEP -- B5A0 LIST 89 8DF2 SPC CA 8A7D LISTO 8A 8DD9 TAB( CB 8A3D NEW 8B -- ELSE CC 8F37 OLD 8C -- THEN CD BEFA RENUMBER 8D -- line no CE 9839 SAVE 8E syntax 8F BF50 =PTR CF BF39 error 90 AEEF =PAGE D0 9239 PTR= 91 AEE3 =TIME D1 927B PAGE= 92 AF2B =LOMEM D2 9224 TIME= 93 AF32 =HIMEM D3 9212 LOMEM= 94 AD8D ABS D4 B461 HIMEM= 95 A8C6 ACS D5 BF61 SOUND 96 AB56 ADVAL D6 8E6C BPUT 97 ACC4 ASC D7 BF33 CALL 98 A8CC ASN D8 9326 CHAIN 99 A907 ATN D9 BF9E CLEAR 9A BF78 BGET DA 8E57 CLOSE 9B A989 COS DB 8E5E CLG 9C AF26 =COUNT DC 8AED CLS 9D ABE7 DEG DD 8AED DATA 9E AFCE ERL DE 90DD DEF 9F AFD5 ERR DF 93A5 DIM A0 AC12 EVAL E0 8050 DRAW A1 AAB4 EXP E1 9310 END A2 BF4F EXT E2 B49C ENDPROC A3 AEF9 FALSE E3 B7DF ENVELOPE A4 B1C4 FN E4 B8B4 FOR A5 AFE8 GET E5 B8EB GOSUB A6 ACD3 INKEY E6 932F GOTO A7 AD08 INSTR E7 9893 GCOL A8 AC9E INT E8 BA62 IF A9 AF00 LEN INPUT AA A804 LN E9 8B57 LET AB ABCD LOG EA 92D5 LOCAL AC ACF7 NOT EB 935A MODE AD BF85 OPENIN EC 93A1 MOVE AE BF81 OPENOUT ED B6AE NEXT AF ABF0 PI EE B934 ON B0 AB64 POINT( EF 93EF VDU B1 AB92 POS F0 93AE PLOT B2 ABD6 RAD F1 8D33 PRINT B3 AF78 RND F2 92B6 PROC B4 ABAD SGN F3 BB39 READ B5 A994 SIN F4 8AED REM B6 A7B4 SQR F5 BBFF REPEAT B7 A6C9 TAN F6 BFE6 REPORT B8 AF0B TO F7 BB00 RESTORE B9 ACEA TOP F8 B8D5 RETURN BA ABFB TRUE F9 BD29 RUN BB AC55 USR FA 8A59 STOP BC AB9B VAL FB 9346 COLOUR BD B3EE VPOS FC 9243 TRACE BE AFEE CHR$ FD BBCC UNTIL BF B055 GET$ FE B4CC WIDTH C0 AFFB INKEY$ FF 9839 Syntax C1 B068 LEFT$ error Compiled by Ian Keeble using bits from : Personal Computer World Using the BBC Micro BBC User Guide Advanced Machine Code Techniques for the BBC Micro The BBC Micro Revealed Note: Most data applicable to OS 1.2 , but zero page addresses came from a pre-1.2 PCW so some of these may have changed.