Introduction

This book is a collection of notes on the use and programming of the Sharp PC-1500 pocket computer. We assume the reader has access to a Sharp PC-1500 or an emulator such as PockEmul, which can even be accessed from a web browser here.

These notes are taken from different sources such as the Sharp PC-1500 Instruction Manual.

The code of the book is available on GitHub.

First steps

When you first start the calculator, which can be done by pressing the ON button, you will be greeted by a prompt. Notice also that above the screen a RUN prompt is displayed. This means that the calculator is in RUN mode, what this means will be explained later, but for now we will always want to be in RUN mode. If you are not in RUN mode, you can switch to it by pressing the MODE key until the RUN prompt is displayed.

Introducing something like

2+2

and pressing enter will give you the expected result:

4

To discard the result simply press the red CL, shorthand for clear, button at the right of the calculator. Now, with a fresh screen, you could even write something like:

2+2*2

obtaining

6

And any other expression you could expect of a calculator. But the real power of the PC-1500 is that it can run any BASIC program. Introducing, for example:

PRINT "Hello, World!"
The spaces are optional, they make the program more readable, but could slow you down when typing.

will produce the expected output:

Hello, World!

We can also assign values to variables and print them:

A=20
PRINT A

will output

20

In this fashion we can only execute one line of program at a time, in the following chapters we will see how to write multi-line programs.

The BASIC programming language

Writing single line programs is kind of limited, so let's see how to write programs with multiple lines.

To write our program we first need to enter the programming mode, to do this simply press the mode key until the PRO indicator is displayed above the screen. This modes gives us a "text editor" like interface that will make writing long programs easier.

TODO: add graphics

Now the computer is ready to accept our program, lets start with the classical Hello, World! program. The program is introduced line by line, so first we introduce the following input.

10 PRINT "HELLO, WORLD!"

When you are done introducing the line, press the enter key to accept it. The first number in the line is the line number, it is used to reference the line in the program, and is mandatory. After the line number we have the statement, in this case PRINT, which prints the string that follows it, in this case "HELLO, WORLD!".

Now we can run the program, to do this, press the MODE key until the RUN prompt is displayed above the screen. Then press enter the following command.

RUN

The program will run and display the HELLO, WORLD! message on the screen.

Let's add a second line to our program, to do this return to the PRO mode and write:

20 PRINT "GOODBYE, WORLD!"

Running the program again will show the two lines, one after another. Let's say we want to output something between the two lines, we can simply add a new line in PRO mode, between the two existing lines.

15 PRINT "I'M A COMPUTOR!"

Running wil yield the expected output, but oops we made a typo, to fix it we can go again into PRO mode and use the list command

LIST 15

This will let us edit the line, and fix the typo, to do this point the cursor to the incorrect character by using the left and right keys, then simply press the character you want to replace it with, in this case E.

15 PRINT "I'M A COMPUTER!"

Expressions

Let's dive deeper into the syntax of BASIC. As we've seen before a program in BASIC consists of a list of lines, each line begins with a line number, followed by a statement.

The line number uniquely identifies each line, the lines of the program are executed in order according to the line number. And are also used as labels for branch statements, which we'll see later.

The statement after the line number tells the computer what to do, we've seen some examples, like the assignment statement:

10 LET A = 10

or simply

10 A = 10

And the print statement:

20 PRINT A

We'll focus on the first for now. In the RUN mode the computer is in a REPL, each expression introduced is immediately evaluated and the result is displayed on the screen. In PRO mode, this is not the case, all expression must be used alongside a statement, such as an assignment or a print statement.

10 A = 10 + (2 * 8)
20 PRINT A + 25

Variable types

In SHARP, there are mainly two types of variables, which correspond to the possible content that can be stored in them: a numeric value or a string of characters. The type of variable can be easily distinguished because character variables need to have their name end with a dollar sign '$', while numeric variables do not. The '$' alerts SHARP to the fact that the variable holds character information. Beyond this distinction, both types function in an analogous manner.

