|
|
ROM subroutines
Input integer number
|
|
addr |
code |
mnemonic |
action |
comments |
EE0...D0 | E072 EA00 | SETH $72, 0000 | $72 <== EA00 | set the address of buffer (in system RAM) |
D4 | E772 0060 | INCL $72, 0060 | $72 <== $72 + 60 |
D8 | E371 0016 | SETL $71, 0016 | $71 <== 16 | save 2010 to the first byte of buffer (max string length) |
DC | A171 7200 | STBI $71, $72, 00 | ($72) <== $71 |
E0 | 0005 0A72 | TRAP 5/0A, $72 | call system function: input string | input string with number |
E4 | E772 0002 | INCL $72, 0002 | $72 <== $72 + 1 | get first symbol to $71 |
E8 | 8171 7200 | LDBI $71, $72, 00 | $71 <== ($72) |
EC | 3171 712D | CMPI $71, $71, 2D | compare $71 and 2D; result - $71 | compare with '-' |
F0 | E373 0001 | SETL $73, 0001 | $73 <== 1 | +1 to sign |
F4 | E374 0000 | SETL $74, 0000 | $74 <== 0 | 0 to string index |
F8 | 4A71 0003 | BNZ $71, 0003 | branch to 104 if $71 <> 0 | bypass for positive numbers |
FC | 2573 7302 | SUBI $73, $73, 02 | $73 <== $73 - 2 | -1 to sign |
100 | E774 0001 | INCL $74, 0001 | $74 <== $74 + 1 | 1 to string index |
104 | E371 0000 | SETL $71, 0000 | $71 <== 0 | 0 to result |
108 | 8275 7274 | LDBU $75, $72, $74 | $75 <== ($72 + $74) | get current symbol from buffer |
10C | 3176 750D | CMPI $76, $75, 0D | compare $75 with 0D; result - $76 | compare with enter code |
110 | 4276 000A | BZ $76, 000A | branch to 138 if $76 = 0 | exit if enter (end of string) |
114 | 2575 7530 | SUBI $75, $75, 30 | $75 <== $75 - 30 | form decimal digit value |
118 | 4075 0009 | BN $75, 0009 | branch to 13C if $75 < 0 | if < 0 - error |
11C | 3176 7509 | CMPI $76, $75, 09 | compare $75 with 09; result - $76 | compare with 9 |
120 | 4476 0007 | BP $76, 0007 | branch to 13C if $76 > 0 | if > 9 - error |
124 | 1971 710A | MULI $71, $71, 0A | $71 <== $71 * 0A | result * 1010 |
128 | 1875 7573 | MUL $75, $75, $73 | $75 <== $75 * $73 | current digit * sign |
12C | 2071 7175 | ADD $71, $71, $75 | $71 <== $71 + $75 | add to result |
130 | 2174 7401 | ADDI $74, $74, 01 | $74 <== $74 + 1 | next bufer index |
134 | F1FF FFF5 | JMPB FFFFF5 | branch to 108 | repeat cycle |
138 | 9F6F 6F00 | GOI $6F, $6F, 00 | return using $6F | (finish subroutine) |
13C | E373 0020 | SETL $73, 0020 | $73 <== 20 | code of space symbol |
140 | 4274 0004 | BZ $74, 0004 | branch to 150 if $74 = 0 | end cycle |
144 | 0005 0273 | TRAP 5/02, $73 | call system function: print symbol | print space under every correct symbol |
148 | 2574 7401 | SUBI $74, $74, 01 | $74 <== $74 - 1 | decrease couner of spaces |
14C | F1FF FFFD | JMPB FFFFFD | branch to 140 | repeat cycle |
150 | 2176 6F00 | ADDI $76, $6F, 00 | $76 <== $6F | store return address and call print string ROM subroutine |
154 | 9F6F 7030 | GOI $6F, $70, 30 | call $70+30; return - $6F |
158 | 075E 3F3F 3F07 0D0A | .^???... | 7 symbols: 'BELL', '^??' '?', 'BELL", CR/LF | text to print (length=7 - first byte) |
160 | 216F 7600 | ADDI $6F, $76, 00 | $6F <== $76 | restore return address |
164 | F1FF FFDB | JMPB FFFFDB | branch to D0 | repeat from the very beginning |
Related topics:
E-MMI software
|
(C) 2003, Evgeny Eremin. rEd-MMI project documentation
|
|