Sharp PC-G850V(S) Reference Pocket-computer guide · BASIC · Z80 · C · CASL/COMET · PIC

Page 1 is the machine guide: modes, keyboard, variables, program structure, the TEXT editor, the machine-language monitor, the Z80/CASL/PIC assemblers, the C compiler, memory map, ports and error codes. Page 2 indexes all 128 BASIC keywords by category with their shortest abbreviation. Page 3 is the Z80 instruction set, the CASL/COMET instruction set and the C runtime library. Hover a row for its full syntax.

Kind: Statement Function (returns a value) Direct / PRO-mode only Mode & system Abbreviations shown after the name: PRINT · P.
Source: SHARP PC-G850V(S) Users Guide, Jack W. Hsu, Version 3.0, 09/2018 — based on the German translation by Jörg Wrabetz of the official Japanese manual, with the 11-pin interface description by Ton Stahl. Ch. 2–13 and Appendices A–M.
Sharp PC-G850V pocket computer, showing its 24-character by 6-line display and full keyboard
Sharp PC-G850V — the self-describing splash screen says it: 24 characters × 6 lines, 32 KB of RAM, and BASIC, C, TEXT, the machine-language monitor, graphics, Z80 assembler and PIC assembler all in ROM. The 11-pin Sharp interface is on the left edge; the reset hole sits below the keyboard.
Colour keythe machineentry, stack & displayprogrammingmathematicsdata objectsvariables & memoryinput, output & interfaceplotting & graphicsreference & systemnative code & hardware

Machine Guide

Modes, editors, assemblers, memory and hardware — everything that is not a BASIC keyword

The Seven Modes

ModeKeysWhat it does
RUNBASICRun BASIC programs and direct commands; 10-digit calculator
PROBASIC BASICEnter and edit BASIC programs (from outside RUN, press twice)
TEXTTEXTASCII editor: BASIC / C / Z80 / CASL / PIC sources, data files, RAM disk, SIO
ASMBLSHIFT+BASIC then AZ80 assembler — assembles the TEXT source into the USER area
CASLSHIFT+BASIC then CCASL assembler + COMET simulator, monitor and trace
PICSHIFT+BASIC then PPIC assembler and loader (PIC16F627/83/84/84A)
CSHIFT+TEXTC compiler: Compile · Trace · Go · Stdout
STATSHIFT+MDF1- and 2-variable statistics (clears previous data on entry)
MONITORtype MON in RUN/PROZ80 machine-language monitor
BASE-nSHIFT+BASE-nROM program BASE_N.BAS — bin/dec/hex convert & calculate. Erases BASIC memory; needs 2961 free bytes

2ndF instead of SHIFT. 2ndF pressed before a key is equivalent to holding SHIFT. BREAK steps back one menu level in TEXT/C; TEXT jumps straight to the TEXT main menu. Switching modes never loses TEXT or BASIC memory.

Auto power-off after ~11 min idle. Disabled while INKEY$ runs, active during INPUT.

Keyboard & Editing

KeyAction
ONPower on (also after auto power-off)
BREAKInterrupt a running program or LOAD/BSAVE; back one menu level
CLSClear screen; clear a displayed error
SHIFT+CAClear display and reset WAIT, USING format, TRON→TROFF, errors
CAPSToggle uppercase (on after power-on); large/small in kanji mode
INS / SHIFT+DELInsert mode (sticky) / delete char under cursor
BSDelete char left of the cursor
TABBASIC: every 7 columns. TEXT: col 8, then 14, then +7
ANSInsert the last calculation result at the cursor
CONSTStore a calculation constant (CONST annunciator); SHIFT+CONST shows it
SHIFT+ANSLCD contrast menu — ◄►, then BASIC/TEXT/CLS to accept
SHIFT+PNPToggle PRINT mode (printer output)
RESETUnder SHIFT: press ON then RESET. MEMORY CLEAR O.K.? (Y/N) — N keeps data

▲ ▼ by mode

State▼ / ▲
RUN, stopped by STOP or BREAK▼ runs the next line then stops · ▲ shows the current line
RUN, error▼ nothing · ▲ shows the line containing the error
RUN, TRON on▼ hold to keep running · ▲ hold to show the line
PRO▼ next program line · ▲ previous line (first press: last/first line)

Typing over a character replaces it. Commands, functions and variables typed in lowercase are converted to uppercase on ENTER.

Display & Annunciators

6 lines × 24 characters, 5×7 dot matrix per character · graphics 144 × 48 pixels, origin (0,0) at the top left.

SymbolMeaning
BUSYExecuting a program or command
BATTBatteries weak — replace
RUN / PRO / TEXT / CASL / STATCurrent mode
2ndF2ndF pressed; clears with the next key
MA non-zero value is in the manual-calculation memory
CAPSUppercase entry
DEG / RAD / GRADAngle mode
CONSTA calculation constant is set (clear with SHIFT+CA)
PRINTReady to send to the printer (RUN mode)
カナKatakana entry; kanji mode toggled by its own key

LOCATE text grid is 0…39 horizontal × 0…5 vertical. The underscore cursor becomes a flashing block when it sits on an existing character.

Constants, Variables & Types

"HELLO"string constant; use CHR$(&H22) for a quote inside&HFFFFhexadecimal constant = 65535A = 556 : B$ = "BYTE"numeric / string assignment
KindNamesSize / notes
Fixed numericA … Z7 bytes, always allocated
Fixed stringA$ … Z$Same memory as A…Z — max 7 chars. Mixing types gives ERROR 91
Simple numericAB, C1, …Allocated on first use; only the first 2 chars are read; must start with a capital
Simple stringAB$, C2$, …Max 16 chars. AB and AB$ coexist
ArraysDIM X(5)Index 0…size, so 6 elements. Size 0…255
String arraysDIM N$(10)*10*length 1…255, default 16
2-D arraysDIM T(2,3)rows, columns — both 0…255

Bytes used: numeric variable/array 7 + 8 per element · string variable 7 + 16 per element · string array 7 + declared length per element. Program lines cost 3 bytes (line no.) + 2 per command/function + 1 per other byte.

Range ±1E−99 … ±9.999999999E+99, 10-digit mantissa + 2-digit exponent, 8 bytes per number. Reserved words (PI, IF, TO, ON, SIN…) cannot be variable names. STAT results land in U…Z.

Operators & Precedence

OpMeaning
+ − * /Arithmetic; + also concatenates strings (work space 255 chars)
^Exponentiation — chained powers evaluate right to left
¥Integer division (operands are rounded first)
MODModulo division
= <> < > <= >=Relational — true is −1, false is 0. Strings compare by ASCII, short strings padded with NUL
AND OR XOR NOTBitwise on 16-bit two's-complement values (−32768…32767)

