In this page...


Index

$AF00-$AFFF - BASIC Jump Table

BASIC Jump Table

The Commodore 128’s BASIC 7.0 includes a feature not found in previous versions: a jump table. Like the Kemal and screen editor jump tables, the BASIC table provides stable entry points to a number of important BASIC routines. If you want to call a BASIC routine from within one of your own machine language programs, you should use the jump table entry if one is provided. If you call a BASIC ROM routine directly, your program will not work if the address of the routine is changed in a future version. Presumably, Commodore will update the jump table if BASIC ROM is ever revised, so that jump table calls will remain valid.

In the discussions below, FAC1 refers to floating-point accumulator #1, locations $63-$67, and FAC2 refers to floating-point accumulator #2, locations $6A-$6E.

44800 $AF00 JAYINT

Entry point for the AYINT routine, currently at $84B4.

This routine converts the contents of FAC1 into a two-byte signed integer value in locations 102-103/$66-$67 (high byte in $66, low byte in $67). The routine tests the original value and generates an ILLEGAL QUANTITY error message if it is not in the range -32768-32767.

44803 $AF03 JGIVAYF

Entry point for the GIVAYF routine, currently at $793C.

This routine converts the two-byte signed integer value in the Y register and accumulator (low byte in Y, high byte in the accumulator) into a floating-point value in FAC1.

44806 $AF06 JFOUT

Entry point for the FOUT routine, currently at $8E42.

This routine creates a string of characters representing the floating-point value in FAC1. The string starts at location 253/$0100 and is terminated with a zero byte. The first character of the string is a space (code 32/$20) if the value was positive, or a minus sign (-) if the value was negative.

44809 $AF09 JVAL_1

Entry point for the VAL_1 routine, currently at $8052.

This routine reads a string of characters from bank 1 and generates the equivalent floating-point value in FAC1. Locations $24-$25 point to the the starting address of the string and the accumulator holds the length of the string. This routine will leave the system in BASIC’s alternate bank 14 configuration in which block 1 RAM is visible, so it shouldn’t be called by a routine in bank 0.

44812 $AF0C JGETADR

Entry point for the GETADR routine, currently at $8815.

This routine converts the current value in FAC1 into a two-byte unsigned integer in locations 22-23/$16-$17 (low byte in $16, high byte in $17). The integer value will also be in the Y register (low byte) and accumulator (high byte) upon return. Before performing the conversion, the routine checks that the value FAC1 is in the range 0-65535, and generates an ILLEGAL QUANTITY error message if it is not.

44815 $AF0F JFLOATC

Entry point for the FLOATC routine, currently at $8C75.

This routine converts the two-byte unsigned integer in locations 100-101/$64-$65 (low byte in $65, high byte in $64) into a floating-point value in FAC1. For this routine to function properly, you must also load the X register with the value 144/$90 and make sure the status register carry bit is set.

44818 $AFI2 JFSUB

Entry point for the FSUB routine, currently at $882E.

This routine subtracts the floating-point value in FAC1 from the five-byte floating-point value from the address in bank I specified in the accumulator (low byte) and Y register (high byte). (The bank 1 value will be loaded into FAC2.) The result will be left in FAC1.

44821 $AF15 JFSUBT

Entry point for the FSUBT routine, currently at $8831.

This routine subtracts the value in FAC1 from the value in FAC2. The result will be left in FAC1.

44824 $AF18 JFADD

Entry point for the FADD routine, currently at $8845.

This routine adds the floating-point value in FAC1 to the fivebyte floating-point value from the address in bank 1 specified in the accumulator (low byte) and Y register (high byte). (The bank 1 value will be loaded into FAC2.) The result will be left in FAC1.

44827 $AF1B JFADDT

Entry point for the FADDT routine, currently at $8848.

This routine adds the value in FAC1 to the value in FAC2. The result will be left in FAC1.

44830 $AF1E JFMULT

Entry point for the FMULT routine, currently at $8A24.

This routine multiplies the floating-point value in FAC1 by the five-byte floating-point value from the address in bank 1 specified in the accumulator (low byte) and Y register (high byte). (The bank 1 value will be loaded into FAC2.) The result will be left in FAC1.

44833 $AF21 JFMULTT

Entry point for the FMULTT routine, currently at $8A27.

This routine multiplies the value in FAC1 by the value in FAC2. The result will be left in FAC1.

44836 $AF24 FDIV

Entry point for the FDIV routine, currently at $8B49.

This routine divides the five-byte floating-point value from the address in bank 1 specified in the accumulator (low byte) and Y register (high byte) by the floating-point value in FAC1. (The bank 1 value will be loaded into FAC2.) The result will be left in FAC1.

44839 $AF27 JFDIVT

