Micro Basic Users Guide I originally wrote Micro Basic in 1980 for a University Computer Club, in which the members were building their own 8085 based systems. I am including it with XASM as a demonstration program. Dave Dunfield MICRO BASIC USERS GUIDE TABLE OF CONTENTS Page 1. INTRODUCTION 1 2. COMMANDS 2 2.1 General commands 2 2.2 Program only commands 5 3. EXPRESSIONS 6 3.1 Numeric operators 6 3.2 Character operators 7 3.3 Numeric conversion 7 3.4 Variables 8 3.5 Special variables 9 4. PROGRAM ENTRY AND EDITING 10 5. CONTROL CHARACTERS 12 6. ERROR MESSAGES 13 7. SOURCE FORMAT 14 8. EXAMPLE PROGRAMS 15 9. THE MICRO BASIC MONITOR 16 9.1 MONITOR SUBROUTINES 17 9.2 USER SUPPLIED OUTPUT DEVICE 19 9.3 8251 USART 20 10. SYSTEM MEMORY MAP 20 MICRO BASIC USERS GUIDE Page: 1 1. INTRODUCTION Micro Basic was implemented with the intention of providing the maximum amount of features and flexibility, in the minimum amount of memory space. It is intended for use on 8080/8085/Z80 based computers which are too small to afford the use of larger programming systems. Currently, the Micro Basic interpreter, is 3K bytes in size. A machine-language MONITOR and all hardware dependant I/O routines are also included, bringing the total rom size to 4K. A minimum of 3K of ram is required if any useful programs are to be implemented. The interpreter only makes use of memory as it needs it, and memory can be expanded at any time, to allow for larger programs or more array space. Micro Basic is quite different from most other BASIC interpreters, in particular the right to left execution of expressions, with no operator precedence, and the use of separate operators for EQUALS and ASSIGNMENT. These implementation decisions, were in part, based on the language APL, which is a favorite language of the author. The Micro Basic rom, is assembled to go at location zero, and occupies the range of addresses from 0000-0FFF. The software supports a 16 line by 64 character 1K memory mapped video display, to be located in the address range from 1000-13FF. The system RAM should start at 1400 and may continue on up to FFFF. The keyboard should be on a parallel input port, located as port#0, with the keystrobe (active high) on bit#7, and ASCII data is expected on bits 0-6. The keystrobe should remain high for as long as the key is pressed. The serial I/O for the tape is expected to be an INTEL 8251 with the data port mapped as port#1, and the control port as port#2. The receive and transmit clocks should be 16x the desired speed. On the following pages, is a brief description of Micro Basic's commands and features. MICRO BASIC USERS GUIDE Page: 2 2. COMMANDS Operands to commands are as followes: - Any expression. - Any variable. - Any array variable. - Any numeric expression. - A line number. [ ] - Optional operands. ... - Multiple extra operands allowed. 2.1 General commands The following commands, may be entered directly from the keyboard, or executed with a BASIC program. CLEAR Clears all numeric and character variables, Delete's all arrays, and resets the control stack and data pointer. DIM a1()[,a2(n2)]... Dimensions integer arrays a1, a2,... makeing them n1, n2,... elements each. Arrays may be REDIMENSIONED with the DIM statement, however this allocates new memory for the array, causing the old memory used by the old array to be made unusable (until 'NEW', 'CLEAR' or a 'RUN' command is issued). Whenever an array is dimensioned or redimensioned via DIM, it is cleared to zeros. NOTE: Array space is allocated in memory, starting at the end of the program source. As a result, if a line is inserted into the program, or any line is replaced in the program, any existing arrays will be deleted. END Stops the program. no messages are issued. EXIT Exits to the system monitor. GOTO Transfers program execution to the statement at the beginning of line . GOTO(),[,]... Transfers program execution to the statement at the beginning of line if =0, to the beginning of line if =1, etc. results in SYNTAX ERROR if is greater than number of line numbers given. MICRO BASIC USERS GUIDE Page: 3 INPUT Requests a value for from the terminal. Prompts with a question mark "?". If is a character variable, then any text can be input. If is numeric, then value supplied must be a number or expression. INPUT "", Same as above, but prompts with instead of "?". can be a null string ( INPUT "", would give no prompt ). NOTE: The value of a character variable can be used in the prompt, but must be concatinated with . EG: ' INPUT ""+A$,V '. LET = (default) Assigns the value of to the variable . If any lines are found by the interpreter which do not contain a command, then they are assumed to be LET. LIST [][,] Lists the program,if no operands are given, then lists the entire program. If is given then only that line is listed. If is also given, then lists from to inclusive. LOAD Loads a program from tape. Flashes a '*' in the upper right-hand corner of the screen for every record (255 Bytes) that is loaded. NEW Clears the program, variables, and arrays. ORDER Positions the read pointer to the start of the line . This line must begin with a DATA statement, or a DATA ERROR will occur. PRINT [,][,]...[,] Prints the expressions on the terminal. Numeric values will be printed with a preceding space. If a numeric expression is preceded by a single '(', then the preceding space is not printed. ( EG: PRINT 12,(12 would display ' 1212' ). If the list of expressions ends with a trailing comma, then no line-feed carriage return will be printed, causing the next PRINT statement to continue at the end of the same line. MICRO BASIC USERS GUIDE Page: 4 PLOT ,[,][,]...[,] Same as PRINT, except cursor is positioned at column , line (from the top lefthand corner of the screen), before the rest of the operands are printed. 'PLOT ,' with no other operands, will position the cursor with no output. READ [,]... Reads the values for variables from data statements. An ORDER statement must be done before the first read in a program, and anytime that you have read all the data in a data block. A data block, is a collection of data statements which are located separately, with no other statements between them. If a read statement does not read all of the data in a given data statement, then the next read will pick up where the last one left off. If a read statement reads beyond the end of a data statement, the it will advance to the next statement and attempt to read from there. REM Comment, the rest of the statement is ignored. RUN Clears variables and arrays, then starts the program running. A running program can be stopped by pressing CONTROL-C. SAVE Saves a program on tape. SIZE Prints the size of the program in bytes. STOP Stops the program, issues message indicating line number where it was executing. USR [,][,] Calls a user supplied machine code routine at address . If is given, its value will be passed in the H-L register pair. If is given, it must be a numeric variable, and will be assigned the value of H-L after the machine language routine returns. MICRO BASIC USERS GUIDE Page: 5 2.2 Program only commands The following commands, can only be executed within a program. DATA [,]... Defines program DATA, to be read by the READ statement, into program variables. DATA statements are not executed by the interpreter. NOTE: Variables can be used in the DATA statements, but the value will be evaluated as the value of that variable at the time that the DATA statement is read. FOR = TO Starts a program loop. The variable will be set to .and will be incremented by one every time around the loop. until it value is equal to . must be a simple numeric variable. See also 'NEXT' statement. GOSUB Calls a BASIC subroutine at given line number. (Same as goto,but stacks return address.) See also 'RETURN' statement. GOSUB(),,... Same as above, but uses computed line number. See also 'GOTO()'. IF THEN Evaluates , If it is true (non-zero) then is executed. If is a number, then assumes GOTO . LIF THEN Long IF, same as IF, except that the entire remainder of the line is executed only if the expression is true. NEXT Closes a program loop. must match the in the matching 'FOR' statement. RETURN Returns to statement following GOSUB statement. (Terminates a BASIC subroutine) MICRO BASIC USERS GUIDE Page: 6 3. EXPRESSIONS Expressions can be either numeric or character. all expressions, are evaluated from right to left, with NO operator precedence (as in the language APL). For example, 1+5*5 evaluates to 26, but 5*5+1 will give the answer 30. Precedence can be forced in numeric expressions with the use of brackets "()". Brackets can be nested to any depth. 3.1 Numeric operators FORMAT: "XY" + Addition. - Subtraction. * Multiplication. % Division. (Remainder assigned to special variable "R"). & Bitwise logical AND of X and Y. | Bitwise logical OR of X and Y. \ Floor. (returns lesser of X and Y). / Ceiling. (returns greater of X and Y). = Assignment. (X takes value of Y). == Equality. (returns 1 if X equals Y, 0 otherwise). > Greater than. (returns 1 if X greater than Y, 0 otherwise). < Less than. (returns 1 if X less than Y, 0 otherwise). >= Greater equals. (Returns 1 if X GE Y, 0 otherwise). <= Less equals. (Returns 1 if X LE Y, 0 otherwise). -= Not equals. (Returns 1 if X not equal to Y, 0 otherwise). ; Null operator, returns value of X. (but executes Y). Especially useful for doing modular arithmetic. The expression "A=R;B%123" will divide B by 123 (without changing B), and then assign the remainder to A. (Right to left execution). MICRO BASIC USERS GUIDE Page: 7 3.2 Character operators FORMAT: "X$Y$" + Concatonation. (Y$ appended to X$). = Assignment. (X$ takes value of Y$). == Equality. (only valid in "IF" and Numeric conversion). -= Not equals. (only valid in "IF" and numeric converson) The following are other operators which perform useful functions: ( ) Brackets, Force operator precedence. [ ] Braces, Used to index numeric arrays, E.G. "A[10]" Also can be used to extract a single character from a character variable. E.G. "A[0]$" returns the first character in variable "A$". (Index starts at zero (0) ). # Hexidecimal constants. EG. "A=FF#+1" calculates "FF#" as 255, adds 1 then assigns result (256) to "A". : Statement separator, can be used to place multiple statements on a single program line: E.G: "A=10:PRINT A" , Operand separator, separates operands to some commands. 3.3 Numeric conversion A character expression can be included in a numeric expression, but must be contained in brackets "()". If the leftmost operator in the character expression is one of "==" or "-=", then a 1 or 0 is returned to the numeric (outside) expression. If the leftmost operator of the character expression is "=",then the value returned is the ASCII value of the first character of the OLD value of the character variable. Otherwise the ASCII value of the first character in the result of the character expression is returned. The ASCII value of a character, is the decimal value of it's binary representation. (E.G. " " (blank) is 32). If a null string ("") is the result of the expression,then the value 255 is returned (ASCII values for characters can only range from 0 to 127). The expression within the brackets does not have to contain operators, I.E. " PRINT ("A") " will print a 65. (The decimal value of an ASCII "A"). MICRO BASIC USERS GUIDE Page: 8 3.4 Variables There are 26 simple integer variables (A-Z). These variables always exist and are cleared to zero when BASIC is entered, when a NEW command is executed, and when a program is RUN. Integers are positive, with a range of 0 to 65535 (16 bits of data). There are also up to 26 integer arrays, (A[n] - Z[n]). An array must be created (via the 'DIM' command) before it exists. Arrays are cleared to zero's when they are created. Arrays when dimensioned, (DIM A(n)) have n+1 elements, subscripts ranging form 0 to n. Subscripts are not checked by the interpreter, therefore, if you type 'DIM A(10),B(10)' then A[11] is the same as B[0]. There are 26 character variables, (A$-Z$). These variables always exist and are cleared to null strings ("") when BASIC is entered, when a NEW is executed,and when a program is RUN. Each character variable can hold up to 35 characters. The individual characters can be read using braces between the character variable name, and the dollar sign. (ie. A[0]$ to A[34]$). If an index is greater than 34, a DIMENSION ERROR will result. If an index is greater than the number of characters currently in the variable, but less than 35, then a null string ("") will be returned. Character variables cannot be assigned values in this manner. The variable names are all separate, you can have A, A[n] and A$, all in the same program, without interaction between them. MICRO BASIC USERS GUIDE Page: 9 3.5 Special variables The simple integer variable 'R' is a special variable because it will be assigned the remainder whenever a divide operation is executed. The following are special variables, unlike 'R', they cannot be used as 'normal' variables: @[n] This variable can only be referenced as an array. When read, it returns the BYTE value (0-255) of the memory location at its index (n). When assigned a value, that value will be assigned to the memory location at its index (n). (if the value assigned is > 255 Then it is divided by 256, and the remainder is used). This is the Same function as 'PEEK' and 'POKE' in some other BASIC's. @[n]$ This character variable, can only be referenced with an index. Its index can range from 0 to 255. It will return the character which has the binary value of its index. (if 255 is used, it will return a null string. This is the same function as 'CHR$' in some other basics. ? This variable can only be referenced as a simple integer variable When read, it returns a random number from 0 to 65535. When given a value, it sets the random seed to that value. Random numbers can be generated within limits by the use of modular arithmetic. (EG. to generate a random number between 0 and 99, and assign it to the variable 'A', use the command 'A=R;?%100').This is similar to the 'RND' function of some other basics. MICRO BASIC USERS GUIDE Page: 10 4. PROGRAM ENTRY AND EDITING To enter or replace a line, simply enter it's line number starting in column one, followed by the text for the new line. To delete a line, just enter it's line number, with no following text. When a line is entered, (and return is pressed), it is copied into a buffer. Parts or all of this old line can be included in a new line, as it is typed in. When the new line is entered,it then becomes the old line. A pointer is kept, indicating the current position in the old line. The following functions are available to perform this 'editing'. CTRL-A Advance: Copy one character from the old line into the new line, and advance the pointer to the next character in the old line. CTRL-C Cancel: Cancels the (partially) complete new line, and restart from the beginning. (resets old line pointer). CTRL-D Delete: Advances the old line pointer by one character,deleteing that character from the old line. the new line is not affected. A '*' character is printed to indicate this has been done. CTRL-F Find: This command requires one extra character to be entered. When it is, the old line is copied (from the current pointer position) into the new line, up to but NOT including the first occurance of that character. The pointer is advanced to point to the character found. If the character is not found, no action is taken.If the second character is a carriage return,the remainder of the old line will be copied into the new line. CTRL-H Backup: This backs up one character,deleteing the last character entered, and backs up the old line pointer in the old line. This effectively cancels the effect of the last character entered. (The DELETE key also invokes this function). CTRL-M Carriage Return: enters the new line, causing it to become the (new) old line, and passes it to the interpreter, as input. MICRO BASIC USERS GUIDE Page: 11 CTRL-I Insert: Toggles insert mode. a "<" is printed when entering insert mode a ">" is printed when leaving insert mode. Normally, when you enter text into the new line, the old line pointer is advanced, so that the characters you are typing, effectivly replace the characters in the old line. In insert mode, this does not happen, therefore the characters you are typing, can be inserted into the old line. (If it is later copied into the new line). The line editor can be used to EDIT program lines, When a list command is executed, the last line listed will be made the old line. To modify line 50, you would just have to type 'LIST 50'. This would display line 50, and would also store it in the old line buffer. Whenever a program stops due to an error, CTRL-C, or a STOP statement, the line it stopped on will also be stored in the old line buffer, ready for editing. MICRO BASIC USERS GUIDE Page: 12 5. CONTROL CHARACTERS The following control characters (other than the ones recognised by the line editor) are recognised. All other control characters, are ignored by the interpreter. CTRL-C Will abort any program, terminated with the message "STOP IN LINE XXXX" where XXXX is the number of the line containing the statement which would have been executed next. Will also abort program, if entered when responding to an INPUT statement, but will not print the "STOP" message. Will also abort output from the LIST command. CTRL-J (line feed) Will stop terminal output and/or program execution, for as long as the key is held down. When released, output/execution will resume normally. CTRL-N (SI) This character, will be ignored when entered from the keyboard, but when printed, will cause the eighth bit to be set in all subsequent characters which are printed. Depending on the video display used, this will cause REVERSE VIDEO, FLASHING, DIM or BRIGHTER output, GRAPHICS CHARACTERS, or will have NO EFFECT (If display ignores extra bit). CTRL-O (SO) This character, will be ignored when entered from the keyboard, but when printed, will cause the eighth bit to be cleared in all characters which are subsequently printed. This will restore normal operation if a special effect was invoked via the CNTRL-N (SI) control character above. For example, if your video display gives reverse video when the eighth bit is set,then you could use the following statement to print "REVERSE" in reverse video: ' PRINT @[14]$,"REVERSE",@[15]$ ' CTRL-L (FF) No effect from keyboard, Clears the screen and homes the cursor when printed. Eg: ' PRINT @[12]$ ' CTRL-K (VT) No effect from keyboard, Homes the cursor when printed. Eg: ' PRINT @[11]$ ' MICRO BASIC USERS GUIDE Page: 13 6. ERROR MESSAGES Below is a list of error messages produced by the interpreter. Errors occuring in a program, will be followed by " IN LINE XXXX" where XXXX is the line on which the error was discovered. All errors except '?BAD DATA - RETRY' are fatal, and will stop an executing program. ?SYNTAX ERROR Results from a statement that is not decodeable. (Does not follow syntax) Also results if you attempt to use a command in the wrong context. Ie. You use a command from the keyboard which is only allowed from within a program. ?NO PROGRAM ERROR Results from an attempt to RUN or to SAVE an zero line program. ?DIMENSION ERROR Results from an attempt to index a non-array variable, from indexing a character variable with a value greater than 34, or attempt to PLOT outside the screen. ?DIVIDE BY ZERO ERROR Results from attempt to divide any value by zero. ?LINE NUMBER ERROR Results from reference to a program line number that does not exist. ?DATA ERROR Results from attempt to ORDER to a line which does not start with a DATA statement, attempt to READ before you have executed an ORDER, reading beyond the end of a DATA BLOCK, or from reading the wrong data type (character or numeric) for the operand variable. ?NESTING ERROR Results from improper nesting of GOSUB/RETURN or FOR/NEXT loops. ?BAD DATA - RETRY Results from any error in a numeric expression typed as the response to an INPUT to a numeric variable. Does not stop, but prompts again. ?I/O ERROR Indicates that a error has occured in the tape system, Check for bad tape. MICRO BASIC USERS GUIDE Page: 14 7. SOURCE FORMAT Micro Basic programs are stored in memory, as variable length records, separated by carriage return character (0D hex). The end of the program is marked by a line starting with a hexidecimal FF. Program lines are in the following format: ------------------------------------------------- |2 bytes|1 byte| variable length section |1 byte| ------------------------------------------------- \___/ \__/ \_____________________/ \____/ ^ ^ ^ ^_ Carriage Return. ^ ^ ^ ^ ^ ^___________________ Program text. ^ ^ ^ ^__________________________________ Length of remainder ^ of line. (+11 hex) ^ ^__________________________________________ Packed decimal line number (0000-9999). (FFxx=end of prog.) MICRO BASIC USERS GUIDE Page: 15 8. EXAMPLE PROGRAMS The following are some simple Micro Basic programs, which demonstrate many of the features of the language. A good excercise to gain experience with the interpreter, is to enter and run them, and observe the results. 0010 REM THIS PROGRAM PLAYS THE HIGH/LOW GAME. 0020 PRINT "I WILL PICK A NUMBER BETWEEN 1 AND 100" 0030 PRINT "THEN I WANT YOU TO TRY AND GUESS IT." 0040 PRINT "I WILL TELL YOU IF YOU ARE TOO HIGH, OR TOO LOW" 0050 C=0 0060 N=1+R;?%100 0070 INPUT "WHAT IS YOUR GUESS?",G 0080 C=C+1 0090 LIF G==N THEN PRINT "YOU GUESSED IT IN ",C," GUESSES!":END 0100 IF G>N THEN PRINT "YOU ARE TOO HIGH." 0110 IF G0THEN40 0050 PRINT R$ MICRO BASIC USERS GUIDE Page: 16 9. THE MICRO BASIC MONITOR The MICRO BASIC roms include a machine language MONITOR, which allows you to read/write memory, load and dump memory to tape, etc. The monitor has its own set of commands, which can be entered, whenever the system is RESET, or when ever BASIC is exited (via EXIT). Operands to commands are read (and executed) as soon as you type them in (no carriage return is needed). Hexidecimal BYTE () values must be entered as TWO characters (eg 5F), and WORD () values must be entered using four characters (eg 00A5). A summary of commands followes: B Enters the BASIC interpreter, initializing program, variables, and arrays. D Downloads Intel hex format through the terminal port. G Go, Begins execution at address L Loads from tape, indicates record count when done (in hex). M , Displays MEMORY from , to . R Reenters BASIC, preserving existing program. Should not be used when the system is first turned on. S XX- Substitutes into memory, starting at address , Displays contents as XX, entering will replace XX and advance to the next. Entering a space will skip to the next, without changeing, and a carriage- return will exit to monitor. T or Enters terminal mode. Simulates an ASCII terminal Operating in either or duplex. Serial port is tape port. U Initalizes the 8251 usart with the value . See INTEL 8251 documentation. W , Writes memory from to to tape. MICRO BASIC USERS GUIDE Page: 17 9.1 MONITOR SUBROUTINES Address |Regs.| Description of (Hex)|(Dec)|Used | Subroutine -----+-----------+------------------------------------------------------- 0037 |0055 |All | Entry point to monitor. ------------------------------------------------------------------------- 00D6 |0214 | | Writes memory to tape, DE=start addr., HL=end addr. ------------------------------------------------------------------------- 0162 |0354 |None | Outputs character in A to output device. ------------------------------------------------------------------------- 027E |0638 |None | Checks terminal for CONTROL-C, sets Z if so, LF halts. ------------------------------------------------------------------------- 023F |0575 | A | Gets a character for A from input device. ------------------------------------------------------------------------- 02EB |0747 | | Gets a record from tape, Carry=1 if more data, 0=EOF. ------------------------------------------------------------------------- 034E |0846 | | Displays message (HL) up to ZERO or carriage return.If | | | carriage return is found, then LF, CR pair is printed. ------------------------------------------------------------------------- 035B |0859 | | Displays a line-feed, carriage return on the screen. ------------------------------------------------------------------------- 037E |0894 | | Positions cursor at position in HL in video display. ------------------------------------------------------------------------- 0396 |0918 | | Starts Cassette deck, and provides delay for speed. ------------------------------------------------------------------------- 03A6 |0934 | | Stops Cassette deck. ------------------------------------------------------------------------- | | | Displays byte in A on output devices in HEX. ------------------------------------------------------------------------- | | | Displays word in HL on output devices in HEX. ------------------------------------------------------------------------- | | | Gets HEX byte for A from input, CY=0 if failure. ------------------------------------------------------------------------- | | | Gets HEX word for HL from input, CY=0 if failure. ------------------------------------------------------------------------- 0400 |1024 | All | Cold start entry point for BASIC, the program and | | | variables will be lost, and basic will be started. ------------------------------------------------------------------------- 040D |1037 | All | Warm start entry point for basic, the program and | | | variables will remain intact. ------------------------------------------------------------------------- 048F |1167 |None | Tests character in A and sets carry flag if it is NOT | | | a valid ASCII numeric digit. ('0' - '9'). ------------------------------------------------------------------------- 0499 |1177 | All | Gets a line from the terminal. All BASIC editing | | | commands can be used. If CONTROL-C is entered, causes | | | a warm start to BASIC. On exit, D-E is left pointing | | | to line just entered. ------------------------------------------------------------------------- MICRO BASIC USERS GUIDE Page: 18 ------------------------------------------------------------------------- 067C |1660 | All | Looks up command word (Ending with or ) | | | pointed to by D-E, in table pointed to by H-L. Table | | | format is words in memory, followed by a blank, and | | | an address to be returned. End table with a single | | | blank, and default address. On exit, A contains value | | | indicating which word in table was found. (0,1,2,...) | | | and H-L contains associated address. ------------------------------------------------------------------------- 06A8 |1704 |A,B,C| Clears all BASIC variables and arrays, and resets the | | H,L | FOR/NEXT, GOSUB/RETURN control stack pointer. ------------------------------------------------------------------------- 06C6 |1734 |A,H,L| As above, but integer and character variables remain. ------------------------------------------------------------------------- 06CC |1740 |A,H,L| As above, but only arrays are cleared, stack remains. ------------------------------------------------------------------------- 077E |1918 |None | Pushes single byte in A on BASIC control stack. ------------------------------------------------------------------------- 0789 |1929 | A | Pops single byte to A from BASIC control stack. ------------------------------------------------------------------------- 0792 |1938 |None | Pushes word in D-E on BASIC control stack. ------------------------------------------------------------------------- 079C |1948 | D,E | Pops word to D-E from BASIC control stack. ------------------------------------------------------------------------- 07C9 |1993 |None | Sets carry flag if character in A is not 'A'-'Z'. ------------------------------------------------------------------------- 07D0 |2000 |ABCHL| Stores value in HL into integer variable passed in A. ------------------------------------------------------------------------- 07E1 |2017 |ABCHL| Reads value for HL from integer variable passed in A. ------------------------------------------------------------------------- 07EE |2030 |A,D,E| Advances to next non-blank character in the line | | | Pointed to by the D-E register pair. ------------------------------------------------------------------------- 0822 |2082 | All | Evaluates BASIC expression pointed to by D-E, ending | | | with a carriage return or ':'. Integer results are | | | returned in H-L. ------------------------------------------------------------------------- 08E8 |2280 |ABCHL| Multiply HL by BC, result in HL. ------------------------------------------------------------------------- 091D |2333 | All | Divide HL by BC, result in DE, remainder in HL. ------------------------------------------------------------------------- 0B88 |2952 | All | Displays number in H-L in decimal. ------------------------------------------------------------------------- 0C86 |3206 |ABCHL| Returns in HL the address of the character variable | | | passed in A. Character variable format is 35 chars, | | | unused characters at end are padded with $FF. ------------------------------------------------------------------------- MICRO BASIC USERS GUIDE Page: 19 The MONITOR keeps a byte of data which defines how I/O will be handled. It is located at address $14FF (5375), and can be modified by the basic interpreter (or machine language program). It is as followes: Bits in I/O configuration byte. +---+---+---+---+---+---+---+---+ | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | (Initial value is 00000011) +---+---+---+---+---+---+---+---+ | | | | | | | | | | | | | | | +--- 0 = Read from Uart. | | | | | | | 1 = Read from Keyboard. | | | | | | +------- 1 = Output to Video Display. | | | | | +----------- 1 = Output to Uart. (8251) | | | | +--------------- 1 = Output to User Supplied | | | | Output Device (See Below). | | | +------------------- 0 = Translate input to upper case. | | | 1 = Disable UPPER CASE translation. | | +----------------------- 1 = Disable CONTROL-C interrupts. | +--------------------------- 1 = Inhibit all output. +------------------------------- 1 = Set Bit 7 in all characters output to Video Display. For example, to prevent a CONTROL-C stop from the keyboard, you could use the following statement: ' @[5375]=@[5375]|20# ' To reenable CNTRL-C stops, you would use: ' @[5375]=@[5375]&DF# '. 9.2 USER SUPPLIED OUTPUT DEVICE The system normally supports two output devices, the VIDEO DISPLAY, and the 8251 UART. In addition, it supports one logical output device, to be defined by the user. This is useful for doing translations before you output a character as well. To use this feature, you must supply a machine language output routine in ram (somewhere outside the range used by the interpreter, basic program, and any arrays). Then, store the address of the routine in the USER DEVICE VECTOR, which is located at addresses 14FD and 14FE (5373-5374), the low order address byte must go first. The logical user output device is now defined, and can be enabled by setting bit 3 of the I/O config. byte. NOTE1: Output may be directed to more than one device at once. NOTE2: If bit#3 of the I/O config. byte is set to 1, before you initialize the USER DEVICE VECTOR, Your computer will probably crash (And you will lose any unsaved programs). When the user routine is called, the character to be printed is passed in the B-REG, and I/O config. byte is passed in recister C. All of the processor registers may be modified by the subroutine. MICRO BASIC USERS GUIDE Page: 20 9.3 8251 USART The 8251 usart, is initialized to 1 stop bit, 7 data bits, no parity, and baud rate of 1/16 times the rx and tx clocks. To indicate when a tape operation is currently under way, the DSR pin of the 8251 will be set HIGH (+5v), and LOW (0v) at all other times. A short delay is produced from the time this pin goes high, and a write to tape operation occures. This allows it to be used as a start/stop control for the tape machine, allowing the tape to get up to speed. 10. SYSTEM MEMORY MAP The memory is used by the interpreter as follows: ADDRESS-RANGE DESCRIPTION OF CONTENTS. 0000-0FFF (4k) Micro Basic Roms. 1000-13FF (1k) Memory Mapped Video Display. 1400-14FC (253 Bytes) Input buffer, Machine stack, Internal storege. 14FD-14FE (2 Bytes) User Device Vector. 14FF (1 Byte) I/O Configuration byte. 1500-15FF (256 Bytes) Edit Buffer, Control stack, Internal storage. 1600-19FF (1k) Fixed integer and character variables, flags. 1A00-FFFF (Any size) Program and Array storage. When not using the Basic Interpreter (Executing machine language programs from the monitor), Any memory starting at 1500 or higher can be used without affecting the system. NOTE: Any time you enter the basic interpreter, anything stored from 1500 to 1CFF may be lost, Even if you do not enter any program text when in Basic.