Precedence (highest first)

1 variable recall, PI2 functions (SIN, LOG, …)3 power, roots4 unary sign5 * / (left to right)6 + −7 relational8 logical9 = , M+

Parentheses override everything. Composite functions evaluate right to left. For levels 3 and 4 the last entry wins: -2^4 = -(2^4), 3^-2 = 3⁻². Numeric and string values cannot mix in one expression — "15"+10 is illegal, "15"+"10" is "1510".

51 ¥ 5 → 1051 MOD 5 → 151 ¥ −5.7 → −851 MOD −5.7 → 341 AND 27 → 941 OR 27 → 59 · 41 XOR 27 → 50 · NOT 3 → −4

Program Structure

10: INPUT A20: PRINT A*A30: END
  • Line numbers 1 … 65279, unique; execution runs in ascending order. Entering a bare line number deletes that line.
  • Multiple statements per line, separated by : — up to 254 characters including ENTER.
  • Labels — a letter plus up to 19 alphanumerics, written *NAME: or "NAME": as the first thing on a line. *label is faster and more readable. Run with RUN *NAME or GOTO *NAME.
  • CommentsREM or ' to end of line.
  • Direct commands (RUN, NEW, RADIAN…) are typed without a line number and execute at once.
  • The colon after the line number is inserted automatically in BASIC — but not in the TEXT editor.

Stack limits

Subroutine stack 90 bytes total: REPEAT-UNTIL 4 B · WHILE-WEND 5 B · SWITCH-CASE 6 B (only one instance) · FOR-NEXT 18 B. Function stack 16 levels, data stack 8, BASIC subroutine stack 10. Exceeding any of these is ERROR 50.

Memory

Program / data area 30179 bytes · fixed variable area 208 bytes · system 2.3 KB. FRE reports what is left.

Control Flow

IF cond THEN line|*label|stmt [ELSE line|*label|stmt[:stmt]…]IF cond THEN ← block form: IF/ELSE/ENDIF must each stmt1 follow a line number directly, andELSE nothing may follow THEN on that line stmt2ENDIF
FOR v = e1 TO e2 [STEP e3] … NEXT vWHILE cond … WENDREPEAT … UNTIL condSWITCH vCASE value1 … CASE value2 … [DEFAULT …] ENDSWITCHGOSUB line|*label … RETURNON expr GOTO l1,l2,… ON expr GOSUB l1,l2,…

WHILE tests first (may run 0 times); REPEAT tests after the body (runs at least once). FOR increments then tests, so the body always runs at least once. Only one SWITCH may be active at a time.

Missing-partner errors: 51 GOTO · 52 NEXT · 53 READ · 61 ENDIF · 62 REPEAT · 63/64 WEND · 66 extra CASE/DEFAULT · 68 ENDSWITCH · 69 SWITCH.

Debugging

TRONtrace on — stops after each line and shows its numberTROFFtrace offSTOPhalt at a chosen point, then inspect variablesCONTresume after STOP / BREAK / PRINT pause
  • In trace mode hold to keep running, release to stop; hold to display the last executed line. Press ENTER to resume.
  • Comment lines display no line number in trace — the previous number stays on screen.
  • Trace stays on until TROFF, SHIFT+CA, or power loss.
  • After an error, switch to PRO and press — the cursor sits at the offending position.
  • Check any variable by typing its name and ENTER in RUN or PRO mode.
  • Insert temporary PRINT statements, or WAIT n to slow the display (n/64 seconds).

Output & USING Formats

PRINT [USING "fmt"] expr|str [ , | ; expr|str ]… [ , | ; ]USING "fmt" ← on its own line: applies to every later PRINTLOCATE col, row ← col 0…39, row 0…5WAIT n ← hold each PRINT for n/64 s (0…65535)
CharMeaning
#One digit of a right-justified numeric field
.Decimal point
,Thousands separator
^Scientific notation
&One character of a left-justified string field
"###"43"###."98."###.##"64.29 · −13.44"##.##^"23.11E 05 · −4.33E−02"###,###."34,567."&&&&&&"ABCDEF

Max 11 # in every format except the comma form, which allows 14. The sign prints only for negative values. WAIT with no argument makes PRINT wait for ENTER. USING is reset by SHIFT+CA. Errors 70/71 flag an impossible or illegal format.

Graphics

144 × 48 pixels — x 0…143 left to right, y 0…47 top to bottom. Coordinates may be given as −32768…32767; anything off-screen is ignored.

PSET (x,y)[,X] PRESET (x,y) POINT (x,y) → 0|1LINE [(x1,y1)]-(x2,y2)[,S|R|X][,mask][,B|BF]CIRCLE (x,y),r[,start,end,ratio[,S|R|X],[fill]]PAINT (x,y),pattern GCURSOR (x,y) GPRINT …
OptionEffect
S / R / XSet · reset (erase) · reverse the dots. Default S
mask0…65535 — a 16-bit repeating line pattern. &H6666 = dashes. Omit for solid
B / BFRectangle · filled rectangle from the two corners
CIRCLE angles−360…360 degrees, 0 = +x axis, counter-clockwise. Negative angle also draws the radius
CIRCLE ratiory/rx — 1 is a circle, anything else an ellipse
fill / PAINTPattern number 0…6

GPRINT bit patterns

Each column is 8 vertical dots, weighted from the top down… bottom dot = 1, then 2, 4, 8, 16, 32, 64, 128 (top). Give the sum as decimal or &hh, or use a hex string in which each pair is one column (first digit = lower 4 dots, second = upper 4). These three are identical:

GPRINT 16;40;18;253;18;40;16GPRINT &10;&28;&12;&FD;&12;&28;&10GPRINT "102812FD122810"

A trailing ; continues from the next cursor position; bare GPRINT moves the graphic cursor down one line. The 8 dots drawn are the ones above and including the GCURSOR point.

Files, RAM Disk & Devices

Part of RAM is a RAM disk (drive E:). BASIC programs there must be LOADed before they run. Data files must first be created in TEXT mode under Rfile → Init.

ItemRule
File nameUp to 8 characters from A–Z a–z 0–9 $ % ' ( ) { } " @
Extension3 characters. .BAS from SAVE · .TXT from TEXT-mode Save · .DAT from Rfile
File number2 or 3 only — at most two RAM-disk files open at once
Data file sizeFixed at Init; occupies size + 34 bytes
OPEN "E:name.ext" FOR INPUT|OUTPUT|APPEND AS #2INPUT# 2, v LNINPUT# 2, s$ PRINT# 2, vIF EOF(2) THEN … N = LOF(2) CLOSE #2OPEN "COM:" half-duplex serial OPEN "COM1:" full duplexOPEN "LPRT:" parallel printer OPEN "PIO:" 8-bit parallel