In the specific case of arrays, as in any other programming language, their behavior is entirely predictable, and they are simply a set of variables of one of the two previously mentioned types. As a clarification, it is important to know that an array-variable X and a variable X are separate and distinct to SHARP

10 A = 10 + (2 * 8)
20 B$ = "HELLO WORLD"

Uninitialized variables

It is important to know that each possible variable name that is not reserved by SHARP is initialized automatically to 0 if it is numeric and to an empty string if it is a character type variable.

Once initialized information within variables is retained until:

  1. A CLEAR or NEW commad is given.
  2. A program is run using the RUN command.
  3. Another Assignment statement is executed for the same variable.
  4. The computer's batteries are changed. Turning the computer off does not affect values stored in variables.

Reserved variable names

Due to conflicts with abbreviations which have other meanings in the BASIC language, SHARP does not allow the use of some variable names such as: LF, IF, LN, PI, TD, LFS, IFS, LNS, PIS, TO$.

Operators

There are four arithmetic operators: +, -, *, /. The precedence of the operators is the usual.

The + and - can also be used in their unary form with a high precedence.

There are also the usual comparison operators <, <=, =, >=, >, <>, which seem to have all the same precedence, that being the second lowest.

There are also boolean bitwise functions AND, OR and NOT, which seem to have all the same precedence, that is the lowest.

Precedence

Calculations are performed in accordance with the following hierarchy; expressions in parentheses having the highest priority and logical operations having the lowest. If two or more operations of the same priority are found in the same expression or sub-expression, they are evaluated from left to right.

    1. Expressions in Parenthesis
    1. Retrieval or values from variables
    1. Functions
    1. Exponentiation
    1. Arithmetic Sign (+ , -)
    1. Multiplication, Division (* , /)
    1. Addition, Subtraction (+ , -)
    1. Comparison Operators (<, <=, =, >= , >, <>)
    1. Logical Operators (AND, OR, NOT)

Statements

First of all, let’s ask ourselves: what is a statement?

A statement is a line of code or expression that performs a specific action or operation. Each statement is an instruction to the computer that tells it what to do, whether it’s executing a calculation, manipulating data, controlling program flow, or interacting with the user. There are different types of statements:

  • Assignment Statements , such as A = B + C

  • Control Flow Statements, such as conditional statements (IF, ELSE) and loops (FOR, WHILE, REPEAT).

  • I/O Statements such as (PRINT, PAUSE, INPUT...)

List

Here is the complete list of all possible statement instructions available:

AREAD

ARUN

BEEP

CLEAR

CLS

CURSOR

DATA

DEGREE

DIM

END

FOR

TO

STEP

GCURSOR

GOSUB

GOTO

GPRINT

GRAD

IF

INPUT

LET

LOCK

NEXT

ON ERROR

ON GOSUB

ON GOTO

OPN

PAUSE

POINT

PRINT

RADIAN

RANDOM

READ

REM

RESTORE

RETURN

STOP

THEN

TRON

TROFF

UNLOCK

USING

WAIT

Basic IO

Key Information

Basic information about SHARP's display, there's only space available for 26 characters, If the length of the information displayed exceeds that number the items at the end of the print list will not be seen.

It is the main statement to produce output, it has several different variations.

The general format of the PRINT statement is the word PRINT followed by an item or a list of items to be printed. These include character strings, expressions, or names of variables whose values will be printed.

Statement Overview

  • ";": Inserts a natural cadence, which results in one space between arguments.

  • ",": Creates a tab jump, equivalent to 8 spaces, between arguments. Strings are left-aligned or "left justified", while numbers are right-aligned or "right justified".

  • Argument Calculations: The PRINT statement can perform calculations on arguments and display the result.

  • Comma Limit: Using a comma , in the PRINT statement restricts the number of arguments to a maximum of two.

    10 BS = " BE "
    20 T = 2
    30 PRINT T; BS; " OR NOT"; 12/3 - 2; BS

