		Casio PB-2000C native system variables

The names of equivalent PB-1000 variables and part of the description taken
from the "Casio PB-1000 technical handbook".
Some unused ones kept for compatibility with other programming languages.
The list is incomplete yet.

address #bytes	name	description
=======	======	====	===========

Screen Data
&H0000	256	INTOP	Intermediate code buffer
&H0100	257	EDTOP	Input buffer
&H0201	1536	LEDTP	Display dot buffer
&H0801	192	LPFTP	4th line of the display dot buffer
&H0801	6	CSRDT	Cursor data buffer, shares space with LPFTP, perhaps
			the address should have been &H08C1 ?
&H08C7	3		contrast data
&H08CA	1	LCDST	LCD state
			Bit 0: At key input / PRINT
			Bit 1: Cursor display enable
			Bit 2: Virtual screen / Actual screen
			Bit 3: Cursor movement range setting
			Bit 4: Cursor on/off
			Bit 5: Reverse field display
&H08CB	1	EDSCR	Cursor position
&H08CC	1	SCTOP	Actual screen top
&H08CD	1	TOEDB	Logical line top
&H08CE	1	BOEDB	Logical line bottom
&H08CF	1	MOEDB	Logical line top (at INPUT)
&H08D0	1	TOARE	Cursor movement range top
&H08D1	1	BOARE	Cursor movement range bottom
&H08D2	1	EDCNT	location after the last character in the logical line,
			number of shifted or cleared character positions
&H08D3	1	DSPMD	&H00 = Normal display
			&H01 = PF display
			&H03 = MENU display
&H08D4	1	SCROL	&H80 = 4-line scroll, &H60 = 3-line scroll
&H08D5	2	ELVAD	pointer to the contrast data
&H08D7	1	CSRCN	cursor flash counter
&H08D8	1		cursor flash rate, default value &H5F
&H08D9	1	APOCN	APO counter, current value of the auto power-off timer
&H08DA	1		default value of the auto power-off timer, to be used
			when waiting for a key press
&H08DB	1	RS1	Bit 0: MT/RS232C
			Bit 1: Odd/Even parity
			Bit 2: OFF/ON
			Bit 3: 7/8 data length
			Bit 4: 1 / 2 stop bit
			Bit 5-7:
				000=9600 baud
				001=4800 baud
				010=2400 baud
				011=1200 baud
				100=600 baud
				101=300 baud
				110=150 baud
				111=75 baud
&H08DC	1	RS2	Bit 0: Output while XOFF in progress
			Bit 1: Input while SO in progress
&H08DD	1	RS3	Bit 0: SI/SO control
			Bit 1: XON/XOFF control
			Bit 2: CTS control
			Bit 3: DSR control
			Bit 4: CD control
			Bit 5: Output SO in progress
			Bit 6: Input XOFF in progress
&H08DE	1	RS4	Bit 0: Buffer overflow
			Bit 1: Parity/Overrun
			Bit 2: Framing
			Bit 3: Not ready
&H08DF	1	INTCK	&H01=data receive
&H08E0	258	RXCNT	RS232C, MT receive buffer
			1 Byte = number of received bytes
			1 Byte = input pointer
			256 Bytes = buffer

Keyboard
&H09E2	2	KANA1
&H09E4	1	KEYMD	bit 7: S mode
			bit 5: ENG/JAP
&H09E5	1	KYSTA	bit 4: contrast preset mode
			bit 1: keyboard beep enabled
&H09E6	1	CHATA	keyboard debounce counter
&H09E7	1	KEYCM	KO
&H09E8	2	KEYIN	KI
&H09EC	1	KYCNT	current number of characters in the keyboard buffer
&H09ED	1		last read position in the keyboard buffer (&H00..&H0F)
&H09EE	1		last write position in the keyboard buffer (&H00..&H0F)
&H09EF	1		size of the keyboard buffer (fixed value &H10)
&H09F0	2		address of the keyboard buffer (fixed value &H09F2)
&H09F2	16		circular keyboard buffer

&H0A02	1	ANSFG	Post calculating flag (1=After calculation, 0=Other)
&H0A03	1	ANGFL	Angle mode (0=DEG, 1=RAD, 2=GRAD)
&H0A04	1		"integer cheating" flag, (1=cheating disabled)
&H0A05	1		tabulation setting (1 to 8)
&H0A06	96	CGRAM	&HF0-&HFF display dot pattern
&H0A66	2		card ROM ID