OUTPUT discards whatever the file held; APPEND adds to the end. A file must be closed before reopening it for a different purpose. Files cannot be created by OPEN. FILES/LFILES list the disk; KILL deletes.

TEXT Mode Editor

*** TEXT EDITOR ***Edit Del PrintSio File Basic Rfile
CmdSyntaxAction
AA [[start][,step]]Auto line numbering
LL [line|label]List
RR [old[,new][,step]]Renumber
DD start[,[end]]Delete lines
CC start,end,destCopy lines
SS [0|1,] stringSearch — 1 forward from start, 0 backward from end
EE [0|1,] find, replReplace: ENTER replaces, SPACE skips, CLS ends

Search/replace strings are max 16 characters; write ¥" to match a quote. The editor prompt is <. Line numbers 1…65279, auto-sorted, no automatic colon or space. A line that must start with a digit needs an apostrophe: 50 '100 FORMAT….

Menus

Del wipes the whole TEXT area (TEXT DELETE OK? (Y)) · Print lists to the CE-126P · File = Save/Load/Kill/Files on the RAM disk · Basic = Basic→text / Text←basic conversion · Rfile = Init/Save/Load/Kill/Files for data files · Sio = Save/Load/Format.

In a file list, SHIFT+M loads the entry marked . Renumbering a converted BASIC program does not fix line numbers inside GOTO/GOSUB/THEN/RESTORE. Text file size = per line 3 (number) + 1 (linefeed) + characters.

Serial I/O (SIO Format)

ParameterValues (default)
baud rate300, 600, 1200, 2400, 4800, 9600
data bit7 or 8
stop bit1 or 2
paritynone, even, odd
end of lineCR, LF, CR LF
end of file00…FF hex (1A) — typed manually
line numberyes = send/expect line numbers · no = strip / auto-add in tens
flowRS/CS, Xon/Xoff, none

In the Format screen ▲▼ change the highlighted value, ◄► move, ENTER saves. Settings persist until RESET, battery change, or the next edit, and apply to OPEN "COM1:" and fopen("stdaux1"). A bad transfer gives I/O DEVICE ERROR; a file with no line numbers when "yes" is set gives LINE NO. ERROR.

Machine-Language Monitor

Enter with MON from RUN or PRO. Prompt is *. Everything is hexadecimal; commas separate addresses. Not available if a PASS password is set.

CmdMeaning
USER01FFReserve the machine-code area 0100H … the given end address
USERShow the reserved area, or FREE:NOT RESERVED
USER00FFRelease the machine-code area
S addr / SEdit memory byte by byte; blank ENTER skips, ▲▼ move
D addr / DDump 16 bytes with ASCII and a checksum (low byte of the sum)
D a1,a2Print the range in 16-byte rows (printer mode)
E addr / EFull-screen hex editor, range 0000–7FFF; TAB toggles hex ↔ ASCII
PToggle printer mode (same as SHIFT+PNP)
G addrCall the machine-code program (it must end in RET)
R / R addrReceive Intel-hex over SIO, to the embedded or given address
W a1,a2Send the range as Intel hex over SIO
BP addr[,n]Breakpoint, up to 4; n = 0…255 hits before stopping, 0 clears
BP / BP 0Show breakpoints · delete all

The keypad doubles as hex entry in the E editor: /=F *=E =D .=A ==B +=C. Breakpoints must sit on an opcode, and each fires only once — re-arm with G. While running, a breakpoint byte is replaced by F7H; pressing RESET first leaves that byte behind, so restore it by hand. Errors: SYNTAX ERROR, MEMORY ERROR, I/O DEVICE ERROR, OTHER ERROR.

Z80 Assembler (ASMBL)

32776 LABEL: ADD HL,30 ;COMMENT line label op operand comment

Workflow: write the source in TEXT mode → reserve space with USER in MON → SHIFT+ASMBL, A to assemble → check with D → run with G addr. Menu: A assemble · D display listing · P print · L send listing to SIO (undocumented on screen).

  • Line 1…65279; whole line up to 254 chars. Lower case is read as upper except inside operands and comments.
  • Label starts immediately after the line number (no space), max 6 characters from A–Z 0–9 [ ] @ ? _, first character a letter or symbol, terminated by : — except after EQU, which takes no colon. Register and condition names (A,B,C,…,AF,BC,HL,IX,IY,SP,NZ,Z,NC,PO,PE,P,M) are forbidden.
  • No label? Then at least one space/TAB between the line number and the opcode.
  • Operands: max 32 chars each, comma-separated. Binary 10111100B · decimal 188 · hex 0BCH (leading 0 if it starts with a letter). Strings in single quotes, '' is one quote, '' alone is 00H.
  • Expressions with + − * / are allowed but have no precedence and are computed in 16 bits; overflow is silently ignored.
  • Comments start at ;.

Pseudo-instructions

DirectiveEffect
ORG exprFirst address of the object. Default ORG 100H
DEFB DB DEFM DMLow byte of each expression; strings become ASCII bytes (max 32 chars)
DEFW DWTwo bytes, low first. A string may be at most 2 characters
DEFS DS nEmit n zero bytes (DS 500H-NXT00 pads to an address)
label EQU exprAssign a constant to a label — no colon after the label
ENDStop assembling. Without it the whole TEXT area is assembled

Errors: OPECODE ERROR · FORMAT ERROR (1) separator, (2) illegal code, (3) operand count, (4) label characters, (5) label >6, (6) unquoted string, (7) field >32 · QUESTIONABLE OPERAND (1) invalid, (2) bad condition, (3) out of range, (4) string >32, (5) ÷0, (6) other · UNDEFINED SYMBOL · MULTI DEFINE SYMBOL · FILE NOT EXIST · USER AREA OVER · WORK AREA OVER (needs ≥307 free bytes) · PRINTER ERROR. Press ENTER to continue past an error, CLS to clear.

C Compiler

Edit in TEXT (TEXT E) with line numbers — the compiler ignores them. Then SHIFT+TEXT: Compile · Trace · Go · Stdout. complete! means success; *EXIT (nn) after a run names the line where it ended. MEMORY FULL = no room for the object.

Trace / pause keys

KeyAction
ENTER / CLeave pause, continue
TContinue tracing
NRun normally, no more tracing
DVariable mode — type a name to see its value; BREAK exits
AAbandon trace, back to the menu

