To make input/output procedures in E-MMI easier, I offer alternative way of system calls organization. There's a Russian saying "to invent a bicycle", that means trying to do what had been already done many years ago. So I tried not to invent myself this thing again and took CP/M structure of console calls (see this link for example) as a base.
To initiate any input/output procedure in E-MMI you can write instruction 00 05 <N> <reg> (TRAP 05 <N> <reg>), where N is a number of function and reg is a register for input /output information.
Function 01: CONSOLE INPUT
Actions: Input symbol from keyboard into specified register
Details: wait, if symbol is not ready; automatically print symbol on display; try to terminate program, when "CTRL"+"C" combination is pressed
Example:
00 05 01 07 | TRAP 05/01 $07 |
get symbol from keyboard to $7 |
Function 02: CONSOLE OUTPUT
Actions: print symbol from specified register
Example:
E3 03 0031 | SETL $03, 31 |
put code of symbol '1' into $3 |
00 05 02 03 | TRAP 05/02 $03 |
print symbol from $3 on display |
Function 06: DIRECT CONSOLE
Actions: Input symbol from keyboard into specified register or print it
Details:
- if input register = FFh, read keyboard: register is set to 0 if symbol is not ready and equal to symbol code otherwise; ignores "CTRL"+"C" combination
Example:
E3 03 00FF | SETL $03, FF |
set $3 equal to FF |
00 05 06 03 | TRAP 05/06 $03 |
get symbol from keyboard to $3 if ready |
- if specified register is not equal to FFh, print symbol from it
Example:
E3 03 0031 | SETL $03, 31 |
put code of symbol '1' into $3 |
00 05 06 03 | TRAP 05/06 $03 |
print symbol from $3 on display |
Function 09: STRING OUTPUT
Actions: Print string till symbol '$'
Ending symbol '$' is a very old tradition, upcoming to CP/M. I'm not sure it is a good idea to follow this custom, but in current E-MMI version it is supported
Details: E-MMI software cuts the string if it is longer than 250 symbols
Example:
E3 00 00E1 | SETL $00, E1 |
address of string buffer to $0 |
00 05 09 00 | TRAP 05/09 $00 |
print string |
Function 0A: BUFFERED INPUT
Actions: input text string till "Enter"
Details: Specified register before function call must show to free memory area and its first byte is set to maximum string length. After its work, function returns the following information: the number of entered symbols (CR symbol is not included into this number!) in the second byte of buffer; then input string is placed (code CR is presented).
Example:
will be published later
Function 0B: CONSOLE STATUS
Actions: returns 0 to specified register if keyboard symbol is not ready and FFh otherwise
Example:
00 05 0B 07 | TRAP 05/0B $07 |
get keyboard status to $7 |
Function 0C: GET VERSION
Actions: print date of I/O functions release
Example:
00 05 0C 00 | TRAP 05/0C $00 |
Current Pascal source for I/O functions module is also published on my site. I hope it may help somebody to understand the details of I/O in E-MMI.
Please note that not all functions are tested carefully. For example, function 0A is practically a draft.
Related topics:
E-MMI software