BASIC-ROM
From C64-Wiki
Jump to navigationJump to search

Commodore Nr. 901226-01
In 8 KByte large memory area 40960-49151 ($A000-$BFFF) are the BASIC-ROM. The BASIC interpreter is in memory area ($A000-$BFFF) and ($E000-$E4D2). To modify the BASIC routines, these areas must be copied into the RAM.
| Hex address | Decimal address | Description |
| $A000 | 40960 | Basic cold start vector ($E394) |
| $A002 | 40962 | Basic warm start vector ($E37B) |
| $A004 | 40964 | Text "cbmbasic" |
| $A00C | 40972 | Addresses of the BASIC-commands -1 (END, FOR, NEXT, ... 35 addresses of 2 byte each) |
| $A052 | 41042 | Addresses of the BASIC functions (SGN, INT, ABS, ... 23 addresses of 2 byte each) |
| $A080 | 41088 | Hierarchy-codes and addresses of the operators -1 (10-times 1+2 Bytes) |
| $A09E | 41118 | BASIC key words as string in PETSCII; Bit 7 of the last character is set |
| $A129 | 41257 | Keywords which have no action addresses - TAB(, TO, SPC(, ...; Bit 7 of the last character is set |
| $A140 | 41280 | Keywords of the operands + - * etc.; also AND, OR as strings. Bit 7 of the last character is set |
| $A14D | 41293 | Keywords of the functions (SGN, INT, ABS, etc.) where bit 7 of the last character is set |
| $A19E | 41374 | Error messages (TOO MANY FILES, FILE OPEN, ... ); 29 messages where bit 7 of the last character is set |
| $A328 | 41768 | Pointer-table to the error messages |
| $A364 | 41828 | Messages of the interpreter (OK, ERROR IN, READY, BREAK) |
| $A38A | 41866 | Routine to search stack for FOR-NEXT and GOSUB |
| $A3B8 | 41912 | Called at BASIC line insertion. Checks, if enough space available. After completion, $A3BF is executed |
| $A3BF | 41919 | Move bytes routine |
| $A3FB | 41979 | Check for space on stack |
| $A408 | 41992 | Array area overflow check |
| $A435 | 42037 | Output of error message ?OUT OF MEMORY |
| $A437 | 42039 | Output of an error message, error number in X-register; uses vector in ($0300) to jump to $E38B |
| $A480 | 42112 | Input waiting loop; uses vector in ($0302) to jump to basic warm start at $A483 |
| $A49C | 42140 | Delete or Insert program lines and tokenize them |
| $A533 | 42291 | Re-link BASIC program |
| $A560 | 42336 | Input of a line via keyboard |
| $A579 | 42361 | Token crunch -> text line to interpreter code; uses vector in ($0304) to get to $A57C |
| $A613 | 42515 | Calculate start address of a program line |
| $A642 | 42562 | BASIC command NEW |
| $A65E | 42590 | BASIC command CLR |
| $A68E | 42638 | Set program pointer to BASIC-start (loads $7A, $7B with $2B-1, $2C-1) |
| $A69C | 42652 | BASIC command LIST |
| $A717 | 42775 | Convert BASIC code to clear text; uses vector (0306) to jump to $A71A |
| $A742 | 42818 | BASIC-command FOR: Move 18 bytes to the stack 1) Pointer to the next instruction, 2) actual line number, 3) upper loop value, 4) step with (default value = 1), 5) name of the lop variable and 6) FOR-token. |
| $A7AE | 42926 | Interpreter loop, set up next statement for execution |
| $A7C4 | 42948 | Check for program end |
| $A7E1 | 42977 | execute BASIC command; uses vector ($0308) to point to $A7E4 |
| $A7ED | 42989 | Executes BASIC keyword |
| $A81D | 43037 | BASIC command RESTORE: set data pointer at $41, $42 to the beginning of the actual basic text |
| $A82C | 43052 | BASIC command STOP (also END and program interruption) |
| $A82F | 43055 | BASIC command STOP |
| $A831 | 43057 | BASIC command END |
| $A857 | 43095 | BASIC command CONT |
| $A871 | 43121 | BASIC command RUN |
| $A883 | 43139 | BASIC command GOSUB: Move 5 bytes to the stack. 1) the pointer within CHRGET, 2) the actual line number, 3) token of GOSUB; after that, GOTO ($a8a0) will be called |
| $A8A0 | 43168 | BASIC command GOTO |
| $A8D2 | 43218 | BASIC command RETURN |
| $A8F8 | 43256 | BASIC command DATA |
| $A906 | 43270 | Find offset of the next separator |
| $A928 | 43304 | BASIC command IF |
| $A93B | 43323 | BASIC command REM |
| $A94B | 43339 | BASIC command ON |
| $A96B | 43371 | Get decimal number (0...63999, usually a line number) from basic text into $14/$15 |
| $A9A5 | 43429 | BASIC command LET |
| $A9C4 | 43460 | Value assignment of integer |
| $A9D6 | 43478 | Value assignment of float |
| $A9D9 | 43481 | Value assignment of string |
| $A9E3 | 43491 | Assigns system variable TI$ |
| $AA1D | 43549 | Check for digit in string, if so, continue with $AA27 |
| $AA27 | 43559 | Add PETSCII digit in string to float accumulator; Assumes C=0 |
| $AA2C | 43564 | Value assignment to string variable (LET for strings) |
| $AA80 | 43648 | BASIC command PRINT# |
| $AA86 | 43654 | BASIC command CMD |
| $AA9A | 43674 | Part of the PRINT routine: Output string and continue with the handling of PRINT |
| $AAA0 | 43680 | BASIC command PRINT |
| $AAB8 | 43704 | Outputs variable; Numbers will be converted into string first |
| $AACA | 43722 | Append $00 as end indicator of string |
| $AAD7 | 43735 | Outputs a CR/soft hyphenation (#$0D), followed by a line feed/newline (#$0A), if the channel number is 128 |
| $AAF8 | 43768 | TAB( (C=1) and SPC( (C=0) |
| $AB1E | 43806 | Output string: Output string, which is indicated by accu/Y reg, until 0 byte or quote is found |
| $AB3B | 43835 | Output of cursor right (or space if output not on screen) |
| $AB3F | 43839 | Output of a space character |
| $AB42 | 43842 | Output of cursor right |
| $AB45 | 43845 | Output of question mark (before error message) |
| $AB47 | 43847 | Output of a PETSCII character, accu must contain PETSCII value |
| $AB4D | 43853 | Output error messages for read commands (INPUT / GET / READ) |
| $AB7B | 43899 | BASIC command GET |
| $ABA5 | 43941 | BASIC command INPUT# |
| $ABBF | 43967 | BASIC command INPUT |
| $ABEA | 44010 | Get line into buffer |
| $ABF9 | 44025 | Display input prompt |
| $AC06 | 44038 | BASIC commands READ, GET and INPUT share this routine and will be distinguished by a flag in $11 |
| $AC35 | 44085 | Input routine for GET |
| $ACFC | 44284 | Messages ?EXTRA IGNORED and ?REDO FROM START, both followed by $0D (CR) and end of string $00. |
| $AD1D | 44317 | BASIC command NEXT |
| $AD61 | 44385 | Check for valid loop |
| $AD8A | 44426 | FRMNUM: Get expression (FRMEVL) and check, if numeric |
| $AD9E | 44446 | FRMEVL: Analyzes any Basic formula expression and shows syntax errors. Set type flag $0D (Number: $00, string $FF). Sety
integer flag $0E (float: $00, integer: $80) puts values in FAC. |
| $AE83 | 44675 | EVAL: Get next element of an expression; uses vector ($030A) to jump to $AE86 |
| $AEA8 | 44712 | Value for constant PI in 5 bytes float format |
| $AEF1 | 44785 | Evaluates expression within brackets |
| $AEF7 | 44791 | Check for closed bracket ")" |
| $AEFA | 44794 | Check for open bracket "(" |
| $AEFD | 44797 | Check for comma |
| $AF08 | 44808 | Outputs error message ?SYNTAX ERROR and returns to READY state |
| $AF0D | 44813 | Calculates NOT |
| $AF14 | 44820 | Check for reserved variables. Set carry flag, if FAC points to ROM. This indicates the use of one of the reserved variables |
| $AF28 | 44840 | Get variable: Searches the variable list for one of the variables named in $45, $46 |
| $AF48 | 44872 | Reads clock counter and generate string, which contains TI$ |
| $AFA7 | 44967 | Calculate function: Determine type of function and evaluates it |
| $AFB1 | 44977 | String function: check for open bracket, get expression (FRMEVL), checks for commas, get string. |
| $AFD1 | 45009 | Analyze numeric function |
| $AFE6 | 45030 | BASIC commands OR and AND, distinguished by flag $0B (= $FF at OR, $00 at AND). |
| $B016 | 45078 | Comparison (<, =, > ) |
| $B01B | 45083 | Numeric comparison |
| $B02E | 45102 | String comparison |
| $B081 | 45185 | BASIC command DIM |
| $B08B | 45195 | Check if variable name is valid |
| $B0E7 | 45287 | Searches variable in list, set variable pointer, create new variable, if name not found |
| $B113 | 45331 | Check for character |
| $B11D | 45341 | Create variable |
| $B194 | 45460 | Calculate pointer to first element of array |
| $B1A5 | 45477 | Constant -32768 as float (5 bytes) |
| $B1AA | 45482 | Convert FAC to integer and save it to accu/Y reg |
| $B1B2 | 45490 | Get positive integer from BASIC text |
| $B1BF | 45503 | Convert FAC to integer |
| $B1D1 | 45521 | Get array variable from BASIC text |
| $B218 | 45592 | Search for array name in pointer ($45, $46) |
| $B245 | 45637 | Output error message ?BAD SUBSCRIPT |
| $B248 | 45640 | Output error message ?ILLEGAL QUANTITY |
| $B24D | 45645 | Output error message ?REDIM\'D ARRAY |
| $B261 | 45665 | Create array variable |
| $B30E | 45838 | Calculate address of a array element, set pointer ($47) |
| $B34C | 45900 | Calculate distance of given array element to the one which ($47) points to and write the result to X reg/Y reg |
| $B37D | 45949 | BASIC function FRE |
| $B391 | 45969 | Convert 16-bit integer in accu/Y reg to float |
| $B39E | 45982 | BASIC function POS |
| $B3A2 | 45986 | Convert the byte in Y reg to float and return it to FAC |
| $B3A6 | 45990 | Check for direct mode: value $FF in flag $3A indicates direct mode |
| $B3AE | 45998 | Output error message ?UNDEF\'D FUNCTION |
| $B3B3 | 46003 | BASIC command DEF FN |
| $B3E1 | 46049 | Check syntax of FN |
| $B3F4 | 46068 | BASIC function FN |
| $B465 | 46181 | BASIC function STR$ |
| $B475 | 46197 | Make space for inserting into string |
| $B487 | 46215 | Get string, pointer in accu/Y reg |
| $B4CA | 46282 | Store string pointer in descriptor stack |
| $B4F4 | 46324 | Reserve space for string, length in accu |
| $B526 | 46374 | Garbage Collection |
| $B606 | 46598 | Searches in simple variables and arrays for a string which has to be saved by the next Garbage Collection interation. |
| $B63D | 46653 | Concatenates two strings |
| $B67A | 46714 | Move String to reserved area |
| $B6A3 | 46755 | String management FRESTR |
| $B6DB | 46811 | Remove string pointer from descriptor stack |
| $B6EC | 46828 | BASIC function CHR$ |
| $B700 | 46848 | BASIC function LEFT$ |
| $B72C | 46892 | BASIC function RIGHT$ |
| $B737 | 46903 | BASIC function MID$ |
| $B761 | 46945 | String parameter from stack: Get pointer for string descriptor and write it to $50, $51 and the length to accu (also X-reg) |
| $B77C | 46972 | BASIC function LEN |
| $B782 | 46978 | Get string parameter (length in Y-reg), switch to numeric |
| $B78B | 46987 | BASIC function ASC |
| $B79B | 47003 | Read and evaluate expression from BASIC text; the 1 byte value is then stored in X-reg and in FAC+4 |
| $B7AD | 47021 | BASIC function VAL |
| $B7EB | 47083 | GETADR and GETBYT: Get 16-bit integer (to $14, $15) and an 8 bit value (to X-reg) - e.g. parameter for WAIT and POKE. |
| $B7F7 | 47095 | Converts FAC in 2-byte integer (scope 0 ... 65535) to $14, $15 and Y-Reg/accu |
| $B80D | 47117 | BASIC function PEEK |
| $B824 | 47140 | BASIC command POKE |
| $B82D | 47149 | BASIC command WAIT |
| $B849 | 47177 | FAC = FAC + 0,5; for rounding |
| $B850 | 47184 | FAC = CONSTANT - FAC , accu and Y-register are pointing to CONSTANT (low and high byte) |
| $B853 | 47187 | FAC = ARG - FAC |
| $B862 | 47202 | Align exponent of FAC and ARG for addition |
| $B867 | 47207 | FAC = CONSTANT (accu/Y reg) + FAC |
| $B86A | 47210 | FAC = ARG + FAC |
| $B947 | 47431 | Invert mantissa of FAC |
| $B97E | 47486 | Output error message OVERFLOW |
| $B983 | 47491 | Multiplies with one byte |
| $B9BC | 47548 | Constant 1.00 (table of constants in extended floating point format for LOG) |
| $B9C1 | 47553 | Constant 03 (grade of polynome, then 4th coefficient) |
| $B9C2 | 47554 | Constant 0.434255942 (1st coefficient) |
| $B9C7 | 47559 | Constant 0.576584541 (2nd coefficient) |
| $B9CC | 47564 | Constant 0.961800759 (3rd coefficient) |
| $B9D1 | 47569 | Constant 2.885390073 (4th coefficient) |
| $B9D6 | 47574 | Constant 0.707106781 = 1/SQR(2) |
| $B9DB | 47579 | Constant 1.41421356 = SQR(2) |
| $B9E0 | 47584 | Constant -0.5 |
| $B9E5 | 47589 | Constant 0.693147181 = LOG(2) |
| $B9EA | 47594 | BASIC-function LOG |
| $BA28 | 47656 | FAC = constant (accu/Y reg) * FAC |
| $BA30 | 47664 | FAC = ARG * FAC |
| $BA59 | 47705 | Multiplies FAC with one byte and stores result to $26 .. $2A |
| $BA8C | 47756 | ARG = constant (accu/Y reg) |
| $BAB7 | 47799 | Checks FAC and ARG |
| $BAE2 | 47842 | FAC = FAC * 10 |
| $BAF9 | 47865 | Constant 10 as extended floating point format |
| $BAFE | 47870 | FAC = FAC / 10 |
| $BB0F | 47887 | FAC = constant (accu/Y reg) / FAC |
| $BB14 | 47892 | FAC = ARG / FAC |
| $BB8A | 48010 | Output error message ?DIVISION BY ZERO |
| $BBA2 | 48034 | Transfer constant (accu/Y reg) to FAC |
| $BBC7 | 48071 | FAC to accu #4 ($5C to $60) |
| $BBCA | 48074 | FAC to accu #3 ($57 to $5B) |
| $BBD0 | 48080 | FAC to variable (the address, where $49 points to) |
| $BBFC | 48124 | ARG to FAC |
| $BC0C | 48140 | FAC (rounded) to ARG |
| $BC1B | 48155 | Rounds FAC |
| $BC2B | 48171 | Get sign of FAC: A=0 if FAC=0, A=1 if FAC positive, A=$FF if FAC negative |
| $BC39 | 48185 | BASIC function SGN |
| $BC58 | 48216 | BASIC function ABS |
| $BC5B | 48219 | Compare constant (accu/Y reg) with FAC: A=0 if equal, A=1 if FAC greater, A=$FF if FAC
smaller |
| $BC9B | 48283 | FAC to integer: converts FAC to 4-byte integer |
| $BCCC | 48332 | BASIC function INT |
| $BCF3 | 48371 | Conversion PETSCII string to floating-point format |
| $BDB3 | 48563 | Constant 9999999.9 (3 constants for float PETSCII conversion) |
| $BDB8 | 48568 | Constant 99999999 |
| $BDBD | 48573 | Constant 1000000000 |
| $BDC2 | 48578 | Output of "IN" and line number (from CURLIN $39, $3A) |
| $BDCD | 48589 | Output positive integer number in accu/X reg |
| $BDDD | 48605 | Convert FAC to PETSCII string which starts with $0100 and ends with $00. Start address in |
| $BE68 | 48744 | TI to string: convert TI to PETSCII string which starts with $0100 and ends with $00 |
| $BF11 | 48913 | Constant 0.5 |
| $BF16 | 48918 | Constant tables for integer PETSCII conversion |
| $BF3A | 48954 | Constant tables to convert TI to TI$ |
| $BF71 | 49009 | BASIC function SQR |
| $BF78 | 49016 | Power function FAC = ARG to the power of constant (accu/Y reg) |
| $BF7B | 49019 | Power function FAC = ARG to the power of FAC |
| $BFB4 | 49076 | Makes FAC negative |
| $BFBF | 49087 | Constant 1.44269504 = 1/LOG(2) (table of 8 constants to evaluate EXP - polynomal table) |
| $BFC4 | 49092 | Constant 07: 7 = Grade of polynome (followed by 8 coefficient constants) |
| $BFC5 | 49093 | Constant 2.149875 E-5 |
| $BFCA | 49098 | Constant 1.435231 E-4 |
| $BFCF | 49103 | Constant 1.342263 E-3 |
| $BFD4 | 49108 | Constant 9.641017 E-3 |
| $BFD9 | 49113 | Constant 5.550513 E-2 |
| $BFDE | 49118 | Constant 2.402263 E-4 |
| $BFE3 | 49123 | Constant 6.931471 E-1 |
| $BFE8 | 49128 | Constant 1.00 |
| $BFED | 49133 | BASIC function EXP |
Links[edit | edit source]
- COMMODORE 64 ROM DISASSEMBLY by Marko Mäkelä
- BASIC ROM LISTING All about your C64-Online-Help