Pointers to main memory areas
&H0A80	2		begin of the p-code
&H0A82	2		end of the p-code, grows upwards
&H0A84	2		top of the LOAD file table, grows downwards
&H0A86	2		end of the LOAD file table
&H0A88	2		begin of the symbol table
&H0A8A	2		end of the symbol table, grows upwards
&H0A8C	2		top of identifier and const. buffer, grows downwards
&H0A8E	2		end of identifier and const. buffer
&H0A90	2
&H0A92	2
&H0A94	2
&H0A96	2
&H0A98	2	IOBF	I/O buffer
&H0A9A	2	SSTOP	begin of the character operation stack, grows upwards
&H0A9C	2	SBOT	end of the character operation stack, grows upwards
&H0A9E	2	FORSK	unused, the same value as TONDT
&H0AA0	2	GOSSK	unused, the same value as TONDT
&H0AA2	2	TONDT	top of contents of numeric variables, grows downwards
&H0AA4	2	DTTB	top of variable table, grows downwards
&H0AA6	2	TOSDT	unused, the same value as HIMEM
&H0AA8	2	PDSTD	unused, the same value as HIMEM
&H0AAA	2	HIMEM	begin of files
&H0AAC	2	BASEN	unused, the same value as HIMEM
&H0AAE	2	MEMEN	end of files, grows upwards
&H0AB0	2	DATDI	top of directory, grows downwards
&H0AB2	2	BASDI	unused, the same value as DIREN
&H0AB4	2	DIREN	end of the directory
&H0AB6	2		begin of the user memory area
&H0AB8	2		default values for RS1, RS3
&H0ABA	2	PRNFG	printer flags tested before and after output of
			character
			Bit 0: BUSY
			Bit 1: ERROR
			Bit 2: ACK
&H0ABC	1	OPTCD	option code
&H0ABD	1	OUTDV	output device, 0=LCD, 2=printer, 4=file
&H0ABE	1	IOSTS	Bit 0: send open
			Bit 1: receive open
&H0AC0	8	ANSAD	ANS data
&H0AC8	1
&H0AC9	2	ONFIL1	preset file address
&H0ACB	2	ONFIL2	preset file address
&H0ACD	2	ONFIL3	preset file address
&H0ACF	2	ONFIL4	preset file address

&H0ADD	1		bit 0: switch on mode Calc/Menu
			bit 6: stop on error
&H0ADE	256	CALC	Calc buffer

&H0CE2	2	ACJMP	jump address for BREAK
&H0CE6	24	WORK1	work buffer
&H0D0B	1	MODE	Bit 0: C
			Bit 1: EDIT
			Bit 2: MEMO
			Bit 3: INPUT
			Bit 4: CALC
			Bit 5: SAVE/LOAD
			Bit 6: MENU
&H0D0C	1		Bits 6,5: select sub-menu
				00: [c     ][newc  ]...
				01: [name  ][kill  ]...
				10: [data  ][llist ]...
				11: [      ][C/S   ]...
&H0D0D	1
&H0D0E	2	NOWFL	directory entry of currently used file
&H0D10	1	NBX1	line drawing work area
&H0D11	1	NBY1	line drawing work area
&H0D12	1	NBX2	line drawing work area
&H0D13	1	NBY2	line drawing work area
&H0D15	15	MENUC	Work

&H0D15 (1 byte) - when the screen shows the file list: index of the selected
 file on the screen, 0 when top left item
&H0D16..&H0D21 (6 words) - when the screen shows the ramdisk file list:
 pointers to the 6 directory entries of the files shown on the screen

&H0D2C	2	NOWFC	start adress of current object FCB
&H0D2F	35	IOBFO	save/load FCB
&H0D45	258	IOBUF	SAVE/LOAD I/O buffer
&H0E54	35		buffer for an I/O control block header
&H0E7C	16	FDDFL
&H0E8C	2	LOADB	Work
&H0E8E	1	MTFL2	segment checksum

&H0E96	2		size of the free space at the end of the edited C file
&H0E98	2		current line number of the edited C file
&H0E9A	511	USPBT	user stack area
&H1099	0	USPTP
&H1099	511	SSPBT	system stack area
&H1298	0	SSPTP

C compiler
&H1298	1	FLAG1
&H1299	1		bit 7: Trace mode
&H129A	1
&H129B	1
&H129C	1
&H129D	1

&H1300	2		pointer to the directory entry of the C source file
			(when in the ramdisk, otherwise 0)
&H1302	2
&H1304	6	TOKEN	buffer for three consecutive tokens fetched from the
			input stream, the latest one first
&H130A	2		copy of the latest token
&H130C	3		"unget" buffer for excess characters read from the
			C source file
&H130F	1		index of the LOAD file table, -1 when invalid
&H1311	2		C source line number
&H1313	2
&H1315	2		top of the linked list of identifiers in the identifier
			and constant buffer
&H1317	258	GPBUF	general purpose buffer
&H1419	2	GPIND	general purpose index
&H141B	1	FLAG2	in the LOAD mode: compiler state
			bit 7: #define directive processed
			bit 6: macro expansion, tokens are fetched from
			       the #define token string buffer
			bit 5: macro name following the #define directive
			       processed
&H141C	1		#include depth
&H141D	1	SCOPE	scope of declared variables
			0 = global, variables are declared outside a function
			1 = declaration of function arguments
			2 = local, variables are declared within a function
			3 = none, variables cannot be declared
