|
|
ROM subroutines
How to call ROM subroutines
|
|
To call any E-MMI ROM subroutine you just follow the below simple recommendations.
- Set register $70 to the beginning of the ROM (EE00 0000 0000 0000) by means of SETH $70, EE00 instruction (its code is E0 70 EE00; see
this link for operation details).
- Find subroutine you need in the list and remember the displacement of its entry from the beginning of ROM (see entry parameter).
- Define input parameters if required (see subroutines list for details). Usually E-MMI ROM use $71 for this aim.
- Add GOI $6F, $70, <entry> instruction (9F 6F 70 <entry>) to your program.
The number of registers from $6F I have selected arbitrary. I strongly hope MMIX users will not want to call into requisition these registers. If this by mischance happens and somebody will need exactly these numbers, I can recompile E-MMI software ROM for him from any value he points.
Example:
To print $1 as integer value input the following code:
addr |
code |
mnemonic |
action |
comments |
0 | E0 70 EE00 | SETH $70, EE00 | $70 <== EE00 | set the beginning ROM address |
4 | 21 71 01 00 | ADDI $71, 01, 0 | $71 <== $1 | move $1 to $71 |
8 | 9F 6F 70 10 | GOI $6F, $70, 10 | call $70+10, return - $6F | call ROM subroutine |
C | 00 000000 | TRAP 0 | exit to system | |
Note that ROM subroutines never modify $70 with ROM beginning address. So if you'll not also do this modification, you may set $70 only once in the beginning of your program.
Related topics:
E-MMI software
|
(C) 2003, Evgeny Eremin. rEd-MMI project documentation
|
|