%%%%% MRS 09 documetation by Busy soft & hard %%%%% Index 951217161614 %%%%%%% ================================================================ == Manual MRS 09/1 [Version 288] - first release == ================================================================ PROLOG Memory resident system is special optimalized integrated tools for making programs in machine code Z80 on ZX Spectrum. MRS 09 contains full-screen source code editor, multipass compiler, multimode disasembler and debugger. MRS 09 does not need ROM (except some functions in debbuger) and can be used if you have 64kB all-ram system - if your rom is replaced by any ram. >>> FULL-SCREEN SOURCE CODE EDITOR <<< Editor can works in two modes: commnad mode and screen mode. Commnad mode prompt is "edi>". Now editor waits for 3-letter commnads. *** Table of editor commnads *** (Text in brackets <> is voluntary) ----------------------------------------------------------------------------- INI ... clear whole source code, initializing editor and jumps into screen mode. You must write this very dangerous commnad with uppercase letters. If is not present, name of source code will be "Noname". PRE ... source code format transformation from MRS version lower 09. source code format of MRS lower 09 is no compatible with 09 (65535 labels). You must write this very dangerous commnad with uppercase letters. loa ... load source code from tape. If name not present, load first found. Name must be separated by one space. If source code is too long, "mem full" error is dysplayed. sav ... save source code into tape. If name not present, then source code name from editor will be used. Save with name is SAVE AS... mer ... merge source code into old text in editor. New text is stored before line with cursor (actual position). If free space (memory-memtop) is too short, "mem full" error is dysplayed. ver ... verify source code. The same as VERYFY""CODE hea ... tape header. Prints heads in this format: - info bajt 0 = basic 1 = number array 2 = character arraty 3 = bytes 4-255 = others - name of file (non-printable characters are print as '.' and '?' - file length - file address, basic start line, array variable - length of basic without variables (source code has 65535 here) spd expr ... set speed of save in editor. MRS has own load-save routines. 0 menas normal baud rate 1500 Bd, 1 means double speed 3000 Bd, 2 and upper causes using rom load-save routines (#4c6 and #562). If spd is set to 0 or 1, then commands loa, hea, mer, ver have special two-speed header what autodetect baud rate and there is no need to set load and verify speed. If spd is set to 2 or greater, then all editor tape commands (with loa,ver,mer) will be executed by calling rom load-save routines. ln= ... \ ln- ... -> jump to screen mode of editor. ln+ ... / Desc(ription) is label or line-number. ln- jumps before actual position, ln+ jumps behind actual position in source code. If line number or desc is not present, ln= jumps to actual position, ln- to begin and ln+ to end of source code. cpb interval ... copy block of source code before line with cursor. dlb interval ... delete block of source code rmc; interval ... remove comment with semicolon on begin of line rmc* interval ... remove comment placed next to instruction (right) rmc! interval ... remove both these comments ins interval ... special command for external modules and utilities mod ... set work mode for external modules and utilities. If expr not presents, last selected value is displayed. dis interval .... reverse asembler - creates source code from binary code in memory with using Z80 instructions dis* interval ... creates source code with using DB number,number... dis: interval ... creates source code with using DW number,number... dis$ interval ... creates source code with using DB 'text' chars 32-127 only dis! interval ... creates source code with using DB 'text' any chars allowed This DIS command uses modul DISASSEMBLER. asm ... compiles source code. See ASSEMBLER ... jumps into debugger. See DEBUGGER This commnad is voluntary, it means if you enter blank line, it's the same as you type commnad dbg and then enter line. ald ... special commnad. Compiles source code and jumps into debugger. mon* ... jumps into basic with RET instructions. mon! ... jumps into basic with RST #08 instructions (generates error OK). mon .... jumps into basic with complere rebuild basic system stack and jumps at #1303. Maybe not works in +3 basic. new ... set basic sys-var RAMTOP. If expr not present, executes basic commnad NEW. These commands tests some basic sys-vars before jump: RAMTOP must be below MEMTOP (see sys commnad) Free space in basic must be at lease 256 bytes. run ... executes machine code from adress expr. If expr not present, use last presented value. RET in executes programs returns into editor. sys ... set variable MEMORY. If expr not presents, nothing is set. Then displays these variables: RAMTOP (basic system variable) MEMORY (low memory limit of source code - begin of free memory) MEMTOP (first address of source code - end of free memory for text) NUMLAB (number of labels - size of label table) NUMLIN (number of lines in source code) LENGTH (length of source code) cls > ... clears screen. If value1 is presents, it do not clears screen but sets border color. If value2 is presents, sets attributes. val expr ... displays value of expr in this format: XXXX XXXX XXXX XXXX YYYY:ZZZZZ X = binary value, Y=hexadecimal value, Z=decimal value. let label=expr ... defines label to velue of expr. Label is defined while you do not use INI, asm, ald. ref ... searches string in source code. If string not presents, searches next occurence last selected string from actual position of cursor. If string found in source code, it jumps in this line of source code. alt label1 label2 ... replace label1 by label2 in whole source code. ...End of editor commands table... ----------------------------------------------------------------------------- Notes: Interval can be: two hexadecimal or decimal numbers separated by space '.' character: Limits are specified by set text-block keys in editor screen mode - SS+W and SS+E Warning - first value must be no upper than second value. Expr is row with decimal or hexadecimal numbers or labels (with simple-defined value) separated by binary operator plus or minus. Expr can be one binary number too. Binary numbers begins with '%' and digits are 0 and 1. Hexadecimal numbers begins with '#' and digits are 0-9,a-z,A-Z. Decimal number do not have special begin character. Digit is 0-9. Label is string max 6 characters long contains digits 0-9, lowercase letters a-z and must begin with letter. *** Screen mode of editorb *** Some commnands (INI,ln,ref) jump into screen mode of editor. You can edit the source code in 23 lines of screen. There is status information in last line: "NameOfText" ZZZ-KKK Lab:XXX Len:XXX Line:XXX Meaning: "NameOfText" ... name of edited source code ZZZ-KKK ... interval selected by keys SS+W and SS+E Lab:XXX ... number of labels - size of label table Len:XXX ... length of source code in bytes Line:XXX ... actual line position of cursor Table of screen mode editor keys (CS=caps shift, SS=symbol shift) -------------------------------------------------------------------------- CS+5,8 ... LEFT, RIGHT ... movement of cursor (*) CS+6,7 ... UP,DOWN ... movement of cursor (x) CS+1 ... EDIT ... one page back (PGUP) (x) CS+2 ... CAPS LOCK ... one page forward (PGDOWN) (x) CS+3 ... TRUE VIDEO ... one field left (HOME) CS+4 ... INV VIDEO ... one field right (END) CS+9 ... GRAPH ... insert one character in field (*) CS+0 ... DELETE ... delete one character in field (*) CS+SS ... EXTEND ... delete actual line with cursor ENTER ... insert one blank line into source code (x) CS+ENTER ... duplicate line in source code (x) SS+ENTER ... refresh screen. Actual line will be first line on screen. (x) SS+SPACE ... jump into last characters in line (not works for comment) SS+Q ... UNDO ... reread actual line from source code SS+W ... set begin of source code block SS+E ... set end of source code block CS+SPACE ... BREAK ... exit from editor screen mode (x) ---------------------------------------------------------------------------- Notes: (*) ... This key works in editor commnad mode too. (x) ... If syntax of edited line is bad, you can not leave actual line. *** Syntax and editing of source code *** There is three kids of lines in source code. First ones are instruction lines, second are commnet lines (begin with ';') and last are directive lines (begin with '*'). Format of instruction lines is: label ins add commnet ....................... /-width in characters Array / Meaning label - 07 - There can be any label or nothing ins - 05 - intruction or pseudoinstruction without parameters adr - 20 - parameter of instruction, if it is needed commnet - 32 - anything what you want ';' character is NOT needed at begin of this array. If you press SPACE key in label,ins and add array then rest of this array is filled by spaces and cursor will be at begin of next array. If you is writing any character string in add array, then this not works and SPACE key puts space character normally. If you leave wrote line by any way (break, up, down...) then this line is accepted and insert in source code. If syntax error is occured, you can't leave this line and cursor is in error array and you can hear error-beep. SS+Q is undo. This means If you changes line and then press SS+Q then all changes will be lost and original line is restored. *** EX AF,AF and non-standart instructions *** EX AF,AF instruction is without apostrof (ex af,af, not ex af,af') Known non-standart instructions: Codes CB30 to CB37 ... syntax: sll register It works with prefix DD and FD of course, example: sll (ix+#ff) All instructions what works with halfs of index registers. These halfs are called xh,xl,yh,yl. Example: ld a,xh Instructions like set 6,(ix+0),B is not supported. *** Writing of address and number values in instructions *** Format of the value must be one of: symbol symbol+symbol symbol-symbol symbol*symbol symbol/symbol symbol!symbol (OR) symbol&symbol (AND) symbol@symbol (XOR) -symbol (negate value) >symbol (hi byte) is voluntary) org value1 <,value2> == set address counter to value1 and store counter to value2. If value2 not present, value1 is used for store counter. Value2 = 0 meaning machine code is NOT stored into memory. This value2 is the same meaning as *c directive. ds value1 <,value2><,value3>... == define space to value1+value2+value3+... bytes. If any value is indefined, address and store counter is marked as undefined. db item <,item><,item>... == define byte(s) Item can be: value ... defines one byte, range can be -256..+255 'text' ... defines text in memory "text" ... defines text in memory as 'text' but bit 7 of last character will be set to 1. dw value1 <,value2><,value3>... == define word(s) Lower byte of word is stored into lower address. label equ value label = value If value is undefined then this do nothing. else it sets label to value and: if label was undefined then it's marked as defined. if label was defined and new value is different than old value then label is marked as multi-defined (it's bad!) end == voluntary end of compiled part of source code If end is missing then all source code will be compiled. ent label1,<,label3>... ext label1,<,label3>... This historical pseudoinstructions without any effects is determined to work with library. *** Directives *** (Text in brackets <> is voluntary) This directives are located on directive lines in source code. This lines is beginning with '*' characters followed by one letters and some parameters if it's needed. *s ... slow mode of compile. Compile protocol is made. *f ... fast mode of compile. Compile protocol is NOT made. (It's meaning that *a,*e,*l,*t have not effect to lines) *a ... turn on printing of compile protocol *e ... turn off printing of compile protocol (Only lines with error are printing in slow mode.) *l ... redirect printing compile protocol into printer *t ... redirect printing compile protocol into console (screen) *p ... send FF (ascii code 12) character into printer (once) If decimal number is present, FF will be send each lines *c ... sets store counter. The same as second parameter in ORG Hexnumber contais digits 0-9 and letter a-f and NOT begin with '#' *oADR,DAT ... OUT ADR,DAT. Adr and dat are decimal number. This is useful if you have ram-banks switchable with out. *z ... If X (not fatal) error is occured in compile and string contains letter X then it jumps into source code into line with this error. String is max 14 characters long. Default (on compile begin) string is empty. >>> Modul ASSEMBLER - Compiling of source code <<< This modul is ran by commands ASM and ALD (in editor) or keys CS+Z and SS+Z in debbuger. MRS is multipass assembler - it means that compiler do not two passes as other asseblers but souce code is compiled several times - how many is needed. Assembler uses two counters: Address counter - where machine code will be runable Store counter - where machine code will be stored by compiling *** Algorytmus of compiling *** 1. If source code has no any labels then go to 5. 2. All labels are marked as undefined. 3. Make one compile pass by this way: A) At begin: both counters is set to MEMORY variable and marked as defined. B) For each instruction or pseudoinstruction it computes new value of counters. If new value of counters are not computable (for example undefined value in ds pseudoinstructions) then counters are marked as undefined. Counters are sets and marked as defined by the org with computable values or by *c directive (for store counter). C) If label is found in label array and address counter is defined and "equ" (or =) is not present in ins array then this label is set to value of address counter. See E) D) If label is found in label array and "equ" (or =) with defined value is present in ins array then label sets to this value. See E) E) Label setting and definition - how is label set to value: If label is undefined, then will be marked as simple-defined. If label is defined (simple or multi) then it compare old and new value: If it's no equal then label will be marked as multi-defined. F) '$' character meaning address counter. If address counter is defined then '$' meaning value of address counter. If address counter is undefined then '$' meaning undefined value. 4. If number of undefined, simple-defined and multi-defined labels has been changed by this pass then go to 3 5. Make last pass with generation of real creation machine code in memory. Make compile protocol. Test (and printing) for errors and fatal errors. Definitions of label is not changing. 6. If "end" not found in source code and compiling is finished without any errors then space allocated by labels not used in source code is marked as empty for next use in future. 7. In the finish of compiling is message "errors: n" printed. THE END Compile protocol contains compiled lines of source code and table of alphabetical sorted labels with values. Format of each line is: Characters Meaning 1 - 5 ... line number of source code 7 ... error code or space if no error occured on this line 9 - 12 ... value of address counter 14 - 21 ... values of bytes stored into memory 25 - 88 ... copy of line from source code All printings can be stopped by 'S' key, released by 'Q' key or aborted by BREAK key. *** Compile errors *** Fatal errors (compiling is aborted immediatelly): mem full - Bad address of storing machine code in compiling. Store counter must be under MEMTOP variable. If you want to run machine code at address greater than MEMTOP then use ORG with two different values. break - compiling is aborted by user (it's possible anywhere in compiling) Non-fatal errors (error-codes in compile protocol): U - undefined value in add array M - multi-defined labels in label array D - multi-defined labels in add array Z - division by zero I - "ent" or "ext" pseudoinstructions in ins array R - value in add array is out of range. If one-byte value is required (for example in "db" pseudoinstruction) then this value must be in range -256...+255 (is meaning hi byte of value must be #00 or #FF) If relative jump is compiling and labels found in add array then difference between address counter and value in add array must be in range -128...+127. Undefined or uncalculable expression meaning value 0. >>> DEBUGGER - BUILT IN MONITOR <<< Debugger runs by "dbg" editor commnad or by entering empty line in editor. *** Information arrangement *** Debbuger dysplays basic status information into two last lines: Z PCPC INSTRUCTION SZAPC AA BBCC DDEE HHLL XHXL YHYL SPSP Z - status information. If nothing is happened, space is here. Instruction - machine code instruction located at address PCPC SZAPC - procesor flags. If flag is set, its letter is displayed. Others are register values. Values of alternative registers is not displayed but you can see they by X key command in debugger. *** Table of debugger commnads *** ------------------------------------------------------------------------------ R - set value of 16-bit register. After 'R' system wants to press one of keys P,A,B,D,X,Y,S. If you set PC registers, then SP is set to #ff3e. E - set value of 8-bit register. After 'E' system wantf to press one of keys A,B,C,D,E,F,H,L,R,I,X,Y. After X or Y you must specify which part of IX or IY register by pressing H or L. I - set interrupt point. System wants address of point. Empty line means old address. Then system wants number to specify how many times you want to program runs trought this point before interrupt. Empty line mean value 0 - program will be interrupted in first run. Each call this point tests BREAK key. Warning - interrupt point is realized by RST #10 instructions, that's why this functions need standard ROM and causes some problems with using ROM-print routine. O - set no interrupt point. G - Go! This key runs program with setting of all registers by values in information arragement. If program returns, status is set to 'E' and all registers except PC is set to value returning by user program. CS+G - The same as G but program is stopped in first run trought int. point. S - step - run one instruction. User protection is tested (see W). There is possible to step programs in ROM. Registers values are updated. CS+S - step without user protection. C - step by interrupt point. CALLs will be run by full real speed. The same as 'S' but there is NOT possible step program in ROM. CS+C - step without user protection. CS+X - skip instruction. Register value is no changed. Only PC is updated to address of next instruction. T - trace mode. This command exerts 'S' repeatly while BREAK not pressed or user protection not failed. Status information is set to 'T'. CS+T - trace without user information. N - the same as 'T' but information arragement is no displayed. CS+N - trace without user information. W - set windows for user protection. System wants press M or P. These keys mean [M]emory or [P]C windows. Then four couples of numbers is displayed. Now you can change any number by pressing keys '1' to '8'. 1 and 2 is first window, 3 and 4 is second window...etc. P - displays dump of modified memory window. This dysplays if any stepped or traced instruction modified any byte in this window. System wants adress of this window. If empty line is entered, window not selected. Then system wants size of window - number of lines. Size of one line is 8 bytes. M - Memory edit. You can edit the memory manually. System want address. Empty line means last entered address. Control keys: LEFT,RIGHT ... movement by 1 character TRUE,INV VIDEO ... movement by 8 character EXTEND ... undo not stored changes SPACE ... put ascii-character 0-9,a-f ... put hexadecimal value ENTER ... return to debugger. CS+M - the same as M but it remember its own last entered address. SS+M - the same as M but there is no need enter address. You will be editing last edited address. D - dump or dysplay memory and search any string in memory. Memory dysplays in 16 lines each 8 bytes in this format: DDDDD HHHH : XX XX XX....XX : AAAAAAAA : BBBBBBBB D = decimal address H = hexadecimal address X = 8 hexadecimal bytes A = 8 ascii characters (only code 32-127) B = 8 ascii characters (as A but bit 7 is set to 0) Control keys in this dumping: UP,DOWN ... movement ENTER ... return to debugger H ... searching of string (entered by hex numbers of bytes) A ... searching of string (entered by ascii text) If you enter empty line in search string commands, next position of last selected string will be found. CS+D - the same as D but it remember its own last entered address. SS+D - the same as D but there is no need enter address. You will be dumping last dumped address. A - disasembler, dump of machine code. Machine code dysplays in 24 lines each in this format: DDDDD HHHH Ins Add BB BB BB BB AAAA D = decimal address H = hexadecimal address Ins = machine code instruction - mnemotechnical name Add = machine code instruction - operands BB = bytes of instruction as hexadecimal numbers A = bytes of instruction as ascii characters Control keys: ENTER ... return to debugger A ... next line of dump CAPSLOCK ... next page of dump EDIT ... previous page (#30 bytes back) CS+A - the same as A but it remember its own last entered address. SS+A - the same as A but there is no need enter address. You will be dumping last dumped address. X - exchange alternative registers. The same as "exx" and "ex af,af". L - spified how many information arragements will be displayed and scrolled in trace or step command. Empty line means only basic arragement will be dysplayed and nothing will be scrolled. Q - quit debugger and call commnad mode editor. CS+Q - quit debugger and jump into basic. The same as "mon" in editor. B - select mode of display information arragement. It switch betweend ROM's and MRS's character set. V - val. The same as "val" in editor. Z - call screen mode if editor. The same as "ln=" in editor. If first entered character is '0' then nothing will do. Pressed BREAK in editor returns back into debugger. CS+Z - the same as 'Z' but BREAK not returns into debugger directly but "ald" editor command is called. This means that you will return into debbuger after compiling source text. SS+Z - the same as "ald" commnad in editor. Compile source code. F - OUT commnad. You must enter 16-bit I/O address and 8-bit data. CS+F - IN function. You must enter 16-bit I/O address and readed data will be displayed in "val" format. Empty line means return into debugger. CS+K - SAVE KEY command. Store register values into 1 of 4 banks. You must specify bank by pressing keys '1' to '4'. K - LOAD KEY command. Load register values from 1 of 4 banks. You must specify bank by pressing keys '1' to '4'. These commnads are useful if you want run some routine more times with the same register values. Y - disable interrupt - the same as "di" CS+Y - enable interrupt - the same as "ei" SS+Y - set interrupt mode - the same as im0,im1,im2 H - Headerless load. You must specify address, length, flagbyte. Empty line means last specified value. After entering you press enter for execute or space for cancel. CS+H - Headerless save. Otherwise the same as H. SS+H - Headerless verify. Otherwise the same as H. J - The same as LOAD"name"CODE add,len SS+J - The same as VERIFY"name"CODE add,len Specified name causes searching for "name" file. If add not present then add from head will be used. If len present then file can't be longer. CS+J - The same as SAVE"name"CODE add,len Empty line means last specified value. Name must be specified always. After entering you press enter for execute or space for cancel. SS+S - Likewise as "spd" editor command. Select baud rate for headerless load-save-verify and normal save (H,CS+H,SS+H,CS+J). System want press key '0' to '9'. 0 means 1500 Bd, 1 means 3000 Bd. If it's set to 0 or 1, then commands J, SS+J and CS+ENTER have special two-speed header what autodetect baud rate and there is no need to set load and verify speed. If you enter '2' and greater, all load-save commnads (with J,SS+J,CS+ENTER) will be executed by calling ROM load-save routines (#4c6 and #562). CS+U - runs machine code form address specified by "run" editor commnad. SS+Q - displays values of some variables as the "sys" editor commnad. SS+F - fill memory. You must specify address, length, byte. Empty line means last specified value. SS+C - copy momory. You must specify source address, length, destination address. Empty line means last specified value. This copying is very intelligent, memory window can be shared. SS+V - compare two memory windows. You must specify window1 address, length, window2 address. Empty line means last specified value. After entering values you can press: S ... causes displaying the same bytes D ... causes displaying different bytes other ... causes displaying nothing Displaying can be stopped by 'S' and continued by 'Q' or aborted by BREAK key. At finish information of the same and different bytes number is dysplayed. SS+X - xor memory. You must specify address, length, byte. Empty line means last specified value. SS+B - reverse memory. Invert bytes sequence in memory window. You must specify address and length. Empty line means last specified value. Try it with parameters add=#4000 and len=#1800 ! CS+ENTER - The same as "hea" editor command SS+SPACE - Likewise as NMI and the same as CALL #66.This is useful if you have some ROM with monitor after NMI and you want to jump into this monitor. EDIT - The same as "ref" editor command. EXTEND - copy of information arrangement by two lines up. This is useful if you select some parameters and you want see this arrangement. DELETE - clear screen. The same as "cls" editor commnad. GRAPH - clear attributes. Fill attributes with actual colours. UP - The same as DEC PC DOWN - The same as INC PC This is useful for modify the PC register in small range. ------------------------------------------------------------------------------ End of debugger commands table. Parameters in debugger commands can be: - decimal number - hexadecimal number (begin with '#') - simple-defined label - expression builded with this three items plugged by plus and minus - one binary number (begin with '%') (only some commands) - nothing (only some commands) *** User protections *** Trace modes S,C,N,T allow keep control of user program. They detect: - rewrite memory - neverending loop - execute illegal instruction - jump into hell Debugger allows to protect memory, break program and filter some instruction. There is [M]emory windows for rewrite protect and [P]C windows for protect before jumps into hell. Meaining of memory windows: Running program must no change aby bytes in any memory window. If some instructions wants write into some memory window, user protection breaks running of program and sets status information to 'M'. Meaning of PC windows: While program is running, PC register must be in at least one PC windows. If any instruction sets PC register out of any PC window, user protection breaks running of program and sets status information to 'P'. At address #FF40 is list of illegal instructions. This list is used by filter to protect before execute illegal instructions. List ends by byte #00 that's why NOP can't be illegal. All instruction in this list is represent by its operating code (obe byte) except instruction with #ED shift - these instructions are represent by two byte (#ED followed by operating code). Bytes #CB,#DD,#FD in list mean all instructions with #CB are illegal, all instructions works with IX (IY) register are illegal. If any illegal instruction wants to be executed, user protection breaks running of program and sets status information to 'I'. Remember that you can trace user program without user protections by pressing keys S,C,N,T with CAPS SHIFT. *** Some important addresses and system variables *** memtop-#c0ff there is source code stored. You can see memtop value in "sys" command. #c100-#c13f buffer for "ref" commnad. #c140-#c17f register key - buffer for the "Save key" and "Load key" (K,CS+K). #c180 ..... physical begin of MRS code. #d508 ..... there is stored parameter selected by "spd" command in editor. #d509 ..... there is stored parameter selected by SS+S command in editor. #d50a ..... Actual speed for load-save routines. One of (d508) or (d509). #d50e-#d50f system variable "mode" (two bytes). Selected by "mod" commnad. #d662 ..... cold start of MRS. Clear source code, memory set to #8000, list of illegal instructions is inicialized to #ED,#7F #d665 ..... warm start of MRS. Clear screen and display welcome message. #d668 ..... jumps into commnad mode if editor directly. #dd77 ..... there is stored jump to routine for printing charecters into printer. You can rewrite address in this jump and set it to your own printer-rotine. Printing character is in A register. #f152 ..... there is stored address of list of illegal instructions. You can rewrite it and move this list into other address. #f4b3 ..... ending address of all programs. If you have destroyed stack you can return to MRS by jump to this address. #fde8 ..... physical end of MRS code. #fe00-#fe3f text buffer of system. #fe40-#feff some other system variables and system stack. #ff00-#ff3f stack for user programs. If you program need more bytes for stack then you must initialize stack in your program. *** Some useful subroutines *** There is specified some subroutines of MRS in this part what can be useful for programs created by beginners. #ebdd - DCBN Convert string of decimal digits into 16-bit value. String must end by any character withou digits '0'-'9'. Input: HL=address of string Output: HL=address of first character after string DE=16-bit value Changes: AF,DE,HL #ebb8 - HXBN Convert string of hexadecimal digits into 16-bit value. String must end by any character withou digits '0'-'9'; 'a'-'f'; 'A'-'F'. Input: HL=address of string Output: HL=address of first character after string DE=16-bit value Changes: AF,DE,HL #eb9d - BNHX Convert 16-bit value into string of hexadecimal digits. Input: DE=value HL=address of buffer, where digits is placed Output: HL=address of first character after string Changes: HL,AF #eb75 - BNDC Convert 16-bit value into string of decimal digits. Input: DE=value HL=address of buffer, where digits is placed Output: HL=address of first character after string Changes: AF,BC,DE,HL #d945 - INKEY Intelligent keyboard read with autorepeat. If no key is pressed, it wait. Output: A=ascii code of pressed key Changes: AF #d8e6 - SCAN Keyboard read. Only test which key is pressed and return. Output: A=ascii code of pressed key, #00 if no key is pressed #d87b - CLEAR Clear screen. Input: (#d88c)=value of attributtes Changes BC,DE,HL. #e01a - CLS Clear screen with initialize print-position AT 0,0 for OUTCHR Input: (#d88c)=value of attributtes (#dc8a)=colour of border plus 8 (for ex. 15=white) Changes: BC,DE,HL #dba2 - OUTCHR Like RST #10 rom routine. Prints one character into screen. At end of line this routine jumps at begin of next line. At end of last line it scrolls screen up. Known control characters: #19 .. move cursor left #18 .. move cursor right #0d .. enter (end of line) jump at begin of next line Input: A=ascii code of character Changes: AF,AF' B,AF,AF' (if screen is scrolled) #dd77 - PNTCHR Send one character into printer. Ascii code of character is in A. See part about connect of printer. #e017 - CURSOR Cursor dysplay - invert character position on screen. Input: HL=position (H=row 0-23, L=column 0-63) Changes: AF,AF' #e008 - OUTHEX Print hexadecimal number into screen. For convert into string uses BNHX and for display uses OUTCHR. Input: HL=value of number Changes: AF,AF' #e00b - OUTDEC Print decimal number into screen. For convert into string uses BNDC and for display uses OUTCHR. Input: HL=value of number Changes: AF,AF' #e014 - OUTBIN Print decimal number into screen. For display uses OUTCHR. Input: HL=value of number Changes: B,E,AF,AF' Warning. There is a small bug - neverending loop caused by scroll of screen. #d7e4 - OUTBUF Display text-buffer (#fe00-#fe3f) at one row of screen. Input: H=row for display (0-23) Changes: AF,AF' #e7ce - CLSBUF Fill text-buffer by spaces (#20) Changes: F #dff5 - OUTTXT Display text. For display one character is OUTCHR called. There is very special input: text follow after CALL OUTTXT and must be ended by ZERO value. For example: call #dff5 db 'This text will be displayed',#00 ... (next program) Changes: AF (And B if scroll of screen is caused.) *** Connect of printer or how print compile protocol *** There is no special routines for some printer control in MRS. User need to have own printer control routine what know printing one character. Then user can modify address of jump at #DD77 to set to address of user's printer-control routine for printing one character in A register. MRS send to printer all standart ascii characters (code 32-127) and special control codes: decimal code 10 - line feed 12 - form feed 13 - carriage return If you have some printer-control program what works by LPRINT or LLIST commnad, you can print compile protocol for example by this way: Before printing execute this short routine: ini ld hl,#10 Modification ld (#dd78),hl of PNTCHR jump. ld a,#03 Redirect stdout into jp #1601 channel #3 - printer. Puts at begin of source code this directives: *l (for redirect output into printer), *a (for display compile protocol), *s (for short mode of compile) and compile source code (by "asm" or "ald" command). For initialize printer you can use *i directive and for form feed and automatic generation of form feed (for all N-lines) you can use *p directive. Be sure that there is no *e,*t,*f directives in source code. This directives can stave off printing of protocol. ______________________________________________________________________________