Entry point for the FDIVT routine, currently at $8B4C.

This routine divides the value in FAC2 by the value in FAC1. The result will be left in FAC1.

44842 $AF2A JLOG

Entry point for the LOG routine, currently at $89CA.

This routine calculates the natural logarithm of the value currently in FAC1, the log to the base e. The result will be left in FAC1.

44845 $AF2D JINT

Entry point for the INT routine, currently at $8CFB.

This routine calculates the whole number portion of the current value of FAC1, removing any fractional portion. The fractional portion is simply truncated; no rounding is performed. The result is a floating-point value in FAC1, not an integer value.

44848 $AF30 JSQR

Entry point for the SQR routine, currently at $8FB7.

This routine calculates the square root of the current value in FAC1. The result will be left in FAC1.

44851 $AF33 JNEGOP

Entry point for the NEGOP routine, currently at $8FFA.

This routine switches the sign of the current value in FAC1, making the value negative if it was positive, or positive if it was negative.

44854 $AF36 JFPWR

Entry point for the FPWR routine, currently at $8FBE.

This routine raises the value in FAC2 to the power specified in the five-byte floating-point value from bank 1 beginning at the address specified in the accumulator and Y register (low byte in the accumulator, high byte in the Y register). The exponent value will be loaded into FAC1. The result of the operation will be left in FAC1.

44857 $AF39 JFPWRT

Entry point for the FPWRT routine, currently at $8FC1.

This routine raises the value in FAC2 to the power specified in FAC1, effectively FAC2 ^ FAC1. The result of the operation will be left in FAC1.

44860 $AF3C JEXP

Entry point for the EXP routine, currently at $9033.

This routine calculates the natural exponential of the value in FAC1, effectively e ^ FAC1, where e = 2.71828. This is the inverse of the LOG operation. The result will be left in FAC1.

44863 $AF3F JCOS

Entry point for the COS routine, currently at $9409.

This routine calculates the cosine of the current value in FAC1, which will be interpreted as an angle in radians. The result will be left in FAC1.

44866 $AF42 JSIN

Entry point for the SIN routine, currently at $9410.

This routine calculates the sine of the current value in FAC1, which will be interpreted as an angle in radians. The result will be left in FAC1.

44869 $AF45 JTAN

Entry point for the TAN routine, currently at $9459.

This routine calculates the tangent of the current value in FAC1, which will be interpreted as an angle in radians. The result will be left in FAC1.

44872 $AF48 JATN

Entry point for the ATN routine, currently at $94B3.

This routine calculates the inverse tangent (arctangent) of the current value in FAC1. The result, which can be interpreted as an angle in radians, will be left in FAC1.

44875 $AF4B JROUND

Entry point for the ROUND routine, currently at $8C47.

This routine will round the least significant bit of FAC1 according to the value in the FAC1 rounding byte, location 113/$71.

44878 $AF4E JABS

Entry point for the ABS routine, currently at $8C84.

This routine will calculate the absolute value of the current value in FAC1, making the value positive regardless of its previous sign.

44881 $AF51 JSIGN

Entry point for the SIGN routine, currently at $8C57.

This routine sets the accumulator (and processor status register) according to the current value in FAC1. If the value is zero, the accumulator will hold 0/$00 upon return (and the status register Z bit will be set). If the FAC1 value is positive, the accumulator will hold 1/$01 (and the status register Z and N bits will both be clear). If the FAC1 value is negative, the accumulator will hold 255/$FF (and the status register N bit will be set).

44884 $AF54 JFCOMP

Entry point for the FCOMP routine, currently at $8C87.

This routine compares the floating-point value in FAC1 against the five-byte floating-point value from the address in bank 1 specified in the accumulator (low byte) and Y register (high byte). The accumulator (and processor status register) will be set according to the result of the comparison. If the two values are equal, the accumulator will hold 0/$00 upon return (and the status register Z bit will be set). If the FAC1 value is greater than the value in bank 1, the accumulator will hold 1/$01 (and the status register Z and N bits will both be clear). If the FAC1 value is less than the value in bank 1, the accumulator will hold 255/$FF (and the status register N bit will be set).

44887 $AF57 JRND_0

Entry point for the RND_0 routine, currently at $8437.

This routine generates a pseudorandom floating-point value according to the setting of the status register Nand Z bits upon entry. The resulting value will be left in FACt. If the N bit is set upon entry, the value in FAC1 will be used as the seed, producing a predictable result. If the Z bit is set, the value in the CIA #1 time-of-day clock is used as a seed. Otherwise, the previous random number in locations $121B-$121F is used as a seed for the next value.

44890 $AF5A JCONUPK

Entry point for the CONUPK routine, currently at $8AB4.

