@nataliapc/mcp-openmsx 1.1.5 → 1.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -2
- package/dist/openmsx.js +9 -0
- package/dist/server.js +502 -327
- package/dist/utils.js +17 -0
- package/package.json +4 -1
- package/resources/audio/toc.json +31 -0
- package/resources/bios/Calling_BIOS_from_MSX-DOS.md +75 -0
- package/resources/bios/MSX2_SUBROM_BIOS_calls.md +734 -0
- package/resources/bios/MSX_BIOS_calls.md +1046 -0
- package/resources/bios/toc.json +24 -0
- package/resources/book--msx2-technical-handbook/Appendix1__BIOS_Listing.md +1464 -0
- package/resources/book--msx2-technical-handbook/Appendix2__Math-Pack.md +427 -0
- package/resources/book--msx2-technical-handbook/Appendix3__Bit_Block_Transfer.md +182 -0
- package/resources/book--msx2-technical-handbook/Appendix4__Work_Area_Listing.md +1637 -0
- package/resources/book--msx2-technical-handbook/Appendix5__VRAM_Map.md +145 -0
- package/resources/book--msx2-technical-handbook/Appendix6__IO_Map.md +128 -0
- package/resources/book--msx2-technical-handbook/Appendix8_10__Control_Codes_and_Escape_Sequences.md +76 -0
- package/resources/book--msx2-technical-handbook/Chapter1__MSX_System_Overview.md +402 -0
- package/resources/book--msx2-technical-handbook/Chapter2__BASIC.md +2148 -0
- package/resources/book--msx2-technical-handbook/Chapter3__MSX-DOS.md +2577 -0
- package/resources/book--msx2-technical-handbook/Chapter4a__VDP_and_Display_Screen.md +2052 -0
- package/resources/book--msx2-technical-handbook/Chapter4b__VDP_and_Display_Screen.md +3311 -0
- package/resources/book--msx2-technical-handbook/Chapter5a__Access_to_Peripherals_through_BIOS.md +2714 -0
- package/resources/book--msx2-technical-handbook/Chapter5b__Access_to_Peripherals_through_BIOS.md +1263 -0
- package/resources/book--msx2-technical-handbook/MSX_Kun_BASIC_Compiler.md +220 -0
- package/resources/book--msx2-technical-handbook/toc.json +82 -0
- package/resources/book--the-msx-red-book/the_msx_red_book.md +10349 -0
- package/resources/book--the-msx-red-book/toc.json +12 -0
- package/resources/msx-dos/MSX-DOS_2_Function_Specifications.md +1366 -0
- package/resources/msx-dos/MSX-DOS_2_Program_Interface_Specification.md +963 -0
- package/resources/msx-dos/toc.json +18 -0
- package/resources/msx-unapi/Ethernet_UNAPI_specification_1.1.md +369 -0
- package/resources/msx-unapi/Introduction_to_MSX-UNAPI.md +132 -0
- package/resources/msx-unapi/MSX_UNAPI_specification_1.1.md +679 -0
- package/resources/msx-unapi/TCP-IP_UNAPI_specification.md +2361 -0
- package/resources/msx-unapi/toc.json +27 -0
- package/resources/others/toc.json +11 -0
- package/resources/processors/Z80_R800_instruction_set.md +482 -0
- package/resources/processors/toc.json +24 -0
- package/resources/processors/z80-undocumented.tex +5617 -0
- package/resources/processors/z80_detailed_instruction_set.md +2025 -0
- package/resources/programming/toc.json +121 -0
- package/resources/system/MSX_IO_ports_overview.md +554 -0
- package/resources/system/toc.json +18 -0
- package/resources/video/V9938_Technical_Data_Book.md +3623 -0
- package/resources/video/V9958_Technical_Data_Book.md +417 -0
- package/resources/video/V9990_Programmers_Manual_Banzai.html +1582 -0
- package/resources/video/VDP_TMS9918A.txt +709 -0
- package/resources/video/toc.json +28 -0
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
# APPENDIX 2 - MATH-PACK
|
|
2
|
+
|
|
3
|
+
The Math-Pack is the core for the mathematical routines of MSX-BASIC and, by calling these routines from an assembly language program, floating-point operations and trigonometrical functions are available.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
<p> </p>
|
|
7
|
+
|
|
8
|
+
## Index
|
|
9
|
+
|
|
10
|
+
- [Math-Pack work area](#math-pack-work-area)
|
|
11
|
+
- [Basic operation](#basic-operation)
|
|
12
|
+
- [Function 1](#function-1)
|
|
13
|
+
- [Function 2](#function-2)
|
|
14
|
+
- [Movement](#movement)
|
|
15
|
+
- [Comparison](#comparison)
|
|
16
|
+
- [Floating-point input/output](#floating-point-inputoutput)
|
|
17
|
+
- [Type conversion](#type-conversion)
|
|
18
|
+
- [Integer operation](#integer-operation)
|
|
19
|
+
- [Power](#power)
|
|
20
|
+
- [Changes from the original](#changes-from-the-original)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
<p> </p>
|
|
24
|
+
|
|
25
|
+
Any operations involving real numbers in Math-Pack are done in BCD (Binary Coded Decimal). There are two ways of expressing a real number, "single precision" and "double precision"; a single precision real number (6 digits) is expressed by 4 bytes and a double precision real number (14 digits) by 8 bytes (see [Figure A.1](#figure-a1--bcd-format-for-expressing-real-numbers) and [Figure A.2](#figure-a2--examples-of-expressions-for-real-numbers)).
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
##### _Figure A.1 BCD format for expressing real numbers_
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
32
|
+
--- --- -------------------------------------------------
|
|
33
|
+
^ ^ |sign | exponent | 0
|
|
34
|
+
| | -------------------------------------------------
|
|
35
|
+
| | -------------------------------------------------
|
|
36
|
+
| | | mantissa 1st place | mantissa 2nd place | 1
|
|
37
|
+
| single -------------------------------------------------
|
|
38
|
+
| precision -------------------------------------------------
|
|
39
|
+
| | | mantissa 3rd place | mantissa 4th place | 2
|
|
40
|
+
| | -------------------------------------------------
|
|
41
|
+
| | -------------------------------------------------
|
|
42
|
+
| V | mantissa 5th place | mantissa 6th place | 3
|
|
43
|
+
double --- -------------------------------------------------
|
|
44
|
+
precision -------------------------------------------------
|
|
45
|
+
| | mantissa 7th place | mantissa 8th place | 4
|
|
46
|
+
| -------------------------------------------------
|
|
47
|
+
| -------------------------------------------------
|
|
48
|
+
| | mantissa 9th place | mantissa 10th place | 5
|
|
49
|
+
| -------------------------------------------------
|
|
50
|
+
| -------------------------------------------------
|
|
51
|
+
| | mantissa 11th place | mantissa 12th place | 6
|
|
52
|
+
| -------------------------------------------------
|
|
53
|
+
| -------------------------------------------------
|
|
54
|
+
V | mantissa 13th place | mantissa 14th place | 7
|
|
55
|
+
--- -------------------------------------------------
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
##### _Figure A.2 Examples of expressions for real numbers_
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
Example of the single precision expression
|
|
63
|
+
|
|
64
|
+
123456 --> 0.123456 E+6
|
|
65
|
+
|
|
66
|
+
1 2 3 4
|
|
67
|
+
-------------------------
|
|
68
|
+
DAC | 46 | 12 | 34 | 56 |
|
|
69
|
+
-------------------------
|
|
70
|
+
|
|
71
|
+
Example of the double precision expression
|
|
72
|
+
|
|
73
|
+
123456.78901234 --> 0.12345678901234 E+6
|
|
74
|
+
|
|
75
|
+
1 2 3 4 5 6 7 8
|
|
76
|
+
-------------------------------------------------
|
|
77
|
+
DAC | 46 | 12 | 34 | 56 | 78 | 90 | 12 | 34 |
|
|
78
|
+
-------------------------------------------------
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
A real number consists of a sign, an exponent, and a mantissa. The sign represents the sign of the mantissa; 0 for positive, 1 for negative. The exponent is a binary expression and can be expressed as a power from +63 to -63, with an excess of 64 (see [Figure A.3](#figure-a3--exponent-format)). [Figure A.4](#figure-a4--valid-range-for-double-precision-real-numbers) shows the valid range of double precision real numbers.
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
##### _Figure A.3 Exponent format_
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
|sign |<--------------- exponent -------------->| meaning
|
|
88
|
+
-------------------------------------------------
|
|
89
|
+
| 0 | 0 0 0 0 0 0 0 | ..... 0
|
|
90
|
+
-------------------------------------------------
|
|
91
|
+
-------------------------------------------------
|
|
92
|
+
| 1 | 0 0 0 0 0 0 0 | ..... undefined (-0?)
|
|
93
|
+
-------------------------------------------------
|
|
94
|
+
-------------------------------------------------
|
|
95
|
+
| x | 0 0 0 0 0 0 1 | ..... -63rd power of 10
|
|
96
|
+
-------------------------------------------------
|
|
97
|
+
-------------------------------------------------
|
|
98
|
+
| x | 1 0 0 0 0 0 0 | ..... 0th power of 10
|
|
99
|
+
-------------------------------------------------
|
|
100
|
+
-------------------------------------------------
|
|
101
|
+
| x | 1 1 1 1 1 1 1 | ..... +63rd power of 10
|
|
102
|
+
-------------------------------------------------
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Note:** "x" is 1 or 0, both of which are allowed.
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
##### _Figure A.4 Valid range for double precision real numbers_
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
7 6 5 4 3 2 1 0 (byte)
|
|
112
|
+
-------------------------------------------------
|
|
113
|
+
DAC | FF | 99 | 99 | 99 | 99 | 99 | 99 | 99 | -0.99999999999999 E+63
|
|
114
|
+
-------------------------------------------------
|
|
115
|
+
.
|
|
116
|
+
.
|
|
117
|
+
.
|
|
118
|
+
-------------------------------------------------
|
|
119
|
+
| 81 | 10 | 00 | 00 | 00 | 00 | 00 | 00 | -0.10000000000000 E-63
|
|
120
|
+
-------------------------------------------------
|
|
121
|
+
-------------------------------------------------
|
|
122
|
+
| 00 | x | x | x | x | x | x | x | 0
|
|
123
|
+
-------------------------------------------------
|
|
124
|
+
-------------------------------------------------
|
|
125
|
+
| 01 | 10 | 00 | 00 | 00 | 00 | 00 | 00 | +0.10000000000000 E-63
|
|
126
|
+
-------------------------------------------------
|
|
127
|
+
.
|
|
128
|
+
.
|
|
129
|
+
.
|
|
130
|
+
-------------------------------------------------
|
|
131
|
+
| 7F | 99 | 99 | 99 | 99 | 99 | 99 | 99 | +0.99999999999999 E+63
|
|
132
|
+
-------------------------------------------------
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
In Math-Pack, the memory is predefined for operation. This memory area is called "DAC (Decimal ACumulator (F7F6H)" and the area which reserves the numerical value to be operated is called "ARG (F847H)". For example, in multiplication, the product of the numbers in DAC and ARG is calculated and the result is returned in the DAC.
|
|
136
|
+
|
|
137
|
+
In the DAC, single precision real numbers, double precision real numbers, and two-byte integers can be stored. In order to distinguish them, "VALTYP (F663H)" is used and its value is 4 for single precision real numbers, 8 for double precision real numbers, and 2 for two-byte integers.
|
|
138
|
+
|
|
139
|
+
Single and double precision numbers must be stored from the top of the DAC. For two-byte integers, the low and high bytes should be stored in DAC + 2 and DAC + 3.
|
|
140
|
+
|
|
141
|
+
Since Math-Pack is an internal routine of BASIC, when an error occurs (such as division by 0 or overflow), control automatically jumps to the corresponding error routine, then returns to BASIC command level. To prevent this, change H.ERRO (FFB1H).
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
<p> </p>
|
|
145
|
+
|
|
146
|
+
## Math-Pack work area
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
-----------------------------------------------------------------------------
|
|
150
|
+
| Label | Address | Size | Meaning |
|
|
151
|
+
|-----------+-----------+--------+------------------------------------------|
|
|
152
|
+
| VALTYP | F663H | 1 | format of the number in DAC |
|
|
153
|
+
| DAC | F7F6H | 16 | floating point accumulator in BCD format |
|
|
154
|
+
| ARG | F847H | 16 | argument of DAC |
|
|
155
|
+
-----------------------------------------------------------------------------
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
<p> </p>
|
|
160
|
+
|
|
161
|
+
## Math-Pack entry
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
<p> </p>
|
|
165
|
+
|
|
166
|
+
### Basic operation
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
-------------------------------------------------
|
|
170
|
+
| Label | Address | Function |
|
|
171
|
+
|-----------+-----------+-----------------------|
|
|
172
|
+
| DECSUB | 268CH | DAC <-- DAC - ARG |
|
|
173
|
+
| DECADD | 269AH | DAC <-- DAC + ARG |
|
|
174
|
+
| DECNRM | 26FAH | normalises DAC (*1) |
|
|
175
|
+
| DECROU | 273CH | rounds DAC |
|
|
176
|
+
| DECMUL | 27E6H | DAC <-- DAC * ARG |
|
|
177
|
+
| DECDIV | 289FH | DAC <-- DAC / ARG |
|
|
178
|
+
-------------------------------------------------
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Note:** These operations treat numbers in DAC and ARG as the double precision number. Registers are not preserved.
|
|
182
|
+
|
|
183
|
+
**\*1** Excessive zeros in mantissa are removed. (0.00123 ⟶ 0.123 E-2)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
<p> </p>
|
|
187
|
+
|
|
188
|
+
### Function 1
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
----------------------------------------------------------------------
|
|
192
|
+
| Label | Address | Function | Register modified |
|
|
193
|
+
|-----------+-----------+----------------------+---------------------|
|
|
194
|
+
| COS | 2993H | DAC <-- COS(DAC) | all |
|
|
195
|
+
| SIN | 29ACH | DAC <-- SIN(DAC) | all |
|
|
196
|
+
| TAN | 29FBH | DAC <-- TAN(DAC) | all |
|
|
197
|
+
| ATN | 2A14H | DAC <-- ATN(DAC) | all |
|
|
198
|
+
| LOG | 2A72H | DAC <-- LOG(DAC) | all |
|
|
199
|
+
| SQR | 2AFFH | DAC <-- SQR(DAC) | all |
|
|
200
|
+
| EXP | 2B4AH | DAC <-- EXP(DAC) | all |
|
|
201
|
+
| RND | 2BDFH | DAC <-- RND(DAC) | all |
|
|
202
|
+
----------------------------------------------------------------------
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**Note:** These processing routines all have the same function names as those in BASIC. "All" registers are A, B, C, D, E, H, and L.
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
<p> </p>
|
|
209
|
+
|
|
210
|
+
### Function 2
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
----------------------------------------------------------------------
|
|
214
|
+
| Label | Address | Function | Register modified |
|
|
215
|
+
|-----------+-----------+----------------------+---------------------|
|
|
216
|
+
| SIGN | 2E71H | A <-- sign of DAC | A |
|
|
217
|
+
| ABSFN | 2E82H | DAC <-- ABS(DAC) | all |
|
|
218
|
+
| NEG | 2E8DH | DAC <-- NEG(DAC) | A,HL |
|
|
219
|
+
| SGN | 2E97H | DAC <-- SGN(DAC) | A,HL |
|
|
220
|
+
----------------------------------------------------------------------
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Note:** Except for SIGN, these processing routines all have the same function names as those in BASIC. Registers are A, B, C, D, E, H, and L. Note that for SGN, the result is represented as a 2-byte integer.
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
<p> </p>
|
|
227
|
+
|
|
228
|
+
### Movement
|
|
229
|
+
|
|
230
|
+
```
|
|
231
|
+
----------------------------------------------------------------------------
|
|
232
|
+
| Label | Address | Function | Object | Reg. mod. |
|
|
233
|
+
|-----------+-----------+---------------------+--------------+-------------|
|
|
234
|
+
| MAF | 2C4DH | ARG <-- DAC | double prec. | A,B,D,E,H,L |
|
|
235
|
+
| MAM | 2C50H | ARG <-- (HL) | double prec. | A,B,D,E,H,L |
|
|
236
|
+
| MOV8DH | 2C53H | (DE) <-- (HL) | double prec. | A,B,D,E,H,L |
|
|
237
|
+
| MFA | 2C59H | DAC <-- ARG | double prec. | A,B,D,E,H,L |
|
|
238
|
+
| MFM | 2C5CH | DAC <-- (HL) | double prec. | A,B,D,E,H,L |
|
|
239
|
+
| MMF | 2C67H | (HL) <-- DAC | double prec. | A,B,D,E,H,L |
|
|
240
|
+
| MOV8HD | 2C6AH | (HL) <-- (DE) | double prec. | A,B,D,E,H,L |
|
|
241
|
+
| XTF | 2C6FH | (SP) <--> DAC | double prec. | A,B,D,E,H,L |
|
|
242
|
+
| PHA | 2CC7H | ARG <-- (SP) | double prec. | A,B,D,E,H,L |
|
|
243
|
+
| PHF | 2CCCH | DAC <-- (SP) | double prec. | A,B,D,E,H,L |
|
|
244
|
+
| PPA | 2CDCH | (SP) <-- ARG | double prec. | A,B,D,E,H,L |
|
|
245
|
+
| PPF | 2CE1H | (SP) <-- DAC | double prec. | A,B,D,E,H,L |
|
|
246
|
+
| PUSHF | 2EB1H | DAC <-- (SP) | single prec. | D,E |
|
|
247
|
+
| MOVFM | 2EBEH | DAC <-- (HL) | single prec. | B,C,D,E,H,L |
|
|
248
|
+
| MOVFR | 2EC1H | DAC <-- (CBED) | single prec. | D,E |
|
|
249
|
+
| MOVRF | 2ECCH | (CBED) <-- DAC | single prec. | B,C,D,E,H,L |
|
|
250
|
+
| MOVRMI | 2ED6H | (CBED) <-- (HL) | single prec. | B,C,D,E,H,L |
|
|
251
|
+
| MOVRM | 2EDFH | (BCDE) <-- (HL) | single prec. | B,C,D,E,H,L |
|
|
252
|
+
| MOVMF | 2EE8H | (HL) <-- DAC | single prec. | A,B,D,E,H,L |
|
|
253
|
+
| MOVE | 2EEBH | (HL) <-- (DE) | single prec. | B,C,D,E,H,L |
|
|
254
|
+
| VMOVAM | 2EEFH | ARG <-- (HL) | VALTYP | B,C,D,E,H,L |
|
|
255
|
+
| MOVVFM | 2EF2H | (DE) <-- (HL) | VALTYP | B,C,D,E,H,L |
|
|
256
|
+
| VMOVE | 2EF3H | (HL) <-- (DE) | VALTYP | B,C,D,E,H,L |
|
|
257
|
+
| VMOVFA | 2F05H | DAC <-- ARG | VALTYP | B,C,D,E,H,L |
|
|
258
|
+
| VMOVFM | 2F08H | DAC <-- (HL) | VALTYP | B,C,D,E,H,L |
|
|
259
|
+
| VMOVAF | 2F0DH | ARG <-- DAC | VALTYP | B,C,D,E,H,L |
|
|
260
|
+
| VMOVMF | 2F10H | (HL) <-- DAC | VALTYP | B,C,D,E,H,L |
|
|
261
|
+
----------------------------------------------------------------------------
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**Note:** (HL), (DE) means the values in memory pointed to by HL or DE. Four
|
|
265
|
+
register names in the parentheses are the single precision real numbers
|
|
266
|
+
which indicate (sign + exponent), (mantissa 1st and 2nd places),
|
|
267
|
+
(mantissa 3th and 4th places), (mantissa 5th and 6th places) from left
|
|
268
|
+
to right. Where the object is VALTYP, the movement (2, 4, 8 bytes) is
|
|
269
|
+
according to the type indicated in VALTYP (F663H).
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
<p> </p>
|
|
273
|
+
|
|
274
|
+
### Comparison
|
|
275
|
+
|
|
276
|
+
```
|
|
277
|
+
-----------------------------------------------------------------------------
|
|
278
|
+
| Label | Address | Object | Left | Right |Reg. mod.|
|
|
279
|
+
|-----------+-----------+--------------------------+------+-------+---------|
|
|
280
|
+
| FCOMP | 2F21H | single prec. real number | CBED | DAC | HL |
|
|
281
|
+
| ICOMP | 2F4DH | 2-byte integer | DE | HL | HL |
|
|
282
|
+
| XDCOMP | 2F5CH | double prec. real number | ARG | DAC | all |
|
|
283
|
+
-----------------------------------------------------------------------------
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
**Note:** Results will be in A register. Meanings of A register are:
|
|
287
|
+
|
|
288
|
+
* A = 1 ⟶ left < right
|
|
289
|
+
* A = 0 ⟶ left = right
|
|
290
|
+
* A = -1 ⟶ left > right
|
|
291
|
+
|
|
292
|
+
In the comparison of single precision real numbers, CBED means that each register has single precision (sign + exponent),v (mantissa 1st and 2nd places), (mantissa 3th and 4th places), and (mantissa 5th and 6th places).
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
<p> </p>
|
|
296
|
+
|
|
297
|
+
### Floating-point input/output
|
|
298
|
+
|
|
299
|
+
```
|
|
300
|
+
-----------------------------------------------------------------------------
|
|
301
|
+
| Label | Address | Function |
|
|
302
|
+
|-----------+-----------+---------------------------------------------------|
|
|
303
|
+
| FIN | 3299H | Stores a string representing the floating-point |
|
|
304
|
+
| | | number in DAC, converting it in real. |
|
|
305
|
+
|---------------------------------------------------------------------------|
|
|
306
|
+
| Entry condition HL <-- Starting address of the string |
|
|
307
|
+
| A <-- First character of the string |
|
|
308
|
+
| Return condition DAC <-- Real number |
|
|
309
|
+
| C <-- FFH: without a decimal point |
|
|
310
|
+
| 0: with a decimal point |
|
|
311
|
+
| B <-- Number of places after the decimal point |
|
|
312
|
+
| D <-- Number of digits |
|
|
313
|
+
-----------------------------------------------------------------------------
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
```
|
|
317
|
+
-----------------------------------------------------------------------------
|
|
318
|
+
| Label | Address | Function |
|
|
319
|
+
|-----------+-----------+---------------------------------------------------|
|
|
320
|
+
| FOUT | 3425H | Converts the real number in DAC to the string |
|
|
321
|
+
| | | (unformatted) |
|
|
322
|
+
| PUFOUT | 3426H | Converts the real number in DAC to the string |
|
|
323
|
+
| | | (formatted) |
|
|
324
|
+
|---------------------------------------------------------------------------|
|
|
325
|
+
| Entry condition A <-- format |
|
|
326
|
+
| bit 7 0: unformatted 1: formatted |
|
|
327
|
+
| bit 6 0: without commas 1: with commas every three digits |
|
|
328
|
+
| bit 5 0: meaningless 1: leading spaces are padded with "." |
|
|
329
|
+
| bit 4 0: meaningless 1: "$" is added before the numerical value |
|
|
330
|
+
| bit 3 0: meaningless 1: "+" is added even for positive values |
|
|
331
|
+
| bit 2 0: meaningless 1: the sign comes after the value |
|
|
332
|
+
| bit 1 unused |
|
|
333
|
+
| bit 0: 0: fixed point 1: floating-point |
|
|
334
|
+
| B <-- number of digits before and not including the decimal point |
|
|
335
|
+
| C <-- number of digits after and including the decimal point |
|
|
336
|
+
| Return condition HL <-- starting address of the string |
|
|
337
|
+
-----------------------------------------------------------------------------
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
```
|
|
341
|
+
-----------------------------------------------------------------------------
|
|
342
|
+
| Label | Address | Function |
|
|
343
|
+
|-----------+-----------+---------------------------------------------------|
|
|
344
|
+
| FOUTB | 371AH | Converts 2-byte integer in DAC+2, 3 to a |
|
|
345
|
+
| | | binary expression string. |
|
|
346
|
+
| FOUTO | 371EH | Converts 2-byte integer in DAC+2, 3 to an |
|
|
347
|
+
| | | octal expression string. |
|
|
348
|
+
| FOUTH | 3722H | Converts 2-byte integer in DAC+2, 3 to a |
|
|
349
|
+
| | | hexadecimal expression string. |
|
|
350
|
+
|---------------------------------------------------------------------------|
|
|
351
|
+
| Entry condition DAC + 2 <-- 2-byte integer |
|
|
352
|
+
| VALTYP <-- 2 |
|
|
353
|
+
| Return condition HL <-- starting address of the string |
|
|
354
|
+
-----------------------------------------------------------------------------
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
**Note:** no strings are reserved. The starting address of the string in the
|
|
358
|
+
output routine is normally in FBUFFR (from F7C5H). In some cases it
|
|
359
|
+
may differ slightly. For the integer in DAC + 2, VALTYP (F663H) must
|
|
360
|
+
be 2, even in cases other than FOUTB, FOUTO and FOUTH.
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
<p> </p>
|
|
364
|
+
|
|
365
|
+
### Type conversion
|
|
366
|
+
|
|
367
|
+
```
|
|
368
|
+
-----------------------------------------------------------------------------
|
|
369
|
+
| Label | Address | Function |
|
|
370
|
+
|-----------+-----------+---------------------------------------------------|
|
|
371
|
+
| FRCINT | 2F8AH | Converts DAC to a 2-byte integer (DAC + 2, 3) |
|
|
372
|
+
| FRCSNG | 2FB2H | Converts DAC to a single precision real number |
|
|
373
|
+
| FRCDBL | 303AH | Converts DAC to a double precision real number |
|
|
374
|
+
| FIXER | 30BEH | DAC <-- SGN(DAC) * INT(ABS(DAC)) |
|
|
375
|
+
-----------------------------------------------------------------------------
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
**Note:** after execution, VALTYP (F663H) will contain the number (2, 4 or 8) representing DAC type. No registers are reserved.
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
<p> </p>
|
|
382
|
+
|
|
383
|
+
### Integer operation
|
|
384
|
+
|
|
385
|
+
```
|
|
386
|
+
-----------------------------------------------------------------------
|
|
387
|
+
| Label | Address | Function | Registers modified |
|
|
388
|
+
|-----------+-----------+----------------------+----------------------|
|
|
389
|
+
| UMULT | 314AH | DE <-- BC * DE | A, B, C, D, E |
|
|
390
|
+
| ISUB | 3167H | HL <-- DE - HL | all |
|
|
391
|
+
| IADD | 3172H | HL <-- DE + HL | all |
|
|
392
|
+
| IMULT | 3193H | HL <-- DE * HL | all |
|
|
393
|
+
| IDIV | 31E6H | HL <-- DE / HL | all |
|
|
394
|
+
| IMOD | 323AH | HL <-- DE mod HL | alle |
|
|
395
|
+
| | | (DE <-- DE/HL) | |
|
|
396
|
+
-----------------------------------------------------------------------
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
<p> </p>
|
|
401
|
+
|
|
402
|
+
### Power
|
|
403
|
+
|
|
404
|
+
```
|
|
405
|
+
-----------------------------------------------------------------------------
|
|
406
|
+
| Label | Address | Function | Base | Exp. | Result |
|
|
407
|
+
|-----------+-----------+----------------------------+------+------+--------|
|
|
408
|
+
| SGNEXP | 37C8H | power of single-prec. real | DAC | ARG | DAC |
|
|
409
|
+
| DBLEXP | 37D7H | power of double-prec. real | DAC | ARG | DAC |
|
|
410
|
+
| INTEXP | 383FH | power of 2-byte integer | DE | HL | DAC |
|
|
411
|
+
-----------------------------------------------------------------------------
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
**Note:** No registers are reserved.
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
<p> </p>
|
|
418
|
+
|
|
419
|
+
## Changes from the original
|
|
420
|
+
|
|
421
|
+
- In the explanation before [Figure A.3](#figure-a3--exponent-format), the indication about the excess 64 method has been added.
|
|
422
|
+
|
|
423
|
+
- In [Figure A.3](#figure-a3--exponent-format), in the third byte, "63rd power of 10" has been corrected to "-63rd power of 10".
|
|
424
|
+
|
|
425
|
+
- In the explanation before [Figure A.3](#figure-a3--exponent-format), the indication about the excess 64 method has been added.
|
|
426
|
+
|
|
427
|
+
- In [Figure A.3](#figure-a3--exponent-format), in the third byte, "63rd power of 10" has been corrected to "-63rd power of 10".
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# APPENDIX 3 - BIT BLOCK TRANSFER
|
|
2
|
+
|
|
3
|
+
The bit block transfer corresponds to the COPY command in BASIC and is used to transfer data from RAM, VRAM, and the disk. It is easily executed by the routine in expansion ROM and available from the assembly language program. Since it is in expansion ROM, use SUBROM or EXTROM of BIOS for this routine.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
<p> </p>
|
|
7
|
+
|
|
8
|
+
## Index
|
|
9
|
+
|
|
10
|
+
- [1. Transferring in VRAM](#1-transferring-in-vram)
|
|
11
|
+
- [2. Transferring data between RAM and VRAM](#2-transferring-data-between-ram-and-vram)
|
|
12
|
+
- [3. Transferring between the disk and RAM or VRAM](#3-transferring-between-the-disk-and-ram-or-vram)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
<p> </p>
|
|
16
|
+
|
|
17
|
+
## 1. Transferring in VRAM
|
|
18
|
+
|
|
19
|
+
#### BLTVV (0191H/SUB)
|
|
20
|
+
* **Function**: transfers data in VRAM area
|
|
21
|
+
* **Input**:
|
|
22
|
+
* HL register ⟵ F562H
|
|
23
|
+
* The following parameters should be set:
|
|
24
|
+
* SX (F562H, 2): X-coordinate of the source
|
|
25
|
+
* SY (F564H, 2): Y-coordinate of the source
|
|
26
|
+
* DX (F566H, 2): X-coordinate of the destination
|
|
27
|
+
* DY (F568H, 2): Y-coordinate of the destination
|
|
28
|
+
* NX (F56AH, 2): number of dots in the X direction
|
|
29
|
+
* NY (F56CH, 2): number of dots in the Y direction
|
|
30
|
+
* CDUMMY (F56EH, 1): dummy (not required to be set)
|
|
31
|
+
* ARG (F56FH, 1): selects the direction and expansion RAM (same as VDP R#45)
|
|
32
|
+
* LOGOP (F570H, 1): logical operation code (same as the logical operation code of VDP)
|
|
33
|
+
* **Output**: the CY flag is reset
|
|
34
|
+
* **Registers**: all
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
<p> </p>
|
|
38
|
+
|
|
39
|
+
## 2. Transferring data between RAM and VRAM
|
|
40
|
+
|
|
41
|
+
To use the routines below, the following memory space should be allocated as graphic area for screen modes.
|
|
42
|
+
|
|
43
|
+
* **screen mode 6:** number of dots in X direction times number of dots in Y direction/4 + 4
|
|
44
|
+
|
|
45
|
+
* **screen mode 5 or 7:** number of dots in X direction times number of dots in Y direction/2 + 4
|
|
46
|
+
|
|
47
|
+
* **screen mode 8:** number of dots in X direction times number of dots in Y direction/2 + 4
|
|
48
|
+
|
|
49
|
+
Note to raise fractions.
|
|
50
|
+
|
|
51
|
+
For disk or RAM, data to indicate the size is added as the array data. The first two bytes of data indicate the number of dots in X direction; the next two bytes indicate the number of dots in the Y direction.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
<p> </p>
|
|
55
|
+
|
|
56
|
+
#### BLTVM (0195H/SUB)
|
|
57
|
+
|
|
58
|
+
* **Function**: transfers the array to VRAM
|
|
59
|
+
* **Input**:
|
|
60
|
+
* HL register ⟵ F562H
|
|
61
|
+
* The following parameters should be set:
|
|
62
|
+
* DPTR (F562H, 2): source address of memory
|
|
63
|
+
* DUMMY (F564H, 2): dummy (not required to be set)
|
|
64
|
+
* DX (F566H, 2): X-coordinate of the destination
|
|
65
|
+
* DY (F568H, 2): Y-coordinate of the destination
|
|
66
|
+
* NX (F56AH, 2): number of dots in the X direction (not required to be set; this is already in the top of data to be transferred)
|
|
67
|
+
* NY (F56CH, 2): number of dots in the Y direction (not required to be set; this is already in the top of data to be transferred)
|
|
68
|
+
* CDUMMY (F56EH, 1): dummy (not required to be set)
|
|
69
|
+
* ARG (F56FH, 1): selects the direction and expansion RAM (same as VDP R#45)
|
|
70
|
+
* LOGOP (F570H, 1): logical operation code (same as the logical operation code of VDP)
|
|
71
|
+
* **Output**: the CY flag is set when the number of data bytes to be transferred is incorrect
|
|
72
|
+
* **Registers**: all
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
<p> </p>
|
|
76
|
+
|
|
77
|
+
#### BLTMV (0199H/SUB)
|
|
78
|
+
|
|
79
|
+
* **Function**: transfers to the array from VRAM
|
|
80
|
+
* **Input**:
|
|
81
|
+
* HL register ⟵ F562H
|
|
82
|
+
* The following parameters should be set:
|
|
83
|
+
* SX (F562H, 2): X-coordinate of the source
|
|
84
|
+
* SY (F564H, 2): Y-coordinate of the source
|
|
85
|
+
* DPTR (F566H, 2): destination address of memory
|
|
86
|
+
* DUMMY (F568H, 2): dummy (not required to be set)
|
|
87
|
+
* NX (F56AH, 2): number of dots in the X direction
|
|
88
|
+
* NY (F56CH, 2): number of dots in the Y direction
|
|
89
|
+
* CDUMMY (F56EH, 1): dummy (not required to be set)
|
|
90
|
+
* ARG (F56FH, 1): selects the direction and expansion RAM (same as VDP R#45)
|
|
91
|
+
* **Output**: the CY flag is reset
|
|
92
|
+
* **Registers**: all
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
<p> </p>
|
|
96
|
+
|
|
97
|
+
## 3. Transferring between the disk and RAM or VRAM
|
|
98
|
+
|
|
99
|
+
The filename should be set first to use the disk (specify the filename as BASIC). The following is an example:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
.
|
|
103
|
+
.
|
|
104
|
+
.
|
|
105
|
+
LD HL,FNAME ; Get pointer to file name
|
|
106
|
+
LD (FNPTR),HL ; Set it to parameter area
|
|
107
|
+
.
|
|
108
|
+
.
|
|
109
|
+
.
|
|
110
|
+
FNAME: DB 22H,"B:TEST.PIC",22H,0 ; "TEST.PIC", end mark
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
When an error occurs, control jumps to the error handler of the BASIC interpreter. Set the hook to handle the error in the user program or to call this routine from MSX-DOS or a ROM cartridge. This hook is H.ERRO (FFB1H).
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
<p> </p>
|
|
117
|
+
|
|
118
|
+
#### BLTVD (019DH/SUB)
|
|
119
|
+
* **Function**: transfers from disk to VRAM
|
|
120
|
+
* **Input**:
|
|
121
|
+
* HL register ⟵ F562H
|
|
122
|
+
* The following parameters should be set:
|
|
123
|
+
* FNPTR (F562H, 2): address of the filename
|
|
124
|
+
* DUMMY (F564H, 2): dummy (not required to be set)
|
|
125
|
+
* DX (F566H, 2): X-coordinate of the destination
|
|
126
|
+
* DY (F568H, 2): Y-coordinate of the destination
|
|
127
|
+
* NX (F56AH, 2): number of dots in the X direction (not required to be set; this is already in the top of data to be transferred)
|
|
128
|
+
* NY (F56CH, 2): number of dots in the Y direction (not required to be set; this is already in the top of data to be transferred)
|
|
129
|
+
* CDUMMY (F56EH, 1): dummy (not required to be set)
|
|
130
|
+
* ARG (F56FH, 1): selects the direction and expansion RAM (same as VDP R#45)
|
|
131
|
+
* LOGOP (F570H, 1): logical operation code (same as the logical operation code of VDP)
|
|
132
|
+
* **Output**: the CY flag is set when there is an error in the parameter
|
|
133
|
+
* **Registers**: all
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
<p> </p>
|
|
137
|
+
|
|
138
|
+
#### BLTDV (01A1H/SUB)
|
|
139
|
+
|
|
140
|
+
* **Function**: transfers from VRAM to disk
|
|
141
|
+
* **Input**:
|
|
142
|
+
* HL register ⟵ F562H
|
|
143
|
+
* The following parameters should be set:
|
|
144
|
+
* SX (F562H, 2): X-coordinate of the source
|
|
145
|
+
* SY (F564H, 2): Y-coordinate of the source
|
|
146
|
+
* FNPTR (F566H, 2): address of the filename
|
|
147
|
+
* DUMMY (F568H, 2): dummy (not required to be set)
|
|
148
|
+
* NX (F56AH, 2): number of dots in the X direction
|
|
149
|
+
* NY (F56CH, 2): number of dots in the Y direction
|
|
150
|
+
* CDUMMY (F56EH, 1): dummy (not required to be set)
|
|
151
|
+
* **Output**: the CY flag is reset
|
|
152
|
+
* **Registers**: all
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
<p> </p>
|
|
156
|
+
|
|
157
|
+
#### BLTMD (01A5H/SUB)
|
|
158
|
+
|
|
159
|
+
* **Function**: loads array data from disk
|
|
160
|
+
* **Input**:
|
|
161
|
+
* HL register ⟵ F562H
|
|
162
|
+
* The following parameters should be set:
|
|
163
|
+
* FNPTR (F562H, 2): address of the filename
|
|
164
|
+
* SY (F564H, 2): dummy (not required to be set)
|
|
165
|
+
* SPTR (F566H, 2): the starting address for loading
|
|
166
|
+
* EPTR (F568H, 2): the end address for loading
|
|
167
|
+
* **Output**: the CY flag is reset
|
|
168
|
+
* **Registers**: all
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
<p> </p>
|
|
172
|
+
|
|
173
|
+
#### BLTDM (01A9H/SUB)
|
|
174
|
+
* **Function**: saves array data to disk
|
|
175
|
+
* **Input**:
|
|
176
|
+
* HL register ⟵ F562H
|
|
177
|
+
* The following parameters should be set:
|
|
178
|
+
* SPTR (F562H, 2): the starting address for saving
|
|
179
|
+
* EPTR (F564H, 2): the end address for saving
|
|
180
|
+
* FNPTR (F566H, 2): address of the filename
|
|
181
|
+
* **Output**: the CY flag is reset
|
|
182
|
+
* **Registers**: all
|