PAUSE

It is a semi-automatic form of the PRINT statement, with the difference that the output remains on the display for a fixed and brief period of time. Basically a PRINT statement followed by a countdown. When the countdown completes, the program automatically continues to the next statement.

All of the various techniques for the PRINT statement are also applicable here. These 2 statements can be mixed at will. It seems like it can only be used in "Programmer mode".

     10 PAUSE "DO";
     20 PAUSE "RE";
     30 PAUSE "MI";
     40 PAUSE "FA";
     50 PAUSE "SOL";
     60 PAUSE "LA";
     70 PAUSE "SI";
     80 PAUSE "DO"

INPUT

The INPUT statement in BASIC is used to gather user-provided data during program execution. It allows programmers to prompt users for specific information and store their responses in variables.

Different Usages:

  • Basic Syntax: The simplest form of the INPUT statement is

    INPUT variable-name
    

    When executed, it displays a ? on the screen, signaling the user to enter data.

  • Prompting the User: To make the prompt more informative, the INPUT statement can include a custom message using a character string

    INPUT "prompt message"; variable-name
    

    This form displays the specified prompt followed by a blinking cursor on the same line, where the user can enter their input.

  • Advanced Prompting: A variation of the prompt uses a comma instead of a semicolon:

    INPUT "prompt message", variable-name
    

    This version clears the prompt message once the user starts typing their response, replacing it with the input.

Key Notes

  • The expected type of data (numeric or character) must match the variable type.

  • The INPUT statement can gather multiple data items at once by specifying a list of variables separated by commas:

    INPUT var1, var2, var3
    

WAIT

The WAIT statement in BASIC allows the programmer to control how long information displayed by the PRINT statement stays on the screen. It modifies the operation of the PRINT statement, allowing the displayed information to remain visible for a specified period of time.

  • The argument is optional. If no argument is provided, the default behavior is "infinite", meaning the information will remain on the screen until the user presses the Enter key. This is the default mode in many programs.

  • If an argument is provided, all subsequent PRINT statements will hold their information on the screen for a time period proportional to the specified argument. This is similar to the PAUSE statement, but unlike PAUSE, the WAIT statement's time period is variable.

Argument Values

  • The argument value must be between 0 and 65535.
    • WAIT 0 causes the information to be displayed so quickly that it is unreadable.
    • WAIT 65535 causes the information to stay on the screen for about 17 minutes.
    • WAIT 64 results in a display time of about 1 second.
    • WAIT 3840 gives a display time of about 1 minute.

To reset the PRINT statement back to its default behavior (waiting for the user to press Enter), simply use WAIT with no argument.

      WAIT argument (64)

Key Notes:

  • The WAIT statement has no effect on the PAUSE statement.

  • The time specified by the WAIT statement can be adjusted for more precise control over the display duration.

READ

The READ statement in BASIC serves as a mechanism to retrieve data from DATA statements and assign it to specified variables. Each variable in the READ statement is assigned the next available data item from the list.

The READ statement consists of the keyword READ, followed by a comma-separated list of variable names. These variables can be either numeric or character types.

Key Notes:

  • Execution Requirements: For every execution of a READ statement, there must be a corresponding data item within a DATA statement. If no data item is available for a variable, the program halts and signals an error.

  • Type Matching: The data type (numeric or character) of the retrieved item must match the type of the variable to which it is being assigned. A mismatch in type results in an error.

     120 READ NS, WT , CS, SX$, L

DATA

The DATA statement allows the programmer to embed data directly within the program. This data can include numbers (in real or scientific notation) and character strings, which are separated by commas.

DATA statements may appear anywhere within a program; however, grouping them at the beginning of the program is a widely adopted convention among programmers.

Extra data items not used during the program execution are ignored.

     10 DATA "MOBY DICK", 20000, " WHITE". " M'', 112

RESTORE