This routine loads FAC2 with the five-byte value at the address in bank 1 pointed to by the accumulator and Y register (low byte/high byte).

44893 $AF5D JROMUPK

Entry point for the ROMUPK routine, currently at $8A89.

This routine loads FAC2 with the five-byte value at the address in the current bank pointed to by the accumulator and Y register (low byte/high byte).

44896 $AF60 JMOVFRM

Entry point for the MOVFRM routine, currently at $7A85.

This routine loads FAC2 with the five-byte value at the address pointed to by locations $24-$25.

44899 $AF63 JMOVFM

Entry point for the MOVFM routine, currently at $8BD4.

This routine loads FAC1 with the five-byte value at the address in the current bank pointed to by the accumulator and Y register (low byte/high byte).

44902 $AF66 JMOVMF

Entry point for the MOVMF routine, currently at $8C00.

This routine copies the contents of FAC1 into a fivebyte area b eginning at the address in the current bank pointed to by the X and Y registers (low byte/high byte).

44905 $AF69 JMOVFA

Entry point for the MOVFA routine, currently at $8C28.

This routine copies the contents of FAC2 into FAC1.

44908 $AF6C JMOVAF

Entry point for the MOVAF routine, currently at $8C38.

This routine copies the contents of FAC1 into FAC2.

44911 $AF6F JOPTAB

This table entry is not a jump vector. Location 44911/$AF6F does contain a JMP instruction, but the target address is not a valid routine. Instead, locations 44912-44913/$AF70-$AF71 provide a fixed reference to the address of the BASIC operator table. This table, currently at 18472/$4828, holds the priorities and dispatch addresses for the mathematical operators such as +, -, ., and /.

44914 $AF72 JDRAWLN

Entry point for the DRAWLN routine, currently at $9B30.

This is the basic bitmapped graphics line-drawing routine.

44917 $AF75 JGPLOT

Entry point for the GPLOT routine, currently at $9BFB.

This routine plots a point on the bitmapped screen using the currently specified color source.

44920 $AF78 JCIRSUB

Entry point for the CIRSUB routine, currently at $6750.

This is the basic bitmapped graphics circle-drawing subroutine.

44923 $AF7B JRUN

Entry point for the RUN routine, currently at $5A9B.

44926 $AF7E JRUNC

Entry point for the RUNC routine, currently at $51F3.

RUNC is actually an alternate entry point into NEW to reset the text pointer to the start of program text and perform CLR.

44929 $AF81 JCLR

Entry point for the CLR routine, currently at $51F8.

44932 $AF84 JNEW

Entry point for the NEW routine, currently at $51D6.

44935 $AF87 JLNKPRG

Entry point for the LNKPRG routine, currently at $4F4F.

This program updates the line links for all lines in the current program.

44938 $AF8A JCRUNCH

Entry point for the CRUNCH routine, currently at $430A.

This routine is the one responsible for converting lines of text into tokenized BASIC statements.

44941 $AF8D JFNDLN

Entry point for the FNDLN routine, currently at $5064.

This routine searches through program text for the line number specified in locations $16-17. Upon exit, the carry bit will be clear if no match was found, or set if the specified line was located.

44944 $AF90 JNEWSTT

Entry point for the NEWSTT routine, currently at $4AF6.

This routine prepares for the execution of the next BASIC statement.

44947 $AF93 JEVAL

Entry point for the EVAL routine, currently at $78D7.

This routine evaluates a single numeric term or variable into a value in FAC1.

44950 $AF96 JFRMEVL

Entry point for the FRMEVL routine, currently at $77EF.

This routine evaluates a numeric expression, leaving the results in FAC1.

44953 $AF99 JRUN_A_PROGRAM

Entry point for the RUN routine, currently at $5AA6.

This routine performs the portion of the RUN routine normally executed for running a program after it has been loaded from disk. The extra steps in this case include relinking the program before it is run.

44956 $AF9C JSETEXC

Entry point for the SETEXC routine, currently at $5A81.

This routine sets BASIC flags to indicate that a program is running.

44959 $AF9F JLINGET

Entry point for the LINGET routine, currently at $50A0.

This routine reads a string of characters and generates a two-byte integer number in locations $16-17. The value must be less than 64000 or a SYNTAX ERROR will occur.

44962 $AFA2 JGARBA2

Entry point for the GARBA2 routine, currently at $92EA.

This routine performs a garbage collection, removing inactive strings from the string pool to increase the amount of available string space.

44965 $AFA5 JEXECUTE_A_LINE

Entry point for the MAIN routine, currently at $4DCD.

This routine is BASIC’s primary immediate mode loop.

44968-45055 $AFA8-$AFFF Unused

All locations in this unused area of ROM are filled with the value 255/$FF.