Types

TypeRangeBits
char / unsigned char−128…127 / 0…2558
int, short (+unsigned)−32768…32767 / 0…6553516
long (+unsigned)±2147483647 / 0…429496729532
float±1E−99 … ±9.999E+9932
double, long double±1E−99 … ±9.999999999E+9964

Names: letters and digits, must start with a letter, max 31 significant characters, no kana. Arrays up to 8 dimensions. struct supported. Storage classes auto · register · static · external. Preprocessor: #include "f", #define (incl. macros), #if/#elif/#else/#endif, #ifdef, #ifndef.

Streams & escapes

stdinkeyboardstdout / stdprnscreen / printer (toggle with Stdout)stdauxhalf-duplex 11-pinstdaux1full duplex 11-pinNULL 0 · EOF −1 · FILE intpredefined¥b ¥n ¥r ¥t ¥¥ ¥' ¥" ¥? ¥ddd ¥xhhescapes (¥ is the backslash key)

printf %[flag][width][.prec][l] d i o u x X f e E g G c s p — flags - + # 0. scanf %[*][width][l] d i o u x f e G c s p. With printer redirection getch returns 0xFF and every other input function returns EOF.

Run-time errors: NO MEMORY · BAD POINTER · DIVISION BY 0 · UNKNOWN ERROR · BAD FUNCTION · BAD STREAM · ARITHMETIC ERROR · FRAME ERROR · I/O ERROR OPEN · I/O ERROR.

CASL / COMET

32776 BGN ADD 0,DAT,1 ;COMMENT line label op operands comment

Write in TEXT mode, then SHIFT+ASMBL C: Assemble · Monitor · Go. The object is placed at address #1000. Labels: up to 6 alphanumerics starting with a letter; operands comma-separated, XR may be omitted; line ≤254 chars.

COMET architecture

RegisterRole
GR0–GR416-bit general registers; GR1–GR4 also index registers; GR4 is the stack pointer
PCProgram counter
FR2-bit flag: 00 greater · 01 equal/zero · 10 smaller
BP / BCBreak pointer (FFFF = none) / break counter

16-bit word length, von Neumann, two's complement. Instructions are 2 words. The stack starts at the top free address and grows down; PUSH decrements GR4, POP increments it. After assembly GR0–GR3 = 0, GR4 = top of object area + 1, PC = start label, FR = 0, BP = FFFF.

Monitor & simulation

M then R registers or O object/memory; ▲▼ scroll, the entry without a colon is the current one. Set a value as decimal (−32768…65535), hex #007B, "LABEL", or 'A'; CLS cancels. G asks for a start address then Normal or Trace. BREAK pauses; G resumes.

Special stop: executing #0000 shows * STP *; PC advances by 2, so define two DC 0 words. Errors: OP CODE / OPERAND / LABEL ERROR (line), MEMORY ERROR (0), OTHER ERROR (no START/END), OBJECT ERROR, * MEM * ERR * (jump out of range), * OPR * ERR * (OUT longer than 97 chars).

PIC Assembler & Loader

Supports PIC16F627 (1K words), 16F83 (512), 16F84 and 16F84A (1K), all 18-pin. Reserve at least 3 KB first: MONUSER0CFF. Then SHIFT+ASMBL P: Assembler (A) and Loader (L). Source follows MPLAB/MPASM conventions.

32767LABEL MOVLW 0x0F9 ; SAMPLE
DirectiveEffect
__CONFIG exprConfiguration word — required. & chaining is not supported here
ORG addrStart address 0x0…0x1FFF, default 0
label EQU exprConstant (number or character)
[label] DW exprOne 14-bit word, values to 0x3FFF
#INCLUDE "f"P16F627.INC · P16F83.INC · P16F84.INC · P16F84A.INC · PIC.INC. One per program, at the top

Labels 1–8 alphanumerics starting with a letter; MPASM names longer than 8 characters are truncated (OPTION_REC → OPTION_R). Hex constants use 0x. Include-file labels do not count against the 102 user labels.

Errors: File not exist! · No USER AREA! · Not __CONFIG data! · Syntax error! · Out of range! · Undefined label! · Undefined line! · Label too long! · Out of memory! · Multi define! · Not include file! — loader adds Not PIC data!, Illegal PIC data!, Connection error!, Low battery!, Verify error!, Break!

STAT Mode

SHIFT+MDF enters STAT and clears all previous statistical data. Choose 1 one-variable or 2 two-variable, then 1 input · 2 delete/clear · 3 calculate · 4 print. BREAK steps back.

Entry: type the value and ENTER; value,count enters a repeated value; 2ndF+ for a negative. Two-variable mode prompts x then y.

ResultMeaning
n · Σx · Σx² · x̄Count, sum, sum of squares, mean
s · σSample (n−1) and population (n) standard deviation
Σy · Σy² · Σxy · ȳ · sy · σyTwo-variable equivalents
a · b · rIntercept ȳ−bx̄ · slope Sxy/Sxx · correlation Sxy/√(Sxx·Syy)
x′ · y′Estimates (y−a)/b and a+bx — the machine prompts for the input

Non-linear regression — transform, then run a linear fit: exponential (x, ln y) · logarithmic (ln x, y) · power (ln x, ln y) · inverse (1/x, y).

Results are kept in fixed variables after leaving STAT — one variable: Z=n, Y=Σx, X=Σx². Two variables: Z=n, Y=Σx, X=Σx², W=Σxy, V=Σy, U=Σy². Re-entering STAT clears them.

Memory Map & System RAM

AddressContents
0000–00FFHeader
0100–…Machine-code (USER) area, ends at [7FFE,7FFF]−1
Program files (RAM disk), then data files
[7973,7974]–[7975,7976]TEXT area
[79E1,79E2]–[79E3,79E4]BASIC program area
Variable area, workspace, fixed variables
[79FC,79FD]–77DFStack area
77E0–7FFFSystem RAM
8000–BFFFROM BANK0 (system)
C000–FFFFROM BANK1 (BASIC) / BANK2 / BANK3, banked

Bracketed addresses hold a pointer to the current boundary.

Useful system addresses

AddrContents
779CContrast (0–31); apply with OUT &H40,&H80+A
7800–78CFFixed variables, 7 bytes each — 7800 is Z
78ED / 78EE / 78EFBaud rate · SIO parameters · EOF byte
7900Bank currently mapped at C000–FFFF
7901–7904Annunciator bits (7901 bit1 CAPS, bit2 kana)
790DVRAM display start row 0–7 (cheap scrolling)
7921 / 7922Cursor line (0–3) / column (0–23)
7966INKEY1 raw key code (see key matrix)
79C0–79C7PASS password
79FC–79FDRAMTOP, bottom of the BASIC variable area
7FFD–Top of stack, at most 178 bytes
7FFE–7FFFFirst address above the USER area