The RESTORE statement in BASIC is used to reset the data pointer, allowing the program to re-read data items from DATA statements.

The RESTORE statement enables the re-use of some or all values defined in DATA statements. It resets the data pointer to a specified location, allowing subsequent READ statements to retrieve previously used data items.

Different Usages:

  • Default Behavior: When executed without additional parameters, the RESTORE statement resets the pointer to the first DATA statement in the program. SubsequentREAD statements will then begin reading from the start of the data list.

  • Selective Restoration: The RESTORE statement can specify a starting point using either a line number or a label.

     RESTORE line_number (150)

This causes the program to begin re-reading data items from the DATA statement located at the specified line number.

Alternatively, a label can be assigned to a DATA statement, and the RESTORE statement can use this label to target the starting point:

     RESTORE label ("X")

Control flow

IF and ## THEN

The IF statement in BASIC provides conditional execution of code based on the result of a logical test. It enables decision-making within a program by evaluating conditions and determining which actions to perform.

The THEN keyword in BASIC is a component of the IF statement, used to specify the action or instruction to execute when a condition evaluates to True. It defines the response to the logical test performed by the IF statement.

     IF condition THEN statement

Logical Flow

  • If the condition evaluates to True, the statement following the THEN keyword is executed.

  • If the condition evaluates to False, the statement is skipped, and program execution continues with the next line.

Types of Statements

The statement after THEN can be any valid BASIC command, including:

  • A PRINT statement to display information.

  • An assignment using LET (required for assignments in this context).

  • A GOTO statement for branching to another line (using a number-line also works).

Key Notes

  • In BASIC, any expression evaluating to a non-zero value is considered True. A zero value is considered False.

  • If the statement following THEN is an assignment, the LET keyword must be included.

ELSE

GOTO

The GOTO statement in BASIC alters the normal sequential flow of a program by jumping to a specified line. It allows for flexible execution paths, skipping or repeating sections of code as necessary.

The GOTO instruction is a command as well as a statement.

Issued as a statement, GOTO tells SHARP to "go to" a line other than the next one and begin executing statements sequentially from there.

    GOTO expression

where:

expression evaluates to a number which is a valid program line-number (1 through 65279).

Issued as a command, in the RUN mode, GOTO begins program execution in a manner similar to the RUN command. However, unlike the RUN command the GOTO command will not clear values from any variables before it begins execution of lhe program.

To begin program execution with the GOTO command ENTER:

    GOTO line_number

where:

line_number is the number of the first line of the program to be executed.

NOTE: Specifying a line number which does not exist will result in an ERROR 11.

Possible usages

  • As a jump instruction inside of an IF statement

  • To create loops manually

  • As a command RUN substitute to start a program in RUN mode

GOSUB

The GOSUB statement is a special type of GOTO statement used to call a subroutine, which is a reusable block of code within a program. Subroutines help avoid duplication of code and allow for modular program design.

It has the same syntax as the GOTO statement with the only difference being that before jumping, the program "remembers" the location of the GOSUB statement so it can return to it after reaching the RETURN statement.

When the RETURN statement is encountered in the subroutine, the program resumes execution at the line following the original GOSUB statement.

FOR and NEXT

The FOR and NEXT statements in BASIC provide a structured mechanism for repeating a sequence of instructions, forming a loop. They are particularly useful for iterative tasks, where a counter variable controls the number of repetitions.

Utilizes a counter variable with defined start, end, and step values to determine the loop's behavior.

FOR counter-variable = initial-value TO final-value [STEP increment-value]
    [statements to repeat]
NEXT counter-variable

RETURN

The RETURN statement is used to indicate the end of a subroutine in BASIC. It ensures the program resumes execution at the point immediately following the corresponding GOSUB statement.

Every GOSUB needs to have its own RETURN statement.

REPEAT

Functions

The functions available on the SHARP calculator, with few exceptions, are basic operations dedicated to performing mathematical calculations. Additionally, there are some for strings. They all have in common that they are direct operations that return a specific result given certain arguments.