&H141E	1
&H141F	2		number of function arguments
&H1421	1		branch/loop nesting level
&H1422	1		&& || ?: nesting level
&H1423	1

&H1424	2		pointer to the array dimension / expression parser
			stack &H1426, grows upwards
&H1426	100		stack area
&H148A	0		end of the stack area

&H148A	2		pointer to the if/while/for stack &H148C, grows upwards
&H148C	100		if/while/for stack area
&H14F0	0		end of the if/while/for stack area

&H14F0	2		pointer to the break table &H14F4, grows upwards
&H14F2	2		pointer to the continue table &H14F4, grows downwards
&H14F4	100		break/continue table
&H1558	0		end of the break/continue table

&H1558	23	SYMB1
&H156F	23	SYMB2
&H1586	23	SYMB3
&H159D	2
&H159F	2		top of the linked list of variables in the symbol table
&H15A1	2		apparently unused
&H15A3	2
&H15A5	2
&H15A7	2		pointer to a symbol identifier
&H15A9	2
&H15AB	2		size of a structure/union member
&H15AD	2		top of the linked list of functions in the symbol table

C interpreter
&H15AF	2	IPC	Interpreter Program Counter, address in the P-code
			buffer of the next instruction to be executed
&H15B1	1
&H15B2	2		top of the linked list of C function return addresses
			on the evaluation stack
&H15B4	8
&H15BC	10
&H15C6	10
&H15D0	10		apparently unused
&H15DA

&H165A	2
&H165C	1		value for the "errno" variable
&H165D	2
&H165F	2
&H1661	2
&H1663	2
&H1665	2
&H1667	2
&H1669	2
&H166B	2
&H166D	2
&H166F	2

&H1675	2
&H1677	2
&H1679	2
&H167B	2
&H167D	1
&H167E	2
&H1680

&H16D3	315		table of 15 file control blocks for file handles 1-15,
			of size of 21 bytes each
&H180E	1		C source file handle
&H180F	13		file name
&H181C	1
&H181D	13		file name
&H182A	13		file name
&H1837


For each opened file, a control block of following structure is allocated in
the I/O buffer:
&H0000	291		block size in bytes
&H0002	1		handle in range 0..15
&H0003	1		access mode
			&H30 = OUTPUT, &H31 = RANDOM, &H32 = INPUT,
			&H34 = APPEND
&H0004	1		device type
			0 = ramdisk, 1 = FDD, 2 = COM port, 3 = tape
&H0005	11		file name
&H0010	2		pointer to the begin of the data buffer
&H0012	2		pointer to the end of the data buffer
&H0014	1		counter of bytes in the data buffer
&H0015	1		memory overflow flag
&H0016	1		EOF flag (0 = not EOF, &HFF = EOF)
&H0017	2		pointer to the current position in the data buffer
&H0019	1
&H001A	2		record number
&H001C	1		file type
&H001D	2		starting address of the RAM file
&H001F	2		ending address of the RAM file
&H0021	2		pointer to the current position in the RAM file
&H0023	256		data buffer


Memory map of the area between the address &H1A00 and the end of RAM

						<- pointer &H0AB6 (1A00)
 =========================================	<- pointer &H0A80 (1A00)
| p-code area                             |
 -----------------------------------------	<- pointer &H0A82
| ...                                     |
| code free area                          |
| ...                                     |
 -----------------------------------------	<- pointer &H0A84
| LOAD file table                         |
 =========================================	<- pointer &H0A86 (4A80)
 =========================================	<- pointer &H0A88 (4A80)
| symbol table                            |
 -----------------------------------------	<- pointer &H0A8A
| ...                                     |
| symbol free area                        |
| ...                                     |
 -----------------------------------------	<- pointer &H0A8C
| Identifier character strings, constants |
 =========================================	<- pointer &H0A8E (7B00)
 =========================================	<- pointer &H0A90 (7B00)
| at LOAD           | at RUN              |
| #define           | Global area         |
| token string      |                     |
 -----------------------------------------	<- pointer &H0A92
| ...                                     |
| stack free area                         |
| ...                                     |
 -----------------------------------------	<- pointer &H0A94
| at LOAD           | at RUN              |
| #define           | Evaluation stack    |
| identifier string |                     |
 =========================================	<- pointer &H0A96 (DC00)
 =========================================	<- pointer IOBF (DC00)
| I/O buffer                              |
 -----------------------------------------	<- pointer SSTOP
| Character operator stack                |
 -----------------------------------------	<- pointer SBOT
| ...                                     |
| work free area                          |
| ...                                     |
 -----------------------------------------	<- pointer TONDT
| Numeric variable data area              |
 -----------------------------------------	<- pointer DTTB
| Variable table                          |
 =========================================	<- pointer HIMEM (E000)
| file area                               |
 -----------------------------------------	<- pointer MEMEN
| ...                                     |
| file free area                          |
| ...                                     |
 -----------------------------------------	<- pointer DATDI
| directory area                          |
 =========================================	<- pointer DIREN (FFFF)