ROM routines (confirmed)

AddrRoutine
84F7Scroll screen up one line
871AInitialise the 11-pin serial interface
BCE8 / BCEBOpen / close the serial interface
BCFDGETCHR — read a character to A
BD00 / BFD0Read / write a pixel string, x in E, y in D
BD03REGOUT — dump all registers, wait for a key
BD09 / BD0FDisplay A / display HL, then wait
BD2D, C110Power off
BE53INKEY — A=0 none, A=52 multiple keys, carry set if pressed
BE62PUTCHR — write A at x,y in DE
BE65INSLN — blank line at x,y in DE
BFAF / BFB2Write A / write a NUL-terminated string to SIO
BFF1Display B chars from HL at DE, wrapping and scrolling
BFF4Enter RUN mode

LCD Ports & Key Matrix

Port 40h = LCD control, 41h = data. Cursor resolution 144 columns × 6 rows; one data byte is a vertical 8-pixel column in GPRINT bit order, and the column advances automatically. Reading port 40h: bit 7 = BUSY, wait before the next OUT. This bypasses VRAM and is the fastest path to the screen.

Port 40hEffect
0n / 1nx-axis low nibble (0–F) / high nibble (0–8)
24 / 25LCD off / on
3nCursor blink rate, 30 fastest … 3F slowest
40–7FVRAM display start row (VRAM is 144×64, 16 rows hidden)
80–9FContrast, brightest → darkest (80–8F is the usable range)
A0/A1 · A4/A5 · A6/A7Mirror off/on · mask off/on · inverse off/on
A8/A9 · AE/AFVoltage on/reduce · all pixels off/on
Bny-axis row, 0–5
CnPartial display: 0 normal, 1 left 16px, 2 right 10px, 3 left 32px, 4 = 1+2, 5 right 42px
OUT &H40,&HA7 ' invert the whole displayFOR A=0 TO 63: OUT &H40,&H40+A: NEXT ' scroll VRAM

Key matrix — OUT 11h, IN 10h