LIST

Here's the complete list of available functions:

ABS

ACS

AND

ASC

ASN

ATN

CHR$

COS

DEG

DMS

EXP

INKEY$

INT

LEFT$

LEN

LOG

LN

MEM

MID$

NOT

OR

𝛑 (PI)

POINT

RND

SGN

SIN

√ (SQR)

STATUS

STR$

TAN

TIME

VAL (value)

Grammar

The grammar has been extracted from sources as much as possible, but a big chunk of it has been reverse engineered from the calculator's behavior. Checked with BNF Visualizer.

/* --- Tokens --- */
<digit> ::= [0-9]
<number> ::= <digit>+
<letter> ::= [A-Z]
<identifier> ::= <letter> (<letter> | <digit>)*
<comparison_op> ::= "=" | "<>" | "<" | ">" | "<=" | ">="
<add_sub_op> ::= "+" | "-"
<mul_div_op> ::= "*" | "/"
<char> ::= [A-Z] | [a-z] | [0-9]
    | " " | "!" | "\"" | "#" | "$" | "%" | "&" | "'" | "(" | ")"
    | "*" | "+" | "," | "-" | "." | "/" | ":" | ";" | "<" | "="
    | ">" | "?" | "@" | "[" | "\\" | "]" | "^" | "_" | "`"
    | "{" | "|" | "}" | "~"
<string> ::= "\"" <char>* "\"" | "\"" <char>*
<newline> ::= "\n"

/* functions */
<and> ::= "AND"
<or> ::= "OR"
<not> ::= "NOT"

/* --- Grammar --- */
<program> ::= <line>+
<line> ::= <number> <stmt> <newline>

/* stmts */
<stmt> ::= <atomic_stmt> (":" <atomic_stmt>)*
<atomic_stmt> ::= <assignment>
    | <print>
    | <pause>
    | <input>
    | <wait>
    | <cursor>
    | <gcursor>
    | <gprint>
    | <if>
    | <for>
    | <next>
    | <goto>
    | <gosub>
    | <return>
    | <end>
    | <comment>
    | <data>
    | <read>
    | <restore>
    | <poke>
    | <call>
    | <dim>

/* Comments */
<comment> ::= "REM" <char>*

/* Variables */
<variable> ::= <identifier> "$"?
<array_subscript> ::= <variable> "(" <expr> ("," <expr> )? ")"
<lvalue> ::= <variable> | <array_subscript>
<assignment> ::= "LET"? <lvalue> "=" <expr>

/* I/O */
<print> ::= "PRINT" <expr> (";" <expr>)*
<pause> ::= "PAUSE" <expr> (";" <expr>)*
<input> ::= "INPUT" (<expr> ";")? <lvalue>
<wait> ::= "WAIT" <expr>?
<cursor> ::= "CURSOR" <expr>
<gcursor> ::= "GCURSOR" <expr>
<gprint> ::= "GPRINT" <expr> (";" <expr>)* | "GPRINT" <string>

/* Data */
<data_item> ::= <number> | <string>
<data> ::= "DATA" <data_item> ("," <data_item>)*
<read> ::= "READ" <lvalue> ("," <lvalue>)*
<restore> ::= "RESTORE" (<number>)?

/* Control flow */
<if> ::= "IF" <expr> "THEN" <stmt> ("ELSE" <stmt>)?
<for> ::= "FOR" <variable> "=" <expr> "TO" <expr> ("STEP" <expr>)?
<next> ::= "NEXT" <variable>
<goto> ::= "GOTO" <number>
<gosub> ::= "GOSUB" <number>
<return> ::= "RETURN"
<end> ::= "END"

/* Assembly */
<poke> ::= "POKE" <number>, (<number>)+
<call> ::= "CALL" <number>

/* Arrays */
<dim> ::= "DIM" <variable> "(" <number> ("," <expr> )? ")" ("*" <number>)?