in\out76543210
7)R–CMM+Enter.KU
6/*+MJY
5963=SPACENHT
4852.TABBGR
37410カナVFE
2πINSCONONCAPSCDW
1BS0;TXTXSQ
0PILBASICZAOFF

A second matrix uses OUT 12h / IN 10h for CLS MDF FE 1/x tan ( log yˣ ln x² cos √ sin DEG 2ndF nPr. BIOS key values: +80h when SHIFT is held, 52h when two or more keys are down.

BEEP tones

BEEP repeat [, level] [, length]level 0…255 → ≈7 kHz down to ≈230 Hz; omitted ≈4 kHzlength ≈ 1300000 / (166 + 22 * level) per second of toneC-major octave levels: 105 99 93 87 82 77 72 68 64 60 56 52

Self-test menu: OUT &H69,6 — may clear memory. A piezo speaker solders to the BZ+ / BZ− pads (older models: 11-pin pins 3 and 7).

BASIC Error Codes

#Meaning
10Syntax error
12Command illegal in this mode (RUN/PRO)
13Illegal CONT
14No program for PASSWORD
15Illegal address for BSAVE M
20Overflow (>1E100)
21Divide by zero
22Illegal operation
30 / 31 / 32Array already dimensioned / not dimensioned / index overflow
33Out of range
40 / 41Line or label does not exist / illegal line number
43 / 44RENUM or LCOPY error / end line < start line
50Stack depth exceeded (GOSUB, FOR, REPEAT, WHILE, SWITCH)
51 / 52 / 53Missing GOTO / NEXT / READ
54 / 55Buffer overflow / string or line > 255 bytes
60Out of memory
61 / 62 / 63 / 64Missing ENDIF / REPEAT / WEND / WEND
66 / 68 / 69Extra CASE or DEFAULT / missing ENDSWITCH / missing SWITCH
70 / 71Cannot print with this USING format / illegal USING format
72 / 77I/O error / file overflow
80 / 81Checksum error / timeout
82 / 83Type mismatch on BLOAD / on INPUT#
84Printer error
85 / 86 / 87Device or file not opened / number already in use / end of file
90 / 91Type mismatch (e.g. using A after A$)
92 / 93Wrong password / password protected
94 / 95 / 96 / 97File not found / illegal file name / BASIC-vs-TEXT mismatch / more than 255 files

During program execution the failing line number is shown too. Clear with CLS.

Specifications & 11-pin Interface

ItemValue
CPU8-bit CMOS, Z80A-equivalent
MemorySystem 2.3 KB · fixed variables 208 B · program/data 30179 B
Precision10-digit mantissa + 2-digit exponent
Display6 × 24 characters (5×7) · 144 × 48 graphics
Power4 × AAA, or 6 V DC 0.2 W (EA-23E); ~90 h typical
Size / weight196 × 95 × 20 mm · 270 g (G850VS 260 g)
Temperature0–40 °C
OptionsCE-126P printer · CE-T800 PC cable · EA-129C computer-to-computer cable

11-pin connector (pin 1 = leftmost)

PinSIOSSIO / PWMPIOPIC
1
2 / 3VCC (+5 V) / GND
4RTS oBUSY oBit0CP o
5DTR oDOUT oBit1CLK# o
6RXD iXIN iBit2DATAIN i
7TXD oXOUT oBit3DATAOUT o
8CD iDIN iBit4LOWBATT# i
9CTS iACK iBit5
10DSR iEX1 iBit6
11CI iEX2 iBit7

Mode is chosen by what you run: OPEN "COM:" SIO · LPRINT without OPEN = CE-126P protocol · OPEN "LPRT:" = LPRT · BSAVE/BLOAD = PWM tape · OPEN "PIO:" = 8-bit parallel · the PIC loader = PIC. Levels are CMOS, not RS-232 — VCC tracks the batteries at 4–6 V.

System bus (right side, 40-pin)

Vcc · M1 MREQ IORQ IORESET WAIT INT1 WR RD · BNK0 BNK1 · CEROM2 CERAM2 · D0–D7 · A0–A15 · GND. CMOS levels must be observed.

BASIC Command Index

128 keywords · shortest abbreviation after the name · hover a row for its full syntax

Math & Trigonometry

32

Basic

ABSAbsolute value |x|
SGNSign: 1, 0 or −1
INTInteger part, rounds toward −∞
FIXInteger part, truncates toward 0
RCPReciprocal 1/x
SQUSquare x²
SQRSquare root √x
CUBCube x³
CURCube root ∛x
^Power yˣ — chains right to left
PI3.141592654
RND · RN.Random; <1 for arg<1, else 1…arg
RANDOMIZE · RA.Reseed the generator

Trigonometric

SINSine — uses the current angle mode
COSCosine
TANTangent — error at 90°(2n−1)
ASNsin⁻¹, −1≤x≤1 → −90…90°
ACScos⁻¹, −1≤x≤1 → 0…180°
ATNtan⁻¹ → −90…90°, any x

Hyperbolic

HSNsinh x
HCScosh x
HTNtanh x
AHSsinh⁻¹ x, |x|<1E50
AHCcosh⁻¹ x, 1≤x<1E50
AHTtanh⁻¹ x, |x|<1

Logarithmic

LNNatural logarithm, 1E−99≤x<1E100
LOGCommon logarithm log₁₀
EXPeˣ, x ≤ 230.2585092
TEN10ˣ, x < 100

Combinatorics

FACTn!, 0 ≤ n ≤ 69
NPRPermutations n!/(n−r)!
NCRCombinations n!/r!(n−r)!

Conversion

8
&HHexadecimal literal → decimal value
HEX$ · H.Decimal → hex string, e.g. "&40"
VAL · V.String → number; also &-prefixed hex
STR$ · STR.Number → string
DEGdd°mm′ss″ → decimal degrees
DMSDecimal degrees → dd°mm′ss″
VDEG · VD."dd°mm′ssrr" string → degrees
POL · RECRectangular ↔ polar coordinates

Strings

7
LENNumber of characters
LEFT$ · LEF.Leftmost n characters
RIGHT$ · RI.Rightmost n characters
MID$ · MI.Substring: length chars from start
ASC · AS.Character code of the first character
CHR$ · CH.Code → character; &H prefix allowed
+Concatenate — 255-char work space

Program Control

12
RUN · R.Start the program in memory
END · E.End the program, close all files
STOP · S.Halt for debugging — resume with CONT
CONT · C.Continue after STOP, BREAK or a PRINT pause
GOTO · G.Unconditional jump
GOSUB · GOS.Call a subroutine; RETURN comes back
RETURN · RE.Return from GOSUB
ON…GOTO · O. G.Jump to the n-th listed line
ON…GOSUB · O. GOS.Call the n-th listed subroutine
REM · 'Comment to end of line
WAIT · W.Hold each PRINT n/64 s; bare WAIT waits for ENTER
BEEPBeep n times; tone 0…255, duration 0…65279

Loops & Branching

15

Conditional

IF · IFSingle-line conditional
THEN · T.Taken when the condition is true
ELSE · EL.Taken when it is false
ENDIF · ENDI.Closes the multi-line IF block

Loops

FOR · F.Counted loop; 18 bytes of stack
NEXT · N.End of the FOR body
STEP · STE.Increment, may be negative
WHILE · WH.Test first — may run zero times
WEND · WE.End of the WHILE body
REPEAT · REP.Test after — always runs once
UNTIL · UN.End of the REPEAT body

Multi-way

SWITCH · SW.Dispatch on a variable — one instance only
CASE · CAS.Branch for one value
DEFAULT · DEFA.Fallback branch, optional
ENDSWITCH · ENDS.Closes the SWITCH block

Data & Variables

7
LET · LE.Assignment — the keyword is optional
DIM · D.Dimension an array, indexes 0…255
DATA · DA.Literal values for READ
READ · REA.Take the next DATA values
RESTORE · RES.Reset the DATA pointer
CLEAR · CL.Erase all variables, reset fixed ones to 0/null
ERASE · ER.Erase named simple/array variables (not A–Z)

Screen & Keyboard

7
PRINT · P.Display values; ; joins, , tabs
USING · U.# . , ^ & format; alone on a line it is sticky
LOCATE · LOC.Set the print position, col 0…39, row 0…5
CLSClear the display
INPUT · I.Prompt and read from the keyboard; ; hides the ?
INKEY$ · INK.Key pressed right now, "" if none
FRE · FR.Free bytes in the program/data area

Graphics

8
PSET · PS.Set a pixel; X inverts it
PRESET · PRE.Clear a pixel
POINT · POI.1 if the pixel is set, else 0
LINE · LIN.Line or rectangle, optional 16-bit dash mask
CIRCLE · CI.Circle, arc, sector or ellipse
PAINT · PAI.Flood-fill with pattern 0…6
GCURSOR · GC.Move the graphic cursor
GPRINT · GP.Draw 8-dot columns from a bit pattern

RAM-Disk Files

12

Programs

SAVE · SA.Store the BASIC program on drive E:
LOAD · LO.Load a program into memory
KILL · K.Delete a file from the RAM disk
FILES · FI.List the RAM disk on the display
LFILES · LF.Print the directory

Data files

OPEN · OP.Open a file (file numbers 2 and 3 only)
CLOSE · CLOS.Close one file or all files
INPUT# · I.#Read fields from a file or SIO
LNINPUT# · LNI.#Read whole lines into strings
PRINT# · P.#Write to a file or SIO
EOF · EO.True at end of a sequential file
LOFSize of an open file in bytes

I/O Ports

9
INPRead a byte from a Z80 I/O port
OUTWrite a byte to a Z80 I/O port
PIOSETPIO direction mask — 1 in, 0 out
PIOGETRead a byte from the 8-bit PIO port
PIOPUTWrite a byte to the PIO port

Device names for OPEN

COM:Serial, half duplex
COM1:Serial, full duplex
LPRT:Parallel printer protocol
PIO:8-bit parallel port

Printer

3
LPRINT · LP.Like PRINT but to the printer; bare LPRINT feeds a line
LLIST · LL.Print a program listing, with ranges
LFILES · LF.Print the RAM-disk directory

On the CE-126P a comma moves to column 13 or 0. Toggle printer output with SHIFT+PNP.

Program Editing (PRO)

6
AUTOAuto line numbers, default 10 by 10
LIST · L.Display the program from a line or label
DELETE · DEL.Delete a line or a range
RENUM · REN.Renumber lines and their references
LCOPY · LC.Copy a block of lines elsewhere
NEWErase all programs and data in memory

All six are blocked while a PASS password is set, as are LIST, LLIST, SAVE, LOAD, BSAVE, BLOAD and PRO mode itself.

Memory & System

5
PEEK · PE.Read a byte, address 0…&HFFFF
POKE · POK.Write one or more bytes
CALL · CA.Run machine code; bank 0…7, default 0
MON · MO.Enter the machine-language monitor
PASS · PA.Set/clear an 8-character password

Modes & Debug

5
DEGREE · DE.Angle mode: decimal degrees (default)
RADIAN · RAD.Angle mode: radians
GRAD · GR.Angle mode: gradians (45° = 50 grad)
TRON · TR.Trace on — stops after every line
TROFF · TROF.Trace off

Tape & PC-to-PC

5
BSAVE · BS.Send the BASIC program to tape or another G850
BLOAD · BLO.Receive a BASIC program
BLOAD? · BLO. ?Verify tape against memory
BSAVE M · BS. MSend a machine-code range, optional load address
BLOAD M · BLO. MReceive machine code to an address

These use Sharp's own PWM protocol, not the SIO settings — good for a CE-126P or a second G850, useless for a PC. Both machines must start the matching command at the same time.

Z80 · CASL/COMET · C Library

Instruction sets and the C runtime — flag column reads S Z H P/V N C, where * = affected, = unchanged, x = undefined

Z80 · 8-bit Load

T
LD r,r'4 — register to register
LD r,n7 — constant into a register
LD r,m7 — (HL) into a register
LD r,(IX+d)19 — indexed load
LD r,(IY+d)19 — indexed load
LD m,r7 — register into (HL)
LD (IX+d),r19 — register into indexed memory
LD (IY+d),r19 — register into indexed memory
LD m,n10 — constant into (HL)
LD (IX+d),n19 — constant into indexed memory
LD (IY+d),n19 — constant into indexed memory
LD A,(BC)7 — memory at BC into A
LD A,(DE)7 — memory at DE into A
LD A,(nn)13 — absolute address into A
LD (BC),A7 — A into memory at BC
LD (DE),A7 — A into memory at DE
LD (nn),A13 — A into an absolute address
LD A,I9 — interrupt register → A · **0F0−
LD A,R9 — refresh register → A · **0F0−
LD I,A9 — A → interrupt register
LD R,A9 — A → refresh register

Z80 · 16-bit Load

T
LD dd,nn10 — constant into a pair
LD IX,nn14 — constant into IX
LD IY,nn14 — constant into IY
LD HL,(nn)16 — memory nn, nn+1 into HL
LD pp,(nn)20 — memory into a pair
LD IX,(nn)20 — memory into IX
LD IY,(nn)20 — memory into IY
LD (nn),HL16 — HL into memory, low byte first
LD (nn),pp20 — pair into memory
LD (nn),IX20 — IX into memory
LD (nn),IY20 — IY into memory
LD SP,HL6 — HL becomes the stack pointer
LD SP,IX10 — IX becomes SP
LD SP,IY10 — IY becomes SP
PUSH qq11 — push a pair
PUSH IX15 — push IX
PUSH IY15 — push IY
POP qq10 — pop into a pair
POP IX14 — pop into IX
POP IY14 — pop into IY

All 16-bit values are stored little-endian.

Z80 · 8-bit Arithmetic & Logic

T

Add / subtract · all ***V0* or ***V1*

ADDr 4 · m 7 · n 7 · (IX+d) 19 — into A
ADCAdd with carry — same timings
SUBSubtract from A
SBCSubtract with carry

Logic

ANDBitwise AND with A · **1p00
ORBitwise OR with A · **0p00
XORBitwise XOR with A · **0p00
CPCompare with A — Z set if equal, C set if A smaller

Increment & adjust

INCr 4 · m 11 · indexed 23 · ***V0−
DECr 4 · m 11 · indexed 23 · ***V1−
DAA4 — BCD correct A after add/subtract
CPL4 — one's complement of A
NEG8 — two's complement: 0 − A
CCFInvert the carry flag
SCF4 — set the carry flag

Z80 · 16-bit Arithmetic & Exchange

T
ADD HL,dd11 — add a pair to HL
ADD IX,pp15 — add a pair to IX
ADD IY,pp15 — add a pair to IY
ADD IX,IX15 — double IX (also ADD IY,IY)
ADC HL,dd15 — add with carry to HL
SBC HL,dd15 — subtract with carry from HL
INC dd6 — increment a pair (IX/IY 10)
DEC dd6 — decrement a pair (IX/IY 10)

Exchange

EX DE,HL4 — swap DE and HL
EX AF,AF'4 — swap AF with its shadow
EXX4 — swap BC, DE, HL with the shadow set
EX (SP),HL19 — swap HL with the top of the stack

Z80 · Branch

T
JP nn10 — absolute jump
JP NZ,nn10 — if Z cleared
JP Z,nn10 — if Z set
JP NC,nn10 — if carry cleared
JP C,nn10 — if carry set
JP PO,nn10 — if parity/overflow cleared
JP PE,nn10 — if parity/overflow set
JP P,nn10 — if sign cleared (positive)
JP M,nn10 — if sign set (minus)
JR nn10 — relative jump
JR NZ,nn12/7 — relative if Z cleared
JR Z,nn12/7 — relative if Z set
JR NC,nn12/7 — relative if carry cleared
JR C,nn12/7 — relative if carry set
JP m4 — jump to the address in HL
JP (IX)8 — jump to the address in IX
JP (IY)8 — jump to the address in IY
DJNZ nn13/8 — decrement B, jump while B≠0

Z80 · Subroutines

T
CALL nn17 — push the return address and jump
CALL NZ,nn17/10 — if Z cleared
CALL Z,nn17/10 — if Z set
CALL NC,nn17/10 — if carry cleared
CALL C,nn17/10 — if carry set
CALL PO,nn17/10 — if parity/overflow cleared
CALL PE,nn17/10 — if parity/overflow set
CALL P,nn17/10 — if sign cleared
CALL M,nn17/10 — if sign set
RST p11 — one-byte call to a restart address
RET10 — return
RET NZ / Z11/5 — conditional on the zero flag
RET NC / C11/5 — conditional on carry
RET PO / PE11/5 — conditional on parity/overflow
RET P / M11/5 — conditional on sign
RETI14 — return from interrupt
RETN14 — return from NMI

Z80 · Shift & Rotate

T

Accumulator · flags --0-0*

RLCA4 — rotate A left, bit 7 → bit 0
RRCA4 — rotate A right, bit 0 → bit 7
RLA4 — rotate A left through carry
RRA4 — rotate A right through carry

Any operand · flags **0p0*

RLC8/15/23 — rotate left, bit 7 → bit 0
RRC8/15/23 — rotate right, bit 0 → bit 7
RL8/15/23 — rotate left through carry
RR8/15/23 — rotate right through carry
SLA8/15/23 — shift left, bit 0 = 0
SRA8/15/23 — shift right, bit 7 preserved
RLD18 — nibble rotate left through A and (HL)
RRD18 — nibble rotate right through A and (HL)

Z80 · Bit & CPU

T

Bit operations · b = 0…7

BIT b,…8/12/20 — test; Z gets the inverse of the bit
SET b,…8/12/20 — set the bit
RES b,…8/12/20 — clear the bit

CPU control

NOP4 — do nothing
HALT4 — NOP until an interrupt or RESET
DI4 — disable interrupts (modes 1 and 2)
EI4 — enable interrupts
IM 08 — interrupt mode 0, external
IM 18 — interrupt mode 1, OS
IM 28 — interrupt mode 2, user vector

Z80 · Block & I/O

T

Copy & compare

LDI16 — (HL)→(DE), HL+ DE+ BC−
LDIR21 — repeat LDI until BC = 0
LDD16 — (HL)→(DE), HL− DE− BC−
LDDR21 — repeat LDD until BC = 0
CPI16 — compare A with (HL), HL+ BC−
CPIR21 — repeat until BC = 0 or a match
CPD16 — compare A with (HL), HL− BC−
CPDR21 — repeat until BC = 0 or a match

Ports

IN A,(n)11 — read port n into A
IN r,(C)12 — read the port in C, B carries A8–A15
INI / IND16 — port (C) → (HL), HL±, B−
INIR / INDR21 — repeat until B = 0
OUT (n),A11 — write A to port n
OUT (C),r12 — write r to the port in C
OUTI / OUTD16 — (HL) → port (C), HL±, B−
OTIR / OTDR21 — repeat until B = 0

Registers: A B C D E H L (8-bit) · IX IY BC DE HL SP (16-bit) · shadow set via EXX and EX AF,AF'. Flag byte F, bits 7→0: S sign · Z zero · bit5 · H half-carry · bit3 · P/V parity/overflow · N add-subtract · C carry.

CASL Instructions

23

Data movement — OP GR,adr[,XR]

LDLoad the word at adr into GR
STStore GR into memory at adr
LEALoad the effective address itself into GR

Arithmetic & logic

ADDGR ← GR + (adr)
SUBGR ← GR − (adr)
ANDBitwise AND, 16 bits
ORBitwise OR
EORBitwise exclusive OR
CPACompare arithmetically (signed)
CPLCompare logically (bit pattern)

Shifts — count comes from adr

SLAArithmetic shift left
SRAArithmetic shift right
SLLLogical shift left
SRLLogical shift right

Branch — OP adr[,XR]

JPZJump if plus or zero
JMIJump if minus
JNZJump if not zero
JZEJump if zero
JMPUnconditional jump

Stack & subroutines

PUSH adrPush the effective address
POP GRPop the top of the stack into GR
CALL adrCall — return address goes on the stack
RETReturn using the stacked address

CASL Directives & Macros

8
STARTProgram start; optional entry label
ENDEnd of the source
DCConstant: −32768…65535, #0000…#FFFF, string or label
DSReserve n words; DS 0 just defines the label
INRead from the keyboard, prompt ?; BREAK returns #FFFF
OUTPrint a string; max 97 characters
WRITEDump all registers, ENTER continues
EXITEnd execution and return

One string character occupies the low half of a word; the length is not stored, so the program must know it. Usable codes: &H20–&H26, &H28–&H5F, &H61–&H7A, &HA6–&HDF. Each macro expands to PUSH, PUSH, CALL, LEA GR4,2,GR4.

C Library · Standard I/O

14
getcharRead one character from stdin
getc · fgetcRead a character from a stream
getsRead a line from stdin; CR/LF becomes ¥0
fgetsRead up to n−1 chars or a line end
scanfFormatted read from stdin
fscanfFormatted read from a stream
sscanfFormatted read from a string
putcharWrite a character to stdout
putc · fputcWrite a character to a stream
putsWrite a string to stdout, ¥0 becomes CR/LF
fputsWrite a string to a stream, no terminator
printfFormatted write to stdout
fprintf · sprintfFormatted write to a stream or a string
fflush · clearerrFlush a buffer · clear the EOF/error state

C Library · Characters, Strings, Memory

17

Character class — int f(int c)

isalnumLetter or digit
isalphaLetter
isdigit · isxdigitDecimal · hexadecimal digit
isupper · islowerCase tests
isspaceWhitespace
iscntrlControl character
isprint · isgraphPrintable, with · without space
ispunctPrintable, not space or alphanumeric
tolower · toupperCase conversion

Strings

strcatAppend s2 to s1
strcpyCopy s2 over s1 including ¥0
strcmp<0, 0 or >0
strchrFirst occurrence of c, or NULL
strlenLength, excluding ¥0

Memory

mallocAllocate size bytes, NULL on failure
callocAllocate n elements of size bytes
freeRelease a malloc/calloc block

C Library · Math

9
absInteger absolute value
sqrtSquare root
powx to the power y
exp
log · log10Natural and common logarithm
sin · cos · tanTrigonometric, current angle mode
asin · acos · atanInverse trigonometric
sinh · cosh · tanhHyperbolic
asinh · acosh · atanhInverse hyperbolic

C Library · Hardware & Graphics

28

Ports, memory, machine code

inportRead an I/O port
outportWrite an I/O port
peekRead a byte of memory
pokeWrite a byte of memory
callRun machine code; arg goes in HL, returns HL

Mini I/O and PIO

minigetRead the mini I/O port
miniputWrite the mini I/O port
piogetRead the 8-bit PIO port
pioputWrite the PIO port
piosetSet the PIO direction mask

Streams & files

fopenModes r/w/a for files, r+/w+/a+ for devices
fcloseClose; writes 0x1A for w/a files, EOF byte for SIO
feofEnd of file — 1 for files, −1 for the SIO buffer
flofUnused bytes remaining in a data file

Graphics — mirror the BASIC commands

psetSet or invert a pixel
presetClear a pixel
pointTest a pixel
linerectangle: 0 line, 1 box, 2 filled box
circleCircle, arc, sector, ellipse
paintFlood fill with a pattern
gcursorMove the graphic cursor
gprintDraw a dot pattern
clrscr · gotoxyClear screen · text cursor, (0,0) top left

Other

getchWait for a keypress
kbhitPoll the keyboard without waiting
angleSet the trigonometric angle mode
breakptEnter BREAK mode from the program
abort · exitAbnormal (shows A B O R T) · normal exit