/* exprs */
<expr> ::= <comparison>
<comparison> ::= <add_sub> (<comparison_op> <add_sub>)*
<add_sub> ::= <mul_div> (<add_sub_op> <mul_div>)*
<mul_div> ::= <factor> (<mul_div_op> <factor>)*
<factor> ::= "-" <factor> | "+" <factor> | <term>
<term> ::= <number> | <lvalue> | <string> | "(" <expr> ")"

Expression of Variables and Programs

Expression of Decimal Numbers

Decimal numbers are represented using 8 bytes to accommodate values within the range: [-9.999999999 \times 10^{99}, + 9.999999999 \times 10^{99}]

Byte Structure

  • 1st Byte: Exponent (binary format, can be negative)
  • 2nd Byte: Mantissa sign (00H for positive, 80H for negative)
  • 3rd to 7th Bytes: Mantissa value within [-9.999999999, + 9.999999999]
  • 8th Byte: Reserved (always 00H)

Numeric Memory Distribution Example


Expression of Binary Numbers

Binary numbers use 8 bytes, though only 3 bytes are active (5th, 6th, and 7th) within the range: [-32768, +32767]

Byte Structure

  • 5th Byte: Reserved (B2H)
  • 6th to 7th Bytes: Binary number value
  • 1st to 4th, 8th Bytes: Invalid data

Binary Number Memory Distribution Example

Expression of Character Strings

Character string information is composed of 8 bytes, where only 4 bytes are used. The character string information resides in the address specified.

Byte Structure

  • 5th Byte: Reserved (D0H)
  • 6th to 7th Bytes: Leading address (0000H to FFFFH)
  • 8th Byte: Size of the string (01H to 50H)
  • 1st to 4th Bytes: Invalid data

String Memory Distribution Example

Structure of Variable Names

Variable names consist of two bytes representing 2 ASCII characters and contain bits to distinguish between numeric and non-numeric variables, with support for array assignments.

Bit Structure

  • 1st to 8th bits: First ASCII character
  • 9th bit: Array assignment (1 for arrays, 0 otherwise)
  • 10th bit: 7th bit of the ASCII code (least significant byte)
  • 11th bit: Indicates if the variable is numeric (0) or non-numeric (1)
  • 12th to 16th bits: Second ASCII character (low-order bits)

Variable Examples Table Array Memory Distribution Example

Structure of Program Lines

Each line in the program consists of a line number, line size, code, and an end code (0DH).

Byte Structure

  • 2 Bytes: Line number
  • 1 Byte: Line size
  • Variable Bytes: Program code
  • 1 Byte: End code (0DH)

Program Memory Distribution Example

Structure of Reserved Area

BASIC Commands and Memory Address

BASIC Command List:

CommandInternal CodeDescription
ABSF170HReturns absolute value of a number
ACSF174HArc cosine function
ANDF150HLogical AND operation
AREADF18OHReads analog input
ARUNF181HAuto-run a program
ASCF160HReturns ASCII code of a character
ASNF173HArc sine function
ATNF175HArc tangent function
BEEPF182HProduces a sound from the device speaker
BREAKF0B3HInterrupts program execution
CALLF18AHCalls a machine language subroutine
CHAINF0B2HLinks to another program
CHR$F163HConverts ASCII code to character
CLEARF187HClears variables and resets memory
CLOADF089HLoads program from tape
CLSF088HClears the display
COM$F858HCommunicates via serial port
CONSOLEF0B1HSwitches to console mode
CONTF183HContinues from a STOP or BREAK
COLORF0B5HSets display text color
COSF17EHCosine function
CSAVEF095HSaves program to tape
CSIZEE680HSets character size for printing
CURSORF084HPositions cursor
DATAF18DHHolds data for READ statements
DEFF165HDefines a function
DEGREEF18CHSets angle mode to degrees
DEV$E857HDevice name for serial communication
DIMF179HDeclares an array with specified dimensions
DMSF166HDegree-minute-second (DMS) conversion
DTEE884HDate function
ENDF19EHMarks end of program
ERLF053HReturns line number of error
ERNF052HReturns error number
ERRORF1B4HError handling function
EXPF176HCalculates e^x
FEEDF0B0HPaper feed on printer
FORF1A5HBegins a FOR loop
GCURSORF093HGraphics cursor control
GLCURSORE682HLower graphics cursor control
GOSUBF194HJumps to subroutine, returning with RETURN
GOTOF192HUnconditional jump to a line number
GPRINTF09FGraphics print
GRADF186HSets angle mode to gradients
GRAPHE681HSwitches to graphics mode
IFF196HConditional branching
INKEY$F15CHReturns last pressed key
INPUTF091HTakes input from the user
INSTATE859FChecks input status
INTF171HConverts to integer
LCURSORE683HLower cursor control
LEFT$F17AHReturns left substring
LENF164HReturns length of a string
LETF198HAssigns a value to a variable
LFF0B6HLine feed
LINEF0B7HDraws line in graphics mode
LISTF090HDisplays program code
LLISTF0B8HList program to printer
LNF176HNatural logarithm
LOCKF1B5HLocks program for editing
LOGF177HNatural Logarithmic function
LPRINTF0B9HPrint to line printer
MEMF158HDisplays memory usage
MERGEF08FHMerges another program into current program
MID$F17BHExtracts a substring
NEWF19BHClears program and data areas
NEXTF19AHEnds a FOR loop
NOTF16DHLogical NOT
OFFF19EHTurns off power (optional in certain models)
ONF19CHHandles events based on specific conditions
OPNF19DHOpens file for I/O
ORF151HLogical OR
OUTSTATE880HChecks output status
PAUSEF1A2HPauses program execution
PEEKF16FHReads data from a memory address
PEEK#F16EHExtended peek for memory data
PIF15DHReturns value of Pi
POINTF168HReturns graphics point color
POKEF1A1HWrites data to a memory address
POKE#F1A0HExtended poke for memory data
PRINTF097HDisplays text on screen
RADIANF1AAHSets angle mode to radians
RANDOMF1A8HReturns a random number
READF1A6HReads data from DATA statements
REMF1ABHComment statement
RESTOREF1A7HResets DATA pointer
RETURNF199HReturns from subroutine
RIGHT$F172HReturns right substring
RINKEY$E85AHReads last input key
RLINEF0BAHReads a line from printer
RMTE7A9HRemote command for communication
RNDF17CHReturns a random number (RANDOM?)
ROTATEE685HRotates graphics display
RUNF1A4HStarts program execution
SETCOME882HSets communication mode
SETDEVE886Sets device configuration
SGNF179HReturns sign of a number
SINF17DHSine function
SORGNE684HSets origin for graphics
SPAVCE$F061HReturns a string of spaces
SQRF16BHReturns the square root of a number
STATUSF167HDisplays status information
STEPF1ADHSpecifies increment in FOR loop
STOPF1ACHPauses program
STR$F161HConverts a number to a string
TABF0BBHMoves cursor to specified position
TANF17FHTangent function
TERMINALE883HSwitches to terminal mode
TESTF0BCHTests condition in program
TEXTE686HSwitches to text mode
THENF1AEHSpecifies action if condition in IF is met
TIMEF15BHReturns current time
TOF1B1HSpecifies range in FOR loop
TRANSMITE885HTransfers data via serial
TROFFF1B0HTurns trace off
TRONF1AFHTurns trace on
UNLOCKF1B6HUnlocks program for editing
USINGF086HFormats output
VALF162HConverts string to a numeric value
WAITF1B3HPauses execution until condition met
ZONEF0B4HSets tabulation zone for printing

System Subroutines List

1. Character Functions

NameMemory AddressDescription
Combination of CharactersD925HCombines multiple characters into a single string
CHR$D9B1HConverts an ASCII code to its corresponding character
STR$D9CFHConverts a string representation of a number back to a numeric value
VALD9D7HConverts a string to a numeric value
LEN, ASCD9DDHLEN: Returns the length of a string; ASC: Returns ASCII code of a character
RIGHT$D9F3HExtracts a specified number of characters from the right end of a string
MID$D9F3HExtracts a substring from a string, given a starting position and length
LEFT$D9F3HExtracts a specified number of characters from the left end of a string

2. Arithmetic Operations

NameMemory AddressDescription
SubtractEFB6HSubtracts one number from another
AddEFBAHAdds two numbers
MultiplyF01AHMultiplies two numbers
DivideF084HDivides one number by another
LNF161HComputes the natural logarithm of a number
LOGF165HComputes the base-10 logarithm of a number
EXPF1CBHCalculates the exponential function (e^x)
10^nF1D4HComputes 10 raised to the power of a specified exponent
COSF391HComputes the cosine of an angle
TANF39EHComputes the tangent of an angle
SINF3A2HComputes the sine of an angle
ACSF492HComputes the arc cosine (inverse cosine) of a value
ATNF496HComputes the arc tangent (inverse tangent) of a value
ASNF49AHComputes the arc sine (inverse sine) of a value
DEGF531HConverts a radian measure to degrees
DMSF564HConverts a degree measure to degrees, minutes, and seconds
ABSF597HComputes the absolute value of a number
SGNF59DHReturns the sign of a number (1 for positive, -1 for negative, 0 for zero)
INTF5BEHReturns the integer portion of a number, discarding any fractional part
Power RiseF89CHRaises a number to a specified power

Arithmetic Operations Table

3. Compare

NameMemory AddressDescription
Numerical ComparisonD0D2HCompares two numeric values and returns a result
Character String ComparisonD0F9HCompares two strings lexicographically to determine order

Compare String Memory Content

NameMemory AddressDescription
Line number SearchD2EAHSearches for a specific line number in the program
KEY Scan (1)E42CHScans the keyboard to detect key presses; single key detection
KEY Scan (2)E243HScans the keyboard for combinations
Variable SearchD461HSearches for a variable by name in the program’s memory

5. Display

NameMemory AddressDescription
Auto-power-offE33FHManages automatic power-off to conserve battery life
Program displayE8CAHDisplays the current program code on the screen
Graphic DisplayEDEFHEnables graphical display mode
HexadecimalED95HDisplays a value in hexadecimal format
One Character DisplayED3BHDisplays a single character at the current position
Cursor Move After One Character DisplayED4DHMoves the cursor one position after displaying
Cursor Move After n Character DisplayED00HMoves the cursor by n positions after displaying

NameMemory AddressDescription
Color DesignationA519HSets the color for subsequent text or graphics display
PrintA781HSends data to be printed
LinefeedA9F1HMoves the cursor or paper to the next line
Paper FeedAA04HAdvances the paper on a connected printer
Get TEXT Mode ReadyACBBHPrepares the system for text mode
Pen Up/DownAAE3HRaises or lowers the pen for drawing or plotting
Motor DriveA8DDHActivates the motor for peripherals like printers
Motor OffA769HTurns off the motor
Get GRAPHIC Mode ReadyABEFHPrepares the system for graphics mode

7. Cassette Tape

NameMemory AddressDescription
Remote OnBF11HActivates remote mode for external control or communication
Remote OffBF43HDeactivates remote mode
One Character SaveBDCCHSaves a single character to memory or storage
One Character LoadBDF0HLoads a single character from memory or storage
Header Input/OutputBCE8HManages input/output operations for data headers
CMT I/O ControlBBF5HControls cassette tape (CMT) input/output functions
Create HeaderBBD6HGenerates a data header for file storage or transmission
Transfer FileBD3CHTransfers a file between devices or storage media

Assembly

Memory