ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
sc61860.c
Go to the documentation of this file.
1/*****************************************************************************
2 * ugBASIC - an isomorphic BASIC language compiler for retrocomputers *
3 *****************************************************************************
4 * Copyright 2021-2026 Marco Spedaletti (asimov@mclink.it)
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *----------------------------------------------------------------------------
18 * Concesso in licenza secondo i termini della Licenza Apache, versione 2.0
19 * (la "Licenza"); è proibito usare questo file se non in conformità alla
20 * Licenza. Una copia della Licenza è disponibile all'indirizzo:
21 *
22 * http://www.apache.org/licenses/LICENSE-2.0
23 *
24 * Se non richiesto dalla legislazione vigente o concordato per iscritto,
25 * il software distribuito nei termini della Licenza è distribuito
26 * "COSì COM'è", SENZA GARANZIE O CONDIZIONI DI ALCUN TIPO, esplicite o
27 * implicite. Consultare la Licenza per il testo specifico che regola le
28 * autorizzazioni e le limitazioni previste dalla medesima.
29 ****************************************************************************/
30
31/****************************************************************************
32 * INCLUDE SECTION
33 ****************************************************************************/
34
35#include "../ugbc.h"
36
37#include <math.h>
38
39/****************************************************************************
40 * CODE SECTION
41 ****************************************************************************/
42
43#if defined(__pc1403__)
44
48
49static void op_addxl( Environment * _environment, int _offset ) {
50
51 // Xl += low(_offset)
52 outline0("LP 0x04" );
53 outline1("ADIM 0x%2.2x", (unsigned char)(_offset & 0xff) );
54
55}
56
57static void op_addba( Environment * _environment ) {
58
59 outline0("LP 0x03");
60 outline0("ADM");
61
62}
63
64static void op_addab( Environment * _environment ) {
65
66 outline0("LP 0x03");
67 outline0("ADM");
68 outline0("EXAM");
69
70}
71
72static void op_addabc( Environment * _environment ) {
73
74 outline0("LP 0x03");
75 outline0("ADCM");
76 outline0("EXAM");
77
78}
79
80static void op_addx_direct( Environment * _environment, int _offset ) {
81
82 // Yl += low(_offset)
83 outline0("LP 0x04" );
84 outline1("ADIM 0x%2.2x", (unsigned char)(_offset & 0xff) );
85
86 // Yh += high(_offset)
87 outline0("LP 0x05" );
88 outline1("ADIM 0x%2.2x", (unsigned char)((_offset>>8) & 0xff) );
89
90}
91
92static void op_anda_direct( Environment * _environment, int _direct ) {
93
94 outline1("ANIA 0x%2.2x", _direct );
95
96}
97
98static void op_andab( Environment * _environment ) {
99
100 outline0("LP 0x03" );
101 outline0("ANMA");
102
103}
104
105static void op_andam( Environment * _environment ) {
106
107 outline0("LP 0x0b" );
108 outline0("ANMA");
109
110}
111
112static void op_addya( Environment * _environment ) {
113
114 outline0("LP 0x06" );
115 outline0("ADM");
116 outline0("LIA 0");
117 outline0("LP 0x07" );
118 outline0("ADCM");
119
120}
121
122static void op_addyl_direct( Environment * _environment, int _offset ) {
123
124 // Yl += low(_offset)
125 outline0("LP 0x06" );
126 outline1("ADIM 0X%2.2x", (unsigned char)(_offset & 0xff) );
127
128}
129
130static void op_addy_direct( Environment * _environment, int _offset ) {
131
132 // Yl += low(_offset)
133 outline0("LP 0x06" );
134 outline1("ADIM 0X%2.2x", (unsigned char)(_offset & 0xff) );
135
136 // Yh += high(_offset)
137 outline0("LP 0x07" );
138 outline1("ADIM 0X%2.2x", (unsigned char)((_offset>>8) & 0xff) );
139
140}
141
142static void op_call( Environment * _environment, char * _label ) {
143
144 outline1("CALL %s", _label );
145
146}
147
148static void op_clc( Environment * _environment ) {
149
150 outline0("RC");
151
152}
153
154static void op_cpb( Environment * _environment ) {
155
156 outline0("LIP 0x03");
157 outline0("CPMA");
158
159}
160
161static void op_cp_direct( Environment * _environment, int _value ) {
162
163 outline1("CPIA 0x%2.2x", (unsigned char)(_value & 0xff));
164
165}
166
167static void op_deca( Environment * _environment ) {
168
169 outline0("DECA");
170
171}
172
173static void op_decjnz( Environment * _environment, char * _label ) {
174
175 outline0("DECJ");
176 outline1("JRNZM %s", _label);
177
178}
179
180static void op_decjz( Environment * _environment, char * _label ) {
181
182 outline0("DECJ");
183 outline1("JRZ %s", _label);
184
185}
186
187static void op_decinz( Environment * _environment, char * _label ) {
188
189 outline0("DECI");
190 outline1("JRNZM %s", _label);
191
192}
193
194static void op_decijnz( Environment * _environment, char * _label ) {
195
196 outline0("DECI");
197 outline1("JRNZM %s", _label);
198 outline0("DECJ");
199 outline1("JRNZM %s", _label);
200
201}
202
203static void op_deciz( Environment * _environment, char * _label ) {
204
205 outline0("DECI");
206 outline1("JRZ %s", _label);
207
208}
209
210static void op_decijz( Environment * _environment, char * _label ) {
211
212 outline0("DECI");
213 outline1("JRZ %s", _label);
214 outline0("DECJ");
215 outline1("JRZ %s", _label);
216
217}
218
219static void op_fild_direct( Environment * _environment, int _value ) {
220
221 outline1("LII 0x%2.2x", (unsigned char)( _value & 0xff ) );
222 outline0("FILD");
223
224}
225
226static void op_fild( Environment * _environment ) {
227
228 outline0("FILD");
229
230}
231
232static void op_inca( Environment * _environment ) {
233
234 outline0("INCA");
235
236}
237
238static void op_lda( Environment * _environment, char * _address ) {
239
240 outline1("LIDP %s", _address );
241 outline0("LDD");
242
243}
244
245static void op_lda_direct( Environment * _environment, int _value ) {
246
247 outline1("LIA 0x%2.2x", (unsigned char)(_value & 0xff) );
248
249}
250
251static void op_ldb( Environment * _environment, char * _address ) {
252
253 outline1("LIDP %s", _address );
254
255 outline0("LII 0x00" );
256 outline0("LP 0x03" );
257 outline0("MVWD");
258
259}
260
261static void op_ldb_direct( Environment * _environment, int _value ) {
262
263 outline1("LIB 0x%2.2x", (unsigned char)(_value & 0xff) );
264
265}
266
267static void op_lda_address_low( Environment * _environment, char * _address ) {
268
269 outline1("LIA %s", _address );
270
271}
272
273static void op_lda_address_high( Environment * _environment, char * _address ) {
274
275 outline1("LIA >%s", _address );
276
277}
278
279static void op_lda_x( Environment * _environment ) {
280
281 // A <- (X)
282 outline0("DX");
283 outline0("IXL");
284
285}
286
287static void op_lda_xn( Environment * _environment ) {
288
289 outline0("IXL");
290
291}
292
293static void op_ldklmn( Environment * _environment, char * _address ) {
294
295 outline1("LIDP %s", _address );
296
297 outline0("LII 0x03" );
298 outline0("LP 0x08" );
299 outline0("MVWD");
300
301}
302
303static void op_ldk( Environment * _environment, char * _address ) {
304
305 outline1("LIDP %s", _address );
306
307 outline0("LII 0x00" );
308 outline0("LP 0x08" );
309 outline0("MVWD");
310
311}
312
313static void op_ldl( Environment * _environment, char * _address ) {
314
315 outline1("LIDP %s", _address );
316
317 outline0("LII 0x00" );
318 outline0("LP 0x09" );
319 outline0("MVWD");
320
321}
322
323static void op_ldm( Environment * _environment, char * _address ) {
324
325 outline1("LIDP %s", _address );
326
327 outline0("LII 0x00" );
328 outline0("LP 0x0a" );
329 outline0("MVWD");
330
331}
332
333static void op_ldn( Environment * _environment, char * _address ) {
334
335 outline1("LIDP %s", _address );
336
337 outline0("LII 0x00" );
338 outline0("LP 0x0b" );
339 outline0("MVWD");
340
341}
342
343static void op_ldklmn_direct( Environment * _environment, int _value ) {
344
345 outline1("LIA 0x%2.2x", (unsigned char)( _value & 0xff ) );
346 outline0("LP 0x08" );
347 outline0("EXAM");
348
349 outline1("LIA 0x%2.2x", (unsigned char)( (_value>>8) & 0xff ) );
350 outline0("LP 0x09" );
351 outline0("EXAM");
352
353 outline1("LIA 0x%2.2x", (unsigned char)( (_value>>16) & 0xff ) );
354 outline0("LP 0x0a" );
355 outline0("EXAM");
356
357 outline1("LIA 0x%2.2x", (unsigned char)( (_value>>24) & 0xff ) );
358 outline0("LP 0x0b" );
359 outline0("EXAM");
360
361}
362
363static void op_stxl( Environment * _environment, char * _address ) {
364
365 outline1("LIDP %s", _address );
366
367 outline0("LII 0x00" );
368 outline0("LP 0x04" );
369 outline0("MVDM");
370
371}
372
373static void op_stxh( Environment * _environment, char * _address ) {
374
375 outline1("LIDP %s", _address );
376
377 outline0("LII 0x00" );
378 outline0("LP 0x05" );
379 outline0("MVDM");
380
381}
382
383static void op_ldxl_direct( Environment * _environment, int _value ) {
384
385 outline1("LIA 0x%2.2x", (unsigned char)( _value & 0xff ) );
386 outline0("LP 0x04" );
387 outline0("EXAM");
388
389}
390
391static void op_ldxl( Environment * _environment, char * _address ) {
392
393 outline1("LIDP %s", _address );
394
395 outline0("LII 0x00" );
396 outline0("LP 0x04" );
397 outline0("MVWD");
398
399}
400
401static void op_ldxh_direct( Environment * _environment, int _value ) {
402
403 outline1("LIA 0x%2.2x", (unsigned char)( _value & 0xff ) );
404 outline0("LP 0x05" );
405 outline0("EXAM");
406
407}
408
409static void op_ldxh( Environment * _environment, char * _address ) {
410
411 outline1("LIDP %s", _address );
412
413 outline0("LII 0x00" );
414 outline0("LP 0x05" );
415 outline0("MVWD");
416
417}
418
419static void op_ldx_direct( Environment * _environment, int _value ) {
420
421 outline1("LIA 0x%2.2x", (unsigned char)( _value & 0xff ) );
422 outline0("LP 0x04" );
423 outline0("EXAM");
424
425 outline1("LIA 0x%2.2x", (unsigned char)( (_value >> 8) & 0xff ) );
426 outline0("LP 0x05" );
427 outline0("EXAM");
428
429}
430
431static void op_ldyl_direct( Environment * _environment, int _value ) {
432
433 outline0("PUSH" );
434 outline1("LIA 0x%2.2x", (unsigned char)( _value & 0xff ) );
435 outline0("LP 0x06" );
436 outline0("EXAM");
437 outline0("POP" );
438
439}
440
441static void op_ldyl( Environment * _environment, char * _address ) {
442
443 outline1("LIDP %s", _address );
444
445 outline0("LII 0x00" );
446 outline0("LP 0x06" );
447 outline0("MVWD");
448
449}
450
451static void op_ldyh_direct( Environment * _environment, int _value ) {
452
453 outline0("PUSH" );
454 outline1("LIA 0x%2.2x", (unsigned char)( _value & 0xff ) );
455 outline0("LP 0x07" );
456 outline0("EXAM");
457 outline0("POP" );
458
459}
460
461static void op_ldyh( Environment * _environment, char * _address ) {
462
463 outline1("LIDP %s", _address );
464
465 outline0("LII 0x00" );
466 outline0("LP 0x07" );
467 outline0("MVWD");
468
469}
470
471static void op_styl( Environment * _environment, char * _address ) {
472
473 outline1("LIDP %s", _address );
474
475 outline0("LII 0x00" );
476 outline0("LP 0x06" );
477 outline0("MVDM");
478
479}
480
481static void op_styh( Environment * _environment, char * _address ) {
482
483 outline1("LIDP %s", _address );
484
485 outline0("LII 0x00" );
486 outline0("LP 0x07" );
487 outline0("MVDM");
488
489}
490
491static void op_ldy_direct( Environment * _environment, int _value ) {
492
493 outline1("LIA 0x%2.2x", (unsigned char)( _value & 0xff ) );
494 outline0("LP 0x06" );
495 outline0("EXAM");
496
497 outline1("LIA 0x%2.2x", (unsigned char)( (_value >> 8) & 0xff ) );
498 outline0("LP 0x07" );
499 outline0("EXAM");
500
501}
502
503static void op_jc( Environment * _environment, char * _label ) {
504
506
507 char longJump[MAX_TEMPORARY_STORAGE];
508 sprintf( longJump, "%slong", label );
509
510 outhead1(".ifgt 128 - ( %s-. ) ", _label);
511 outline1("JRCP %s", _label);
512 outhead0(".else");
513 outline1("JRNCP %s", longJump);
514 outline1("JP %s", _label);
515 outhead1("%s:", longJump);
516 outhead0(".endif");
517
518}
519
520static void op_jnc( Environment * _environment, char * _label ) {
521
523
524 char longJump[MAX_TEMPORARY_STORAGE];
525 sprintf( longJump, "%slong", label );
526
527 outhead1(".ifgt 128 - ( %s-. ) ", _label);
528 outline1("JRNCP %s", _label);
529 outhead0(".else");
530 outline1("JRCP %s", longJump);
531 outline1("JP %s", _label);
532 outhead1("%s:", longJump);
533 outhead0(".endif");
534
535}
536
537static void op_jp( Environment * _environment, char * _label ) {
538
539 outline1("JP %s", _label);
540
541}
542
543static void op_jz( Environment * _environment, char * _label ) {
544
546
547 char longJump[MAX_TEMPORARY_STORAGE];
548 sprintf( longJump, "%slong", label );
549
550 outhead1(".ifgt 128 - ( %s-. ) ", _label);
551 outline1("JRZP %s", _label);
552 outhead0(".else");
553 outline1("JRNZP %s", longJump);
554 outline1("JP %s", _label);
555 outhead1("%s:", longJump);
556 outhead0(".endif");
557
558}
559
560static void op_jnz( Environment * _environment, char * _label ) {
561
563
564 char longJump[MAX_TEMPORARY_STORAGE];
565 sprintf( longJump, "%slong", label );
566
567 outhead1(".ifgt 128 - ( %s-. ) ", _label);
568 outline1("JRNZP %s", _label);
569 outhead0(".else");
570 outline1("JRZP %s", longJump);
571 outline1("JP %s", _label);
572 outhead1("%s:", longJump);
573 outhead0(".endif");
574
575}
576
577static void op_ldi( Environment * _environment, char * _address ) {
578
579 outline1("LIDP %s", _address );
580
581 outline0("LII 0x00" );
582 outline0("LP 0x00" );
583 outline0("MVWD");
584
585}
586
587static void op_sti( Environment * _environment, char * _address ) {
588
589 outline1("LIDP %s", _address );
590
591 outline0("LII 0x00" );
592 outline0("LP 0x00" );
593 outline0("MVDM");
594
595}
596
597static void op_ldi_direct( Environment * _environment, int _value ) {
598
599 outline1("LII 0x%2.2x", (unsigned char)(_value & 0xff ) );
600
601}
602
603static void op_ldj( Environment * _environment, char * _address ) {
604
605 outline1("LIDP %s", _address );
606
607 outline0("LII 0x00" );
608 outline0("LP 0x01" );
609 outline0("MVWD");
610
611}
612
613static void op_stj( Environment * _environment, char * _address ) {
614
615 outline1("LIDP %s", _address );
616
617 outline0("LII 0x00" );
618 outline0("LP 0x01" );
619 outline0("MVDM");
620
621}
622
623static void op_ldj_direct( Environment * _environment, int _value ) {
624
625 outline1("LIJ 0x%2.2x", (unsigned char)(_value & 0xff ) );
626
627}
628
629static void op_ldij( Environment * _environment, char * _address ) {
630
631 outline1("LIDP %s", _address );
632
633 outline0("LII 0x01" );
634 outline0("LP 0x00" );
635 outline0("MVWD");
636
637}
638
639static void op_ldijab( Environment * _environment, char * _address ) {
640
641 outline1("LIDP %s", _address );
642
643 outline0("LII 0x03" );
644 outline0("LP 0x00" );
645 outline0("MVWD");
646
647}
648
649static void op_ldij_direct( Environment * _environment, int _value ) {
650
651 outline1("LII 0x%2.2x", (unsigned char)(_value&0xff) );
652 outline1("LIJ 0x%2.2x", (unsigned char)((_value>>8)&0xff) );
653
654}
655
656static void op_ldab( Environment * _environment, char * _address ) {
657
658 outline1("LIDP %s", _address );
659
660 outline0("LII 0x01" );
661 outline0("LP 0x02" );
662 outline0("MVWD");
663 outline0("EXAB");
664
665}
666
667static void op_ldab_direct( Environment * _environment, int _value ) {
668
669 outline1("LIB 0x%2.2x", (unsigned char)(_value&0xff) );
670 outline1("LIA 0x%2.2x", (unsigned char)((_value>>8)&0xff) );
671
672}
673
674static void op_ldk_direct( Environment * _environment, int _value ) {
675
676 outline1("LIA 0x%2.2x", (unsigned char)(_value) );
677 outline0("LP 0x08" );
678 outline0("EXAM");
679
680}
681
682
683static void op_stk( Environment * _environment, char * _address ) {
684
685 outline1("LIDP %s", _address );
686
687 outline0("LII 0x00" );
688 outline0("LP 0x08" );
689 outline0("MVDM");
690
691}
692
693static void op_ldl_direct( Environment * _environment, int _value ) {
694
695 outline1("LIA 0x%2.2x", (unsigned char)(_value) );
696 outline0("LP 0x09" );
697 outline0("EXAM");
698
699}
700
701static void op_stl( Environment * _environment, char * _address ) {
702
703 outline1("LIDP %s", _address );
704
705 outline0("LII 0x00" );
706 outline0("LP 0x09" );
707 outline0("MVDM");
708
709}
710
711static void op_ldm_direct( Environment * _environment, int _value ) {
712
713 outline1("LIA 0x%2.2x", (unsigned char)(_value) );
714 outline0("LP 0x0a" );
715 outline0("EXAM");
716
717}
718
719static void op_stm( Environment * _environment, char * _address ) {
720
721 outline1("LIDP %s", _address );
722
723 outline0("LII 0x00" );
724 outline0("LP 0x0a" );
725 outline0("MVDM");
726
727}
728
729static void op_ldn_direct( Environment * _environment, int _value ) {
730
731 outline1("LIA 0x%2.2x", (unsigned char)(_value) );
732 outline0("LP 0x0b" );
733 outline0("EXAM");
734
735}
736
737static void op_stn( Environment * _environment, char * _address ) {
738
739 outline1("LIDP %s", _address );
740
741 outline0("LII 0x00" );
742 outline0("LP 0x0b" );
743 outline0("MVDM");
744
745}
746
747static void op_ldx( Environment * _environment, char * _address ) {
748
749 // DP <- address
750 outline1("LIDP %s", _address );
751
752 // X <- (DP)
753 outline0("LII 0x01" );
754 outline0("LP 0x04" );
755 outline0("MVWD");
756
757}
758
759static void op_ldy( Environment * _environment, char * _address ) {
760
761 // DP <- address
762 outline1("LIDP %s", _address );
763
764 // Y <- (DP)
765 outline0("LII 0x01" );
766 outline0("LP 0x06" );
767 outline0("MVWD");
768
769}
770
771static void op_lddp_direct( Environment * _environment, char * _address ) {
772
773 // DP <- address
774 outline1("LIDP %s", _address);
775
776}
777
778static void op_lddp( Environment * _environment, char * _address ) {
779
780 // DP <- address
781 outline1("LIDP %s", _address);
782 // X <- (address)
783 outline0("LII 0x01" );
784 outline0("LP 0x04" );
785 outline0("MVWD");
786 outline0("DX");
787 outline0("IX");
788
789}
790
791static void op_orab( Environment * _environment ) {
792
793 outline0("LP 0x03" );
794 outline0("ORMA");
795
796}
797
798static void op_oram( Environment * _environment ) {
799
800 outline0("LP 0x0b" );
801 outline0("ORMA");
802
803}
804
805static void op_push( Environment * _environment ) {
806
807 outline0("PUSH");
808
809}
810
811static void op_pop( Environment * _environment ) {
812
813 outline0("POP");
814
815}
816
817static void op_sla( Environment * _environment ) {
818
819 outline0("SL");
820
821}
822
823static void op_sra( Environment * _environment ) {
824
825 outline0("SR");
826
827}
828
829static void op_sta( Environment * _environment, char * _address ) {
830
831 // DP <- target
832 outline1("LIDP %s", _address );
833
834 // (DP) <- A
835 outline0("STD");
836
837}
838
839static void op_stab( Environment * _environment, char * _address ) {
840
841 // DP <- target
842 outline1("LIDP %s", _address );
843
844 // (DP) <- A
845 outline0("EXAB");
846 outline0("STD");
847 outline0("EXAB");
848
849 // DP <- target
850 outline1("LIDP %s", address_displacement( _environment, _address, "1" ) );
851
852 // (DP) <- A
853 outline0("STD");
854
855}
856
857static void op_stb( Environment * _environment, char * _address ) {
858
859 outline1("LIDP %s", _address );
860
861 outline0("LII 0x01" );
862 outline0("LP 0x01" );
863 outline0("MVDM");
864
865}
866
867static void op_sta_y( Environment * _environment ) {
868
869 outline0("DY");
870 outline0("IYS");
871
872}
873
874static void op_sta_yn( Environment * _environment ) {
875
876 outline0("IYS");
877
878}
879
880static void op_subba( Environment * _environment ) {
881
882 outline0("LP 0x03");
883 outline0("SBM");
884
885}
886
887static void op_subab( Environment * _environment ) {
888
889 outline0("LP 0x03");
890 outline0("SBM");
891 outline0("EXAM");
892
893}
894
895static void op_subabc( Environment * _environment ) {
896
897 outline0("LP 0x03");
898 outline0("SBCM");
899 outline0("EXAM");
900
901}
902
903static void op_swab( Environment * _environment ) {
904
905 outline0("EXAB");
906
907}
908
909static void op_swan( Environment * _environment ) {
910
911 outline0("LIP 0x0b");
912 outline0("EXAM");
913
914}
915
916static void op_xab( Environment * _environment ) {
917
918 outline0("LIP 0x03");
919 outline0("EXAM");
920
921}
922
923static void op_xxla( Environment * _environment ) {
924
925 outline0("LIP 0x04");
926 outline0("EXAM");
927
928}
929
930static void op_xxha( Environment * _environment ) {
931
932 outline0("LIP 0x05");
933 outline0("EXAM");
934
935}
936
937static void op_wait_direct( Environment * _environment, int _value ) {
938
939 outline1("WAIT %2.2x", _value );
940
941}
942
946
947void cpu_nop( Environment * _environment ) {
948
949 outline0("NOPW");
950
951}
952
953void cpu_init( Environment * _environment ) {
954
955 _environment->stackSize = 0x005b - 0x000c;
956 _environment->stackStartAddress = 0x005b;
957
958}
959
960void cpu_ztoa( Environment * _environment ) {
961
963
964 outline1("JRZP %syes", label );
965 outline0("LIA 0");
966 outline1("JRP %s", label );
967 outhead1("%syes:", label );
968 outline0("LIA 0xff");
969 outhead1("%s:", label );
970
971}
972
973void cpu_ctoa( Environment * _environment ) {
974
976
977 outline1("JRC %syes", label );
978 outline0("LIA 0");
979 outline1("JRP %s", label );
980 outhead1("%syes:", label );
981 outline0("LIA 0xff");
982 outhead1("%s:", label );
983
984}
985
1000void cpu_beq( Environment * _environment, char * _label ) {
1001
1003
1004 outline1("JRZP %syes", label );
1005 outline1("JRP %s", label );
1006 outhead1("%syes:", label );
1007 outline1("JP %s", _label);
1008 outhead1("%s:", label );
1009
1010}
1011
1018void cpu_bneq( Environment * _environment, char * _label ) {
1019
1021
1022 outline1("JRNZP %syes", label );
1023 outline1("JRP %s", label );
1024 outhead1("%syes:", label );
1025 outline1("JP %s", _label);
1026 outhead1("%s:", label );
1027
1028}
1029
1030void cpu_bveq( Environment * _environment, char * _value, char * _label ) {
1031
1032 outline1("LIDP %s", _value);
1033 outline0("LDD");
1034 outline0("CPIA 0");
1035 cpu_beq( _environment, _label );
1036
1037}
1038
1039void cpu_bvneq( Environment * _environment, char * _value, char * _label ) {
1040
1041 outline1("LIDP %s", _value);
1042 outline0("LDD");
1043 outline0("CPIA 0");
1044 cpu_bneq( _environment, _label );
1045
1046}
1047
1048void cpu_label( Environment * _environment, char * _label ) {
1049 outhead1("%s:", _label);
1050}
1051
1052void cpu_peek( Environment * _environment, char * _address, char * _target ) {
1053
1054 op_ldx( _environment, _address );
1055
1056 op_lda_x( _environment );
1057
1058 op_sta( _environment, _target );
1059
1060}
1061
1062void cpu_poke( Environment * _environment, char * _address, char * _source ) {
1063
1064 op_ldy( _environment, _address );
1065
1066 op_lda( _environment, _source );
1067
1068 op_sta_y( _environment );
1069
1070}
1071
1072void cpu_poke_const( Environment * _environment, char * _address, int _source ) {
1073
1074 op_ldy( _environment, _address );
1075
1076 op_lda_direct( _environment, _source );
1077
1078 op_sta_y( _environment );
1079
1080}
1081
1082void cpu_peekw( Environment * _environment, char * _address, char * _target ) {
1083
1084 op_ldx( _environment, _address );
1085
1086 op_lda_x( _environment );
1087
1088 op_sta( _environment, _target );
1089
1090 op_lda_xn( _environment );
1091
1092 op_sta( _environment, address_displacement( _environment, _target, "1" ) );
1093
1094}
1095
1096void cpu_pokew( Environment * _environment, char * _address, char * _source ) {
1097
1098 op_ldy( _environment, _address );
1099
1100 op_lda( _environment, _source );
1101
1102 op_sta_y( _environment );
1103
1104 op_lda( _environment, address_displacement( _environment, _source, "1" ) );
1105
1106 op_sta_yn( _environment );
1107
1108
1109}
1110
1111void cpu_pokew_const( Environment * _environment, char * _address, int _source ) {
1112
1113 op_ldy( _environment, _address );
1114
1115 op_lda_direct( _environment, (unsigned char)(_source & 0xff ) );
1116
1117 op_sta_y( _environment );
1118
1119 op_lda_direct( _environment, (unsigned char)((_source>>8) & 0xff ) );
1120
1121 op_sta_yn( _environment );
1122
1123
1124}
1125
1126void cpu_peekd( Environment * _environment, char * _address, char * _target ) {
1127
1128 op_ldx( _environment, _address );
1129
1130 op_lda_x( _environment );
1131
1132 op_sta( _environment, _target );
1133
1134 op_lda_xn( _environment );
1135
1136 op_sta( _environment, address_displacement( _environment, _target, "1" ) );
1137
1138 op_lda_xn( _environment );
1139
1140 op_sta( _environment, address_displacement( _environment, _target, "2" ) );
1141
1142 op_lda_xn( _environment );
1143
1144 op_sta( _environment, address_displacement( _environment, _target, "3" ) );
1145
1146
1147}
1148
1149void cpu_poked( Environment * _environment, char * _address, char * _source ) {
1150
1151 op_ldy( _environment, _address );
1152
1153 op_lda( _environment, _source );
1154
1155 op_sta_y( _environment );
1156
1157 op_lda( _environment, address_displacement( _environment, _source, "1" ) );
1158
1159 op_sta_yn( _environment );
1160
1161 op_lda( _environment, address_displacement( _environment, _source, "2" ) );
1162
1163 op_sta_yn( _environment );
1164
1165 op_lda( _environment, address_displacement( _environment, _source, "3" ) );
1166
1167 op_sta_yn( _environment );
1168
1169}
1170
1171void cpu_poked_const( Environment * _environment, char * _address, int _source ) {
1172
1173 op_ldy( _environment, _address );
1174
1175 op_lda_direct( _environment, (unsigned char)(_source&0xff) );
1176
1177 op_sta_y( _environment );
1178
1179 op_lda_direct( _environment, (unsigned char)((_source>>8)&0xff) );
1180
1181 op_sta_yn( _environment );
1182
1183 op_lda_direct( _environment, (unsigned char)((_source>>16)&0xff) );
1184
1185 op_sta_yn( _environment );
1186
1187 op_lda_direct( _environment, (unsigned char)((_source>>24)&0xff) );
1188
1189 op_sta_yn( _environment );
1190
1191}
1192
1206void cpu_fill_blocks( Environment * _environment, char * _address, char * _blocks, char * _pattern ) {
1207
1209
1210 op_ldj( _environment, _blocks );
1211
1212 op_lda( _environment, _pattern );
1213
1214 op_lddp( _environment, _address );
1215
1216 outhead1("%s:", label );
1217
1218 op_fild_direct( _environment, 0xff );
1219
1220 op_decjnz( _environment, label );
1221
1222}
1223
1237void cpu_fill( Environment * _environment, char * _address, char * _bytes, int _bytes_width, char * _pattern ) {
1238
1240
1241 if ( _bytes_width == 8 ) {
1242
1243 op_ldi( _environment, _bytes );
1244
1245 op_lda( _environment, _pattern );
1246
1247 op_lddp( _environment, _address );
1248
1249 op_fild( _environment );
1250
1251 } else {
1252
1253 char repeatLabel[MAX_TEMPORARY_STORAGE];
1254 sprintf( repeatLabel, "%srepeat", label );
1255
1256 op_ldi( _environment, _bytes );
1257
1258 op_lda( _environment, _pattern );
1259
1260 op_lddp( _environment, _address );
1261
1262 op_fild( _environment );
1263
1264 op_decjz( _environment, label);
1265
1266 outhead1("%s:", repeatLabel );
1267
1268 op_fild_direct( _environment, 0xff );
1269 op_decjnz( _environment, repeatLabel );
1270
1271 outhead1("%s", label );
1272
1273 }
1274
1275}
1276
1290void cpu_fill_size( Environment * _environment, char * _address, int _bytes, char * _pattern ) {
1291
1293
1294 if ( _bytes < 256 ) {
1295
1296 op_lda( _environment, _pattern );
1297
1298 op_lddp( _environment, _address );
1299
1300 op_fild_direct( _environment, (unsigned char)(_bytes&0xff) );
1301
1302 } else {
1303
1304 char repeatLabel[MAX_TEMPORARY_STORAGE];
1305 sprintf( repeatLabel, "%srepeat", label );
1306
1307 op_ldij_direct( _environment, _bytes );
1308
1309 op_lda( _environment, _pattern );
1310
1311 op_lddp( _environment, _address );
1312
1313 op_fild( _environment );
1314 op_decjz( _environment, label );
1315
1316 outhead1("%s:", repeatLabel );
1317
1318 op_fild_direct( _environment, 0xff );
1319
1320 op_decjnz( _environment, repeatLabel );
1321
1322 outhead1("%s:", label );
1323
1324 }
1325
1326}
1327
1341void cpu_fill_size_value( Environment * _environment, char * _address, int _bytes, int _pattern ) {
1342
1344
1345 if ( _bytes < 256 ) {
1346
1347 op_lda_direct( _environment, _pattern );
1348
1349 op_lddp( _environment, _address );
1350
1351 op_fild_direct( _environment, _bytes );
1352
1353 } else {
1354
1355 char repeatLabel[MAX_TEMPORARY_STORAGE];
1356 sprintf( repeatLabel, "%srepeat", label );
1357
1358 op_ldij_direct( _environment, _bytes );
1359
1360 op_lda_direct( _environment, _pattern );
1361
1362 op_lddp( _environment, _address );
1363
1364 op_fild( _environment );
1365
1366 op_decjz( _environment, label );
1367
1368 outhead1("%s:", repeatLabel );
1369
1370 op_fild_direct( _environment, 0xff );
1371 op_decjnz( _environment, label );
1372
1373 outhead1("%s:", label );
1374 }
1375
1376}
1377
1391void cpu_fill_direct( Environment * _environment, char * _address, char * _bytes, char * _pattern ) {
1392
1394
1395 char repeatLabel[MAX_TEMPORARY_STORAGE];
1396 sprintf( repeatLabel, "%srepeat", label );
1397
1398 op_ldij( _environment, _bytes );
1399
1400 op_lda( _environment, _pattern );
1401
1402 op_lddp_direct( _environment, _address );
1403
1404 op_fild( _environment );
1405 op_decjz( _environment, label );
1406
1407 outhead1("%s:", repeatLabel );
1408
1409 op_fild_direct( _environment, 0xff );
1410 op_decjnz( _environment, repeatLabel );
1411
1412 outhead1("%sdone:", label );
1413
1414}
1415
1429void cpu_fill_direct_size( Environment * _environment, char * _address, int _bytes, char * _pattern ) {
1430
1432
1433 char repeatLabel[MAX_TEMPORARY_STORAGE];
1434 sprintf( repeatLabel, "%srepeat", label );
1435
1436 op_ldij_direct( _environment, _bytes );
1437
1438 op_lda( _environment, _pattern );
1439
1440 op_lddp_direct( _environment, _address );
1441
1442 op_fild( _environment );
1443 op_decjz( _environment, label );
1444
1445 outhead1("%s:", repeatLabel );
1446
1447 op_fild_direct( _environment, 0xff );
1448 op_decjnz( _environment, repeatLabel );
1449
1450 outhead1("%sdone:", label );
1451
1452
1453}
1454
1468void cpu_fill_direct_size_value( Environment * _environment, char * _address, int _bytes, int _pattern ) {
1469
1471
1472 char repeatLabel[MAX_TEMPORARY_STORAGE];
1473 sprintf( repeatLabel, "%srepeat", label );
1474
1475 op_ldij_direct( _environment, _bytes );
1476
1477 op_lda_direct( _environment, _pattern );
1478
1479 op_lddp_direct( _environment, _address );
1480
1481 op_fild( _environment );
1482 op_decjz( _environment, label );
1483
1484 outhead1("%s:", repeatLabel );
1485
1486 op_fild_direct( _environment, 0xff );
1487 op_decjnz( _environment, repeatLabel );
1488
1489 outhead1("%sdone:", label );
1490
1491}
1492
1493/*****************************************************************************
1494 * 8 BIT MANIPULATION
1495 ****************************************************************************/
1496
1504void cpu_move_8bit( Environment * _environment, char *_source, char *_destination ) {
1505
1506 op_lda( _environment, _source );
1507
1508 op_sta( _environment, _destination );
1509
1510}
1511
1519void cpu_store_8bit( Environment * _environment, char *_destination, int _value ) {
1520
1521 op_lda_direct( _environment, _value );
1522
1523 op_sta( _environment, _destination );
1524
1525}
1526
1534void cpu_store_char( Environment * _environment, char *_destination, int _value ) {
1535
1536 op_lda_direct( _environment, _value );
1537
1538 op_sta( _environment, _destination );
1539
1540}
1541
1542void cpu_store_8bit_with_offset( Environment * _environment, char *_destination, int _value, int _offset ) {
1543
1544 op_ldy( _environment, _destination );
1545
1546 op_addy_direct( _environment, _offset );
1547
1548 op_lda_direct( _environment, _value );
1549
1550 op_sta_y( _environment );
1551
1552}
1553
1554void cpu_store_8bit_with_offset2( Environment * _environment, char *_destination, char * _offset, int _value ) {
1555
1556 op_lda( _environment, _offset );
1557
1558 op_ldy( _environment, _destination );
1559
1560 op_addya( _environment );
1561
1562 op_lda_direct( _environment, _value );
1563
1564 op_sta_y( _environment );
1565
1566}
1567
1577void cpu_compare_8bit( Environment * _environment, char *_source, char *_destination, char *_other, int _positive ) {
1578
1580
1581 char doneLabel[MAX_TEMPORARY_STORAGE];
1582 sprintf( doneLabel, "%sb2", label );
1583
1584 op_lda( _environment, _destination );
1585
1586 op_xab( _environment );
1587
1588 op_lda( _environment, _source );
1589
1590 op_cpb( _environment );
1591
1592 op_jnz( _environment, label );
1593
1594 op_lda_direct( _environment, 0xff*_positive );
1595
1596 if ( _other ) {
1597 op_sta( _environment, _other );
1598 } else {
1599 op_sta( _environment, _destination );
1600 }
1601
1602 op_jp( _environment, doneLabel );
1603
1604 outhead1("%s:", label);
1605
1606 op_lda_direct( _environment, 0xff*(1-_positive) );
1607
1608 if ( _other ) {
1609 op_sta( _environment, _other );
1610 }
1611
1612 outhead1("%s:", doneLabel);
1613
1614}
1615
1625void cpu_compare_8bit_const( Environment * _environment, char *_source, int _destination, char *_other, int _positive ) {
1626
1628
1629 char doneLabel[MAX_TEMPORARY_STORAGE];
1630 sprintf( doneLabel, "%sb2", label );
1631
1632 op_lda( _environment, _source );
1633
1634 op_cp_direct( _environment, _destination );
1635
1636 op_jnz( _environment, label );
1637
1638 op_lda_direct( _environment, 0xff*_positive );
1639
1640 if ( _other ) {
1641 op_sta( _environment, _other );
1642 }
1643
1644 op_jp( _environment, doneLabel );
1645
1646 outhead1("%s:", label);
1647
1648 op_lda_direct( _environment, 0xff*(1-_positive) );
1649
1650 op_sta( _environment, _other );
1651
1652 outhead1("%s:", doneLabel);
1653
1654}
1655
1656void cpu_compare_and_branch_8bit( Environment * _environment, char *_source, char * _destination, char *_label, int _positive ) {
1657
1659
1660 op_ldx( _environment, _destination );
1661
1662 op_lda_x( _environment );
1663
1664 op_xab( _environment );
1665
1666 op_lda( _environment, _source );
1667
1668 op_cpb( _environment );
1669
1670 if ( _positive ) {
1671 op_jnz( _environment, label );
1672 op_jp( _environment, _label );
1673 } else {
1674 op_jz( _environment, label );
1675 op_jp( _environment, _label );
1676 }
1677
1678 outhead1("%s:", label);
1679
1680}
1681
1691void cpu_compare_and_branch_8bit_const( Environment * _environment, char *_source, int _destination, char *_label, int _positive ) {
1692
1694
1695 op_lda( _environment, _source );
1696
1697 op_cp_direct( _environment, _destination );
1698
1699 if ( _positive ) {
1700 op_jnz( _environment, label );
1701 op_jp( _environment, _label );
1702 } else {
1703 op_jz( _environment, label );
1704 op_jp( _environment, _label );
1705 }
1706
1707 outhead1("%s:", label);
1708
1709}
1710
1720void cpu_prepare_for_compare_and_branch_8bit( Environment * _environment, char *_source ) {
1721
1722 op_lda( _environment, _source );
1723
1724}
1725
1735void cpu_execute_compare_and_branch_8bit_const( Environment * _environment, int _destination, char *_label, int _positive ) {
1736
1738
1739 op_cp_direct( _environment, _destination );
1740
1741 if ( _positive ) {
1742 op_jnz( _environment, label );
1743 op_jp( _environment, _label );
1744 } else {
1745 op_jz( _environment, label );
1746 op_jp( _environment, _label );
1747 }
1748
1749 outhead1("%s:", label);
1750
1751}
1752
1762void cpu_compare_and_branch_char_const( Environment * _environment, char *_source, int _destination, char *_label, int _positive ) {
1763
1764 cpu_compare_and_branch_8bit_const( _environment, _source, _destination, _label, _positive );
1765
1766}
1767
1777void cpu_less_than_8bit( Environment * _environment, char *_source, char *_destination, char *_other, int _equal, int _signed ) {
1778
1780
1782
1783 embedded( cpu_less_than_8bit, src_hw_sc61860_cpu_less_than_8bit_asm );
1784
1785 if ( _signed ) {
1786
1787 op_ldi( _environment, _source );
1788 op_lda( _environment, _destination );
1789 if ( _equal ) {
1790 op_call( _environment, "CPULTE8S" );
1791 } else {
1792 op_call( _environment, "CPULT8S" );
1793 }
1794 if ( _other ) {
1795 op_sta( _environment, _other );
1796 } else {
1797 op_sta( _environment, _destination );
1798 }
1799
1800 } else {
1801
1802 op_ldi( _environment, _source );
1803 op_lda( _environment, _destination );
1804 if ( _equal ) {
1805 op_call( _environment, "CPULTE8U" );
1806 } else {
1807 op_call( _environment, "CPULT8U" );
1808 }
1809 if ( _other ) {
1810 op_sta( _environment, _other );
1811 } else {
1812 op_sta( _environment, _destination );
1813 }
1814
1815 }
1816
1817 done( )
1818
1819}
1820
1821void cpu_less_than_8bit_const( Environment * _environment, char *_source, int _destination, char *_other, int _equal, int _signed ) {
1822
1824
1826
1827 embedded( cpu_less_than_8bit, src_hw_sc61860_cpu_less_than_8bit_asm );
1828
1829 if ( _signed ) {
1830
1831 op_ldi( _environment, _source );
1832
1833 op_lda_direct( _environment, _destination );
1834
1835 if ( _equal ) {
1836 op_call( _environment, "CPULTE8S" );
1837 } else {
1838 op_call( _environment, "CPULT8S" );
1839 }
1840
1841 op_sta( _environment, _other );
1842
1843 } else {
1844
1845 op_ldi( _environment, _source );
1846
1847 op_lda_direct( _environment, _destination );
1848
1849 if ( _equal ) {
1850 op_call( _environment, "CPULTE8U" );
1851 } else {
1852 op_call( _environment, "CPULT8U" );
1853 }
1854
1855 op_sta( _environment, _other );
1856
1857 }
1858
1859 done( )
1860
1861}
1862
1863void cpu_less_than_and_branch_8bit_const( Environment * _environment, char *_source, int _destination, char *_label, int _equal, int _signed ) {
1864
1866
1867 if ( _signed ) {
1868
1869 char positiveLabel[MAX_TEMPORARY_STORAGE];
1870 sprintf( positiveLabel, "%spos", label );
1871
1872 char doneLabel[MAX_TEMPORARY_STORAGE];
1873 sprintf( doneLabel, "%sb2", label );
1874
1875 op_lda( _environment, _source );
1876
1877 op_anda_direct( _environment, 0x80 );
1878 op_cp_direct( _environment, 0x00 );
1879 op_jz( _environment, positiveLabel );
1880
1881 op_cp_direct( _environment, _destination );
1882
1883 if ( _equal ) {
1884 op_jz( _environment, label );
1885 }
1886 op_jnc( _environment, label );
1887
1888 op_jp( _environment, doneLabel );
1889
1890 outhead1("%s:", positiveLabel);
1891
1892 op_cp_direct( _environment, _destination );
1893
1894 op_jc( _environment, label );
1895 if ( _equal ) {
1896 op_jnz( _environment, label );
1897 }
1898
1899 op_jp( _environment, doneLabel );
1900
1901 outhead1("%s:", label);
1902
1903 op_jp( _environment, _label );
1904
1905 outhead1("%s:", doneLabel);
1906
1907 } else {
1908
1909 char doneLabel[MAX_TEMPORARY_STORAGE];
1910 sprintf( doneLabel, "%sb2", label );
1911
1912 op_lda( _environment, _source );
1913
1914 op_cp_direct( _environment, _destination );
1915
1916 op_jc( _environment, label );
1917 if ( _equal ) {
1918 op_jnz( _environment, label );
1919 }
1920
1921 op_jp( _environment, doneLabel );
1922
1923 outhead1("%s:", label);
1924
1925 op_jp( _environment, _label );
1926
1927 outhead1("%s:", doneLabel);
1928
1929 }
1930
1931}
1932
1942void cpu_greater_than_8bit( Environment * _environment, char *_source, char *_destination, char *_other, int _equal, int _signed ) {
1943
1944 cpu_less_than_8bit( _environment, _source, _destination, _other, !_equal, _signed );
1945 if ( _other ) {
1946 cpu_not_8bit( _environment, _other, _other );
1947 } else {
1948 cpu_not_8bit( _environment, _destination, _destination );
1949 }
1950
1951}
1952
1953void cpu_greater_than_8bit_const( Environment * _environment, char *_source, int _destination, char *_other, int _equal, int _signed ) {
1954
1955 cpu_less_than_8bit_const( _environment, _source, _destination, _other, !_equal, _signed );
1956 cpu_not_8bit( _environment, _other, _other );
1957
1958}
1959
1968void cpu_math_add_8bit( Environment * _environment, char *_source, char *_destination, char *_other ) {
1969
1971
1972 op_lda( _environment, _source );
1973
1974 op_xab( _environment );
1975
1976 op_lda( _environment, _destination );
1977
1978 op_addab( _environment );
1979
1980 if ( _other ) {
1981 op_sta( _environment, _other );
1982 } else {
1983 op_sta( _environment, _destination );
1984 }
1985
1986}
1987
1988void cpu_math_add_8bit_const( Environment * _environment, char *_source, int _destination, char *_other ) {
1989
1991
1992 op_lda( _environment, _source );
1993
1994 op_xab( _environment );
1995
1996 op_lda_direct( _environment, _destination );
1997
1998 op_addab( _environment );
1999
2000 if ( _other ) {
2001 op_sta( _environment, _other );
2002 }
2003
2004}
2005
2014void cpu_math_sub_8bit( Environment * _environment, char *_source, char *_destination, char *_other ) {
2015
2017
2018 op_lda( _environment, _source );
2019
2020 op_xab( _environment );
2021
2022 op_lda( _environment, _destination );
2023
2024 op_subab( _environment );
2025
2026 if ( _other ) {
2027 op_sta( _environment, _other );
2028 } else {
2029 op_sta( _environment, _destination );
2030 }
2031
2032}
2033
2041void cpu_math_double_8bit( Environment * _environment, char *_source, char *_other, int _signed ) {
2042
2043 if ( _signed ) {
2044
2045 op_lda( _environment, _source );
2046 op_anda_direct( _environment, 0x80 );
2047 op_swab( _environment );
2048
2049 op_lda( _environment, _source );
2050 op_sla( _environment );
2051 op_orab( _environment );
2052 if ( _other ) {
2053 op_sta( _environment, _other );
2054 } else {
2055 op_sta( _environment, _source );
2056 }
2057
2058 } else {
2059
2060 op_lda( _environment, _source );
2061 op_sla( _environment );
2062 if ( _other ) {
2063 op_sta( _environment, _other );
2064 } else {
2065 op_sta( _environment, _source );
2066 }
2067 }
2068
2069}
2070
2079
2080void cpu_math_mul_8bit_to_16bit( Environment * _environment, char *_source, char *_destination, char *_other, int _signed ) {
2081
2083
2085
2086 embedded( cpu_math_mul_8bit_to_16bit, src_hw_sc61860_cpu_math_mul_8bit_to_16bit_asm );
2087
2088 if ( _signed ) {
2089
2090 op_ldi( _environment, _source );
2091
2092 op_lda( _environment, _destination );
2093
2094 op_call( _environment, "CPUMUL8B8T16S");
2095
2096 op_sta( _environment, _other );
2097
2098 op_xab( _environment );
2099
2100 op_sta( _environment, address_displacement( _environment, _other, "1" ) );
2101
2102 } else {
2103
2104 op_ldi( _environment, _source );
2105
2106 op_lda( _environment, _destination );
2107
2108 op_call( _environment, "CPUMUL8B8T16U");
2109
2110 op_sta( _environment, _other );
2111
2112 op_xab( _environment );
2113
2114 op_sta( _environment, address_displacement( _environment, _other, "1" ) );
2115
2116 }
2117
2118 done( )
2119
2120}
2121
2129void cpu_math_div2_const_8bit( Environment * _environment, char *_source, int _steps, int _signed, char * _remainder ) {
2130
2132
2134
2135 embedded( cpu_math_div2_const_8bit, src_hw_sc61860_cpu_math_div2_const_8bit_asm );
2136
2137 if ( _remainder ) {
2138 op_lda( _environment, _source );
2139 op_anda_direct( _environment, 0x01 );
2140 op_sta( _environment, _remainder );
2141 }
2142
2143 if ( _signed ) {
2144
2145 op_ldi_direct( _environment, _steps );
2146
2147 op_lda( _environment, _source );
2148
2149 op_call( _environment, "CPUDIV2CONST8S" );
2150
2151 op_sta( _environment, _source );
2152
2153 } else {
2154
2155 op_ldi_direct( _environment, _steps );
2156
2157 op_lda( _environment, _source );
2158
2159 op_call( _environment, "CPUDIV2CONST8U" );
2160
2161 op_sta( _environment, _source );
2162
2163 }
2164
2165 done( )
2166
2167}
2168
2176void cpu_math_mul2_const_8bit( Environment * _environment, char *_source, int _steps, int _signed ) {
2177
2179
2181
2182 embedded( cpu_math_mul2_const_8bit, src_hw_sc61860_cpu_math_mul2_const_8bit_asm );
2183
2184 if ( _signed ) {
2185
2186 op_ldi_direct( _environment, _steps );
2187
2188 op_lda( _environment, _source );
2189
2190 op_call( _environment, "CPUMUL2CONST8S" );
2191
2192 op_sta( _environment, _source );
2193
2194 } else {
2195
2196 op_ldi_direct( _environment, _steps );
2197
2198 op_lda( _environment, _source );
2199
2200 op_call( _environment, "CPUMUL2CONST8U" );
2201
2202 op_sta( _environment, _source );
2203
2204 }
2205
2206 done( )
2207
2208}
2209
2217void cpu_math_complement_const_8bit( Environment * _environment, char *_source, int _value ) {
2218
2220
2221 op_lda( _environment, _source );
2222
2223 op_xab( _environment );
2224
2225 op_lda_direct( _environment, _value );
2226
2227 op_subab( _environment );
2228
2229 op_sta( _environment, _source );
2230
2232
2233}
2234
2242void cpu_math_and_const_8bit( Environment * _environment, char *_source, int _mask ) {
2243
2244 inline( cpu_math_and_const_8bit )
2245
2246 op_lda( _environment, _source );
2247
2248 op_anda_direct( _environment, _mask );
2249
2250 op_sta( _environment, _source );
2251
2253
2254}
2255
2256/*****************************************************************************
2257 * 16 BIT MANIPULATION
2258 ****************************************************************************/
2259
2267void cpu_move_16bit( Environment * _environment, char *_source, char *_destination ) {
2268
2269 inline( cpu_move_16bit )
2270
2271 op_lda( _environment, _source );
2272
2273 op_sta( _environment, _destination );
2274
2275 op_lda( _environment, address_displacement( _environment, _source, "1" ) );
2276
2277 op_sta( _environment, address_displacement( _environment, _destination, "1" ) );
2278
2280
2281}
2282
2283void cpu_addressof_16bit( Environment * _environment, char *_source, char *_destination ) {
2284
2285 inline( cpu_addressof_16bit )
2286
2287 op_lda_address_low( _environment, _source );
2288
2289 op_sta( _environment, _destination );
2290
2291 op_lda_address_high( _environment, _source );
2292
2293 op_sta( _environment, address_displacement( _environment, _destination, "1" ) );
2294
2296
2297}
2298
2306void cpu_store_16bit( Environment * _environment, char *_destination, int _value ) {
2307
2308 inline( cpu_store_16bit )
2309
2310 op_lda_direct( _environment, _value & 0xff );
2311
2312 op_sta( _environment, _destination );
2313
2314 op_lda_direct( _environment, (_value >> 8) & 0xff );
2315
2316 op_sta( _environment, address_displacement( _environment, _destination, "1" ) );
2317
2319
2320}
2321
2330void cpu_compare_16bit( Environment * _environment, char *_source, char *_destination, char *_other, int _positive ) {
2331
2333
2335
2336 embedded( cpu_compare_16bit, src_hw_sc61860_cpu_compare_16bit_asm )
2337
2338 op_ldk_direct( _environment, (0xff*_positive) );
2339 op_ldl_direct( _environment, ( 0xff*(1-_positive)) );
2340
2341 op_ldij( _environment, _source );
2342
2343 op_ldab( _environment, _destination );
2344
2345 op_call( _environment, "CPUCOMPARE16");
2346 if ( _other ) {
2347 op_sta( _environment, _other );
2348 } else {
2349 op_sta( _environment, _destination );
2350 }
2351
2352 done( )
2353
2354}
2355
2364void cpu_compare_16bit_const( Environment * _environment, char *_source, int _destination, char *_other, int _positive ) {
2365
2367
2369
2370 embedded( cpu_compare_16bit, src_hw_sc61860_cpu_compare_16bit_asm )
2371
2372 op_ldk_direct( _environment, (0xff*_positive) );
2373 op_ldl_direct( _environment, ( 0xff*(1-_positive)) );
2374
2375 op_ldij( _environment, _source );
2376
2377 op_ldab_direct( _environment, _destination );
2378
2379 op_call( _environment, "CPUCOMPARE16");
2380
2381 op_sta( _environment, _other );
2382
2383 done( )
2384
2385}
2386
2387void cpu_compare_and_branch_16bit( Environment * _environment, char *_source, char *_destination, char *_label, int _positive ) {
2388
2390
2392
2393 op_ldk_direct( _environment, (0xff*_positive) );
2394 op_ldl_direct( _environment, ( 0xff*(1-_positive)) );
2395
2396 op_ldij( _environment, _source );
2397
2398 op_ldab( _environment, _destination );
2399
2400 op_call( _environment, "CPUCOMPARE16");
2401 op_cp_direct( _environment, (0xff*_positive) );
2402 op_jnz( _environment, label );
2403 op_jp( _environment, _label );
2404 outhead1("%s", label );
2405
2407
2408}
2409
2419void cpu_compare_and_branch_16bit_const( Environment * _environment, char *_source, int _destination, char *_label, int _positive ) {
2420
2422
2424
2425 op_ldk_direct( _environment, (0xff*_positive) );
2426 op_ldl_direct( _environment, ( 0xff*(1-_positive)) );
2427
2428 op_ldij( _environment, _source );
2429
2430 op_ldab_direct( _environment, _destination );
2431
2432 op_call( _environment, "CPUCOMPARE16");
2433 op_cp_direct( _environment, (0xff*_positive) );
2434 op_jnz( _environment, label );
2435 op_jp( _environment, _label );
2436 outhead1("%s", label );
2437
2439
2440}
2441
2451void cpu_less_than_16bit( Environment * _environment, char *_source, char *_destination, char *_other, int _equal, int _signed ) {
2452
2454
2456
2457 embedded( cpu_less_than_16bit, src_hw_sc61860_cpu_less_than_16bit_asm );
2458
2459 if ( _signed ) {
2460
2461 op_ldij( _environment, _source );
2462
2463 op_ldab( _environment, _destination );
2464
2465 if ( _equal ) {
2466 op_call( _environment, "CPULTE16S" );
2467 } else {
2468 op_call( _environment, "CPULT16S" );
2469 }
2470 if ( _other ) {
2471 op_sta( _environment, _other );
2472 } else {
2473 op_sta( _environment, _destination );
2474 }
2475
2476 } else {
2477
2478 op_ldij( _environment, _source );
2479
2480 op_ldab( _environment, _destination );
2481
2482 if ( _equal ) {
2483 op_call( _environment, "CPULTE16U" );
2484 } else {
2485 op_call( _environment, "CPULT16U" );
2486 }
2487 if ( _other ) {
2488 op_sta( _environment, _other );
2489 } else {
2490 op_sta( _environment, _destination );
2491 }
2492
2493 }
2494
2495 done( )
2496
2497}
2498
2499void cpu_less_than_16bit_const( Environment * _environment, char *_source, int _destination, char *_other, int _equal, int _signed ) {
2500
2502
2504
2505 embedded( cpu_less_than_16bit, src_hw_sc61860_cpu_less_than_16bit_asm );
2506
2507 if ( _signed ) {
2508
2509 op_ldij( _environment, _source );
2510
2511 op_ldab_direct( _environment, _destination );
2512
2513 if ( _equal ) {
2514 op_call( _environment, "CPULTE16S" );
2515 } else {
2516 op_call( _environment, "CPULT16S" );
2517 }
2518
2519 op_sta( _environment, _other );
2520
2521 } else {
2522
2523 op_ldij( _environment, _source );
2524
2525 op_ldab_direct( _environment, _destination );
2526
2527 if ( _equal ) {
2528 op_call( _environment, "CPULTE16U" );
2529 } else {
2530 op_call( _environment, "CPULT16U" );
2531 }
2532
2533 op_sta( _environment, _other );
2534
2535 }
2536
2537 done( )
2538
2539}
2540
2550void cpu_greater_than_16bit( Environment * _environment, char *_source, char *_destination, char *_other, int _equal, int _signed ) {
2551
2552 cpu_less_than_16bit( _environment, _source, _destination, _other, !_equal, _signed );
2553 if ( _other ) {
2554 cpu_not_8bit( _environment, _other, _other );
2555 } else {
2556 cpu_not_8bit( _environment, _destination, _destination );
2557 }
2558
2559}
2560
2561void cpu_greater_than_16bit_const( Environment * _environment, char *_source, int _destination, char *_other, int _equal, int _signed ) {
2562
2563 cpu_less_than_16bit_const( _environment, _source, _destination, _other, !_equal, _signed );
2564 cpu_not_8bit( _environment, _other, _other );
2565
2566}
2567
2576void cpu_math_add_16bit( Environment * _environment, char *_source, char *_destination, char *_other ) {
2577
2578 inline( cpu_math_add_16bit )
2579
2581
2582 op_lda( _environment, _source );
2583
2584 op_xab( _environment );
2585
2586 op_lda( _environment, _destination );
2587
2588 op_addab( _environment );
2589
2590 if ( _other ) {
2591 op_sta( _environment, _other );
2592 } else {
2593 op_sta( _environment, _destination );
2594 }
2595
2596 op_lda( _environment, address_displacement( _environment, _source, "1" ) );
2597
2598 op_xab( _environment );
2599
2600 op_lda( _environment, address_displacement( _environment, _destination, "1" ) );
2601
2602 op_addabc( _environment );
2603
2604 if ( _other ) {
2605 op_sta( _environment, address_displacement( _environment, _other, "1" ) );
2606 } else {
2607 op_sta( _environment, address_displacement( _environment, _destination, "1" ) );
2608 }
2609
2611
2612}
2613
2614void cpu_math_add_16bit_const( Environment * _environment, char *_source, int _destination, char *_other ) {
2615
2616 inline( cpu_math_add_16bit_const )
2617
2619
2620 op_lda( _environment, _source );
2621
2622 op_xab( _environment );
2623
2624 op_lda_direct( _environment, _destination );
2625
2626 op_addab( _environment );
2627
2628 op_sta( _environment, _other );
2629
2630 op_lda( _environment, address_displacement( _environment, _source, "1" ) );
2631
2632 op_xab( _environment );
2633
2634 op_lda_direct( _environment, _destination>>8 );
2635
2636 op_addabc( _environment );
2637
2638 op_sta( _environment, address_displacement( _environment, _other, "1" ) );
2639
2641
2642}
2643
2644void cpu_math_add_16bit_with_16bit( Environment * _environment, char *_source, char *_destination, char *_other ) {
2645
2647
2649
2650 op_lda( _environment, _source );
2651
2652 op_xab( _environment );
2653
2654 op_lda_address_low( _environment, _destination );
2655
2656 op_addab( _environment );
2657
2658 op_sta( _environment, _other );
2659
2660 op_lda( _environment, address_displacement( _environment, _source, "1" ) );
2661
2662 op_xab( _environment );
2663
2664 op_lda_address_high( _environment, _destination );
2665
2666 op_addabc( _environment );
2667
2668 op_sta( _environment, address_displacement( _environment, _other, "1" ) );
2669
2671
2672}
2673
2681void cpu_math_double_16bit( Environment * _environment, char *_source, char *_other, int _signed ) {
2682
2683 if ( _signed ) {
2684
2685 op_ldab( _environment, _source );
2686 op_xab( _environment );
2687 op_clc( _environment );
2688 op_sla( _environment );
2689 op_xab( _environment );
2690 op_sla( _environment );
2691 op_anda_direct( _environment, 0x7f );
2692 if ( _other ) {
2693 op_stab( _environment, _other );
2694 } else {
2695 op_stab( _environment, _source );
2696 }
2697
2698 } else {
2699
2700 op_ldab( _environment, _source );
2701 op_xab( _environment );
2702 op_clc( _environment );
2703 op_sla( _environment );
2704 op_xab( _environment );
2705 op_sla( _environment );
2706 if ( _other ) {
2707 op_stab( _environment, _other );
2708 } else {
2709 op_stab( _environment, _source );
2710 }
2711 }
2712
2713}
2714
2723void cpu_math_mul_16bit_to_32bit( Environment * _environment, char *_source, char *_destination, char *_other, int _signed ) {
2724
2726
2728
2729 embedded( cpu_math_mul_8bit_to_16bit, src_hw_sc61860_cpu_math_mul_8bit_to_16bit_asm );
2730
2731 if ( _signed ) {
2732
2733 CRITICAL_UNIMPLEMENTED( "sc61860_math_mul_16bit_to_32bit(signed)" );
2734
2735 // outline1("LD IX, (%s)", _source );
2736 // outline1("LD IY, (%s)", _destination );
2737 // outline0("CALL CPUMUL16B16T32S")
2738 // outline1("LD (%s), HL", _other );
2739 // outline1("LD (%s), BC", address_displacement( _environment, _other, "2" ) );
2740
2741 } else {
2742
2744
2745 op_ldij( _environment, _source );
2746
2747 op_ldab( _environment, _destination );
2748
2749 op_call( _environment, "CPUMUL16B16T16U");
2750
2751 op_stab( _environment, _other );
2752
2753 }
2754
2755 done( )
2756
2757}
2758
2767void cpu_math_sub_16bit( Environment * _environment, char *_source, char *_destination, char *_other ) {
2768
2769 inline( cpu_math_sub_16bit )
2770
2772
2773 op_lda( _environment, _source );
2774
2775 op_xab( _environment );
2776
2777 op_lda( _environment, _destination );
2778
2779 op_subab( _environment );
2780
2781 if ( _other ) {
2782 op_sta( _environment, _other );
2783 } else {
2784 op_sta( _environment, _destination );
2785 }
2786
2787 op_lda( _environment, address_displacement( _environment, _source, "1" ) );
2788
2789 op_xab( _environment );
2790
2791 op_lda( _environment, address_displacement( _environment, _destination, "1" ) );
2792
2793 op_subabc( _environment );
2794
2795 if ( _other ) {
2796 op_sta( _environment, address_displacement( _environment, _other, "1" ) );
2797 } else {
2798 op_sta( _environment, address_displacement( _environment, _destination, "1" ) );
2799 }
2800
2802
2803}
2804
2812void cpu_math_complement_const_16bit( Environment * _environment, char *_source, int _value ) {
2813
2814 op_lda( _environment, _source );
2815
2816 op_ldab( _environment, _source );
2817
2818 op_lda_direct( _environment, _value & 0xff );
2819
2820 op_subab( _environment );
2821
2822 op_sta( _environment, _source );
2823
2824 op_ldab( _environment, address_displacement( _environment, _source, "1" ) );
2825
2826 op_lda_direct( _environment, ( _value >> 8 ) );
2827
2828 op_subabc( _environment );
2829
2830 op_sta( _environment, address_displacement( _environment, _source, "1" ) );
2831
2832}
2833
2841void cpu_math_div2_const_16bit( Environment * _environment, char *_source, int _steps, int _signed, char * _remainder ) {
2842
2844
2846
2847 embedded( cpu_math_div2_const_16bit, src_hw_sc61860_cpu_math_div2_const_16bit_asm );
2848
2849 if ( _remainder ) {
2850 op_lda( _environment, _source );
2851 op_anda_direct( _environment, 0x01 );
2852 op_sta( _environment, _remainder );
2853 }
2854
2855 if ( _signed ) {
2856
2857 op_ldi_direct( _environment, _steps );
2858
2859 op_ldab( _environment, _source );
2860
2861 op_call( _environment, "CPUDIV2CONST16S" );
2862
2863 op_stab( _environment, _source );
2864
2865 } else {
2866
2867 op_ldi_direct( _environment, _steps );
2868
2869 op_ldab( _environment, _source );
2870
2871 op_call( _environment, "CPUDIV2CONST16U" );
2872
2873 op_stab( _environment, _source );
2874
2875 }
2876
2877 done( )
2878
2879}
2880
2888void cpu_math_mul2_const_16bit( Environment * _environment, char *_source, int _steps, int _signed ) {
2889
2891
2893
2894 embedded( cpu_math_mul2_const_16bit, src_hw_sc61860_cpu_math_mul2_const_16bit_asm );
2895
2896 if ( _signed ) {
2897
2898 op_ldi_direct( _environment, _steps );
2899
2900 op_ldab( _environment, _source );
2901
2902 op_call( _environment, "CPUMUL2CONST16S" );
2903
2904 op_stab( _environment, _source );
2905
2906 } else {
2907
2908 op_ldi_direct( _environment, _steps );
2909
2910 op_ldab( _environment, _source );
2911
2912 op_call( _environment, "CPUMUL2CONST16U" );
2913
2914 op_stab( _environment, _source );
2915
2916 }
2917
2918 done( )
2919}
2920
2928void cpu_math_and_const_16bit( Environment * _environment, char *_source, int _mask ) {
2929
2930 inline( cpu_math_and_const_16bit )
2931
2932 op_ldab( _environment, _source );
2933
2934 op_anda_direct( _environment, _mask >> 8 );
2935
2936 op_swab( _environment );
2937
2938 op_anda_direct( _environment, _mask );
2939
2940 op_swab( _environment );
2941
2942 op_stab( _environment, _source );
2943
2945
2946}
2947
2948/*****************************************************************************
2949 * 32 BIT MANIPULATION
2950 ****************************************************************************/
2951
2959void cpu_move_32bit( Environment * _environment, char *_source, char *_destination ) {
2960
2961 inline( cpu_move_16bit )
2962
2963 op_lda( _environment, _source );
2964
2965 op_sta( _environment, _destination );
2966
2967 op_lda( _environment, address_displacement( _environment, _source, "1" ) );
2968
2969 op_sta( _environment, address_displacement( _environment, _destination, "1" ) );
2970
2971 op_lda( _environment, address_displacement( _environment, _source, "2" ) );
2972
2973 op_sta( _environment, address_displacement( _environment, _destination, "2" ) );
2974
2975 op_lda( _environment, address_displacement( _environment, _source, "3" ) );
2976
2977 op_sta( _environment, address_displacement( _environment, _destination, "3" ) );
2978
2980
2981}
2982
2990void cpu_store_32bit( Environment * _environment, char *_destination, int _value ) {
2991
2992 inline( cpu_store_16bit )
2993
2994 op_lda_direct( _environment, _value );
2995
2996 op_sta( _environment, _destination );
2997
2998 op_lda_direct( _environment, (_value >> 8) );
2999
3000 op_sta( _environment, address_displacement( _environment, _destination, "1" ) );
3001
3002 op_lda_direct( _environment, (_value >> 16) );
3003
3004 op_sta( _environment, address_displacement( _environment, _destination, "2" ) );
3005
3006 op_lda_direct( _environment, (_value >> 24) );
3007
3008 op_sta( _environment, address_displacement( _environment, _destination, "3" ) );
3009
3011
3012}
3013
3023void cpu_compare_32bit( Environment * _environment, char *_source, char *_destination, char *_other, int _positive ) {
3024
3026
3028
3029 embedded( cpu_compare_32bit, src_hw_sc61860_cpu_compare_32bit_asm )
3030
3031 op_ldx_direct( _environment, (0xff*_positive)||(0xff00*(1-_positive)) );
3032
3033 op_ldijab( _environment, _source );
3034 op_ldklmn( _environment, _destination );
3035
3036 op_call( _environment, "CPUCOMPARE32");
3037 if ( _other ) {
3038 op_sta( _environment, _other );
3039 } else {
3040 op_sta( _environment, _destination );
3041 }
3042
3043 done( )
3044
3045}
3046
3056void cpu_compare_32bit_const( Environment * _environment, char *_source, int _destination, char *_other, int _positive ) {
3057
3059
3061
3062 embedded( cpu_compare_32bit, src_hw_sc61860_cpu_compare_32bit_asm )
3063
3064 op_ldx_direct( _environment, (0xff*_positive)||(0xff00*(1-_positive)) );
3065
3066 op_ldijab( _environment, _source );
3067 op_ldklmn_direct( _environment, _destination );
3068
3069 op_call( _environment, "CPUCOMPARE32");
3070 op_sta( _environment, _other );
3071
3072 done( )
3073
3074}
3075
3085void cpu_compare_and_branch_32bit_const( Environment * _environment, char *_source, int _destination, char *_label, int _positive ) {
3086
3088
3089 embedded( cpu_compare_32bit, src_hw_sc61860_cpu_compare_32bit_asm )
3090
3092
3093 op_ldx_direct( _environment, (0xff*_positive)||(0xff00*(1-_positive)) );
3094
3095 op_ldijab( _environment, _source );
3096 op_ldklmn_direct( _environment, _destination );
3097
3098 op_call( _environment, "CPUCOMPARE32");
3099 op_cp_direct( _environment, (0xff*_positive) );
3100 op_jnz( _environment, label );
3101 op_jp( _environment, _label );
3102 outhead1("%s", label );
3103
3104 done( )
3105
3106}
3107
3117void cpu_less_than_32bit( Environment * _environment, char *_source, char *_destination, char *_other, int _equal, int _signed ) {
3118
3120
3122
3123 embedded( cpu_less_than_32bit, src_hw_sc61860_cpu_less_than_32bit_asm );
3124
3125 if ( _signed ) {
3126
3127 CRITICAL_UNIMPLEMENTED( "sc61860_less_than_32bit(signed)" );
3128
3129 } else {
3130
3131 op_ldijab( _environment, _source );
3132
3133 op_ldklmn( _environment, _destination );
3134
3135 if ( _equal ) {
3136 op_call( _environment, "CPULTE32U" );
3137 } else {
3138 op_call( _environment, "CPULT32U" );
3139 }
3140
3141 if ( _other ) {
3142 op_sta( _environment, _other );
3143 } else {
3144 op_sta( _environment, _destination );
3145 }
3146
3147 }
3148
3149 done( )
3150
3151}
3152
3153void cpu_less_than_32bit_const( Environment * _environment, char *_source, int _destination, char *_other, int _equal, int _signed ) {
3154
3156
3158
3159 embedded( cpu_less_than_32bit, src_hw_sc61860_cpu_less_than_32bit_asm );
3160
3161 if ( _signed ) {
3162
3163 CRITICAL_UNIMPLEMENTED( "sc61860_less_than_32bit_const(signed)" );
3164
3165 } else {
3166
3167 op_ldijab( _environment, _source );
3168
3169 op_ldklmn_direct( _environment, _destination );
3170
3171 if ( _equal ) {
3172 op_call( _environment, "CPULTE32U" );
3173 } else {
3174 op_call( _environment, "CPULT32U" );
3175 }
3176
3177 op_sta( _environment, _other );
3178
3179 }
3180
3181 done( )
3182
3183}
3184
3194void cpu_greater_than_32bit( Environment * _environment, char *_source, char *_destination, char *_other, int _equal, int _signed ) {
3195
3196 cpu_less_than_32bit( _environment, _source, _destination, _other, !_equal, _signed );
3197 if ( _other ) {
3198 cpu_not_8bit( _environment, _other, _other );
3199 } else {
3200 cpu_not_8bit( _environment, _destination, _destination );
3201 }
3202
3203}
3204
3205void cpu_greater_than_32bit_const( Environment * _environment, char *_source, int _destination, char *_other, int _equal, int _signed ) {
3206
3207 cpu_less_than_32bit_const( _environment, _source, _destination, _other, !_equal, _signed );
3208 cpu_not_8bit( _environment, _other, _other );
3209
3210}
3211
3220void cpu_math_add_32bit( Environment * _environment, char *_source, char *_destination, char *_other ) {
3221
3222 inline( cpu_math_add_16bit )
3223
3225
3226 op_lda( _environment, _source );
3227
3228 op_xab( _environment );
3229
3230 op_lda( _environment, _destination );
3231
3232 op_addab( _environment );
3233
3234 if ( _other ) {
3235 op_sta( _environment, _other );
3236 } else {
3237 op_sta( _environment, _destination );
3238 }
3239
3240 op_lda( _environment, address_displacement( _environment, _source, "1" ) );
3241
3242 op_xab( _environment );
3243
3244 op_lda( _environment, address_displacement( _environment, _destination, "1" ) );
3245
3246 op_addabc( _environment );
3247
3248 if ( _other ) {
3249 op_sta( _environment, address_displacement( _environment, _other, "1" ) );
3250 } else {
3251 op_sta( _environment, address_displacement( _environment, _destination, "1" ) );
3252 }
3253
3254 op_lda( _environment, address_displacement( _environment, _source, "2" ) );
3255
3256 op_xab( _environment );
3257
3258 op_lda( _environment, address_displacement( _environment, _destination, "2" ) );
3259
3260 op_addabc( _environment );
3261
3262 if ( _other ) {
3263 op_sta( _environment, address_displacement( _environment, _other, "2" ) );
3264 } else {
3265 op_sta( _environment, address_displacement( _environment, _destination, "2" ) );
3266 }
3267
3268 op_lda( _environment, address_displacement( _environment, _source, "3" ) );
3269
3270 op_xab( _environment );
3271
3272 op_lda( _environment, address_displacement( _environment, _destination, "3" ) );
3273
3274 op_addabc( _environment );
3275
3276 if ( _other ) {
3277 op_sta( _environment, address_displacement( _environment, _other, "3" ) );
3278 } else {
3279 op_sta( _environment, address_displacement( _environment, _destination, "3" ) );
3280 }
3281
3283
3284}
3285
3286void cpu_math_add_32bit_const( Environment * _environment, char *_source, int _destination, char *_other ) {
3287
3288 inline( cpu_math_add_16bit )
3289
3291
3292 op_lda( _environment, _source );
3293
3294 op_xab( _environment );
3295
3296 op_lda_direct( _environment, _destination );
3297
3298 op_addab( _environment );
3299
3300 op_sta( _environment, _other );
3301
3302 op_lda( _environment, address_displacement( _environment, _source, "1" ) );
3303
3304 op_xab( _environment );
3305
3306 op_lda_direct( _environment,_destination >> 8 );
3307
3308 op_addabc( _environment );
3309
3310 op_sta( _environment, address_displacement( _environment, _other, "1" ) );
3311
3312 op_lda( _environment, address_displacement( _environment, _source, "2" ) );
3313
3314 op_xab( _environment );
3315
3316 op_lda_direct( _environment,_destination >> 16 );
3317
3318 op_addabc( _environment );
3319
3320 op_sta( _environment, address_displacement( _environment, _other, "2" ) );
3321
3322 op_lda( _environment, address_displacement( _environment, _source, "3" ) );
3323
3324 op_xab( _environment );
3325
3326 op_lda_direct( _environment,_destination >> 24 );
3327
3328 op_addabc( _environment );
3329
3330 op_sta( _environment, address_displacement( _environment, _other, "3" ) );
3331
3333
3334}
3335
3343void cpu_math_double_32bit( Environment * _environment, char *_source, char *_other, int _signed ) {
3344
3345 if ( _other ) {
3346 cpu_math_add_32bit( _environment, _source, _source, _other );
3347 } else {
3348 cpu_math_add_32bit( _environment, _source, _source, _source );
3349 }
3350
3351}
3352
3361void cpu_math_sub_32bit( Environment * _environment, char *_source, char *_destination, char *_other ) {
3362
3363 inline( cpu_math_sub_16bit )
3364
3366
3367 op_lda( _environment, _source );
3368
3369 op_xab( _environment );
3370
3371 op_lda( _environment, _destination );
3372
3373 op_subab( _environment );
3374
3375 if ( _other ) {
3376 op_sta( _environment, _other );
3377 } else {
3378 op_sta( _environment, _destination );
3379 }
3380
3381 op_lda( _environment, address_displacement( _environment, _source, "1" ) );
3382
3383 op_xab( _environment );
3384
3385 op_lda( _environment, address_displacement( _environment, _destination, "1" ) );
3386
3387 op_subabc( _environment );
3388
3389 if ( _other ) {
3390 op_sta( _environment, address_displacement( _environment, _other, "1" ) );
3391 } else {
3392 op_sta( _environment, address_displacement( _environment, _destination, "1" ) );
3393 }
3394
3395 op_lda( _environment, address_displacement( _environment, _source, "2" ) );
3396
3397 op_xab( _environment );
3398
3399 op_lda( _environment, address_displacement( _environment, _destination, "2" ) );
3400
3401 op_subabc( _environment );
3402
3403 if ( _other ) {
3404 op_sta( _environment, address_displacement( _environment, _other, "2" ) );
3405 } else {
3406 op_sta( _environment, address_displacement( _environment, _destination, "2" ) );
3407 }
3408
3409 op_lda( _environment, address_displacement( _environment, _source, "3" ) );
3410
3411 op_xab( _environment );
3412
3413 op_lda( _environment, address_displacement( _environment, _destination, "3" ) );
3414
3415 op_subabc( _environment );
3416
3417 if ( _other ) {
3418 op_sta( _environment, address_displacement( _environment, _other, "3" ) );
3419 } else {
3420 op_sta( _environment, address_displacement( _environment, _destination, "3" ) );
3421 }
3422
3424
3425}
3426
3434void cpu_math_complement_const_32bit( Environment * _environment, char *_source, int _value ) {
3435
3436 inline( cpu_math_sub_16bit )
3437
3439
3440 op_lda( _environment, _source );
3441
3442 op_xab( _environment );
3443
3444 op_lda_direct( _environment, _value );
3445
3446 op_subab( _environment );
3447
3448 op_sta( _environment, _source );
3449
3450 op_lda( _environment, address_displacement( _environment, _source, "1" ) );
3451
3452 op_xab( _environment );
3453
3454 op_lda_direct( _environment, _value >> 8 );
3455
3456 op_subabc( _environment );
3457
3458 op_sta( _environment, address_displacement( _environment, _source, "1" ) );
3459
3460 op_lda( _environment, address_displacement( _environment, _source, "2" ) );
3461
3462 op_xab( _environment );
3463
3464 op_lda_direct( _environment, _value >> 16 );
3465
3466 op_subabc( _environment );
3467
3468 op_sta( _environment, address_displacement( _environment, _source, "2" ) );
3469
3470 op_lda( _environment, address_displacement( _environment, _source, "3" ) );
3471
3472 op_xab( _environment );
3473
3474 op_lda_direct( _environment, _value >> 24 );
3475
3476 op_subabc( _environment );
3477
3478 op_sta( _environment, address_displacement( _environment, _source, "3" ) );
3479
3481}
3482
3490void cpu_math_div2_const_32bit( Environment * _environment, char *_source, int _steps, int _signed, char * _remainder ) {
3491
3493
3494 if ( _remainder ) {
3495 op_lda( _environment, _source );
3496 op_anda_direct( _environment, 0x01 );
3497 op_sta( _environment, _remainder );
3498 }
3499
3500 if ( _signed ) {
3501
3502 op_ldab( _environment, address_displacement( _environment, _source, "2" ) );
3503 op_swab( _environment );
3504 op_anda_direct( _environment, 0x80 );
3505 op_swan( _environment );
3506
3507 while( _steps ) {
3508 op_ldab( _environment, _source );
3509 op_swab( _environment );
3510 op_sra( _environment );
3511 op_swab( _environment );
3512 op_sra( _environment );
3513 op_stab( _environment, _source );
3514 op_ldab( _environment, address_displacement( _environment, _source, "2" ) );
3515 op_swab( _environment );
3516 op_sra( _environment );
3517 op_swab( _environment );
3518 op_sra( _environment );
3519 op_stab( _environment, address_displacement( _environment, _source, "2" ) );
3520 --_steps;
3521 }
3522
3523 op_ldab( _environment, address_displacement( _environment, _source, "2" ) );
3524 op_swab( _environment );
3525 op_oram( _environment );
3526 op_swab( _environment );
3527 op_stab( _environment, address_displacement( _environment, _source, "2" ) );
3528
3529 } else {
3530
3531 while( _steps ) {
3532 op_ldab( _environment, _source );
3533 op_swab( _environment );
3534 op_sra( _environment );
3535 op_swab( _environment );
3536 op_sra( _environment );
3537 op_stab( _environment, _source );
3538 op_ldab( _environment, address_displacement( _environment, _source, "2" ) );
3539 op_swab( _environment );
3540 op_sra( _environment );
3541 op_swab( _environment );
3542 op_sra( _environment );
3543 op_stab( _environment, address_displacement( _environment, _source, "2" ) );
3544 --_steps;
3545 }
3546
3547 }
3548
3549}
3550
3558void cpu_math_mul2_const_32bit( Environment * _environment, char *_source, int _steps, int _signed ) {
3559
3561
3562 if ( _signed ) {
3563
3564 op_ldab( _environment, address_displacement( _environment, _source, "2" ) );
3565 op_swab( _environment );
3566 op_anda_direct( _environment, 0x80 );
3567 op_swan( _environment );
3568
3569 op_swan( _environment );
3570 while( _steps ) {
3571 op_ldab( _environment, _source );
3572 op_sla( _environment );
3573 op_swab( _environment );
3574 op_sla( _environment );
3575 op_swab( _environment );
3576 op_stab( _environment, _source );
3577 op_ldab( _environment, address_displacement( _environment, _source, "2" ) );
3578 op_sla( _environment );
3579 op_swab( _environment );
3580 op_sla( _environment );
3581 op_swab( _environment );
3582 op_stab( _environment, address_displacement( _environment, _source, "2" ) );
3583 --_steps;
3584 }
3585
3586 op_ldab( _environment, address_displacement( _environment, _source, "2" ) );
3587 op_swab( _environment );
3588 op_oram( _environment );
3589 op_swab( _environment );
3590 op_stab( _environment, address_displacement( _environment, _source, "2" ) );
3591
3592 } else {
3593
3594 while( _steps ) {
3595 op_ldab( _environment, _source );
3596 op_sla( _environment );
3597 op_swab( _environment );
3598 op_sla( _environment );
3599 op_swab( _environment );
3600 op_stab( _environment, _source );
3601 op_ldab( _environment, address_displacement( _environment, _source, "2" ) );
3602 op_sla( _environment );
3603 op_swab( _environment );
3604 op_sla( _environment );
3605 op_swab( _environment );
3606 op_stab( _environment, address_displacement( _environment, _source, "2" ) );
3607 --_steps;
3608 }
3609
3610 }
3611
3612}
3613
3621void cpu_math_and_const_32bit( Environment * _environment, char *_source, int _mask ) {
3622
3623 inline( cpu_math_and_const_32bit )
3624
3625 op_ldab( _environment, _source );
3626
3627 op_anda_direct( _environment, _mask >> 8 );
3628
3629 op_swab( _environment );
3630
3631 op_anda_direct( _environment, _mask );
3632
3633 op_swab( _environment );
3634
3635 op_stab( _environment, _source );
3636
3637 op_ldab( _environment, address_displacement( _environment, _source, "2" ) );
3638
3639 op_anda_direct( _environment, _mask >> 24 );
3640
3641 op_swab( _environment );
3642
3643 op_anda_direct( _environment, _mask >> 16 );
3644
3645 op_swab( _environment );
3646
3647 op_stab( _environment, address_displacement( _environment, _source, "2" ) );
3648
3650
3651}
3652
3656void cpu_combine_nibbles( Environment * _environment, char * _low_nibble, char * _hi_nibble, char * _byte ) {
3657
3658 CRITICAL_UNIMPLEMENTED( "sc61860_combine_nibbles" );
3659
3660}
3661
3662void cpu_jump( Environment * _environment, char * _label ) {
3663
3664 outline1("JP %s", _label );
3665
3666}
3667
3668void cpu_call_addr( Environment * _environment, int _address ) {
3669
3670 outline1("CALL 0x%4.4x", _address );
3671
3672}
3673
3674void cpu_call( Environment * _environment, char * _label ) {
3675
3676 outline1("CALL %s", _label );
3677
3678}
3679
3680void cpu_call_indirect( Environment * _environment, char * _value ) {
3681
3683
3684 char indirectLabel[MAX_TEMPORARY_STORAGE]; sprintf( indirectLabel, "%sindirect", label );
3685
3686 cpu_jump( _environment, label );
3687 cpu_label( _environment, indirectLabel );
3688 cpu_jump( _environment, "0x0000" );
3689 cpu_label( _environment, label );
3690 op_ldab( _environment, _value );
3691 op_stab( _environment, address_displacement( _environment, indirectLabel, "1" ) );
3692 cpu_call( _environment, indirectLabel );
3693
3694}
3695
3696void cpu_jump_indirect( Environment * _environment, char * _value ) {
3697
3699
3700 char indirectLabel[MAX_TEMPORARY_STORAGE]; sprintf( indirectLabel, "%sindirect", label );
3701
3702 cpu_jump( _environment, label );
3703
3704 cpu_label( _environment, indirectLabel );
3705 cpu_jump( _environment, "0x0000" );
3706
3707 cpu_label( _environment, label );
3708 op_ldab( _environment, _value );
3709 op_stab( _environment, address_displacement( _environment, indirectLabel, "1" ) );
3710 cpu_jump( _environment, indirectLabel );
3711
3712}
3713
3714int cpu_register_decode( Environment * _environment, char * _register ) {
3715
3717
3718 if ( !_environment->emptyProcedure ) {
3719
3720 if ( strcmp( _register, "A" ) == 0 ) {
3721 result = REGISTER_A;
3722 } else if ( strcmp( _register, "B" ) == 0 ) {
3723 result = REGISTER_B;
3724 } else if ( strcmp( _register, "XL" ) == 0 ) {
3725 result = REGISTER_XL;
3726 } else if ( strcmp( _register, "XH" ) == 0 ) {
3727 result = REGISTER_XH;
3728 } else if ( strcmp( _register, "YL" ) == 0 ) {
3729 result = REGISTER_YL;
3730 } else if ( strcmp( _register, "YH" ) == 0 ) {
3731 result = REGISTER_YH;
3732 } else if ( strcmp( _register, "K" ) == 0 ) {
3733 result = REGISTER_K;
3734 } else if ( strcmp( _register, "L" ) == 0 ) {
3735 result = REGISTER_L;
3736 } else if ( strcmp( _register, "M" ) == 0 ) {
3737 result = REGISTER_M;
3738 } else if ( strcmp( _register, "N" ) == 0 ) {
3739 result = REGISTER_N;
3740 } else {
3741
3742 }
3743
3744 }
3745
3746 return (int)result;
3747
3748}
3749
3750void cpu_set_asmio( Environment * _environment, int _asmio, int _value ) {
3751
3752 if ( IS_REGISTER( _asmio ) ) {
3753
3755
3756 SC61860Register reg = (SC61860Register) _asmio;
3757
3758 switch ( reg ) {
3759 case REGISTER_NONE:
3761 break;
3762 case REGISTER_J:
3763 op_ldj_direct( _environment, _value );
3764 break;
3765 case REGISTER_A:
3766 op_lda_direct( _environment, _value );
3767 break;
3768 case REGISTER_B:
3769 op_ldb_direct( _environment, _value );
3770 break;
3771 case REGISTER_XL:
3772 op_push( _environment );
3773 op_ldxl_direct( _environment, _value );
3774 op_pop( _environment );
3775 break;
3776 case REGISTER_XH:
3777 op_push( _environment );
3778 op_ldxh_direct( _environment, _value );
3779 op_pop( _environment );
3780 break;
3781 case REGISTER_YL:
3782 op_push( _environment );
3783 op_ldyl_direct( _environment, _value );
3784 op_pop( _environment );
3785 break;
3786 case REGISTER_YH:
3787 op_push( _environment );
3788 op_ldyh_direct( _environment, _value );
3789 op_pop( _environment );
3790 break;
3791 case REGISTER_K:
3792 op_push( _environment );
3793 op_ldk_direct( _environment, _value );
3794 op_pop( _environment );
3795 break;
3796 case REGISTER_L:
3797 op_push( _environment );
3798 op_ldl_direct( _environment, _value );
3799 op_pop( _environment );
3800 break;
3801 case REGISTER_M:
3802 op_push( _environment );
3803 op_ldm_direct( _environment, _value );
3804 op_pop( _environment );
3805 break;
3806 case REGISTER_N:
3807 op_push( _environment );
3808 op_ldn_direct( _environment, _value );
3809 op_pop( _environment );
3810 break;
3811 }
3812
3813 } else {
3814
3815 SC61860Stack stk = (SC61860Stack) _asmio;
3816
3817 switch ( stk ) {
3818 case STACK_NONE:
3819 break;
3820 case STACK_BYTE:
3821 op_lda_direct( _environment, _value );
3822 op_push( _environment );
3823 break;
3824 case STACK_WORD:
3825 op_lda_direct( _environment, _value );
3826 op_push( _environment );
3827 op_lda_direct( _environment, _value >> 8 );
3828 op_push( _environment );
3829 break;
3830 case STACK_DWORD:
3831 op_lda_direct( _environment, _value );
3832 op_push( _environment );
3833 op_lda_direct( _environment, _value >> 8 );
3834 op_push( _environment );
3835 op_lda_direct( _environment, _value >> 16 );
3836 op_push( _environment );
3837 op_lda_direct( _environment, _value >> 24 );
3838 op_push( _environment );
3839 break;
3840 }
3841
3842 }
3843
3844}
3845
3846void cpu_set_asmio_indirect( Environment * _environment, int _asmio, char * _value ) {
3847
3848 if ( IS_REGISTER( _asmio ) ) {
3849
3851
3852 SC61860Register reg = (SC61860Register) _asmio;
3853
3854 switch ( reg ) {
3855 case REGISTER_NONE:
3857 break;
3858 case REGISTER_J:
3859 op_ldj( _environment, _value );
3860 break;
3861 case REGISTER_A:
3862 op_lda( _environment, _value );
3863 break;
3864 case REGISTER_B:
3865 op_ldb( _environment, _value );
3866 break;
3867 case REGISTER_XL:
3868 op_ldxl( _environment, _value );
3869 break;
3870 case REGISTER_XH:
3871 op_ldxh( _environment, _value );
3872 break;
3873 case REGISTER_YL:
3874 op_ldyl( _environment, _value );
3875 break;
3876 case REGISTER_YH:
3877 op_ldyh( _environment, _value );
3878 break;
3879 case REGISTER_K:
3880 op_ldk( _environment, _value );
3881 break;
3882 case REGISTER_L:
3883 op_ldl( _environment, _value );
3884 break;
3885 case REGISTER_M:
3886 op_ldm( _environment, _value );
3887 break;
3888 case REGISTER_N:
3889 op_ldn( _environment, _value );
3890 break;
3891 }
3892
3893 } else {
3894
3895 SC61860Stack stk = (SC61860Stack) _asmio;
3896
3897 switch ( stk ) {
3898 case STACK_NONE:
3899 break;
3900 case STACK_BYTE:
3901 op_lda( _environment, _value );
3902 op_push( _environment );
3903 break;
3904 case STACK_WORD:
3905 op_lda( _environment, _value );
3906 op_push( _environment );
3907 op_lda( _environment, address_displacement( _environment, _value, "1" ) );
3908 op_push( _environment );
3909 break;
3910 case STACK_DWORD:
3911 op_lda( _environment, _value );
3912 op_push( _environment );
3913 op_lda( _environment, address_displacement( _environment, _value, "1" ) );
3914 op_push( _environment );
3915 op_lda( _environment, address_displacement( _environment, _value, "2" ) );
3916 op_push( _environment );
3917 op_lda( _environment, address_displacement( _environment, _value, "3" ) );
3918 op_push( _environment );
3919 break;
3920 }
3921
3922 }
3923
3924}
3925
3926void cpu_get_asmio_indirect( Environment * _environment, int _asmio, char * _value ) {
3927
3928 if ( IS_REGISTER( _asmio ) ) {
3929
3931
3932 SC61860Register reg = (SC61860Register) _asmio;
3933
3934 switch ( reg ) {
3935 case REGISTER_NONE:
3937 break;
3938 case REGISTER_I:
3939 op_sti( _environment, _value );
3940 break;
3941 case REGISTER_J:
3942 op_stj( _environment, _value );
3943 break;
3944 case REGISTER_A:
3945 op_sta( _environment, _value );
3946 break;
3947 case REGISTER_B:
3948 op_stb( _environment, _value );
3949 break;
3950 case REGISTER_XL:
3951 op_stxl( _environment, _value );
3952 break;
3953 case REGISTER_XH:
3954 op_stxh( _environment, _value );
3955 break;
3956 case REGISTER_YL:
3957 op_styl( _environment, _value );
3958 break;
3959 case REGISTER_YH:
3960 op_styh( _environment, _value );
3961 break;
3962 case REGISTER_K:
3963 op_stk( _environment, _value );
3964 break;
3965 case REGISTER_L:
3966 op_stl( _environment, _value );
3967 break;
3968 case REGISTER_M:
3969 op_stm( _environment, _value );
3970 break;
3971 case REGISTER_N:
3972 op_stn( _environment, _value );
3973 break;
3974 }
3975
3976 } else {
3977
3978 SC61860Stack stk = (SC61860Stack) _asmio;
3979
3980 switch ( stk ) {
3981 case STACK_NONE:
3982 break;
3983 case STACK_BYTE:
3984 op_lda( _environment, _value );
3985 op_push( _environment );
3986 break;
3987 case STACK_WORD:
3988 op_lda( _environment, _value );
3989 op_push( _environment );
3990 op_lda( _environment, address_displacement( _environment, _value, "1" ) );
3991 op_push( _environment );
3992 break;
3993 case STACK_DWORD:
3994 op_lda( _environment, _value );
3995 op_push( _environment );
3996 op_lda( _environment, address_displacement( _environment, _value, "1" ) );
3997 op_push( _environment );
3998 op_lda( _environment, address_displacement( _environment, _value, "2" ) );
3999 op_push( _environment );
4000 op_lda( _environment, address_displacement( _environment, _value, "3" ) );
4001 op_push( _environment );
4002 break;
4003 }
4004
4005 }
4006
4007}
4008
4009void cpu_return( Environment * _environment ) {
4010
4011 outline0("RTN" );
4012
4013}
4014
4015void cpu_pop( Environment * _environment ) {
4016
4017 outline0("POP" );
4018
4019}
4020
4021void cpu_halt( Environment * _environment ) {
4022
4024
4025 outhead1("%s:", label );
4026 outline1("JP %s", label );
4027
4028}
4029
4030void cpu_end( Environment * _environment ) {
4031
4032 cpu_halt( _environment );
4033
4034}
4035
4036void cpu_random( Environment * _environment, char * _entropy ) {
4037
4038 CRITICAL_UNIMPLEMENTED( "sc61860_random" );
4039
4041
4042 // inline( cpu_random )
4043
4044 if ( _entropy ) {
4045 // outline0("LD HL, (CPURANDOM_SEED)");
4046 // outline0("LD B, (HL)");
4047 // outline0("INC HL");
4048 // outline0("LD A, (HL)");
4049 // outline0("XOR B");
4050 // outline1("LD DE, (%s)", _entropy);
4051 // // outline0("LD B, H");
4052 // outline0("LD C, L");
4053 // outline0("ADD HL, HL");
4054 // outline0("RL E");
4055 // outline0("RL D");
4056 // outline0("ADD HL, DE");
4057 // outline0("RL E");
4058 // outline0("RL D");
4059 // outline0("INC L");
4060 // outline0("ADD HL, BC");
4061 // outline0("LD (CPURANDOM_SEED), HL");
4062 // outline0("LD HL, (CPURANDOM_SEED+2)");
4063 // outline0("ADD HL, DE");
4064 // outline0("LD (CPURANDOM_SEED+1), HL");
4065 // outline0("EX DE, HL");
4066 // outline0("LD HL, (CPURANDOM_SEED)");
4067 // outline1("LD DE, (%s)", _entropy);
4068 // outline0("ADD HL, HL");
4069 // outline0("RL C");
4070 // outline0("RL B");
4071 // outline0("LD (CPURANDOM_SEED+1), BC");
4072 // outline0("SBC A, A");
4073 // outline0("AND %11000101");
4074 // outline0("XOR L");
4075 // outline0("LD L, A");
4076 // outline0("LD (CPURANDOM_SEED+1), HL");
4077 // outline0("EX DE, HL");
4078 // outline0("ADD HL, BC");
4079 }
4080
4081 // embedded( cpu_random, src_hw_sc61860_cpu_random_asm );
4082
4083 // done()
4084
4085
4086}
4087
4088void cpu_random_8bit( Environment * _environment, char * _entropy, char * _result ) {
4089
4090 CRITICAL_UNIMPLEMENTED( "sc61860_random_8bit" );
4091
4092 cpu_random( _environment, _entropy );
4093
4094 if ( _result ) {
4095 // outline0("CALL CPURANDOM16" );
4096 // outline0("LD A, H" );
4097 // outline1("LD (%s), A", _result );
4098 }
4099
4100}
4101
4102void cpu_random_16bit( Environment * _environment, char * _entropy, char * _result ) {
4103
4104 CRITICAL_UNIMPLEMENTED( "sc61860_random_16bit" );
4105
4106 cpu_random( _environment, _entropy );
4107
4108 if ( _result ) {
4109 // outline0("CALL CPURANDOM16" );
4110 // outline1("LD (%s), HL", _result );
4111 }
4112
4113}
4114
4115void cpu_random_32bit( Environment * _environment, char * _entropy, char * _result ) {
4116
4117 CRITICAL_UNIMPLEMENTED( "sc61860_random_32bit" );
4118
4119 cpu_random( _environment, _entropy );
4120
4121 if ( _result ) {
4122 // outline0("CALL CPURANDOM32" );
4123 // outline1("LD (%s), HL", _result );
4124 // outline1("LD (%s), BC", address_displacement( _environment, _result, "2" ) );
4125 }
4126
4127}
4128
4129void cpu_limit_16bit( Environment * _environment, char * _variable, int _value ) {
4130
4131 CRITICAL_UNIMPLEMENTED( "sc61860_limit_16bit" );
4132
4134
4135 // outline1( "LD A, (%s)", _variable );
4136 // outline1( "CP 0x%2.2x", _value );
4137 // outline1( "JR C, %s", label );
4138 // outline1( "SUB 0x%2.2x", _value );
4139 // outline1( "LD (%s), A", _variable );
4140 // outhead1( "%s:", label );
4141
4142}
4143
4144void cpu_busy_wait( Environment * _environment, char * _timing ) {
4145
4147
4148 char waitLabel[MAX_TEMPORARY_STORAGE];
4149 sprintf( waitLabel, "%swait", label );
4150 char waitValueLabel[MAX_TEMPORARY_STORAGE];
4151 sprintf( waitValueLabel, "%swait+1", label );
4152
4153 op_lda( _environment, _timing );
4154 op_sta( _environment, waitValueLabel );
4155 outhead1("%s:", waitLabel );
4156 op_wait_direct( _environment, 0 );
4157
4158}
4159
4167void cpu_port_out( Environment * _environment, char * _port, char * _value ) {
4168
4169 // outline1("LD A, (%s)", _value );
4170 // outline1("OUT (%s), A", _port );
4171
4172}
4173
4174void cpu_logical_and_8bit( Environment * _environment, char * _left, char * _right, char * _result ) {
4175
4177
4178 char doneLabel[MAX_TEMPORARY_STORAGE];
4179 sprintf( doneLabel, "%sdone", label );
4180
4181 op_lda( _environment, _left );
4182 op_cp_direct( _environment, 0 );
4183 op_jz( _environment, label );
4184 op_lda( _environment, _right );
4185 op_cp_direct( _environment, 0 );
4186 op_jz( _environment, label );
4187 op_lda_direct( _environment, 0xff );
4188 op_sta( _environment, _result );
4189 op_jp( _environment, doneLabel );
4190 cpu_label( _environment, label );
4191 op_lda_direct( _environment, 0 );
4192 op_sta( _environment, _result );
4193 cpu_label( _environment, doneLabel );
4194
4195}
4196
4197void cpu_and_8bit( Environment * _environment, char * _left, char * _right, char * _result ) {
4198
4199 op_ldb( _environment, _right );
4200 op_lda( _environment, _left );
4201 op_andab( _environment );
4202 op_stb( _environment, _result );
4203
4204}
4205
4206void cpu_and_8bit_const( Environment * _environment, char * _left, int _right, char * _result ) {
4207
4208 op_ldb_direct( _environment, _right );
4209 op_lda( _environment, _left );
4210 op_andab( _environment );
4211 op_stb( _environment, _result );
4212
4213}
4214
4215void cpu_and_16bit( Environment * _environment, char * _left, char * _right, char * _result ) {
4216
4217 cpu_and_8bit( _environment, _left, _right, _result );
4218 cpu_and_8bit( _environment, address_displacement( _environment, _left, "1" ), address_displacement( _environment, _right, "1" ), address_displacement( _environment, _result, "1" ) );
4219
4220}
4221
4222void cpu_and_32bit( Environment * _environment, char * _left, char * _right, char * _result ) {
4223
4224 cpu_and_8bit( _environment, _left, _right, _result );
4225 cpu_and_8bit( _environment, address_displacement( _environment, _left, "1" ), address_displacement( _environment, _right, "1" ), address_displacement( _environment, _result, "1" ) );
4226 cpu_and_8bit( _environment, address_displacement( _environment, _left, "2" ), address_displacement( _environment, _right, "2" ), address_displacement( _environment, _result, "2" ) );
4227 cpu_and_8bit( _environment, address_displacement( _environment, _left, "3" ), address_displacement( _environment, _right, "2" ), address_displacement( _environment, _result, "3" ) );
4228
4229}
4230
4231void cpu_logical_or_8bit( Environment * _environment, char * _left, char * _right, char * _result ) {
4232
4234
4235 char doneLabel[MAX_TEMPORARY_STORAGE];
4236 sprintf( doneLabel, "%sdone", label );
4237
4238 op_lda( _environment, _left );
4239 op_cp_direct( _environment, 0 );
4240 op_jnz( _environment, label );
4241 op_lda( _environment, _right );
4242 op_cp_direct( _environment, 0 );
4243 op_jnz( _environment, label );
4244 op_lda_direct( _environment, 0 );
4245 op_sta( _environment, _result );
4246 op_jp( _environment, doneLabel );
4247 cpu_label( _environment, label );
4248 op_lda_direct( _environment, 0xff );
4249 op_sta( _environment, _result );
4250 cpu_label( _environment, doneLabel );
4251
4252}
4253
4254void cpu_or_8bit( Environment * _environment, char * _left, char * _right, char * _result ) {
4255
4257
4258 op_ldb( _environment, _right );
4259 op_lda( _environment, _left );
4260 op_orab( _environment );
4261 op_stb( _environment, _result );
4262
4263}
4264
4265void cpu_or_8bit_const( Environment * _environment, char * _left, int _right, char * _result ) {
4266
4268
4269 op_ldb_direct( _environment, _right );
4270 op_lda( _environment, _left );
4271 op_orab( _environment );
4272 op_stb( _environment, _result );
4273
4274}
4275
4276void cpu_or_16bit( Environment * _environment, char * _left, char * _right, char * _result ) {
4277
4279
4280 cpu_or_8bit( _environment, _left, _right, _result );
4281 cpu_or_8bit( _environment, address_displacement( _environment, _left, "1" ), address_displacement( _environment, _right, "1" ), address_displacement( _environment, _result, "1" ) );
4282
4283}
4284
4285void cpu_or_32bit( Environment * _environment, char * _left, char * _right, char * _result ) {
4286
4288
4289 cpu_or_8bit( _environment, _left, _right, _result );
4290 cpu_or_8bit( _environment, address_displacement( _environment, _left, "1" ), address_displacement( _environment, _right, "1" ), address_displacement( _environment, _result, "1" ) );
4291 cpu_or_8bit( _environment, address_displacement( _environment, _left, "2" ), address_displacement( _environment, _right, "2" ), address_displacement( _environment, _result, "2" ) );
4292 cpu_or_8bit( _environment, address_displacement( _environment, _left, "3" ), address_displacement( _environment, _right, "2" ), address_displacement( _environment, _result, "3" ) );
4293
4294}
4295
4296void cpu_xor_8bit( Environment * _environment, char * _left, char * _right, char * _result ) {
4297
4298 CRITICAL_UNIMPLEMENTED( "sc61860_xor_8bit" );
4299
4301
4302 // outline1("LD HL, %s", _left );
4303 // outline1("LD IX, %s", _right );
4304 // outline1("LD DE, %s", _result );
4305 // outline0("LD A, (HL)" );
4306 // outline0("XOR (IX)" );
4307 // outline0("LD (DE), A" );
4308
4309}
4310
4311void cpu_xor_8bit_const( Environment * _environment, char * _left, int _right, char * _result ) {
4312
4313 CRITICAL_UNIMPLEMENTED( "sc61860_xor_8bit_const" );
4314
4316
4317 // outline1("LD HL, %s", _left );
4318 // outline1("LD IX, %s", _right );
4319 // outline1("LD DE, %s", _result );
4320 // outline0("LD A, (HL)" );
4321 // outline0("XOR (IX)" );
4322 // outline0("LD (DE), A" );
4323
4324}
4325
4326void cpu_xor_16bit( Environment * _environment, char * _left, char * _right, char * _result ) {
4327
4328 CRITICAL_UNIMPLEMENTED( "sc61860_xor_16bit" );
4329
4331
4332 // outline1("LD HL, %s", _left );
4333 // outline1("LD IX, %s", _right );
4334 // outline1("LD DE, %s", _result );
4335 // outline0("LD A, (HL)" );
4336 // outline0("XOR (IX)" );
4337 // outline0("LD (DE), A" );
4338 // outline0("INC HL" );
4339 // outline0("INC DE" );
4340 // outline0("LD A, (HL)" );
4341 // outline0("XOR (IX+1)" );
4342 // outline0("LD (DE), A" );
4343 // outline0("INC HL" );
4344 // outline0("INC DE" );
4345
4346}
4347
4348void cpu_xor_16bit_const( Environment * _environment, char * _left, int _right, char * _result ) {
4349
4350 CRITICAL_UNIMPLEMENTED( "sc61860_xor_16bit_const" );
4351
4353
4354 // outline1("LD HL, %s", _left );
4355 // outline1("LD IX, %s", _right );
4356 // outline1("LD DE, %s", _result );
4357 // outline0("LD A, (HL)" );
4358 // outline0("XOR (IX)" );
4359 // outline0("LD (DE), A" );
4360 // outline0("INC HL" );
4361 // outline0("INC DE" );
4362 // outline0("LD A, (HL)" );
4363 // outline0("XOR (IX+1)" );
4364 // outline0("LD (DE), A" );
4365 // outline0("INC HL" );
4366 // outline0("INC DE" );
4367
4368}
4369
4370void cpu_xor_32bit( Environment * _environment, char * _left, char * _right, char * _result ) {
4371
4372 CRITICAL_UNIMPLEMENTED( "sc61860_xor_32bit" );
4373
4375
4376 // outline1("LD HL, %s", _left );
4377 // outline1("LD IX, %s", _right );
4378 // outline1("LD DE, %s", _result );
4379 // outline0("LD A, (HL)" );
4380 // outline0("XOR (IX)" );
4381 // outline0("LD (DE), A" );
4382 // outline0("INC HL" );
4383 // outline0("INC DE" );
4384 // outline0("LD A, (HL)" );
4385 // outline0("XOR (IX+1)" );
4386 // outline0("LD (DE), A" );
4387 // outline0("INC HL" );
4388 // outline0("INC DE" );
4389 // outline0("LD A, (HL)" );
4390 // outline0("XOR (IX+2)" );
4391 // outline0("LD (DE), A" );
4392 // outline0("INC HL" );
4393 // outline0("INC DE" );
4394 // outline0("LD A, (HL)" );
4395 // outline0("XOR (IX+3)" );
4396 // outline0("LD (DE), A" );
4397
4398}
4399
4400void cpu_xor_32bit_const( Environment * _environment, char * _left, int _right, char * _result ) {
4401
4402 CRITICAL_UNIMPLEMENTED( "sc61860_xor_32bit_const" );
4403
4405
4406 // outline1("LD HL, %s", _left );
4407 // outline1("LD IX, %s", _right );
4408 // outline1("LD DE, %s", _result );
4409 // outline0("LD A, (HL)" );
4410 // outline0("XOR (IX)" );
4411 // outline0("LD (DE), A" );
4412 // outline0("INC HL" );
4413 // outline0("INC DE" );
4414 // outline0("LD A, (HL)" );
4415 // outline0("XOR (IX+1)" );
4416 // outline0("LD (DE), A" );
4417 // outline0("INC HL" );
4418 // outline0("INC DE" );
4419 // outline0("LD A, (HL)" );
4420 // outline0("XOR (IX+2)" );
4421 // outline0("LD (DE), A" );
4422 // outline0("INC HL" );
4423 // outline0("INC DE" );
4424 // outline0("LD A, (HL)" );
4425 // outline0("XOR (IX+3)" );
4426 // outline0("LD (DE), A" );
4427
4428}
4429
4430void cpu_swap_8bit( Environment * _environment, char * _left, char * _right ) {
4431
4432 op_lda( _environment, _left );
4433 op_ldb( _environment, _right );
4434 op_xab( _environment );
4435 op_sta( _environment, _left );
4436 op_sta( _environment, _right );
4437
4438}
4439
4440void cpu_swap_16bit( Environment * _environment, char * _left, char * _right ) {
4441
4442 cpu_swap_8bit( _environment, _left, _right );
4443 cpu_swap_8bit( _environment, address_displacement( _environment, _left, "1" ), address_displacement( _environment, _right, "1" ) );
4444
4445}
4446
4447void cpu_swap_32bit( Environment * _environment, char * _left, char * _right ) {
4448
4449 cpu_swap_8bit( _environment, _left, _right );
4450 cpu_swap_8bit( _environment, address_displacement( _environment, _left, "1" ), address_displacement( _environment, _right, "1" ) );
4451 cpu_swap_8bit( _environment, address_displacement( _environment, _left, "2" ), address_displacement( _environment, _right, "2" ) );
4452 cpu_swap_8bit( _environment, address_displacement( _environment, _left, "3" ), address_displacement( _environment, _right, "3" ) );
4453
4454}
4455
4456void cpu_logical_not_8bit( Environment * _environment, char * _value, char * _result ) {
4457
4458 // NOT(A) = (-1) - A
4459
4460 op_lda_direct( _environment, 0xff );
4461 op_xab( _environment );
4462 op_lda( _environment, _value );
4463 op_subab( _environment );
4464 op_sta( _environment, _result );
4465
4466}
4467
4468void cpu_not_8bit( Environment * _environment, char * _value, char * _result ) {
4469
4470 op_lda_direct( _environment, 0xff );
4471 op_xab( _environment );
4472 op_lda( _environment, _value );
4473 op_subab( _environment );
4474 op_sta( _environment, _result );
4475
4476}
4477
4478void cpu_not_16bit( Environment * _environment, char * _value, char * _result ) {
4479
4480 cpu_not_8bit( _environment, _value, _result );
4481 cpu_not_8bit( _environment, address_displacement( _environment, _value, "1" ), address_displacement( _environment, _result, "1" ) );
4482
4483}
4484
4485void cpu_not_32bit( Environment * _environment, char * _value, char * _result ) {
4486
4487 cpu_not_8bit( _environment, _value, _result );
4488 cpu_not_8bit( _environment, address_displacement( _environment, _value, "1" ), address_displacement( _environment, _result, "1" ) );
4489 cpu_not_8bit( _environment, address_displacement( _environment, _value, "2" ), address_displacement( _environment, _result, "2" ) );
4490 cpu_not_8bit( _environment, address_displacement( _environment, _value, "3" ), address_displacement( _environment, _result, "3" ) );
4491
4492}
4493
4494void cpu_di( Environment * _environment ) {
4495
4496 // outline0("DI" );
4497
4498}
4499
4500void cpu_ei( Environment * _environment ) {
4501
4502 // outline0("EI" );
4503
4504}
4505
4506void cpu_inc( Environment * _environment, char * _variable ) {
4507
4508 op_lda( _environment, _variable );
4509 op_inca( _environment );
4510 op_sta( _environment, _variable );
4511
4512}
4513
4514void cpu_dec( Environment * _environment, char * _variable ) {
4515
4516 op_lda( _environment, _variable );
4517 op_deca( _environment );
4518 op_sta( _environment, _variable );
4519
4520}
4521
4522void cpu_inc_16bit( Environment * _environment, char * _variable ) {
4523
4525
4526 op_lda( _environment, _variable );
4527 op_inca( _environment );
4528 op_sta( _environment, _variable );
4529 op_cp_direct( _environment, 0 );
4530 op_jnz( _environment, label );
4531 op_lda( _environment, address_displacement( _environment, _variable, "1" ) );
4532 op_inca( _environment );
4533 op_sta( _environment, address_displacement( _environment, _variable, "1" ) );
4534 outhead1("%s:", label );
4535
4536}
4537
4538void cpu_inc_32bit( Environment * _environment, char * _variable ) {
4539
4541
4542 op_lda( _environment, _variable );
4543 op_inca( _environment );
4544 op_sta( _environment, _variable );
4545 op_cp_direct( _environment, 0 );
4546 op_jnz( _environment, label );
4547
4548 op_lda( _environment, address_displacement( _environment, _variable, "1" ) );
4549 op_inca( _environment );
4550 op_sta( _environment, address_displacement( _environment, _variable, "1" ) );
4551 op_cp_direct( _environment, 0 );
4552 op_jnz( _environment, label );
4553
4554 op_lda( _environment, address_displacement( _environment, _variable, "2" ) );
4555 op_inca( _environment );
4556 op_sta( _environment, address_displacement( _environment, _variable, "2" ) );
4557 op_cp_direct( _environment, 0 );
4558 op_jnz( _environment, label );
4559
4560 op_lda( _environment, address_displacement( _environment, _variable, "3" ) );
4561 op_inca( _environment );
4562 op_sta( _environment, address_displacement( _environment, _variable, "3" ) );
4563
4564 outhead1("%s:", label );
4565
4566}
4567
4568void cpu_dec_16bit( Environment * _environment, char * _variable ) {
4569
4571
4572 op_lda( _environment, _variable );
4573 op_deca( _environment );
4574 op_sta( _environment, _variable );
4575 op_cp_direct( _environment, 0xff );
4576 op_jnz( _environment, label );
4577
4578 op_lda( _environment, address_displacement( _environment, _variable, "1" ) );
4579 op_deca( _environment );
4580 op_sta( _environment, address_displacement( _environment, _variable, "1" ) );
4581 op_cp_direct( _environment, 0 );
4582 op_jnz( _environment, label );
4583
4584 outhead1("%s:", label );
4585
4586}
4587
4588void cpu_dec_32bit( Environment * _environment, char * _variable ) {
4589
4591
4592 op_lda( _environment, _variable );
4593 op_deca( _environment );
4594 op_sta( _environment, _variable );
4595 op_cp_direct( _environment, 0xff );
4596 op_jnz( _environment, label );
4597
4598 op_lda( _environment, address_displacement( _environment, _variable, "1" ) );
4599 op_deca( _environment );
4600 op_sta( _environment, address_displacement( _environment, _variable, "1" ) );
4601 op_cp_direct( _environment, 0 );
4602 op_jnz( _environment, label );
4603
4604 op_lda( _environment, address_displacement( _environment, _variable, "2" ) );
4605 op_deca( _environment );
4606 op_sta( _environment, address_displacement( _environment, _variable, "2" ) );
4607 op_cp_direct( _environment, 0 );
4608 op_jnz( _environment, label );
4609
4610 op_lda( _environment, address_displacement( _environment, _variable, "3" ) );
4611 op_deca( _environment );
4612 op_sta( _environment, address_displacement( _environment, _variable, "3" ) );
4613
4614 outhead1("%s:", label );
4615
4616}
4617
4618void cpu_mem_move( Environment * _environment, char *_source, char *_destination, char *_size ) {
4619
4621
4622 op_ldx( _environment, _source );
4623 op_ldy( _environment, _destination );
4624 op_ldi( _environment, _size );
4625
4626 outline0("DX");
4627 outline0("DY");
4628
4629 cpu_label( _environment, label );
4630 outline0("IXL")
4631 outline0("IYS")
4632 op_decinz( _environment, label );
4633
4634}
4635
4636void cpu_mem_move_16bit( Environment * _environment, char *_source, char *_destination, char *_size ) {
4637
4639
4640 op_ldx( _environment, _source );
4641 op_ldy( _environment, _destination );
4642 op_ldij( _environment, _size );
4643
4644 outline0("DX");
4645 outline0("DY");
4646
4647 cpu_label( _environment, label );
4648 outline0("IXL")
4649 outline0("IYS")
4650 op_decijnz( _environment, label );
4651
4652}
4653
4654void cpu_mem_move_direct( Environment * _environment, char *_source, char *_destination, char *_size ) {
4655
4656 CRITICAL_UNIMPLEMENTED( "sc61860_mem_move_direct" );
4657
4658 // deploy( duff, src_hw_sc61860_duff_asm );
4659
4660 // outline1("LD HL, %s", _source);
4661 // outline1("LD DE, %s", _destination);
4662 // outline1("LD A, (%s)", _size);
4663 // outline0("LD C, A");
4664 // outline0("LD B, 0");
4665 // outline0("CALL DUFFDEVICE");
4666
4667}
4668
4669void cpu_mem_move_direct2( Environment * _environment, char *_source, char *_destination, char *_size ) {
4670
4671 CRITICAL_UNIMPLEMENTED( "sc61860_mem_move_direct2" );
4672
4673 // deploy( duff, src_hw_sc61860_duff_asm );
4674
4675 // outline1("LD HL, (%s)", _source);
4676 // outline1("LD DE, %s", _destination);
4677 // outline1("LD BC, (%s)", _size);
4678 // outline0("CALL DUFFDEVICE");
4679
4680}
4681
4682void cpu_mem_move_direct2_size( Environment * _environment, char *_source, char *_destination, int _size ) {
4683
4684 CRITICAL_UNIMPLEMENTED( "sc61860_mem_move_direct2_size" );
4685
4686 // deploy( duff, src_hw_sc61860_duff_asm );
4687
4688 // outline1("LD HL, (%s)", _source);
4689 // outline1("LD DE, %s", _destination);
4690 // outline1("LD BC, 0x%4.4x", _size);
4691 // outline0("CALL DUFFDEVICE");
4692
4693}
4694
4695void cpu_mem_move_size( Environment * _environment, char *_source, char *_destination, int _size ) {
4696
4697 if ( _size > 0 ) {
4698
4700
4701 op_ldij_direct( _environment, _size );
4702 op_ldx( _environment, _source );
4703 op_ldy( _environment, _destination );
4704
4705 outline0("DX");
4706 outline0("DY");
4707
4708 cpu_label( _environment, label );
4709 outline0("IXL")
4710 outline0("LDD")
4711 outline0("IYS")
4712 outline0("STD")
4713 op_decijnz( _environment, label );
4714
4715 }
4716
4717}
4718
4719void cpu_mem_move_direct_size( Environment * _environment, char *_source, char *_destination, int _size ) {
4720
4721 CRITICAL_UNIMPLEMENTED( "sc61860_mem_move_direct_size" );
4722
4723 if ( _size > 0 ) {
4724
4725 // deploy( duff, src_hw_sc61860_duff_asm );
4726
4727 // outline1("LD HL, %s", _source);
4728 // outline1("LD DE, %s", _destination);
4729 // outline1("LD A, 0x%2.2x", ( _size & 0xff ) );
4730 // outline0("LD C, A");
4731 // outline1("LD B, 0x%2.2x", ( _size >> 8 ) & 0xff );
4732 // outline0("CALL DUFFDEVICE");
4733 }
4734
4735}
4736
4737void cpu_mem_move_direct_indirect_size( Environment * _environment, char *_source, char *_destination, int _size ) {
4738
4739 CRITICAL_UNIMPLEMENTED( "sc61860_mem_move_direct_indirect_size" );
4740
4741 if ( _size ) {
4742
4743 // deploy( duff, src_hw_sc61860_duff_asm );
4744
4745 // outline1("LD HL, %s", _source);
4746 // outline1("LD DE, (%s)", _destination);
4747 // outline1("LD A, 0x%2.2x", ( _size & 0xff ) );
4748 // outline0("LD C, A");
4749 // outline1("LD B, 0x%2.2x", ( _size >> 8 ) & 0xff );
4750 // outline0("CALL DUFFDEVICE");
4751 }
4752
4753}
4754
4755void cpu_mem_move_indirect_direct_size( Environment * _environment, char *_source, char *_destination, int _size ) {
4756
4757 CRITICAL_UNIMPLEMENTED( "sc61860_mem_move_indirect_direct_size" );
4758
4759 if ( _size ) {
4760
4761 // deploy( duff, src_hw_sc61860_duff_asm );
4762
4763 // outline1("LD HL, (%s)", _source);
4764 // outline1("LD DE, %s", _destination);
4765 // outline1("LD A, 0x%2.2x", ( _size & 0xff ) );
4766 // outline0("LD C, A");
4767 // outline1("LD B, 0x%2.2x", ( _size >> 8 ) & 0xff );
4768 // outline0("CALL DUFFDEVICE");
4769 }
4770
4771}
4772
4773void cpu_compare_memory( Environment * _environment, char *_source, char *_destination, char *_size, char * _result, int _equal ) {
4774
4775 CRITICAL_UNIMPLEMENTED( "sc61860_compare_memory" );
4776
4778
4779 // outline1("LD A, (%s)", _size);
4780 // outline0("CP 0");
4781 // outline1("JR Z, %sequal", label);
4782 // outline0("LD C, A");
4783 // outline1("LD HL, (%s)", _source);
4784 // outline1("LD DE, (%s)", _destination);
4785 // outhead1("%s:", label );
4786 // outline0("LD A, (HL)");
4787 // outline0("LD B, A");
4788 // outline0("LD A, (DE)");
4789 // outline0("CP B");
4790 // outline1("JR NZ, %sdiff", label);
4791 // outline0("INC DE");
4792 // outline0("INC HL");
4793 // outline0("DEC C");
4794 // outline1("JR NZ, %s", label);
4795 // outhead1("%sequal:", label );
4796 // outline1("LD A, 0x%2.2x", _equal ? 255 : 0 );
4797 // outline1("LD (%s), A", _result );
4798 // outline1("JMP %sfinal", label );
4799 // outhead1("%sdiff:", label );
4800 // outline1("LD A, 0x%2.2x", _equal ? 0 : 255 );
4801 // outline1("LD (%s), A", _result );
4802 // outhead1("%sfinal:", label );
4803
4804}
4805
4806void cpu_compare_memory_size( Environment * _environment, char *_source, char *_destination, int _size, char * _result, int _equal ) {
4807
4808 CRITICAL_UNIMPLEMENTED( "sc61860_compare_memory_size" );
4809
4811
4812 // outline1("LD HL, (%s)", _source);
4813 // outline1("LD DE, (%s)", _destination);
4814 // outline1("LD A, 0x%2.2x", ( _size & 0xff ) );
4815 // outline0("LD C, A");
4816 // outhead1("%s:", label );
4817 // outline0("LD A, (HL)");
4818 // outline0("LD B, A");
4819 // outline0("LD A, (DE)");
4820 // outline0("CP B");
4821 // outline1("JR NZ, %sdiff", label);
4822 // outline0("INC DE");
4823 // outline0("INC HL");
4824 // outline0("DEC C");
4825 // outline1("JR NZ, %s", label);
4826 // outline1("LD A, 0x%2.2x", _equal ? 255 : 0 );
4827 // outline1("LD (%s), A", _result );
4828 // outline1("JMP %sfinal", label );
4829 // outhead1("%sdiff:", label );
4830 // outline1("LD A, 0x%2.2x", _equal ? 0 : 255 );
4831 // outline1("LD (%s), A", _result );
4832 // outhead1("%sfinal:", label );
4833
4834}
4835
4836void cpu_less_than_memory( Environment * _environment, char *_source, char *_destination, char *_size, char * _result, int _equal ) {
4837
4838 CRITICAL_UNIMPLEMENTED( "sc61860_less_than_memory" );
4839
4841
4842 // outline1("LD HL, (%s)", _source);
4843 // outline1("LD DE, (%s)", _destination);
4844 // outline1("LD A, (%s)", _size);
4845 // outline0("LD C, A");
4846 // outhead1("%s:", label );
4847 // outline0("LD A, (DE)");
4848 // outline0("LD B, A");
4849 // outline0("LD A, (HL)");
4850 // outline0("CP B");
4851 if ( _equal ) {
4852 // outline1("JR Z, %seq", label);
4853 }
4854 // outline1("JR NC, %sdiff", label);
4855 if ( ! _equal ) {
4856 // outline1("JR Z, %sdiff", label);
4857 }
4858 // outhead1("%seq:", label );
4859 // outline0("INC DE");
4860 // outline0("INC HL");
4861 // outline0("DEC C");
4862 // outline1("JR NZ, %s", label);
4863 // outline0("LD A, 0xff" );
4864 // outline1("LD (%s), A", _result );
4865 // outline1("JMP %sfinal", label );
4866 // outhead1("%sdiff:", label );
4867 // outline0("LD A, 0" );
4868 // outline1("LD (%s), A", _result );
4869 // outhead1("%sfinal:", label );
4870
4871}
4872
4873void cpu_less_than_memory_size( Environment * _environment, char *_source, char *_destination, int _size, char * _result, int _equal ) {
4874
4875 CRITICAL_UNIMPLEMENTED( "sc61860_less_than_memory_size" );
4876
4878
4879 // outline1("LD HL, (%s)", _source);
4880 // outline1("LD DE, (%s)", _destination);
4881 // outline1("LD A, 0x%2.2x", ( _size & 0xff ) );
4882 // outline0("LD C, A");
4883 // outhead1("%s:", label );
4884 // outline0("LD A, (DE)");
4885 // outline0("LD B, A");
4886 // outline0("LD A, (HL)");
4887 // outline0("CP B");
4888 if ( _equal ) {
4889 // outline1("JR Z, %seq", label);
4890 }
4891 // outline1("JR NC, %sdiff", label);
4892 if ( ! _equal ) {
4893 // outline1("JR Z, %sdiff", label);
4894 }
4895 // outhead1("%seq:", label );
4896 // outline0("INC DE");
4897 // outline0("INC HL");
4898 // outline0("DEC C");
4899 // outline1("JR NZ, %s", label);
4900 // outline0("LD A, 0xff" );
4901 // outline1("LD (%s), A", _result );
4902 // outline1("JMP %sfinal", label );
4903 // outhead1("%sdiff:", label );
4904 // outline0("LD A, 0" );
4905 // outline1("LD (%s), A", _result );
4906 // outhead1("%sfinal:", label );
4907
4908}
4909
4910void cpu_greater_than_memory( Environment * _environment, char *_source, char *_destination, char *_size, char * _result, int _equal ) {
4911
4912 CRITICAL_UNIMPLEMENTED( "sc61860_greater_than_memory" );
4913
4915
4916 // outline1("LD HL, (%s)", _source);
4917 // outline1("LD DE, (%s)", _destination);
4918 // outline1("LD A, (%s)", _size);
4919 // outline0("LD C, A");
4920 // outhead1("%s:", label );
4921 // outline0("LD A, (DE)");
4922 // outline0("LD B, A");
4923 // outline0("LD A, (HL)");
4924 // outline0("CP B");
4925 if ( !_equal ) {
4926 // outline1("JR Z, %sdiff", label);
4927 }
4928 // outline1("JR C, %sdiff", label);
4929 // outline0("INC DE");
4930 // outline0("INC HL");
4931 // outline0("DEC C");
4932 // outline1("JR NZ, %s", label);
4933 // outline1("LD A, 0x%2.2x", 255 );
4934 // outline1("LD (%s), A", _result );
4935 // outline1("JMP %sfinal", label );
4936 // outhead1("%sdiff:", label );
4937 // outline1("LD A, 0x%2.2x", 0 );
4938 // outline1("LD (%s), A", _result );
4939 // outhead1("%sfinal:", label );
4940
4941}
4942
4943void cpu_greater_than_memory_size( Environment * _environment, char *_source, char *_destination, int _size, char * _result, int _equal ) {
4944
4945 CRITICAL_UNIMPLEMENTED( "sc61860_greater_than_memory_size" );
4946
4948
4949 // outline1("LD HL, (%s)", _source);
4950 // outline1("LD DE, (%s)", _destination);
4951 // outline1("LD A, 0x%2.2x", ( _size & 0xff ) );
4952 // outline0("LD C, A");
4953 // outhead1("%s:", label );
4954 // outline0("LD A, (DE)");
4955 // outline0("LD B, A");
4956 // outline0("LD A, (HL)");
4957 // outline0("CP B");
4958 if ( ! _equal ) {
4959 // outline1("JR Z, %sdiff", label);
4960 }
4961 // outline1("JR C, %sdiff", label);
4962 // outline0("INC DE");
4963 // outline0("INC HL");
4964 // outline0("DEC C");
4965 // outline1("JR NZ, %s", label);
4966 // outline1("LD A, 0x%2.2x", 255 );
4967 // outline1("LD (%s), A", _result );
4968 // outline1("JMP %sfinal", label );
4969 // outhead1("%sdiff:", label );
4970 // outline1("LD A, 0x%2.2x", 0 );
4971 // outline1("LD (%s), A", _result );
4972 // outhead1("%sfinal:", label );
4973
4974}
4975
4976void cpu_math_add_16bit_with_8bit( Environment * _environment, char *_source, char *_destination, char *_other ) {
4977
4978 outline0("LIA 0");
4979 outline0("EXAB");
4980 outline1("LIDP %s", _source);
4981 outline0("LDD");
4982 outline0("LIP 0");
4983 outline0("EXAM");
4984 outline1("LIDP %s", address_displacement( _environment, _source, "1" ) );
4985 outline0("LDD");
4986 outline0("LIP 1");
4987 outline0("EXAM");
4988 outline1("LIDP %s", _destination );
4989 outline0("LDD");
4990 outline0("LIP 0");
4991 outline0("ADB");
4992 if ( _other ) {
4993 outline1("LIDP %s", _other );
4994 } else {
4995 outline1("LIDP %s", _destination );
4996 }
4997 outline0("LIP 0");
4998 outline0("LDM");
4999 outline0("STD");
5000 if ( _other ) {
5001 outline1("LIDP %s", address_displacement( _environment, _other, "1" ) );
5002 } else {
5003 outline1("LIDP %s", address_displacement( _environment, _destination, "1" ) );
5004 }
5005 outline0("LIP 1");
5006 outline0("LDM");
5007 outline0("STD");
5008
5009}
5010
5011void cpu_math_sub_16bit_with_8bit( Environment * _environment, char *_source, char *_destination, char *_other ) {
5012
5013 CRITICAL_UNIMPLEMENTED( "sc61860_math_sub_16bit_with_8bit" );
5014
5015 // outline1("LD HL, (%s)", _source );
5016 // outline0("LD DE, 0" );
5017 // outline1("LD A, (%s)", _destination );
5018 // outline0("LD E, A" );
5019 // outline0("SBC HL, DE" );
5020 if ( _other ) {
5021 // outline1("LD (%s), HL", _other );
5022 } else {
5023 // outline1("LD (%s), HL", _destination );
5024 }
5025
5026}
5027
5028void cpu_uppercase( Environment * _environment, char *_source, char *_size, char *_result ) {
5029
5030 CRITICAL_UNIMPLEMENTED( "sc61860_uppercase" );
5031
5033
5034 // outline1("LD A, (%s)", _size);
5035 // outline0("LD C, A" );
5036 // outline1("LD HL, (%s)", _source );
5037 if ( _result ) {
5038 // outline1("LD DE, (%s)", _result );
5039 } else {
5040 // outline1("LD DE, (%s)", _source );
5041 }
5042 // outhead1("%supper:", label );
5043 // outline0("LD A, (HL)" );
5044
5045 // outline0("CP 97");
5046 // outline1("JR C, %snext", label);
5047
5048 // outline0("CP 122");
5049 // outline1("JR NC, %snext", label);
5050
5051 // outline0("SUB A, 32");
5052 // outline0("LD (DE), A" );
5053 // outline1("JP %s// done", label );
5054
5055 // outhead1("%snext:", label );
5056 // outline0("LD (DE), A" );
5057 // outhead1("%s// done:", label );
5058 // outline0("INC HL" );
5059 // outline0("INC DE" );
5060 // outline0("DEC C" );
5061 // outline0("LD A, C" );
5062 // outline0("CP 0" );
5063 // outline1("JR NZ, %supper", label);
5064
5065}
5066
5067void cpu_lowercase( Environment * _environment, char *_source, char *_size, char *_result ) {
5068
5070
5071 CRITICAL_UNIMPLEMENTED( "sc61860_lowercase" );
5072
5073 // outline1("LD A, (%s)", _size);
5074 // outline0("LD C, A" );
5075 // outline1("LD HL, (%s)", _source );
5076 if ( _result ) {
5077 // outline1("LD DE, (%s)", _result );
5078 } else {
5079 // outline1("LD DE, (%s)", _source );
5080 }
5081 // outhead1("%slower:", label );
5082 // outline0("LD A, (HL)" );
5083
5084 // outline0("CP 65");
5085 // outline1("JR C, %snext", label);
5086
5087 // outline0("CP 91");
5088 // outline1("JR NC, %snext", label);
5089
5090 // outline0("ADC A, 31");
5091 // outline0("LD (DE), A" );
5092 // outline1("JP %s// done", label );
5093 // outhead1("%snext:", label );
5094 // outline0("LD (DE), A" );
5095 // outhead1("%s// done:", label );
5096 // outline0("INC HL" );
5097 // outline0("INC DE" );
5098 // outline0("DEC C" );
5099 // outline0("LD A, C" );
5100 // outline0("CP 0" );
5101 // outline1("JR NZ, %slower", label);
5102
5103}
5104
5105void cpu_convert_string_into_8bit( Environment * _environment, char * _string, char * _len, char * _value ) {
5106
5107 Variable * temp = variable_temporary( _environment, VT_WORD, "(temp)" );
5108
5109 cpu_convert_string_into_16bit( _environment, _string, _len, temp->realName );
5110
5111 cpu_move_8bit( _environment, temp->realName, _value );
5112
5113}
5114
5115void cpu_convert_string_into_16bit( Environment * _environment, char * _string, char * _len, char * _value ) {
5116
5117 CRITICAL_UNIMPLEMENTED( "sc61860_convert_string_into_16bit" );
5118
5120
5121 // outline1("LD A, (%s)", _len );
5122 // outline0("LD IX, 0" );
5123 // outline0("LD IXL, A" );
5124
5125 // outline0("LD A, 0" );
5126 // outline1("LD (%s), A", _value );
5127 // outline1("LD (%s+1), A", _value );
5128
5129 // outline1("LD HL, (%s)", _string );
5130
5131 // outhead1("%srepeat:", label );
5132
5133 // outline0("LD A, (HL)" );
5134 // outline0("CP 0x40" );
5135 // outline1("JR NC, %send", label);
5136 // outline0("CP 0x30" );
5137 // outline1("JR C, %send", label);
5138 // outline0("SBC A, 0x30" );
5139
5140 // outline0("PUSH AF" );
5141 // outline1("LD A, (%s)", address_displacement(_environment, _value, "1") );
5142 // outline0("LD B, A" );
5143 // outline1("LD A, (%s)", _value );
5144 // outline0("LD C, A" );
5145 // outline0("POP AF" );
5146 // outline0("LD E, A" );
5147 // outline0("LD D, 0" );
5148 // outline0("PUSH HL" );
5149 // outline0("LD HL, 0" );
5150 // outline0("ADC HL, DE" );
5151 // outline0("ADC HL, BC" );
5152 // outline1("LD (%s), HL", _value );
5153 // outline0("POP HL" );
5154
5155
5156 // MULT x 10
5157
5158 // outline0("INC HL" );
5159 // outline0("DEC IX" );
5160 // outline0("LD A, 0" );
5161 // outline0("CP IXL" );
5162 // outline1("JR Z,%send", label );
5163
5164 // outline0("PUSH HL" );
5165
5166 // outline1("LD DE, (%s)", _value );
5167 // outline0("LD A, 10" );
5168 // outline0("LD B, 8" );
5169 // outline0("LD HL, 0" );
5170 // outline0("ADD HL, HL" );
5171 // outline0("RLCA" );
5172 // outline0("JR NC,0x+3" );
5173 // outline0("ADD HL, DE" );
5174 // outline0("DJNZ 0x-5" );
5175 // outline1("LD (%s), HL", _value );
5176
5177 // outline0("POP HL" );
5178
5179 // outline1("JMP %srepeat", label );
5180
5181 // outhead1("%send:", label );
5182
5183}
5184
5185void cpu_fill_indirect( Environment * _environment, char * _address, char * _size, char * _pattern, int _size_size ) {
5186
5187 CRITICAL_UNIMPLEMENTED( "sc61860_fill_indirect" );
5188
5190
5191 // Use the current bitmap address as starting address for filling routine.
5192 // outline1("LD DE, (%s)", _address);
5193 // outline1("LD HL, (%s)", _pattern);
5194
5195 // Fill the bitmap with the given pattern.
5196 if ( _size_size >= 16 ) {
5197 // outline1("LD A, (%s)", _size);
5198 // outline0("LD C, A" );
5199 // outline1("LD A, (%s+1)", _size);
5200 // outline0("LD B, A" );
5201 // outhead1("%sx:", label);
5202 // outline0("LD A, (HL)");
5203 // outline0("LD (DE),A");
5204 // outline0("INC DE");
5205 // outline0("DEC BC");
5206 // outline0("LD A, B");
5207 // outline0("OR C");
5208 // outline1("JR NZ,%sx", label);
5209 } else {
5210 // outline1("LD A, (%s)", _size);
5211 // outline0("LD C, A" );
5212 // outhead1("%sx:", label);
5213 // outline0("LD A, (HL)");
5214 // outline0("LD (DE),A");
5215 // outline0("INC DE");
5216 // outline0("DEC C");
5217 // outline1("JR NZ,%sx", label);
5218 }
5219
5220}
5221
5222void cpu_flip_8bit( Environment * _environment, char * _source, char * _destination ) {
5223
5224 CRITICAL_UNIMPLEMENTED( "sc61860_flip_8bit" );
5225
5226 // no_inline( cpu_flip )
5227
5228 // embedded( cpu_flip, src_hw_sc61860_cpu_flip_asm );
5229
5230 // outline1("LD HL, (%s)", _source);
5231 // outline1("LD DE, (%s)", _destination);
5232 // outline1("LD A, (%s)", _size);
5233 // outline0("CALL CPUFLIP");
5234
5235 // done( )
5236
5237}
5238
5239void cpu_move_8bit_indirect( Environment * _environment, char *_source, char * _value ) {
5240
5241 CRITICAL_UNIMPLEMENTED( "sc61860_move_8bit_indirect" );
5242
5243 // outline1("LD DE, (%s)", _value);
5244 // outline1("LD A, (%s)", _source);
5245 // outline0("LD (DE), A");
5246
5247}
5248
5249void cpu_move_8bit_with_offset2( Environment * _environment, char *_source, char * _value, char * _offset ) {
5250
5251 CRITICAL_UNIMPLEMENTED( "sc61860_move_8bit_with_offset2" );
5252
5253 // outline1("LD HL, %s", _value);
5254 // outline1("LD A, (%s)", _offset );
5255 // outline0("LD E, A" );
5256 // outline0("LD D, 0" );
5257 // outline0("ADD HL, DE" );
5258 // outline1("LD A, (%s)", _source);
5259 // outline0("LD (HL), A");
5260
5261}
5262
5263void cpu_move_8bit_indirect_with_offset( Environment * _environment, char *_source, char * _value, int _offset ) {
5264
5265 CRITICAL_UNIMPLEMENTED( "sc61860_move_8bit_indirect_with_offset" );
5266
5267 // outline1("LD HL, (%s)", _value);
5268 // outline1("LD DE, 0x%2.2x", ( _offset & 0xff ) );
5269 // outline0("ADD HL, DE" );
5270 // outline1("LD A, (%s)", _source);
5271 // outline0("LD (HL), A");
5272
5273}
5274
5275void cpu_move_8bit_indirect2( Environment * _environment, char * _value, char *_source ) {
5276
5277 CRITICAL_UNIMPLEMENTED( "sc61860_move_8bit_indirect2" );
5278
5279 // outline1("LD DE, (%s)", _value);
5280 // outline0("LD A, (DE)");
5281 // outline1("LD (%s), A", _source);
5282
5283}
5284
5285void cpu_move_8bit_indirect2_8bit( Environment * _environment, char * _value, char * _offset, char *_source ) {
5286
5287 CRITICAL_UNIMPLEMENTED( "sc61860_move_8bit_indirect2_8bit" );
5288
5289 // outline1("LD HL, %s", _value);
5290 // outline1("LD A, (%s)", _offset);
5291 // outline0("LD E, A");
5292 // outline0("LD A, 0");
5293 // outline0("LD D, A");
5294 // outline0("ADD HL, DE");
5295 // outline0("LD A, (HL)");
5296 // outline1("LD (%s), A", _source );
5297
5298}
5299
5300void cpu_move_8bit_indirect2_16bit( Environment * _environment, char * _value, char * _offset, char *_source ) {
5301
5302 CRITICAL_UNIMPLEMENTED( "sc61860_move_8bit_indirect2_16bit" );
5303
5304 // outline1("LD HL, %s", _value);
5305 // outline1("LD DE, (%s)", _offset);
5306 // outline0("ADD HL, DE");
5307 // outline0("LD A, (HL)");
5308 // outline1("LD (%s), A", _source );
5309
5310}
5311
5312void cpu_move_16bit_indirect( Environment * _environment, char *_source, char * _value ) {
5313
5314 CRITICAL_UNIMPLEMENTED( "sc61860_move_16bit_indirect" );
5315
5316 // outline1("LD DE, (%s)", _value);
5317 // outline1("LD HL, (%s)", _source);
5318 // outline0("LD A, L");
5319 // outline0("LD (DE), A");
5320 // outline0("INC DE");
5321 // outline0("LD A, H");
5322 // outline0("LD (DE), A");
5323
5324}
5325
5326void cpu_move_16bit_indirect2( Environment * _environment, char * _value, char *_source ) {
5327
5328 CRITICAL_UNIMPLEMENTED( "sc61860_move_16bit_indirect2" );
5329
5330 // outline1("LD DE, (%s)", _value);
5331 // outline0("LD A, (DE)");
5332 // outline1("LD (%s), A", _source);
5333 // outline0("INC DE");
5334 // outline0("LD A, (DE)");
5335 // outline1("LD (%s), A", address_displacement(_environment, _source, "1"));
5336
5337}
5338
5339void cpu_move_16bit_indirect2_8bit( Environment * _environment, char * _value, char * _offset, char *_source ) {
5340
5341 CRITICAL_UNIMPLEMENTED( "sc61860_move_16bit_indirect2_8bit" );
5342
5343 // outline1("LD HL, %s", _value);
5344 // outline1("LD A, (%s)", _offset);
5345 // outline0("LD E, A");
5346 // outline0("LD A, 0");
5347 // outline0("LD D, A");
5348 // outline0("ADD HL, DE");
5349 // outline0("ADD HL, DE");
5350 // outline0("LD A, (HL)");
5351 // outline1("LD (%s), A", _source );
5352 // outline0("INC HL");
5353 // outline0("LD A, (HL)");
5354 // outline1("LD (%s), A", address_displacement(_environment, _source, "1") );
5355
5356}
5357
5358void cpu_move_32bit_indirect( Environment * _environment, char *_source, char * _value ) {
5359
5360 CRITICAL_UNIMPLEMENTED( "sc61860_move_32bit_indirect" );
5361
5362 // outline1("LD DE, (%s)", _value);
5363 // outline1("LD HL, (%s)", _source);
5364 // outline0("LD A, L");
5365 // outline0("LD (DE), A");
5366 // outline0("INC DE");
5367 // outline0("LD A, H");
5368 // outline0("LD (DE), A");
5369 // outline0("INC DE");
5370 // outline1("LD HL, (%s)", address_displacement(_environment, _source, "2"));
5371 // outline0("LD A, L");
5372 // outline0("LD (DE), A");
5373 // outline0("INC DE");
5374 // outline0("LD A, H");
5375 // outline0("LD (DE), A");
5376 // outline0("INC DE");
5377
5378}
5379
5380void cpu_move_nbit_indirect( Environment * _environment, int _n, char *_source, char * _value ) {
5381
5382 CRITICAL_UNIMPLEMENTED( "sc61860_move_nbit_indirect" );
5383
5384 // outline1("LD DE, (%s)", _value);
5385
5386 char step[MAX_TEMPORARY_STORAGE];
5387 char step2[MAX_TEMPORARY_STORAGE];
5388
5389 int stepIndex = 0;
5390 while( _n ) {
5391 sprintf( step, "%d", stepIndex );
5392 sprintf( step2, "%d", stepIndex+2 );
5393 if ( _n >= 32 ) {
5394 // outline1("LD HL, (%s)", address_displacement(_environment, _source, step));
5395 // outline0("LD A, L");
5396 // outline0("LD (DE), A");
5397 // outline0("INC DE");
5398 // outline0("LD A, H");
5399 // outline0("LD (DE), A");
5400 // outline0("INC DE");
5401 // outline1("LD HL, (%s)", address_displacement(_environment, _source, step2));
5402 // outline0("LD A, L");
5403 // outline0("LD (DE), A");
5404 // outline0("INC DE");
5405 // outline0("LD A, H");
5406 // outline0("LD (DE), A");
5407 // outline0("INC DE");
5408 stepIndex += 4;
5409 _n -= 32;
5410 break;
5411 } else {
5412 switch( _n ) {
5413 case 32: case 31: case 30: case 29:
5414 case 28: case 27: case 26: case 25:
5415 // outline1("LD HL, (%s)", address_displacement(_environment, _source, step));
5416 // outline0("LD A, L");
5417 // outline0("LD (DE), A");
5418 // outline0("INC DE");
5419 // outline0("LD A, H");
5420 // outline0("LD (DE), A");
5421 // outline0("INC DE");
5422 // outline1("LD HL, (%s)", address_displacement(_environment, _source, step2));
5423 // outline0("LD A, L");
5424 // outline0("LD (DE), A");
5425 // outline0("INC DE");
5426 // outline0("LD A, H");
5427 // outline0("LD (DE), A");
5428 // outline0("INC DE");
5429 break;
5430 case 24: case 23: case 22: case 21:
5431 case 20: case 19: case 18: case 17:
5432 // outline1("LD HL, (%s)", address_displacement(_environment, _source, step));
5433 // outline0("LD A, L");
5434 // outline0("LD (DE), A");
5435 // outline0("INC DE");
5436 // outline0("LD A, H");
5437 // outline0("LD (DE), A");
5438 // outline0("INC DE");
5439 // outline1("LD A, (%s)", address_displacement(_environment, _source, step2));
5440 // outline0("LD (DE), A");
5441 // outline0("INC DE");
5442 break;
5443 case 16: case 15: case 14: case 13:
5444 case 12: case 11: case 10: case 9:
5445 // outline1("LD HL, (%s)", address_displacement(_environment, _source, step));
5446 // outline0("LD A, L");
5447 // outline0("LD (DE), A");
5448 // outline0("INC DE");
5449 // outline0("LD A, H");
5450 // outline0("LD (DE), A");
5451 // outline0("INC DE");
5452 break;
5453 case 8: case 7: case 6: case 5:
5454 case 4: case 3: case 2: case 1:
5455 // outline1("LD A, (%s)", address_displacement(_environment, _source, step));
5456 // outline0("LD (DE), A");
5457 // outline0("INC DE");
5458 break;
5459 }
5460 _n = 0;
5461 }
5462 }
5463}
5464
5465void cpu_move_32bit_indirect2( Environment * _environment, char * _value, char *_source ) {
5466
5467 CRITICAL_UNIMPLEMENTED( "sc61860_move_32bit_indirect2" );
5468
5469 // outline1("LD DE, (%s)", _value);
5470 // outline0("LD A, (DE)");
5471 // outline0("LD L, A");
5472 // outline0("INC DE");
5473 // outline0("LD A, (DE)");
5474 // outline0("LD H, A");
5475 // outline0("INC DE");
5476 // outline1("LD (%s), HL", _source);
5477 // outline0("LD A, (DE)");
5478 // outline0("LD L, A");
5479 // outline0("INC DE");
5480 // outline0("LD A, (DE)");
5481 // outline0("LD H, A");
5482 // outline0("INC DE");
5483 // outline1("LD (%s), HL", address_displacement( _environment, _source, "2" ) );
5484
5485}
5486
5487void cpu_move_nbit_indirect2( Environment * _environment, int _n, char * _value, char *_source ) {
5488
5489 CRITICAL_UNIMPLEMENTED( "sc61860_move_nbit_indirect2" );
5490
5491 // outline1("LD DE, (%s)", _value);
5492
5493 char step[MAX_TEMPORARY_STORAGE];
5494 char step2[MAX_TEMPORARY_STORAGE];
5495
5496 int stepIndex = 0;
5497 while( _n ) {
5498 sprintf( step, "%d", stepIndex );
5499 sprintf( step2, "%d", stepIndex+2 );
5500 if ( _n >= 32 ) {
5501 // outline0("LD A, (DE)");
5502 // outline0("LD L, A");
5503 // outline0("INC DE");
5504 // outline0("LD A, (DE)");
5505 // outline0("LD H, A");
5506 // outline0("INC DE");
5507 // outline1("LD (%s), HL", address_displacement( _environment, _source, step ) );
5508 // outline0("LD A, (DE)");
5509 // outline0("LD L, A");
5510 // outline0("INC DE");
5511 // outline0("LD A, (DE)");
5512 // outline0("LD H, A");
5513 // outline0("INC DE");
5514 // outline1("LD (%s), HL", address_displacement( _environment, _source, step2 ) );
5515 stepIndex += 4;
5516 _n -= 32;
5517 break;
5518 } else {
5519 switch( _n ) {
5520 case 32: case 31: case 30: case 29:
5521 case 28: case 27: case 26: case 25:
5522 // outline0("LD A, (DE)");
5523 // outline0("LD L, A");
5524 // outline0("INC DE");
5525 // outline0("LD A, (DE)");
5526 // outline0("LD H, A");
5527 // outline0("INC DE");
5528 // outline1("LD (%s), HL", address_displacement( _environment, _source, step ) );
5529 // outline0("LD A, (DE)");
5530 // outline0("LD L, A");
5531 // outline0("INC DE");
5532 // outline0("LD A, (DE)");
5533 // outline0("LD H, A");
5534 // outline0("INC DE");
5535 // outline1("LD (%s), HL", address_displacement( _environment, _source, step2 ) );
5536 break;
5537 case 24: case 23: case 22: case 21:
5538 case 20: case 19: case 18: case 17:
5539 // outline0("LD A, (DE)");
5540 // outline0("LD L, A");
5541 // outline0("INC DE");
5542 // outline0("LD A, (DE)");
5543 // outline0("LD H, A");
5544 // outline0("INC DE");
5545 // outline1("LD (%s), HL", address_displacement( _environment, _source, step ) );
5546 // outline0("LD A, (DE)");
5547 // outline0("INC DE");
5548 // outline1("LD (%s), A", address_displacement( _environment, _source, step2 ) );
5549 break;
5550 case 16: case 15: case 14: case 13:
5551 case 12: case 11: case 10: case 9:
5552 // outline0("LD A, (DE)");
5553 // outline0("LD L, A");
5554 // outline0("INC DE");
5555 // outline0("LD A, (DE)");
5556 // outline0("LD H, A");
5557 // outline0("INC DE");
5558 // outline1("LD (%s), HL", address_displacement( _environment, _source, step ) );
5559 break;
5560 case 8: case 7: case 6: case 5:
5561 case 4: case 3: case 2: case 1:
5562 // outline0("LD A, (DE)");
5563 // outline0("INC DE");
5564 // outline1("LD (%s), A", address_displacement( _environment, _source, step ) );
5565 break;
5566 }
5567 _n = 0;
5568 }
5569 }
5570
5571}
5572
5573void cpu_math_div_32bit_to_16bit( Environment * _environment, char *_source, char *_destination, char *_other, char * _other_remainder, int _signed ) {
5574
5575 CRITICAL_UNIMPLEMENTED( "sc61860_math_div_32bit_to_16bit" );
5576
5578
5579 if ( _signed ) {
5580
5581 // outline1("LD A, (%s)", address_displacement(_environment, _source, "3"));
5582 // outline0("ANIA 0x80");
5583 // outline0("CP 0" );
5584 // outline0("PUSH AF");
5585 // outline1("JR Z,%spositive", label);
5586 cpu_complement2_32bit( _environment, _source, NULL );
5587 // outhead1("%spositive:", label);
5588 // outline1("LD A, (%s)", address_displacement(_environment, _destination, "1"));
5589 // outline0("ANIA 0x80");
5590 // outline0("CP 0" );
5591 // outline0("PUSH AF");
5592 // outline1("JR Z,%spositive2", label);
5593 cpu_complement2_16bit( _environment, _destination, NULL );
5594 // outhead1("%spositive2:", label);
5595
5596 // // outline1("LD HL, %s", _source);
5597 // // outline0("LD A, (HL)");
5598 // // outline0("PUSH AF");
5599 // // outline0("POP IX");
5600 // // outline0("INC HL");
5601 // // outline0("INC HL");
5602 // // outline0("LD A, (HL)");
5603 // // outline0("LD C, A");
5604 // // outline0("INC HL");
5605 // // outline0("LD A, (HL)");
5606 // // outline1("LD DE, (%s)", _destination);
5607
5608 // // outline0("LD HL, 0");
5609 // // outline0("LD B, 32");
5610 // // outhead1("%sloop:", label);
5611 // // outline0("ADD IX, IX");
5612 // // outline0("RL C");
5613 // // outline0("RLA");
5614 // // outline0("ADC HL, HL");
5615 // // outline1("JR C, %soverflow", label);
5616 // // outline0("SBC HL, DE");
5617 // // outline1("JR NC, %ssetbit", label);
5618 // // outline0("ADD HL, DE");
5619 // // outline1("DJNZ %sloop", label);
5620 // // outline1("JMP %send", label);
5621 // // outhead1("%soverflow:", label);
5622 // // outline0("OR A");
5623 // // outline0("SBC HL, DE");
5624 // // outhead1("%ssetbit:", label);
5625 // // outline0("INC IXL");
5626 // // outline1("DJNZ %sloop", label);
5627 // // outhead1("%send:", label);
5628 // // outline1("LD (%s), HL", _other_remainder);
5629 // // outline1("LD HL, %s", _other);
5630 // // outline0("PUSH AF");
5631 // // outline0("PUSH IX");
5632 // // outline0("POP AF");
5633 // // outline0("LD (HL), A");
5634 // // outline0("POP AF");
5635 // // outline0("INC HL");
5636 // // outline0("INC HL");
5637 // // outline0("INC HL");
5638 // // outline0("LD (HL), A");
5639 // // outline0("DEC HL");
5640 // // outline0("LD C, (HL)");
5641
5642 // outline1("LD A, (%s)", _destination);
5643 // outline0("LD E, A");
5644 // outline1("LD A, (%s)", address_displacement(_environment, _destination, "1"));
5645 // outline0("LD D, A");
5646 // outline1("LD IX, (%s)", _source);
5647 // outline1("LD A, (%s)", address_displacement(_environment, _source, "2"));
5648 // outline0("LD C, A");
5649 // outline1("LD A, (%s)", address_displacement(_environment, _source, "3"));
5650
5651 // outline0("LD HL, 0");
5652 // outline0("LD B, 32");
5653 // outhead1("%sdiv32a:", label);
5654 // outline0("ADD IX, IX");
5655 // outline0("RL C");
5656 // outline0("RLA");
5657 // outline0("ADC HL, HL");
5658 // outline1("JR C, %sdiv32ov", label);
5659 // outline0("SBC HL, DE");
5660 // outline1("JR NC, %sdiv32setbit", label);
5661 // outline0("ADD HL, DE");
5662 // outline1("DJNZ %sdiv32a", label);
5663 // outline1("JR %sdiv32end", label);
5664 // outhead1("%sdiv32ov:", label);
5665 // outline0("OR A");
5666 // outline0("SBC HL, DE");
5667 // outhead1("%sdiv32setbit:", label);
5668 // outline0("INC IX");
5669 // outline1("DJNZ %sdiv32a", label);
5670 // outhead1("%sdiv32end:", label);
5671
5672 // outline1("LD (%s), A", address_displacement(_environment, _other, "3"));
5673 // outline0("LD A, C" );
5674 // outline1("LD (%s), A", address_displacement(_environment, _other, "2"));
5675 // outline1("LD (%s), IX", _other);
5676 // outline0("LD A, L");
5677 // outline1("LD (%s), A", _other_remainder);
5678 // outline0("LD A, H");
5679 // outline1("LD (%s), A", address_displacement(_environment, _other_remainder, "1"));
5680
5681 // outline0("POP AF");
5682 // outline0("LD B, A");
5683 // outline0("CMP 0x80");
5684 // outline1("JR NZ, %srepositive", label);
5685 cpu_complement2_16bit( _environment, _destination, NULL );
5686 // outhead1("%srepositive:", label);
5687 // outline0("POP AF");
5688 // outline0("LD C, A");
5689 // outline0("CMP 0x80");
5690 // outline1("JR NZ, %srepositive2", label );
5691 cpu_complement2_32bit( _environment, _source, NULL );
5692 // outhead1("%srepositive2:", label);
5693 // outline0("LD A, B");
5694 // outline0("XOR C");
5695 // outline0("ANIA 0x80");
5696 // outline0("CP 0x80");
5697 // outline1("JR NZ, %srepositive3", label );
5698 cpu_complement2_32bit( _environment, _other, NULL );
5699 // outhead1("%srepositive3:", label);
5700
5701 } else {
5702
5703 // // outline1("LD HL, %s", _source);
5704 // // outline0("LD A, (HL)");
5705 // // outline0("PUSH AF");
5706 // // outline0("POP IX");
5707 // // outline0("INC HL");
5708 // // outline0("INC HL");
5709 // // outline0("LD A, (HL)");
5710 // // outline0("LD C, A");
5711 // // outline0("INC HL");
5712 // // outline0("LD A, (HL)");
5713 // // outline1("LD DE, (%s)", _destination);
5714
5715 // // outline0("LD HL, 0");
5716 // // outline0("LD B, 32");
5717 // // outhead1("%sloop:", label);
5718 // // outline0("ADD IX, IX");
5719 // // outline0("RL C");
5720 // // outline0("RLA");
5721 // // outline0("ADC HL, HL");
5722 // // outline1("JR C, %soverflow", label);
5723 // // outline0("SBC HL, DE");
5724 // // outline1("JR NC, %ssetbit", label);
5725 // // outline0("ADD HL, DE");
5726 // // outline1("DJNZ %sloop", label);
5727 // // outline1("JMP %send", label);
5728 // // outhead1("%soverflow:", label);
5729 // // outline0("OR A");
5730 // // outline0("SBC HL, DE");
5731 // // outhead1("%ssetbit:", label);
5732 // // outline0("INC IXL");
5733 // // outline1("DJNZ %sloop", label);
5734 // // outhead1("%send:", label);
5735 // // outline1("LD (%s), HL", _other_remainder);
5736 // // outline1("LD HL, %s", _other);
5737 // // outline0("PUSH AF");
5738 // // outline0("PUSH IX");
5739 // // outline0("POP AF");
5740 // // outline0("LD (HL), A");
5741 // // outline0("POP AF");
5742 // // outline0("INC HL");
5743 // // outline0("INC HL");
5744 // // outline0("INC HL");
5745 // // outline0("LD (HL), A");
5746 // // outline0("DEC HL");
5747 // // outline0("LD C, (HL)");
5748 // ; IN: ACIX=dividend, DE=divisor
5749 // ; OUT: ACIX=quotient, DE=divisor, HL=remainder, B=0
5750
5751 // outline1("LD HL, (%s)", _source);
5752 // outline0("LD IX, HL");
5753 // outline1("LD HL, (%s)", address_displacement(_environment, _source, "2"));
5754 // outline0("LD A, L");
5755 // outline0("LD C, A");
5756 // outline0("LD A, H");
5757 // outline1("LD DE, (%s)", _destination);
5758
5759 // outline0("LD HL, 0");
5760 // outline0("LD B, 32");
5761 // outhead1("%sloop1:", label);
5762 // outline0("ADD IX, IX");
5763 // outline0("RL C");
5764 // outline0("RLA");
5765 // outline0("ADC HL, HL");
5766 // outline1("JR C, %sloop2", label);
5767 // outline0("SBC HL, DE");
5768 // outline1("JR NC, %sloop3", label);
5769 // outline0("ADD HL, DE");
5770 // outline1("DJNZ %sloop1", label);
5771 // outline1("JR %s// done", label);
5772 // outhead1("%sloop2:", label);
5773 // outline0("OR A");
5774 // outline0("SBC HL, DE");
5775 // outhead1("%sloop3:", label);
5776 // outline0("INC IXL");
5777 // outline1("DJNZ %sloop1", label);
5778 // outhead1("%s// done:", label);
5779
5780 // outline1("LD (%s), HL", _other_remainder);
5781 // outline0("LD H, A");
5782 // outline0("LD A, C");
5783 // outline0("LD L, C");
5784 // outline1("LD (%s), HL", _other);
5785 // outline0("LD HL, IX");
5786 // outline1("LD (%s), HL", _other);
5787
5788 }
5789
5790}
5791
5792void cpu_math_div_32bit_to_16bit_const( Environment * _environment, char *_source, int _destination, char *_other, char * _other_remainder, int _signed ) {
5793
5794 CRITICAL_UNIMPLEMENTED( "sc61860_math_div_32bit_to_16bit_const" );
5795
5796}
5797
5798void cpu_math_div_16bit_to_16bit( Environment * _environment, char *_source, char *_destination, char *_other, char * _other_remainder, int _signed ) {
5799
5800 CRITICAL_UNIMPLEMENTED( "sc61860_math_div_16bit_to_16bit" );
5801
5803
5804 if ( _signed ) {
5805
5806 // outline1("LD A, (%s)", address_displacement(_environment, _source, "1"));
5807 // outline0("ANIA 0x80");
5808 // outline0("CP 0" );
5809 // outline0("PUSH AF");
5810 // outline1("JR Z,%spositive", label);
5811 cpu_complement2_16bit( _environment, _source, NULL );
5812 // outhead1("%spositive:", label);
5813 // outline1("LD A, (%s)", address_displacement(_environment, _destination, "1"));
5814 // outline0("ANIA 0x80");
5815 // outline0("CP 0" );
5816 // outline0("PUSH AF");
5817 // outline1("JR Z,%spositive2", label);
5818 cpu_complement2_16bit( _environment, _destination, NULL );
5819 // outhead1("%spositive2:", label);
5820
5821 // outline1("LD HL, %s", _source);
5822 // outline0("LD A, (HL)");
5823 // outline0("LD C, A");
5824 // outline0("INC HL");
5825 // outline0("LD A, (HL)");
5826 // outline1("LD DE, (%s)", _destination);
5827
5828 // outline0("LD HL, 0");
5829 // outline0("LD B, 16");
5830 // outhead1("%sloop:", label );
5831 // outline0("SLL C");
5832 // outline0("RLA");
5833 // outline0("ADC HL, HL");
5834 // outline0("SBC HL, DE");
5835 // outline0("JR NC, 0x+4");
5836 // outline0("ADD HL, DE");
5837 // outline0("DEC C");
5838 // outline1("DJNZ %sloop", label);
5839 // outline1("LD (%s), HL", _other_remainder);
5840 // outline1("LD DE, %s", _other);
5841 // outline0("LD B, A");
5842 // outline0("LD A, C");
5843 // outline0("LD (DE), A");
5844 // outline0("INC DE");
5845 // outline0("LD A, B");
5846 // outline0("LD (DE), A");
5847
5848 // outline0("POP AF");
5849 // outline0("LD B, A");
5850 // outline0("CMP 0x80");
5851 // outline1("JR NZ, %srepositive", label);
5852 cpu_complement2_16bit( _environment, _destination, NULL );
5853 // outhead1("%srepositive:", label);
5854 // outline0("POP AF");
5855 // outline0("LD C, A");
5856 // outline0("CMP 0x80");
5857 // outline1("JR NZ, %srepositive2", label );
5858 cpu_complement2_16bit( _environment, _source, NULL );
5859 // outhead1("%srepositive2:", label);
5860 // outline0("LD A, B");
5861 // outline0("XOR C");
5862 // outline0("ANIA 0x80");
5863 // outline0("CP 0x80");
5864 // outline1("JR NZ, %srepositive3", label );
5865 cpu_complement2_16bit( _environment, _other, NULL );
5866 // outhead1("%srepositive3:", label);
5867
5868 } else {
5869
5870 // outline1("LD HL, %s", _source);
5871 // outline0("LD A, (HL)");
5872 // outline0("LD C, A");
5873 // outline0("INC HL");
5874 // outline0("LD A, (HL)");
5875 // outline1("LD DE, (%s)", _destination);
5876
5877 // outline0("LD HL, 0");
5878 // outline0("LD B, 16");
5879 // outhead1("%sloop:", label );
5880 // outline0("SLL C");
5881 // outline0("RLA");
5882 // outline0("ADC HL, HL");
5883 // outline0("SBC HL, DE");
5884 // outline0("JR NC, 0x+4");
5885 // outline0("ADD HL, DE");
5886 // outline0("DEC C");
5887 // outline1("DJNZ %sloop", label);
5888 // outline1("LD (%s), HL", _other_remainder);
5889 // outline1("LD DE, %s", _other);
5890 // outline0("LD B, A");
5891 // outline0("LD A, C");
5892 // outline0("LD (DE), A");
5893 // outline0("INC DE");
5894 // outline0("LD A, B");
5895 // outline0("LD (DE), A");
5896
5897 }
5898
5899}
5900
5901void cpu_math_div_16bit_to_16bit_const( Environment * _environment, char *_source, int _destination, char *_other, char * _other_remainder, int _signed ) {
5902
5903 CRITICAL_UNIMPLEMENTED( "sc61860_math_div_16bit_to_16bit_const" );
5904
5905}
5906
5907void cpu_math_div_8bit_to_8bit( Environment * _environment, char *_source, char *_destination, char *_other, char * _other_remainder, int _signed ) {
5908
5909 CRITICAL_UNIMPLEMENTED( "sc61860_math_div_8bit_to_8bit" );
5910
5912
5913 if ( _signed ) {
5914
5915 // outline1("LD A, (%s)", _source );
5916 // outline0("LD B, A" );
5917 // outline1("LD A, (%s)", _destination );
5918 // outline0("XOR A, B" );
5919 // outline0("ANIA 0x80" );
5920 // outline0("PUSH AF" );
5921 // outline1("LD A, (%s)", _source );
5922 // outline0("ANIA 0x80" );
5923 // outline0("CP 0" );
5924 // outline1("JR Z,%spos", label );
5925 // outline1("LD A, (%s)", _source );
5926 // outline0("XOR 0xFF" );
5927 // outline0("ADC 0x1" );
5928 // outline1("JMP %spos2", label );
5929 // outhead1("%spos:", label );
5930 // outline1("LD A, (%s)", _source );
5931 // outhead1("%spos2:", label );
5932 // outline0("LD D, A");
5933
5934 // outline1("LD A, (%s)", _destination );
5935 // outline0("ANIA 0x80" );
5936 // outline0("CP 0" );
5937 // outline1("JR Z,%sposx", label );
5938 // outline1("LD A, (%s)", _destination );
5939 // outline0("XOR 0xFF" );
5940 // outline0("ADC 0x1" );
5941 // outline1("JMP %sposx2", label );
5942 // outhead1("%sposx:", label );
5943 // outline1("LD A, (%s)", _destination );
5944 // outhead1("%sposx2:", label );
5945 // outline0("LD E, A");
5946
5947 // outline0("XOR A");
5948 // outline0("AND A");
5949 // outline0("LD B, 8");
5950 // outhead1("%sloop:", label);
5951 // outline0("SLA D");
5952 // outline0("RLA");
5953 // outline0("CP E");
5954 // outline0("JR C, 0x+4");
5955 // outline0("SUB E");
5956 // outline0("INC D");
5957 // outline1("DJNZ %sloop", label );
5958
5959 // outline1("LD (%s), A", _other_remainder);
5960 // outline0("LD A, D");
5961 // outline1("LD (%s), A", _other);
5962
5963 // outline0("POP AF" );
5964 // outline0("ANIA 0x80" );
5965 // outline0("CP 0" );
5966 // outline1("JR Z,%spos3", label );
5967 // outline1("LD A, (%s)", _other );
5968 // outline0("XOR 0xFF" );
5969 // outline0("ADC 0x1" );
5970 // outline1("LD (%s), A", _other );
5971 // outhead1("%spos3:", label );
5972
5973 } else {
5974
5975 // outline1("LD A, (%s)", _source);
5976 // outline0("LD D, A");
5977 // outline1("LD A, (%s)", _destination);
5978 // outline0("LD E, A");
5979
5980 // outline0("XOR A");
5981 // outline0("LD B, 8");
5982 // outhead1("%sloop:", label);
5983
5984 // outline0("SLA D");
5985 // outline0("RLA");
5986 // outline0("CP E");
5987 // outline0("JR C, 0x+4");
5988 // outline0("SUB E");
5989 // outline0("INC D");
5990 // outline1("DJNZ %sloop", label );
5991
5992 // outline1("LD (%s), A", _other_remainder);
5993 // outline0("LD A, D");
5994 // outline1("LD (%s), A", _other);
5995
5996 }
5997}
5998
5999void cpu_math_div_8bit_to_8bit_const( Environment * _environment, char *_source, int _destination, char *_other, char * _other_remainder, int _signed ) {
6000
6001 CRITICAL_UNIMPLEMENTED( "sc61860_math_div_8bit_to_8bit_const" );
6002
6004
6005}
6006
6007void cpu_bit_check( Environment * _environment, char *_value, int _position, char * _result, int _bitwidth ) {
6008
6009 CRITICAL_UNIMPLEMENTED( "sc61860_bit_check" );
6010
6011 // no_inline( cpu_bit_check_extended )
6012
6013 // embedded( cpu_bit_check_extended, src_hw_sc61860_cpu_bit_check_extended_asm );
6014
6015 // outline1("LD DE, %s", _value);
6016 // outline1("LD A, 0x%2.2x", _position );
6017 // outline0("CALL CPUBITCHECKEXTENDED" );
6018
6019 if ( _result ) {
6020 // outline1("LD (%s), A", _result);
6021 }
6022
6023 // done( )
6024
6025}
6026
6027void cpu_bit_check_extended( Environment * _environment, char *_value, char * _position, char * _result, int _bitwidth ) {
6028
6029 CRITICAL_UNIMPLEMENTED( "sc61860_bit_check_extended" );
6030
6032
6033 // no_inline( cpu_bit_check_extended )
6034
6035 // embedded( cpu_bit_check_extended, src_hw_sc61860_cpu_bit_check_extended_asm );
6036
6037 // outline1("LD DE, %s", _value);
6038 // outline1("LD A, (%s)", _position );
6039 // outline0("CALL CPUBITCHECKEXTENDED" );
6040
6041 if ( _result ) {
6042 // outline1("LD (%s), A", _result);
6043 }
6044
6045 // done( )
6046
6047}
6048
6049void cpu_bit_inplace_8bit( Environment * _environment, char * _value, int _position, int * _bit ) {
6050
6051 CRITICAL_UNIMPLEMENTED( "sc61860_bit_inplace_8bit" );
6052
6053 _environment->bitmaskNeeded = 1;
6054
6056
6057 // no_inline( cpu_bit_inplace )
6058
6059 // embedded( cpu_bit_inplace, src_hw_sc61860_cpu_bit_inplace_asm );
6060
6061 if ( _bit ) {
6062 if ( * _bit ) {
6063 // outline0("LD A, 0xff" );
6064 } else {
6065 // outline0("LD A, 0x0" );
6066 }
6067 // outline0("SRL A" );
6068 }
6069 // outline1("LD DE, %s", _value );
6070 // outline1("LD A, 0x%2.2x", _position);
6071 // outline0("CALL CPUBITINPLACE");
6072
6073 // done( )
6074
6075}
6076
6077void cpu_bit_inplace_8bit_extended_indirect( Environment * _environment, char * _address, char * _position, char * _bit ) {
6078
6079 CRITICAL_UNIMPLEMENTED( "sc61860_bit_inplace_8bit_extended_indirect" );
6080
6081 _environment->bitmaskNeeded = 1;
6082
6084
6085 // no_inline( cpu_bit_inplace )
6086
6087 // embedded( cpu_bit_inplace, src_hw_sc61860_cpu_bit_inplace_asm );
6088
6089 if ( _bit ) {
6090 // outline1("LD A, (%s)", _bit );
6091 // outline0("CP 0x0" );
6092 // outline1("JR Z, %s", label );
6093 // outline0("LD A, 1" );;
6094 // outline0("SRL A" );
6095 // outhead1("%s:", label );
6096 }
6097 // outline1("LD DE, (%s)", _address );
6098 // outline1("LD A, (%s)", _position);
6099 // outline0("CALL CPUBITINPLACE");
6100
6101 // done( )
6102
6103}
6104
6106
6107}
6108
6109void cpu_number_to_string( Environment * _environment, char * _number, char * _string, char * _string_size, int _bits, int _signed ) {
6110
6112
6113 deploy( numberToString, src_hw_sc61860_number_to_string_asm );
6114
6115 outline1("LIDP %s", _string );
6116 outline0("LIP 0x4");
6117 outline0("LDD");
6118 outline0("EXAM");
6119 outline1("LIDP %s", address_displacement(_environment, _string, "1") );
6120 outline0("LIP 0x5");
6121 outline0("LDD");
6122 outline0("EXAM");
6123
6124 outline0("LIA 0x0");
6125 outline0("LIP 0x0c");
6126 outline0("EXAM");
6127 outline0("LIA 0x0");
6128 outline0("LIP 0x0d");
6129 outline0("EXAM");
6130 outline0("LIA 0x0");
6131 outline0("LIP 0x0e");
6132 outline0("EXAM");
6133 outline0("LIA 0x0");
6134 outline0("LIP 0x0f");
6135 outline0("EXAM");
6136 outline0("LIA 0x0");
6137 outline0("LIP 0x10");
6138 outline0("EXAM");
6139
6140 switch( _bits ) {
6141 case 32:
6142 outline1("LIDP %s", address_displacement(_environment, _number, "3") );
6143 outline0("LDD");
6144 if ( _signed ) {
6145 outline0("ANIA 0x80");
6146 outline0("LIP 0x10");
6147 outline0("EXAM");
6148 outline0("LDD");
6149 }
6150 outline0("LIP 0x0f");
6151 outline0("EXAM");
6152 outline1("LIDP %s", address_displacement(_environment, _number, "2") );
6153 outline0("LDD");
6154 outline0("LIP 0x0e");
6155 outline0("EXAM");
6156 case 16:
6157 outline1("LIDP %s", address_displacement(_environment, _number, "1") );
6158 outline0("LDD");
6159 if ( _signed && _bits == 16 ) {
6160 outline0("ANIA 0x80");
6161 outline0("LIP 0x10");
6162 outline0("EXAM");
6163 outline0("LDD");
6164 }
6165 outline0("LIP 0x0d");
6166 outline0("EXAM");
6167 case 8:
6168 outline1("LIDP %s", _number );
6169 outline0("LDD");
6170 if ( _signed && _bits == 8 ) {
6171 outline0("ANIA 0x80");
6172 outline0("LIP 0x10");
6173 outline0("EXAM");
6174 outline0("LDD");
6175 }
6176 outline0("LIP 0x0c");
6177 outline0("EXAM");
6178 }
6179
6180 outline0("LIP 0x10");
6181 outline0("LDM");
6182 outline0("ANIA 0x80" );
6183 outline1("JRZP %spositive", label );
6184
6185 // switch( _bits ) {
6186 // case 32:
6187 // outline0("LIP 0x0f");
6188 // outline0("LDM");
6189 // outline0("EOR #$ff" );
6190 // outline0("STA MATHPTR3" );
6191 // outline0("LDA MATHPTR2" );
6192 // outline0("EOR #$ff" );
6193 // outline0("STA MATHPTR2" );
6194 // case 16:
6195 // outline0("LDA MATHPTR1" );
6196 // outline0("EOR #$ff" );
6197 // outline0("STA MATHPTR1" );
6198 // case 8:
6199 // outline0("LDA MATHPTR0" );
6200 // outline0("EOR #$ff" );
6201 // outline0("STA MATHPTR0" );
6202 // }
6203
6204 // outline0("CLC" );
6205 // outline0("LDA #$01" );
6206 // outline0("ADC MATHPTR0" );
6207 // outline0("STA MATHPTR0" );
6208 // outline0("LDA #$00" );
6209 // outline0("ADC MATHPTR1" );
6210 // outline0("STA MATHPTR1" );
6211 // outline0("LDA #$00" );
6212 // outline0("ADC MATHPTR2" );
6213 // outline0("STA MATHPTR2" );
6214 // outline0("LDA #$00" );
6215 // outline0("ADC MATHPTR3" );
6216 // outline0("STA MATHPTR3" );
6217
6218 outhead1("%spositive:", label );
6219 outline1("LIA 0x%2.2X", _bits );
6220 outline0("LIP 0x11");
6221 outline0("EXAM");
6222
6223 outline0("CALL N2STRING");
6224
6225 outline0("LIP 0x11");
6226 outline0("LDM");
6227 outline1("LIDP %s", _string_size);
6228 outline0("STD");
6229
6230}
6231
6232void cpu_bits_to_string_vars( Environment * _environment ) {
6233
6234 variable_import( _environment, "BINSTRBUF", VT_BUFFER, 32 );
6235
6236}
6237
6238void cpu_bits_to_string( Environment * _environment, char * _number, char * _string, char * _string_size, int _bits, char * _zero, char * _one ) {
6239
6240 CRITICAL_UNIMPLEMENTED( "sc61860_bits_to_string" );
6241
6242 // deploy_with_vars( bitsToString,src_hw_sc61860_bits_to_string_asm, cpu_bits_to_string_vars );
6243
6244 switch( _bits ) {
6245 case 32:
6246 // outline1("LD BC, (%s)", address_displacement(_environment, _number, "2") );
6247 // outline1("LD DE, (%s)", _number );
6248 break;
6249 case 16:
6250 // outline0("LD BC, 0" );
6251 // outline1("LD DE, (%s)", _number );
6252 break;
6253 case 8:
6254 // outline0("LD BC, 0" );
6255 // outline0("LD D, 0" );
6256 // outline1("LD A, (%s)", _number );
6257 // outline0("LD E, A" );
6258 // outline0("LD A, 0" );
6259 break;
6260 }
6261
6262 // outline1("LD A, 0x%2.2x", ( _bits & 0xff ) );
6263 // outline0("CALL BINSTR");
6264
6265 // outline1("LD DE, (%s)", _string);
6266 // outline1("LD A, 0x%2.2x", ( (_bits) & 0xff ) );
6267 // outline0("LD C, A");
6268 // outline0("LD B, 0");
6269 // outline0("LDIR");
6270
6271 // outline1("LD A, 0x%2.2x", ( _bits & 0xff ) );
6272 // outline1("LD HL, %s", _string_size );
6273 // outline0("LD (HL), A" );
6274
6275}
6276
6277void cpu_hex_to_string( Environment * _environment, char * _number, char * _string, char * _string_size, int _bits ) {
6278
6279 CRITICAL_UNIMPLEMENTED( "sc61860_hex_to_string" );
6280
6282
6283 // inline( cpu_hex_to_string )
6284
6285 // embedded( cpu_hex_to_string, src_hw_sc61860_cpu_hex_to_string_asm );
6286
6287 // outline1("LD A, 0x%2.2x", _bits);
6288 // outline0("LD IXL, A");
6289
6290 switch( _bits ) {
6291 case 8:
6292 // outline1("LD A, (%s)", _number );
6293 // outline0("LD L, A" );
6294 // outline0("LD H, 0" );
6295 // outline1("LD DE, (%s)", _string );
6296
6297 // outline0("CALL H2STRING" );
6298 break;
6299 case 16:
6300
6301 // outline1("LD HL, (%s)", _number );
6302 // outline1("LD DE, (%s)", _string );
6303
6304 // outline0("CALL H2STRING" );
6305 break;
6306
6307 case 32:
6308
6309 // outline1("LD HL, (%s)", address_displacement(_environment, _number, "2") );
6310 // outline1("LD DE, (%s)", _string );
6311
6312 // outline0("CALL H2STRING" );
6313
6314 // outline1("LD HL, (%s)", _number );
6315 // outline1("LD DE, (%s)", _string );
6316 // outline0("INC DE" );
6317 // outline0("INC DE" );
6318 // outline0("INC DE" );
6319 // outline0("INC DE" );
6320
6321 // outline0("CALL H2STRING" );
6322 break;
6323
6324 }
6325
6326 // outline1("LD A, 0x%2.2x", ( _bits >> 2 ) );
6327 // outline1("LD (%s), A", _string_size );
6328
6329 // done()
6330
6331}
6332
6333
6334void cpu_dsdefine( Environment * _environment, char * _string, char * _index ) {
6335
6336 deploy( dstring,src_hw_sc61860_dstring_asm );
6337
6338 outline1( "LIA %s", _string );
6339 outline0( "LIP 0x04" );
6340 outline0( "EXAM" );
6341 outline1( "LIA >%s", _string );
6342 outline0( "LIP 0x05" );
6343 outline0( "EXAM" );
6344 outline0( "CALL DSDEFINE" );
6345 outline0( "EXAB" );
6346 outline1( "LIDP %s", _index );
6347 outline0( "STD" );
6348
6349}
6350
6351void cpu_dsalloc( Environment * _environment, char * _size, char * _index ) {
6352
6353 deploy( dstring,src_hw_sc61860_dstring_asm );
6354
6355 outline1( "LIDP %s", _size );
6356 outline0( "LDD" );
6357 outline0( "LIP 0x08" );
6358 outline0( "EXAM" );
6359 outline0( "CALL DSALLOC" );
6360 outline0( "EXAB" );
6361 outline1( "LIDP %s", _index );
6362 outline0( "STD" );
6363
6364}
6365
6366void cpu_dsalloc_size( Environment * _environment, int _size, char * _index ) {
6367
6368 deploy( dstring,src_hw_sc61860_dstring_asm );
6369
6370 outline1( "LIA 0x%2.2x", _size );
6371 outline0( "CALL DSALLOC" );
6372 outline0( "EXAB" );
6373 outline1( "LIDP %s", _index );
6374 outline0( "STD" );
6375
6376}
6377
6378void cpu_dsfree( Environment * _environment, char * _index ) {
6379
6380 deploy( dstring,src_hw_sc61860_dstring_asm );
6381
6382 outline1( "LIDP %s", _index );
6383 outline0( "LDD" );
6384 outline0( "EXAB" );
6385 outline0( "CALL DSFREE" );
6386
6387}
6388
6389void cpu_dswrite( Environment * _environment, char * _index ) {
6390
6391 deploy( dstring,src_hw_sc61860_dstring_asm );
6392
6393 outline1( "LIDP %s", _index );
6394 outline0( "LDD" );
6395 outline0( "EXAB" );
6396 outline0( "CALL DSWRITE" );
6397
6398}
6399
6400void cpu_dsresize( Environment * _environment, char * _index, char * _resize ) {
6401
6402 deploy( dstring,src_hw_sc61860_dstring_asm );
6403
6404 outline1( "LIDP %s", _index );
6405 outline0( "LDD" );
6406 outline0( "EXAB" );
6407 outline1( "LIDP %s", _resize );
6408 outline0( "LDD" );
6409 outline0( "LIP 0x08" );
6410 outline0( "EXAM" );
6411 outline0( "CALL DSRESIZE" );
6412
6413}
6414
6415void cpu_dsresize_size( Environment * _environment, char * _index, int _resize ) {
6416
6417 deploy( dstring,src_hw_sc61860_dstring_asm );
6418
6419 outline1( "LIDP %s", _index );
6420 outline0( "EXAB" );
6421 outline1( "LIA 0x%2.2x", ( _resize & 0xff ) );
6422 outline0( "LIP 0x08" );
6423 outline0( "EXAM" );
6424 outline0( "CALL DSRESIZE" );
6425
6426}
6427
6428void cpu_dsinit( Environment * _environment ) {
6429
6430 deploy( dstring,src_hw_sc61860_dstring_asm );
6431
6432 outline0( "CALL DSINIT" );
6433
6434}
6435
6436void cpu_dsgc( Environment * _environment ) {
6437
6438 deploy( dstring,src_hw_sc61860_dstring_asm );
6439
6440 outline0( "CALL DSGC" );
6441
6442}
6443
6444void cpu_dsdescriptor( Environment * _environment, char * _index, char * _address, char * _size ) {
6445
6446 deploy( dstring,src_hw_sc61860_dstring_asm );
6447
6448 outline1( "LIDP %s", _index );
6449 outline0( "LDD" );
6450 outline0( "EXAB" );
6451 outline0( "CALL DSDESCRIPTOR" );
6452 outline0( "LIP 0x0c" );
6453 outline0( "LDM" );
6454 outline1( "LIDP %s", _size );
6455 outline0( "STD" );
6456 outline0( "LIP 0x0d" );
6457 outline0( "LDM" );
6458 outline1( "LIDP %s", _address );
6459 outline0( "STD" );
6460 outline0( "LIP 0x0e" );
6461 outline0( "LDM" );
6462 outline1( "LIDP %s", address_displacement( _environment, _address, "1" ) );
6463 outline0( "STD" );
6464
6465}
6466
6467void cpu_move_8bit_indirect_with_offset2( Environment * _environment, char *_source, char * _value, char * _offset ) {
6468
6469 CRITICAL_UNIMPLEMENTED( "sc61860_move_8bit_indirect_with_offset2" );
6470
6471 // outline1("LD HL, (%s)", _value);
6472 // outline1("LD A, (%s)", _offset );
6473 // outline0("LD E, A" );
6474 // outline0("LD A, 0" );
6475 // outline0("LD D, A" );
6476 // outline0("ADD HL, DE" );
6477 // outline1("LD A, (%s)", _source);
6478 // outline0("LD (HL), A");
6479
6480}
6481
6482void cpu_complement2_8bit( Environment * _environment, char * _source, char * _destination ) {
6483
6484 CRITICAL_UNIMPLEMENTED( "sc61860_complement2_8bit" );
6485
6486 // outline1( "LD A, (%s)", _source );
6487 // outline0( "XOR 0xFF" );
6488 if ( _destination ) {
6489 // outline1( "LD (%s), A", _destination );
6490 } else {
6491 // outline1( "LD (%s), A", _source );
6492 }
6493 if ( _destination ) {
6494 cpu_inc( _environment, _destination );
6495 } else {
6496 cpu_inc( _environment, _source );
6497 }
6498}
6499
6500void cpu_complement2_16bit( Environment * _environment, char * _source, char * _destination ) {
6501
6502 CRITICAL_UNIMPLEMENTED( "sc61860_complement2_16bit" );
6503
6504 // outline1( "LD A, (%s)", _source );
6505 // outline0( "XOR 0xFF" );
6506 if ( _destination ) {
6507 // outline1( "LD (%s), A", _destination );
6508 } else {
6509 // outline1( "LD (%s), A", _source );
6510 }
6511 // outline1( "LD A, (%s)", address_displacement(_environment, _source, "1") );
6512 // outline0( "XOR 0xFF" );
6513 if ( _destination ) {
6514 // outline1( "LD (%s), A", address_displacement(_environment, _destination, "1") );
6515 } else {
6516 // outline1( "LD (%s), A", address_displacement(_environment, _source, "1") );
6517 }
6518 if ( _destination ) {
6519 cpu_inc_16bit( _environment, _destination );
6520 } else {
6521 cpu_inc_16bit( _environment, _source );
6522 }
6523}
6524
6525void cpu_complement2_32bit( Environment * _environment, char * _source, char * _destination ) {
6526
6527 CRITICAL_UNIMPLEMENTED( "sc61860_complement2_32bit" );
6528
6529 // outline1( "LD A, (%s)", _source );
6530 // outline0( "XOR 0xFF" );
6531 if ( _destination ) {
6532 // outline1( "LD (%s), A", _destination );
6533 } else {
6534 // outline1( "LD (%s), A", _source );
6535 }
6536 // outline1( "LD A, (%s)", address_displacement(_environment, _source, "1") );
6537 // outline0( "XOR 0xFF" );
6538 if ( _destination ) {
6539 // outline1( "LD (%s), A", address_displacement(_environment, _destination, "1") );
6540 } else {
6541 // outline1( "LD (%s), A", address_displacement(_environment, _source, "1") );
6542 }
6543 // outline1( "LD A, (%s)", address_displacement(_environment, _source, "2") );
6544 // outline0( "XOR 0xFF" );
6545 if ( _destination ) {
6546 // outline1( "LD (%s), A", address_displacement(_environment, _destination, "2") );
6547 } else {
6548 // outline1( "LD (%s), A", address_displacement(_environment, _source, "2") );
6549 }
6550 // outline1( "LD A, (%s)", address_displacement(_environment, _source, "3") );
6551 // outline0( "XOR 0xFF" );
6552 if ( _destination ) {
6553 // outline1( "LD (%s), A", address_displacement(_environment, _destination, "3") );
6554 } else {
6555 // outline1( "LD (%s), A", address_displacement(_environment, _source, "3") );
6556 }
6557 if ( _destination ) {
6558 cpu_inc_32bit( _environment, _destination );
6559 } else {
6560 cpu_inc_32bit( _environment, _source );
6561 }
6562}
6563
6564void cpu_sqroot( Environment * _environment, char * _number, char * _result ) {
6565
6566 CRITICAL_UNIMPLEMENTED( "sc61860_sqroot" );
6567
6568 // deploy( sqr, src_hw_sc61860_sqr_asm );
6569
6570 // outline1("LD HL, (%s)", _number );
6571
6572 // outline0("CALL SQROOT" );
6573
6574 // outline1("LD (%s),A", _result );
6575
6576}
6577
6578void cpu_dstring_vars( Environment * _environment ) {
6579
6580 int count = _environment->dstring.count == 0 ? DSTRING_DEFAULT_COUNT : _environment->dstring.count;
6581 int space = _environment->dstring.space == 0 ? DSTRING_DEFAULT_SPACE : _environment->dstring.space;
6582 int i;
6583
6584 outhead1("stringscount .equ %d", count );
6585 outhead1("stringsspace .equ %d", space );
6586 outhead0("USING: .db 0" );
6587 outhead0("MAXSTRINGS: .db stringscount" );
6588 outhead0("DESCRIPTORS:" );
6589 for( i=0; i<count; ++i ) {
6590 outline0( ".db 0, 0, 0, 0 " );
6591 }
6592 outhead0("WORKING:" );
6593 for( i=0; i<space / 4; ++i ) {
6594 outline0( ".db 0, 0, 0, 0 " );
6595 }
6596 outhead0("TEMPORARY:" );
6597 for( i=0; i<space / 4; ++i ) {
6598 outline0( ".db 0, 0, 0, 0 " );
6599 }
6600 outhead0("FREE_STRING: .db (stringsspace-1),>(stringsspace-1)" );
6601 outhead0("STACKX: .db 0x30" );
6602
6603}
6604
6605void cpu_protothread_vars( Environment * _environment ) {
6606
6607 int count = _environment->protothreadConfig.count;
6608
6609 out0("PROTOTHREADLC: .db ");
6610 for( int i=0; i<count-1; ++i ) {
6611 out0("0,");
6612 }
6613 outline0("0");
6614
6615 out0("PROTOTHREADST: .db ");
6616 for( int i=0; i<count-1; ++i ) {
6617 out0("0,");
6618 }
6619 outline0("0");
6620
6621 outhead1("PROTOTHREADCOUNT: .db 0x%2.2x", count );
6622
6623 // outhead0("PROTOTHREADCT: .db 0" );
6624 outhead0("PROTOTHREADLOOP:");
6625
6626 for( int i=0; i<count; ++i ) {
6627 outline1("LIA 0x%2.2x", i );
6628 outline0("LIDP PROTOTHREADCT" );
6629 outline0("STD" );
6630 outline0("CALL PROTOTHREADVOID" );
6631 }
6632
6633 outline0("RTN" );
6634
6635}
6636
6637
6638void cpu_protothread_loop( Environment * _environment ) {
6639
6640 deploy_with_vars( protothread, src_hw_sc61860_protothread_asm, cpu_protothread_vars );
6641
6642 outline0("CALL PROTOTHREADLOOP" );
6643
6644}
6645
6646void cpu_protothread_register_at( Environment * _environment, char * _index, char * _label ) {
6647
6648 deploy_with_vars( protothread, src_hw_sc61860_protothread_asm, cpu_protothread_vars );
6649
6650 outline1("LIA %s", _label );
6651 outline0("LIP 0x0c" );
6652 outline0("EXAM" );
6653 outline1("LIA >%s", _label );
6654 outline0("LIP 0x0d" );
6655 outline0("EXAM" );
6656 outline1("LIDP %s", _index );
6657 outline0("LDD");
6658 outline0("LIP 0");
6659 outline0("EXAM");
6660 outline0("CALL PROTOTHREADREGAT" );
6661
6662}
6663
6664void cpu_protothread_register( Environment * _environment, char * _label, char * _index ) {
6665
6666 deploy_with_vars( protothread, src_hw_sc61860_protothread_asm, cpu_protothread_vars );
6667
6668 outline1("LIA %s", _label );
6669 outline0("LIP 0x0c" );
6670 outline0("EXAM" );
6671 outline1("LIA >%s", _label );
6672 outline0("LIP 0x0d" );
6673 outline0("EXAM" );
6674 outline0("CALL PROTOTHREADREG" );
6675 outline0("LIP 0" );
6676 outline0("EXAM" );
6677 outline1("LIDP %s", _index );
6678 outline0("STD" );
6679
6680}
6681
6682void cpu_protothread_unregister( Environment * _environment, char * _index ) {
6683
6684 deploy_with_vars( protothread, src_hw_sc61860_protothread_asm, cpu_protothread_vars );
6685
6686 outline1("LIDP %s", _index );
6687 outline0("LDD");
6688 outline0("LIP 0");
6689 outline0("EXAM");
6690 outline0("CALL PROTOTHREADUNREG" );
6691
6692}
6693
6694void cpu_protothread_save( Environment * _environment, char * _index, int _step ) {
6695
6696 deploy_with_vars( protothread, src_hw_sc61860_protothread_asm, cpu_protothread_vars );
6697
6698 outline1("LIDP %s", _index );
6699 outline0("LDD");
6700 outline0("LIP 0");
6701 outline0("EXAM");
6702 outline1("LIA 0x%2.2x", _step );
6703 outline0("LIP 1");
6704 outline0("EXAM");
6705 outline0("CALL PROTOTHREADSAVE" );
6706
6707}
6708
6709void cpu_protothread_restore( Environment * _environment, char * _index, char * _step ) {
6710
6711 deploy_with_vars( protothread, src_hw_sc61860_protothread_asm, cpu_protothread_vars );
6712
6713 outline1("LIDP %s", _index );
6714 outline0("LDD");
6715 outline0("LIP 0");
6716 outline0("EXAM");
6717 outline0("CALL PROTOTHREADRESTORE" );
6718 outline0("LIP 1");
6719 outline0("EXAM");
6720 outline1("LIDP %s", _step);
6721 outline0("STD");
6722
6723}
6724
6725void cpu_protothread_set_state( Environment * _environment, char * _index, int _state ) {
6726
6727 deploy_with_vars( protothread, src_hw_sc61860_protothread_asm, cpu_protothread_vars );
6728
6729 outline1("LIDP %s", _index );
6730 outline0("LDD");
6731 outline0("LIP 0");
6732 outline0("EXAM");
6733 outline1("LIA 0x%2.2x", _state );
6734 outline0("LIP 1");
6735 outline0("EXAM");
6736 outline0("CALL PROTOTHREADSETSTATE" );
6737
6738}
6739
6740void cpu_protothread_get_state( Environment * _environment, char * _index, char * _state ) {
6741
6742 deploy_with_vars( protothread, src_hw_sc61860_protothread_asm, cpu_protothread_vars );
6743
6744 outline1("LIDP %s", _index );
6745 outline0("LDD");
6746 outline0("LIP 0");
6747 outline0("EXAM");
6748 outline0("CALL PROTOTHREADRESTORE" );
6749 outline0("LIP 1");
6750 outline0("EXAM");
6751 outline1("LIDP %s", _state);
6752 outline0("STD");
6753
6754}
6755
6756void cpu_protothread_current( Environment * _environment, char * _current ) {
6757
6758 deploy_with_vars( protothread, src_hw_sc61860_protothread_asm, cpu_protothread_vars );
6759
6760 outline0("LIDP PROTOTHREADCT" );
6761 outline0("LDD" );
6762 outline1("LIDP %s", _current );
6763 outline0("STD" );
6764
6765}
6766
6767void cpu_protothread_get_address( Environment * _environment, char * _index, char * _address ) {
6768
6769 outline1("LIDP %s", _index );
6770 outline0("LDD");
6771 outline0("LIP 0");
6772 outline0("EXAM");
6773 outline0("CALL PROTOTHREADGETADDRESS" );
6774 outline0("LIP 0x0c");
6775 outline0("EXAM");
6776 outline1("LIDP %s", _address);
6777 outline0("STD");
6778 outline0("LIP 0x0d");
6779 outline0("EXAM");
6780 outline1("LIDP %s", address_displacement( _environment, _address, "1" ) );
6781 outline0("STD");
6782
6783}
6784
6785void cpu_set_callback( Environment * _environment, char * _callback, char * _label ) {
6786
6787 CRITICAL_UNIMPLEMENTED( "sc61860_set_callback" );
6788
6789 // outline1("LD DE, %s", _label );
6790 // outline1("LD HL, %s", _callback );
6791 // outline0("INC HL" );
6792 // outline0("LD (HL), E" );
6793 // outline0("INC HL" );
6794 // outline0("LD (HL), D" );
6795
6796}
6797
6798void cpu_msc1_uncompress_direct_direct( Environment * _environment, char * _input, char * _output ) {
6799
6800 CRITICAL_UNIMPLEMENTED( "sc61860_msc1_uncompress_direct_direct" );
6801
6803
6804 // inline( cpu_msc1_uncompress )
6805
6806 // embedded( cpu_msc1_uncompress, src_hw_sc61860_msc1_asm );
6807
6808 // outline1("LD HL, %s", _input);
6809 // outline1("LD DE, %s", _output);
6810 // outline0("CALL MSC1UNCOMPRESS");
6811
6812 // done()
6813
6814}
6815
6816void cpu_msc1_uncompress_direct_indirect( Environment * _environment, char * _input, char * _output ) {
6817
6818 CRITICAL_UNIMPLEMENTED( "sc61860_msc1_uncompress_direct_indirect" );
6819
6821
6822 // inline( cpu_msc1_uncompress )
6823
6824 // embedded( cpu_msc1_uncompress, src_hw_sc61860_msc1_asm );
6825
6826 // outline1("LD HL, %s", _input);
6827 // outline1("LD DE, (%s)", _output);
6828 // outline0("CALL MSC1UNCOMPRESS");
6829
6830 // done()
6831
6832}
6833
6834void cpu_msc1_uncompress_indirect_direct( Environment * _environment, char * _input, char * _output ) {
6835
6836 CRITICAL_UNIMPLEMENTED( "sc61860_msc1_uncompress_indirect_direct" );
6837
6839
6840 // inline( cpu_msc1_uncompress )
6841
6842 // embedded( cpu_msc1_uncompress, src_hw_sc61860_msc1_asm );
6843
6844 // outline1("LD HL, (%s)", _input);
6845 // outline1("LD DE, %s", _output);
6846 // outline0("CALL MSC1UNCOMPRESS");
6847
6848 // done()
6849
6850}
6851
6852void cpu_msc1_uncompress_indirect_indirect( Environment * _environment, char * _input, char * _output ) {
6853
6854 CRITICAL_UNIMPLEMENTED( "sc61860_msc1_uncompress_indirect_indirect" );
6855
6857
6858 // inline( cpu_msc1_uncompress )
6859
6860 // embedded( cpu_msc1_uncompress, src_hw_sc61860_msc1_asm );
6861
6862 // outline1("LD HL, (%s)", _input);
6863 // outline1("LD DE, (%s)", _output);
6864 // outline0("CALL MSC1UNCOMPRESS");
6865
6866 // done()
6867
6868}
6869
6870void cpu_out( Environment * _environment, char * _port, char * _value ) {
6871
6872 CRITICAL_UNIMPLEMENTED( "sc61860_out" );
6873
6874 // outline1("LD A, (%s)", _value );
6875 // outline1("LD BC, (%s)", _port );
6876 // outline0("OUT (C), A" );
6877
6878}
6879
6880void cpu_in( Environment * _environment, char * _port, char * _value ) {
6881
6882 CRITICAL_UNIMPLEMENTED( "sc61860_in" );
6883
6884 // outline1("LD BC, (%s)", _port );
6885 // outline0("IN A, (C)" );
6886 // outline1("LD (%s), A", _value );
6887
6888}
6889
6890void cpu_out_direct( Environment * _environment, char * _port, char * _value ) {
6891
6892 CRITICAL_UNIMPLEMENTED( "sc61860_out_direct" );
6893
6894 // outline1("LD A, (%s)", _value );
6895 // outline1("LD BC, %s", _port );
6896 // outline0("OUT (C), A" );
6897
6898}
6899
6900void cpu_in_direct( Environment * _environment, char * _port, char * _value ) {
6901
6902 CRITICAL_UNIMPLEMENTED( "sc61860_in_direct" );
6903
6904 // outline1("LD BC, %s", _port );
6905 // outline0("IN A, (C)" );
6906 // outline1("LD (%s), A", _value );
6907
6908}
6909
6910void cpu_string_sub( Environment * _environment, char * _source, char * _source_size, char * _pattern, char * _pattern_size, char * _destination, char * _destination_size ) {
6911
6912 CRITICAL_UNIMPLEMENTED( "sc61860_string_sub" );
6913
6915
6916 // inline( cpu_string_sub )
6917
6918 // embedded( cpu_string_sub, src_hw_sc61860_cpu_string_sub_asm );
6919
6920 // outline1("LD A, (%s)", _source);
6921 // outline0("LD L, A");
6922 // outline1("LD A, (%s)", address_displacement(_environment, _source, "1"));
6923 // outline0("LD H, A");
6924 // outline1("LD A, (%s)", _source_size);
6925 // outline0("LD IYL, A");
6926
6927 // outline1("LD A, (%s)", _pattern);
6928 // outline0("LD IXL, A");
6929 // outline1("LD A, (%s)", address_displacement(_environment, _pattern, "1"));
6930 // outline0("LD IXH, A");
6931 // outline1("LD A, (%s)", _pattern_size);
6932 // outline0("LD IYH, A");
6933
6934 // outline1("LD A, (%s)", _destination);
6935 // outline0("LD E, A");
6936 // outline1("LD A, (%s)", address_displacement(_environment, _destination, "1"));
6937 // outline0("LD D, A");
6938
6939 // outline0("CALL CPUSTRINGSUB");
6940
6941 // outline0("LD A, IYL");
6942 // outline1("LD (%s), A", _destination_size);
6943
6944 // done()
6945}
6946
6947static char SC616860_BLIT_REGISTER[][2] = {
6948 "L",
6949 "H",
6950 "E",
6951 "D"
6952};
6953
6954#define SC616860_BLII_REGISTER_COUNT ( sizeof( SC616860_BLIT_REGISTER ) / 2 )
6955
6956void cpu_blit_initialize( Environment * _environment ) {
6957
6958 CRITICAL_UNIMPLEMENTED( "sc61860_blit_initialize" );
6959
6960 _environment->blit.freeRegisters = 0;
6961 _environment->blit.usedMemory = 0;
6962
6963 // outline0("PUSH HL");
6964 // outline0("PUSH DE");
6965
6966}
6967
6968void cpu_blit_finalize( Environment * _environment ) {
6969
6970 CRITICAL_UNIMPLEMENTED( "sc61860_blit_finalize" );
6971
6972 _environment->blit.freeRegisters = 0;
6973 _environment->blit.usedMemory = 0;
6974
6975 // outline0("POP DE");
6976 // outline0("POP HL");
6977
6978}
6979
6980char * cpu_blit_register_name( Environment * _environment, int _register ) {
6981
6982 CRITICAL_UNIMPLEMENTED( "sc61860_blit_register_name" );
6983
6984 if ( _register < SC616860_BLII_REGISTER_COUNT ) {
6985 return &SC616860_BLIT_REGISTER[_register][0];
6986 } else {
6987 return &SC616860_BLIT_REGISTER[ (_register & 0xff00) >> 8][0];
6988 }
6989}
6990
6992
6993 CRITICAL_UNIMPLEMENTED( "sc61860_blit_alloc_register" );
6994
6995 int reg = 0;
6996
6997 for( reg = 0; reg < SC616860_BLII_REGISTER_COUNT; ++reg ) {
6998 int registerMask = ( 0x01 << reg );
6999 int isRegisterUsed = _environment->blit.freeRegisters & registerMask;
7000 if ( ! isRegisterUsed ) {
7001 _environment->blit.freeRegisters |= registerMask;
7002 // printf( "sc61860_blit_alloc_register() %4.4x -> 0x%4.4x\n", _environment->blit.freeRegisters, reg );
7003 return reg;
7004 }
7005 }
7006
7007 int location = _environment->blit.usedMemory++;
7008
7009 if ( location > 0xff ) {
7011 }
7012
7013 for( reg = 0; reg < SC616860_BLII_REGISTER_COUNT; ++reg ) {
7014 int registerMask = ( 0x10 << reg );
7015 int isRegisterUsed = _environment->blit.freeRegisters & registerMask;
7016 if ( ! isRegisterUsed ) {
7017 // outline1( "LD A, %s", &SC616860_BLIT_REGISTER[reg][0] );
7018 // outline2( "LD (%sbs+0x%2.2x), A", _environment->blit.realName, location );
7019 _environment->blit.freeRegisters |= registerMask;
7020 // printf( "sc61860_blit_alloc_register() -> %4.4x 0x%4.4x\n", _environment->blit.freeRegisters, ( ( reg << 8 ) | location ) );
7021 return ( ( reg << 8 ) | location );
7022 }
7023 }
7024
7026
7027}
7028
7029void cpu_blit_free_register( Environment * _environment, int _register ) {
7030
7031 CRITICAL_UNIMPLEMENTED( "sc61860_blit_free_register" );
7032
7033 // printf( "sc61860_blit_free_register(0x%4.4x)\n", _register );
7034
7035 int location = _register & 0xff;
7036 int reg;
7037
7038 if ( _register < SC616860_BLII_REGISTER_COUNT ) {
7039 int registerMask = ( 0x01 << _register );
7040 int isRegisterUsed = _environment->blit.freeRegisters & registerMask;
7041 if ( isRegisterUsed ) {
7042 _environment->blit.freeRegisters &= ~registerMask;
7043 return;
7044 } else {
7045 CRITICAL_BLIT_INVALID_FREE_REGISTER( _environment->blit.name, _register );
7046 }
7047 } else {
7048 int registerMask = 0x10 << ( ( _register >> 8 ) & 0xff );
7049 int isRegisterUsed = _environment->blit.freeRegisters & registerMask;
7050 if ( isRegisterUsed ) {
7051 // outline2( "LD A, (%sbs+0x%2.2x)", _environment->blit.realName, location );
7052 // outline1( "LD %s, A", &SC616860_BLIT_REGISTER[reg][0] );
7053 _environment->blit.freeRegisters &= ~registerMask;
7054 return;
7055 }
7056 }
7057
7058 CRITICAL_BLIT_INVALID_FREE_REGISTER( _environment->blit.name, _register );
7059
7060}
7061
7070void cpu_store_nbit( Environment * _environment, char *_destination, int _n, int _value[] ) {
7071
7072 CRITICAL_UNIMPLEMENTED( "sc61860_store_nbit" );
7073
7074 int i = 0;
7075 while( _n ) {
7076 char destinationAddress[MAX_TEMPORARY_STORAGE]; sprintf( destinationAddress, "%s+%d", _destination, i*4 );
7077 if ( _n <= 32 ) {
7078 switch( _n ) {
7079 case 1: case 2: case 3: case 4:
7080 case 5: case 6: case 7: case 8:
7081 cpu_store_8bit( _environment, destinationAddress, ( _value[i] & (0xff>>(8-_n)) ) );
7082 break;
7083 case 9: case 10: case 11: case 12:
7084 case 13: case 14: case 15: case 16:
7085 cpu_store_8bit( _environment, destinationAddress, ( _value[i] & (0xff) ) );
7086 sprintf( destinationAddress, "%s+%d", _destination, i*4+1 );
7087 cpu_store_8bit( _environment, destinationAddress, ( _value[i+1] & (0xff>>(16-_n)) ) );
7088 break;
7089 case 17: case 18: case 19: case 20:
7090 case 21: case 22: case 23: case 24:
7091 cpu_store_8bit( _environment, destinationAddress, ( _value[i] & (0xff) ) );
7092 sprintf( destinationAddress, "%s+%d", _destination, i*4+1 );
7093 cpu_store_8bit( _environment, destinationAddress, ( _value[i+1] & (0xff) ) );
7094 sprintf( destinationAddress, "%s+%d", _destination, i*4+2 );
7095 cpu_store_8bit( _environment, destinationAddress, ( _value[i+2] & (0xff>>(24-_n)) ) );
7096 break;
7097 case 25: case 26: case 27: case 28:
7098 case 29: case 30: case 31: case 32:
7099 default:
7100 cpu_store_8bit( _environment, destinationAddress, ( _value[i] & (0xff) ) );
7101 sprintf( destinationAddress, "%s+%d", _destination, i*4+1 );
7102 cpu_store_8bit( _environment, destinationAddress, ( _value[i+1] & (0xff) ) );
7103 sprintf( destinationAddress, "%s+%d", _destination, i*4+2 );
7104 cpu_store_8bit( _environment, destinationAddress, ( _value[i+2] & (0xff) ) );
7105 sprintf( destinationAddress, "%s+%d", _destination, i*4+3 );
7106 cpu_store_8bit( _environment, destinationAddress, ( _value[i+3] & (0xff>>(32-_n)) ) );
7107 break;
7108 }
7109 _n = 0;
7110 } else {
7111 cpu_store_8bit( _environment, destinationAddress, ( _value[i] & (0xff) ) );
7112 sprintf( destinationAddress, "%s+%d", _destination, i*4+1 );
7113 cpu_store_8bit( _environment, destinationAddress, ( _value[i+1] & (0xff) ) );
7114 sprintf( destinationAddress, "%s+%d", _destination, i*4+2 );
7115 cpu_store_8bit( _environment, destinationAddress, ( _value[i+2] & (0xff) ) );
7116 sprintf( destinationAddress, "%s+%d", _destination, i*4+3 );
7117 cpu_store_8bit( _environment, destinationAddress, ( _value[i+3] & (0xff>>(32-_n)) ) );
7118 _n -= 32;
7119 }
7120 ++i;
7121 }
7122
7123}
7124
7133void cpu_move_nbit( Environment * _environment, int _n, char * _source, char *_destination ) {
7134
7135 CRITICAL_UNIMPLEMENTED( "sc61860_move_nbit" );
7136
7137 int i = 0;
7138 while( _n ) {
7139 char sourceAddress[MAX_TEMPORARY_STORAGE]; sprintf( sourceAddress, "%s+%d", _source, i*4 );
7140 char destinationAddress[MAX_TEMPORARY_STORAGE]; sprintf( destinationAddress, "%s+%d", _destination, i*4 );
7141 if ( _n <= 32 ) {
7142 switch( _n ) {
7143 case 1: case 2: case 3: case 4:
7144 case 5: case 6: case 7: case 8:
7145 cpu_move_8bit( _environment, sourceAddress, destinationAddress );
7146 break;
7147 case 9: case 10: case 11: case 12:
7148 case 13: case 14: case 15: case 16:
7149 cpu_move_8bit( _environment, sourceAddress, destinationAddress );
7150 sprintf( sourceAddress, "%s+%d", _source, i*4+1 );
7151 sprintf( destinationAddress, "%s+%d", _destination, i*4+1 );
7152 cpu_move_8bit( _environment, sourceAddress, destinationAddress );
7153 break;
7154 case 17: case 18: case 19: case 20:
7155 case 21: case 22: case 23: case 24:
7156 cpu_move_8bit( _environment, sourceAddress, destinationAddress );
7157 sprintf( sourceAddress, "%s+%d", _source, i*4+1 );
7158 sprintf( destinationAddress, "%s+%d", _destination, i*4+1 );
7159 cpu_move_8bit( _environment, sourceAddress, destinationAddress );
7160 sprintf( sourceAddress, "%s+%d", _source, i*4+2 );
7161 sprintf( destinationAddress, "%s+%d", _destination, i*4+2 );
7162 cpu_move_8bit( _environment, sourceAddress, destinationAddress );
7163 break;
7164 case 25: case 26: case 27: case 28:
7165 case 29: case 30: case 31: case 32:
7166 default:
7167 cpu_move_8bit( _environment, sourceAddress, destinationAddress );
7168 sprintf( sourceAddress, "%s+%d", _source, i*4+1 );
7169 sprintf( destinationAddress, "%s+%d", _destination, i*4+1 );
7170 cpu_move_8bit( _environment, sourceAddress, destinationAddress );
7171 sprintf( sourceAddress, "%s+%d", _source, i*4+2 );
7172 sprintf( destinationAddress, "%s+%d", _destination, i*4+2 );
7173 cpu_move_8bit( _environment, sourceAddress, destinationAddress );
7174 sprintf( sourceAddress, "%s+%d", _source, i*4+3 );
7175 sprintf( destinationAddress, "%s+%d", _destination, i*4+3 );
7176 cpu_move_8bit( _environment, sourceAddress, destinationAddress );
7177 break;
7178 }
7179 _n = 0;
7180 } else {
7181 cpu_move_8bit( _environment, sourceAddress, destinationAddress );
7182 sprintf( sourceAddress, "%s+%d", _source, i*4+1 );
7183 sprintf( destinationAddress, "%s+%d", _destination, i*4+1 );
7184 cpu_move_8bit( _environment, sourceAddress, destinationAddress );
7185 sprintf( sourceAddress, "%s+%d", _source, i*4+2 );
7186 sprintf( destinationAddress, "%s+%d", _destination, i*4+2 );
7187 cpu_move_8bit( _environment, sourceAddress, destinationAddress );
7188 sprintf( sourceAddress, "%s+%d", _source, i*4+3 );
7189 sprintf( destinationAddress, "%s+%d", _destination, i*4+3 );
7190 cpu_move_8bit( _environment, sourceAddress, destinationAddress );
7191 _n -= 32;
7192 }
7193 ++i;
7194 }
7195
7196}
7197
7206void cpu_compare_nbit( Environment * _environment, int _n, char *_source, char *_destination, char *_name, int _positive ) {
7207
7208 CRITICAL_UNIMPLEMENTED( "sc61860_compare_nbit" );
7209
7211
7212 char differentLabel[MAX_TEMPORARY_STORAGE];
7213 sprintf( differentLabel, "%sdifferent:", label );
7214
7215 int i = 0;
7216 while( _n ) {
7217 char sourceAddress[MAX_TEMPORARY_STORAGE]; sprintf( sourceAddress, "%s+%d", _source, i*4 );
7218 char destinationAddress[MAX_TEMPORARY_STORAGE]; sprintf( destinationAddress, "%s+%d", _destination, i*4 );
7219 if ( _n <= 32 ) {
7220 switch( _n ) {
7221 case 1: case 2: case 3: case 4:
7222 case 5: case 6: case 7: case 8:
7223 cpu_compare_8bit( _environment, sourceAddress, destinationAddress, _name, _positive );
7224 cpu_compare_and_branch_8bit_const( _environment, _name, 0, differentLabel, _positive );
7225 break;
7226 case 9: case 10: case 11: case 12:
7227 case 13: case 14: case 15: case 16:
7228 cpu_compare_8bit( _environment, sourceAddress, destinationAddress, _name, _positive );
7229 cpu_compare_and_branch_8bit_const( _environment, _name, 0, differentLabel, _positive );
7230 sprintf( sourceAddress, "%s+%d", _source, i*4+1 );
7231 sprintf( destinationAddress, "%s+%d", _destination, i*4+1 );
7232 cpu_compare_8bit( _environment, sourceAddress, destinationAddress, _name, _positive );
7233 cpu_compare_and_branch_8bit_const( _environment, _name, 0, differentLabel, _positive );
7234 break;
7235 case 17: case 18: case 19: case 20:
7236 case 21: case 22: case 23: case 24:
7237 cpu_compare_8bit( _environment, sourceAddress, destinationAddress, _name, _positive );
7238 cpu_compare_and_branch_8bit_const( _environment, _name, 0, differentLabel, _positive );
7239 sprintf( sourceAddress, "%s+%d", _source, i*4+1 );
7240 sprintf( destinationAddress, "%s+%d", _destination, i*4+1 );
7241 cpu_compare_8bit( _environment, sourceAddress, destinationAddress, _name, _positive );
7242 cpu_compare_and_branch_8bit_const( _environment, _name, 0, differentLabel, _positive );
7243 sprintf( sourceAddress, "%s+%d", _source, i*4+2 );
7244 sprintf( destinationAddress, "%s+%d", _destination, i*4+2 );
7245 cpu_compare_8bit( _environment, sourceAddress, destinationAddress, _name, _positive );
7246 cpu_compare_and_branch_8bit_const( _environment, _name, 0, differentLabel, _positive );
7247 break;
7248 case 25: case 26: case 27: case 28:
7249 case 29: case 30: case 31: case 32:
7250 default:
7251 cpu_compare_8bit( _environment, sourceAddress, destinationAddress, _name, _positive );
7252 cpu_compare_and_branch_8bit_const( _environment, _name, 0, differentLabel, _positive );
7253 sprintf( sourceAddress, "%s+%d", _source, i*4+1 );
7254 sprintf( destinationAddress, "%s+%d", _destination, i*4+1 );
7255 cpu_compare_8bit( _environment, sourceAddress, destinationAddress, _name, _positive );
7256 cpu_compare_and_branch_8bit_const( _environment, _name, 0, differentLabel, _positive );
7257 sprintf( sourceAddress, "%s+%d", _source, i*4+2 );
7258 sprintf( destinationAddress, "%s+%d", _destination, i*4+2 );
7259 cpu_compare_8bit( _environment, sourceAddress, destinationAddress, _name, _positive );
7260 cpu_compare_and_branch_8bit_const( _environment, _name, 0, differentLabel, _positive );
7261 sprintf( sourceAddress, "%s+%d", _source, i*4+3 );
7262 sprintf( destinationAddress, "%s+%d", _destination, i*4+3 );
7263 cpu_compare_8bit( _environment, sourceAddress, destinationAddress, _name, _positive );
7264 cpu_compare_and_branch_8bit_const( _environment, _name, 0, differentLabel, _positive );
7265 break;
7266 }
7267 _n = 0;
7268 } else {
7269 cpu_compare_8bit( _environment, sourceAddress, destinationAddress, _name, _positive );
7270 cpu_compare_and_branch_8bit_const( _environment, _name, 0, differentLabel, _positive );
7271 sprintf( sourceAddress, "%s+%d", _source, i*4+1 );
7272 sprintf( destinationAddress, "%s+%d", _destination, i*4+1 );
7273 cpu_compare_8bit( _environment, sourceAddress, destinationAddress, _name, _positive );
7274 cpu_compare_and_branch_8bit_const( _environment, _name, 0, differentLabel, _positive );
7275 sprintf( sourceAddress, "%s+%d", _source, i*4+2 );
7276 sprintf( destinationAddress, "%s+%d", _destination, i*4+2 );
7277 cpu_compare_8bit( _environment, sourceAddress, destinationAddress, _name, _positive );
7278 cpu_compare_and_branch_8bit_const( _environment, _name, 0, differentLabel, _positive );
7279 sprintf( sourceAddress, "%s+%d", _source, i*4+3 );
7280 sprintf( destinationAddress, "%s+%d", _destination, i*4+3 );
7281 cpu_compare_8bit( _environment, sourceAddress, destinationAddress, _name, _positive );
7282 cpu_compare_and_branch_8bit_const( _environment, _name, 0, differentLabel, _positive );
7283 _n -= 32;
7284 }
7285 ++i;
7286 }
7287
7288 // outline1("LD A, 0x%2.2x", _positive * 0xff );
7289 // outline1("LD (%s), A", _name );
7290 // outline1("JP %s// done", label );
7291
7292 // outhead0(differentLabel);
7293 // outline1("LD A, 0x%2.2x", (1-_positive) * 0xff );
7294 // outline1("LD (%s), A", _name );
7295
7296 // outhead1("%s// done:", label );
7297
7298}
7299
7300// [0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
7301// FAST (24) seeeeeee mmmmmmmm mmmmmmmm
7302
7303void cpu_float_fast_from_double_to_int_array( Environment * _environment, double _value, int _result[] ) {
7304
7305 CRITICAL_UNIMPLEMENTED( "sc61860_float_fast_from_double_to_int_array" );
7306
7307 double value = 0.0;
7308 double integral = 0.0;
7309 double fractional = 0.0;
7310 int sign = 0;
7311 int left = 0;
7312 int right[2];
7313 int steps = 0;
7314 int exp = 0;
7315 int mantissa_bits = 16;
7316
7317 memset( &right[0], 0, sizeof( int ) * 2 );
7318
7319 // Step 1: Determine Sign
7320 // If the number is positive, then the sign bit will be 0. If the number is negative, then the sign bit
7321 // will be 1. For the number zero, both positive and negative zero are possible, and these are considered
7322 // different values (a quirk of using sign bits).
7323
7324 if ( _value >= 0 ) {
7325 sign = 0;
7326 } else {
7327 sign = 1;
7328 }
7329
7330 value = fabs( _value );
7331
7332 // Step 2: Convert the Integral Portion to Unsigned Binary
7333 // Convert the integral portion of the floating-point value to unsigned binary (not two's complement).
7334 // The integral portion is the part of the number before the decimal point. For example, if the
7335 // number to convert is -0.75, then 0 is the integral portion, and it's unsigned binary representation
7336 // is simply 0. As another example, if the number to convert is 127.99, then the integral portion would
7337 // be 127, and it's unsigned binary representation is 1111111.
7338
7339 fractional = modf(value, &integral);
7340
7341 left = (unsigned int) integral;
7342
7343 // Step 3: Convert the Fractional Portion to Binary
7344 // The fractional portion of the number must also be converted to binary, though the conversion process
7345 // is much different from what you're used to. The algorithm you'll used is based on performing repeated
7346 // multiplications by 2, and then checking if the result is >= 1.0. If the result is >= 1.0, then a 1 is
7347 // recorded for the binary fractional component, and the leading 1 is chopped of the result. If the
7348 // result is < 1.0, then a 0 is recorded for the binary fractional component, and the result is kept
7349 // as-is. The recorded builds are built-up left-to-right. The result keeps getting chained along in this
7350 // way until one of the following is true:
7351 // - The result is exactly 1.0
7352 // - 23 iterations of this process have occurred; i.e. the final converted binary value holds 23 bits
7353 // With the first possible terminating condition (the result is exactly 1.0), this means that the fractional
7354 // component has been represented without any loss of precision. With the second possible terminating
7355 // condition (23 iterations have passed), this means that we ran out of bits in the final result, which
7356 // can never exceed 23. In this case, precision loss occurs (an unfortunate consequence of using a finite
7357 // number of bits).
7358
7359 while( ( fractional != 1.0 ) && ( steps < mantissa_bits ) ) {
7360
7361 // printf("%f %d %2.2x %2.2x\n", fractional, steps, (unsigned char) right[0], (unsigned char) right[1] );
7362
7363 right[1] = right[1] << 1;
7364 right[0] = right[0] << 1;
7365 if ( ( right[1] & 0x100 ) ) {
7366 right[0] = right[0] | 0x1;
7367 }
7368 right[1] = right[1] & 0xff;
7369 right[0] = right[0] & 0xff;
7370
7371 fractional = fractional * 2;
7372
7373 if ( fractional >= 1.0 ) {
7374 right[1] |= 1;
7375 fractional = modf(fractional, &integral);
7376 }
7377
7378 ++steps;
7379
7380 }
7381
7382 // Step 4: Normalize the Value via Adjusting the Exponent
7383 // A trick to encode an extra bit is to make it so that the binary scientific representation is always
7384 // of the form 1.XXXX * 2YYYY. That is, a 1 always leads, so there is no need to explicitly encode it.
7385 // In order to encode this properly, we need to move the decimal point to a position where it is
7386 // immediately after the first 1, and then record exactly how we moved it. To see this in action, consider
7387 // again the example of 0.75, which is encoded in binary as such (not IEEE-754 notation):
7388 // 0.11
7389 // In order to make the decimal point be after the first 1, we will need to move it one position to the right, like so:
7390 // 1.1
7391 // Most importantly, we need to record that we moved the decimal point by one position to the right.
7392 // Moves to the right result in negative exponents, and moves to the left result in positive exponents.
7393 // In this case, because we moved the decimal point one position to the right, the recorded exponent should be -1.
7394 // As another example, consider the following binary floating point representation (again, not IEEE-754):
7395 // 1111111.11100
7396 // In this case, we need to move the decimal point six positions to the left to make this begin with a single 1, like so:
7397 // 1.11111111100
7398 // Because this moves six positions to the left, the recorded exponent should be 6.
7399
7400 int mantissa_high_bit = 0x80000000 >> ( 32 - mantissa_bits);
7401 int mantissa_mask = 0xffffffff >> ( 32 - mantissa_bits);
7402
7403 if ( left == 0 ) {
7404
7405 if ( value != 0 ) {
7406
7407 while( left == 0 ) {
7408
7409 // printf("exp = %d left = %2.2x right = %2.2x %2.2x\n", exp, (unsigned char) left, (unsigned char) right[0], (unsigned char) right[1] );
7410
7411 if ( ! right[0] && ! right[1] && ! right[2] ) {
7412 left = 0x1;
7413 }
7414
7415 if ( right[0] & 0x80 ) {
7416 left = 0x1;
7417 }
7418
7419 right[0] = right[0] << 1;
7420 right[1] = right[1] << 1;
7421 if ( ( right[1] & 0x100 )) {
7422 right[0] = right[0] | 0x1;
7423 }
7424 right[0] = right[0] & 0xff;
7425 right[1] = right[1] & 0xff;
7426
7427 --exp;
7428 }
7429
7430 } else {
7431
7432 exp = -63;
7433
7434 }
7435
7436 // printf("exp = %d left = %2.2x right = %2.2x %2.2x\n", exp, (unsigned char) left, (unsigned char) right[0], (unsigned char) right[1] );
7437
7438 } else {
7439
7440 while( left ) {
7441
7442 // printf("left = %8.8x right = %2.2x %2.2x\n", left, (unsigned char) right[0], (unsigned char) right[1] );
7443
7444 if ( ( right[0] & 0x01 ) ) {
7445 right[1] = right[1] | 0x100;
7446 }
7447 right[0] = right[0] >> 1;
7448 right[1] = right[1] >> 1;
7449 if ( left & 0x1 ) {
7450 right[0] = right[0] | 0x80;
7451 }
7452 left = left >> 1;
7453 ++exp;
7454 }
7455 --exp;
7456 left = 1;
7457 right[1] = right[1] << 1;
7458 right[0] = right[0] << 1;
7459 if ( right[1] & 0x100 ) {
7460 right[0] = right[0] | 0x01;
7461 }
7462 right[1] = right[1] & 0xff;
7463 right[0] = right[0] & 0xff;
7464
7465 }
7466
7467 // Step 5: Add Bias to the Exponent
7468 // Internally, IEEE-754 values store their exponents in an unsigned representation, which may seem odd considering that
7469 // the exponent can be negative. Negative exponents are accomodated by using a biased representation, wherein a
7470 // pre-set number is always subtracted from the given unsigned number. Because the given unsigned number may be less
7471 // than this number, this allows for negative values to be effectively encoded without resorting to two's complement.
7472 // Specifically, for the binary32 representation, the number 127 will be subtracted from anything encoded in the
7473 // exponent field of the IEEE-754 number. As such, in this step, we need to add 127 to the normalized exponent value
7474 // from the previous step.
7475
7476 exp += 63;
7477
7478 // printf("exp = %2.2x\n", exp );
7479
7480 // Step 6: Convert the Biased Exponent to Unsigned Binary
7481 // The biased exponent value from the previous step must be converted into unsigned binary, using the usual process.
7482 // The result must be exactly 8 bits. It should not be possible to need more than 8 bits. If fewer than 8 bits are
7483 // needed in this conversion process, then leading zeros must be added to the front of the result to produce an
7484 // 8-bit value.
7485
7486 exp = exp & 0xff;
7487
7488 // printf("exp = %2.2x\n", exp );
7489
7490 // Step 7: Determine the Final Bits for the Mantissa
7491 // After step 4, there are a bunch of bits after the normalized decimal point. These bits will become the
7492 // mantissa (note that we ignore the bits to the left of the decimal point - normalization allows us to do this,
7493 // because it should always be just a 1). We need exactly 23 mantissa bits. If less than 23 mantissa bits follow the
7494 // decimal point, and the algorithm in step 3 ended with a result that wasn't 1.0, then follow the algorithm in step 3
7495 // until we can fill enough bits. If that's still not enough (eventually reaching 1.0 before we had enough bits, or
7496 // perhaps it had ended with 1.0 already), then the right side can be padded with zeros until 23 bits is reached.
7497 // If there are more than 23 bits after the decimal point in step 4, then these extra bits are simply cutoff from the
7498 // right. For example, if we had 26 bits to the right of the decimal point, then the last three would need to be cutoff
7499 // to get us to 23 bits. Note that in this case we will necessarily lose some precision.
7500
7501 // Step 8: Put it All Together
7502 // The sign bit from step 1 will be the first bit of the final result. The next 8 bits will be from the exponent from
7503 // step 6. The last 23 bits will be from the mantissa from step 7. The result will be a 32-bit number encoded in
7504 // IEEE-754 binary32 format, assuming no mistakes were made in the process.
7505
7506 // [0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
7507 // FAST (24) seeeeeee mmmmmmmm mmmmmmmm
7508
7509 _result[0] = ( sign << 7 ) | ( exp & 0x7f );
7510 _result[1] = ( right[0] );
7511 _result[2] = ( right[1] );
7512
7513 // printf( "%2.2x %2.2x %2.2x\n", _result[0], _result[1], _result[2] );
7514
7515}
7516
7517//
7518// [0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
7519// SINGLE (32) seeeeeee emmmmmmm mmmmmmmm mmmmmmmm
7520//
7521
7522void cpu_float_single_from_double_to_int_array( Environment * _environment, double _value, int _result[] ) {
7523
7524 CRITICAL_UNIMPLEMENTED( "sc61860_float_single_from_double_to_int_array" );
7525
7526 double value = 0.0;
7527 double integral = 0.0;
7528 double fractional = 0.0;
7529 int sign = 0;
7530 int left = 0;
7531 int right[3];
7532 int steps = 0;
7533 int exp = 0;
7534 int mantissa_bits = 23;
7535
7536 memset( &right[0], 0, sizeof( int ) * 3 );
7537
7538 // Step 1: Determine Sign
7539 // If the number is positive, then the sign bit will be 0. If the number is negative, then the sign bit
7540 // will be 1. For the number zero, both positive and negative zero are possible, and these are considered
7541 // different values (a quirk of using sign bits).
7542
7543 if ( _value >= 0 ) {
7544 sign = 0;
7545 } else {
7546 sign = 1;
7547 }
7548
7549 value = fabs( _value );
7550
7551 // Step 2: Convert the Integral Portion to Unsigned Binary
7552 // Convert the integral portion of the floating-point value to unsigned binary (not two's complement).
7553 // The integral portion is the part of the number before the decimal point. For example, if the
7554 // number to convert is -0.75, then 0 is the integral portion, and it's unsigned binary representation
7555 // is simply 0. As another example, if the number to convert is 127.99, then the integral portion would
7556 // be 127, and it's unsigned binary representation is 1111111.
7557
7558 fractional = modf(value, &integral);
7559
7560 left = (unsigned int) integral;
7561
7562 // Step 3: Convert the Fractional Portion to Binary
7563 // The fractional portion of the number must also be converted to binary, though the conversion process
7564 // is much different from what you're used to. The algorithm you'll used is based on performing repeated
7565 // multiplications by 2, and then checking if the result is >= 1.0. If the result is >= 1.0, then a 1 is
7566 // recorded for the binary fractional component, and the leading 1 is chopped of the result. If the
7567 // result is < 1.0, then a 0 is recorded for the binary fractional component, and the result is kept
7568 // as-is. The recorded builds are built-up left-to-right. The result keeps getting chained along in this
7569 // way until one of the following is true:
7570 // - The result is exactly 1.0
7571 // - 23 iterations of this process have occurred; i.e. the final converted binary value holds 23 bits
7572 // With the first possible terminating condition (the result is exactly 1.0), this means that the fractional
7573 // component has been represented without any loss of precision. With the second possible terminating
7574 // condition (23 iterations have passed), this means that we ran out of bits in the final result, which
7575 // can never exceed 23. In this case, precision loss occurs (an unfortunate consequence of using a finite
7576 // number of bits).
7577
7578 while( ( fractional != 1.0 ) && ( steps < mantissa_bits ) ) {
7579
7580 // printf("%f %d %2.2x %2.2x %2.2x\n", fractional, steps, (unsigned char) right[0], (unsigned char) right[1], (unsigned char) right[2] );
7581
7582 right[2] = right[2] << 1;
7583 right[1] = right[1] << 1;
7584 right[0] = right[0] << 1;
7585 if ( ( right[2] & 0x100 ) ) {
7586 right[1] = right[1] | 0x1;
7587 }
7588 if ( ( right[1] & 0x100 ) ) {
7589 right[0] = right[0] | 0x1;
7590 }
7591 right[2] = right[2] & 0xff;
7592 right[1] = right[1] & 0xff;
7593 right[0] = right[0] & 0x7f;
7594
7595 fractional = fractional * 2;
7596
7597 if ( fractional >= 1.0 ) {
7598 right[2] |= 1;
7599 fractional = modf(fractional, &integral);
7600 }
7601
7602 ++steps;
7603
7604 }
7605
7606 // Step 4: Normalize the Value via Adjusting the Exponent
7607 // A trick to encode an extra bit is to make it so that the binary scientific representation is always
7608 // of the form 1.XXXX * 2YYYY. That is, a 1 always leads, so there is no need to explicitly encode it.
7609 // In order to encode this properly, we need to move the decimal point to a position where it is
7610 // immediately after the first 1, and then record exactly how we moved it. To see this in action, consider
7611 // again the example of 0.75, which is encoded in binary as such (not IEEE-754 notation):
7612 // 0.11
7613 // In order to make the decimal point be after the first 1, we will need to move it one position to the right, like so:
7614 // 1.1
7615 // Most importantly, we need to record that we moved the decimal point by one position to the right.
7616 // Moves to the right result in negative exponents, and moves to the left result in positive exponents.
7617 // In this case, because we moved the decimal point one position to the right, the recorded exponent should be -1.
7618 // As another example, consider the following binary floating point representation (again, not IEEE-754):
7619 // 1111111.11100
7620 // In this case, we need to move the decimal point six positions to the left to make this begin with a single 1, like so:
7621 // 1.11111111100
7622 // Because this moves six positions to the left, the recorded exponent should be 6.
7623
7624 int mantissa_high_bit = 0x80000000 >> ( 32 - mantissa_bits);
7625 int mantissa_mask = 0xffffffff >> ( 32 - mantissa_bits);
7626
7627 if ( left == 0 ) {
7628
7629 if ( value != 0 ) {
7630
7631 while( left == 0 ) {
7632
7633 // printf("exp = %d left = %2.2x right = %2.2x %2.2x %2.2x\n", exp, (unsigned char) left, (unsigned char) right[0], (unsigned char) right[1], (unsigned char) right[2] );
7634
7635 if ( right[0] & 0x40 ) {
7636 left = 0x1;
7637 }
7638
7639 right[0] = right[0] << 1;
7640 right[1] = right[1] << 1;
7641 right[2] = right[2] << 1;
7642 if ( ( right[1] & 0x100 )) {
7643 right[0] = right[0] | 0x1;
7644 }
7645 if ( ( right[2] & 0x100 )) {
7646 right[1] = right[1] | 0x1;
7647 }
7648 right[0] = right[0] & 0x7f;
7649 right[1] = right[1] & 0xff;
7650 right[2] = right[2] & 0xff;
7651
7652 --exp;
7653 }
7654
7655 } else {
7656
7657 exp = -127;
7658
7659 }
7660
7661 // printf("exp = %d left = %2.2x right = %2.2x %2.2x %2.2x\n", exp, (unsigned char) left, (unsigned char) right[0], (unsigned char) right[1], (unsigned char) right[2] );
7662
7663 } else {
7664
7665 while( left ) {
7666
7667 // printf("left = %8.8x right = %2.2x %2.2x %2.2x\n", left, (unsigned char) right[0], (unsigned char) right[1], (unsigned char) right[2] );
7668
7669 if ( ( right[0] & 0x01 ) ) {
7670 right[1] = right[1] | 0x100;
7671 }
7672 if ( ( right[1] & 0x01 ) ) {
7673 right[2] = right[2] | 0x100;
7674 }
7675 right[0] = right[0] >> 1;
7676 right[1] = right[1] >> 1;
7677 // right[2] = right[2] >> 1;
7678 if ( left & 0x1 ) {
7679 right[0] = right[0] | 0x40;
7680 }
7681 left = left >> 1;
7682 ++exp;
7683 }
7684 --exp;
7685 left = 1;
7686 right[2] = right[2] << 1;
7687 right[1] = right[1] << 1;
7688 right[0] = right[0] << 1;
7689 if ( right[2] & 0x100 ) {
7690 right[1] = right[1] | 0x01;
7691 }
7692 if ( right[1] & 0x100 ) {
7693 right[0] = right[0] | 0x01;
7694 }
7695 right[2] = right[2] & 0xff;
7696 right[1] = right[1] & 0xff;
7697 right[0] = right[0] & 0x7f;
7698
7699 }
7700
7701 // Step 5: Add Bias to the Exponent
7702 // Internally, IEEE-754 values store their exponents in an unsigned representation, which may seem odd considering that
7703 // the exponent can be negative. Negative exponents are accomodated by using a biased representation, wherein a
7704 // pre-set number is always subtracted from the given unsigned number. Because the given unsigned number may be less
7705 // than this number, this allows for negative values to be effectively encoded without resorting to two's complement.
7706 // Specifically, for the binary32 representation, the number 127 will be subtracted from anything encoded in the
7707 // exponent field of the IEEE-754 number. As such, in this step, we need to add 127 to the normalized exponent value
7708 // from the previous step.
7709
7710 exp += 127;
7711
7712 // printf("exp = %2.2x\n", exp );
7713
7714 // Step 6: Convert the Biased Exponent to Unsigned Binary
7715 // The biased exponent value from the previous step must be converted into unsigned binary, using the usual process.
7716 // The result must be exactly 8 bits. It should not be possible to need more than 8 bits. If fewer than 8 bits are
7717 // needed in this conversion process, then leading zeros must be added to the front of the result to produce an
7718 // 8-bit value.
7719
7720 exp = exp & 0xff;
7721
7722 // printf("exp = %2.2x\n", exp );
7723
7724 // Step 7: Determine the Final Bits for the Mantissa
7725 // After step 4, there are a bunch of bits after the normalized decimal point. These bits will become the
7726 // mantissa (note that we ignore the bits to the left of the decimal point - normalization allows us to do this,
7727 // because it should always be just a 1). We need exactly 23 mantissa bits. If less than 23 mantissa bits follow the
7728 // decimal point, and the algorithm in step 3 ended with a result that wasn't 1.0, then follow the algorithm in step 3
7729 // until we can fill enough bits. If that's still not enough (eventually reaching 1.0 before we had enough bits, or
7730 // perhaps it had ended with 1.0 already), then the right side can be padded with zeros until 23 bits is reached.
7731 // If there are more than 23 bits after the decimal point in step 4, then these extra bits are simply cutoff from the
7732 // right. For example, if we had 26 bits to the right of the decimal point, then the last three would need to be cutoff
7733 // to get us to 23 bits. Note that in this case we will necessarily lose some precision.
7734
7735 // Step 8: Put it All Together
7736 // The sign bit from step 1 will be the first bit of the final result. The next 8 bits will be from the exponent from
7737 // step 6. The last 23 bits will be from the mantissa from step 7. The result will be a 32-bit number encoded in
7738 // IEEE-754 binary32 format, assuming no mistakes were made in the process.
7739
7740 // [0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
7741 // SINGLE (32) seeeeeee emmmmmmm mmmmmmmm mmmmmmmm
7742
7743 _result[3] = ( sign << 7 ) | ( ( exp >> 1 ) & 0x7f );
7744 _result[2] = ( ( exp & 0x01 ) << 7 ) | ( right[0] );
7745 _result[1] = ( right[1] );
7746 _result[0] = ( right[2] );
7747
7748 // printf( "%2.2x %2.2x %2.2x %2.2x\n", _result[0], _result[1], _result[2], _result[3] );
7749
7750}
7751
7752//
7753// [0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
7754// EXTENDED (80) seeeeeee eeeeeeee mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm
7755//
7756
7757void cpu_float_double_from_double_to_int_array( Environment * _environment, double _value, int _result[] ) {
7758
7759 CRITICAL_UNIMPLEMENTED( "sc61860_float_double_from_double_to_int_array" );
7760
7761}
7762
7763void cpu_float_fast_to_string( Environment * _environment, char * _x, char * _string, char * _string_size ) {
7764
7765 CRITICAL_UNIMPLEMENTED( "sc61860_float_fast_to_string" );
7766
7768
7769 // deploy( fp_mul16, src_hw_sc61860_fp_mul16_asm );
7770 // deploy( fp_fast_mul, src_hw_sc61860_fp_fast_mul_asm );
7771 // deploy( fp_fast_pow10_lut, src_hw_sc61860_fp_fast_pow10_lut_asm );
7772 // deploy( fp_format_str, src_hw_sc61860_fp_format_str_asm );
7773 // deploy( fp_fast_to_string, src_hw_sc61860_fp_fast_to_string_asm );
7774
7775 // ;converts a 24-bit float to a string
7776
7777 // ;Inputs:
7778 // ; AHL is the float to convert
7779
7780 // outline1( "LD A, (%s)", address_displacement( _environment, _x, "+2" ) );
7781 // outline0( "LD L, A" );
7782 // outline1( "LD A, (%s)", address_displacement( _environment, _x, "+1" ) );
7783 // outline0( "LD H, A" );
7784 // outline1( "LD A, (%s)", _x );
7785
7786 // ; DE points to where to write the string
7787 // outline1( "LD DE, (%s)", _string );
7788
7789 // outline0( "CALL FPFASTTOA" );
7790
7791 // ;Output:
7792 // ; HL pointing to the string
7793 // outline0( "PUSH HL" );
7794 // outline0( "POP DE" );
7795 // outhead1( "%s:", label );
7796 // outline0( "LD A, (DE)" );
7797 // outline0( "CP 0" );
7798 // outline1( "JR Z, %s// done", label );
7799 // outline0( "INC DE" );
7800 // outline0( "INC C" );
7801 // outline1( "JR %s", label );
7802 // outhead1( "%s// done:", label );
7803 // outline0( "LD A, C" );
7804 // outline1( "LD (%s), A", _string_size );
7805
7806 // ;Destroys:
7807 // ; A,DE,BC
7808 // ;Notes:
7809 // ; Uses up to 12 bytes to store the string
7810
7811}
7812
7813void cpu_float_single_to_string( Environment * _environment, char * _x, char * _string, char * _string_size ) {
7814
7815 CRITICAL_UNIMPLEMENTED( "sc61860_float_single_to_string" );
7816
7818
7819 // deploy( fp_pushpop, src_hw_sc61860_fp_pushpop_asm );
7820 // deploy( fp_mul24_stack_based, src_hw_sc61860_fp_mul24_stack_based_asm );
7821 // deploy( fp_c_times_bde, src_hw_sc61860_fp_c_times_bde_asm );
7822 // deploy( fp_single_pow10_lut, src_hw_sc61860_fp_single_pow10_lut_asm );
7823 // deploy( fp_single_mul, src_hw_sc61860_fp_single_mul_asm );
7824 // deploy( fp_mov4, src_hw_sc61860_fp_mov4_asm );
7825 // deploy( fp_common_str, src_hw_sc61860_fp_common_str_asm );
7826 // deploy( fp_format_str, src_hw_sc61860_fp_format_str_asm );
7827 // deploy( fp_single_to_string, src_hw_sc61860_fp_single_to_string_asm );
7828
7829 // ;converts a 32-bit float to a string
7830
7831 // ;Inputs:
7832 // ; HL points to the input float
7833 // ; BC points to where the string gets written.
7834
7835 // outline1( "LD HL, %s", _x );
7836
7837 // outline1( "LD BC, (%s)", _string );
7838
7839 // outline0( "CALL FPSINGLETOA" );
7840
7841 // ;Output:
7842 // ; HL pointing to the string
7843 // outline0( "PUSH HL" );
7844 // outline0( "POP DE" );
7845 // outhead1( "%s:", label );
7846 // outline0( "LD A, (DE)" );
7847 // outline0( "CP 0" );
7848 // outline1( "JR Z, %s// done", label );
7849 // outline0( "INC DE" );
7850 // outline0( "INC C" );
7851 // outline1( "JR %s", label );
7852 // outhead1( "%s// done:", label );
7853 // outline0( "LD A, C" );
7854 // outline1( "LD (%s), A", _string_size );
7855
7856}
7857
7858void cpu_float_double_to_string( Environment * _environment, char * _x, char * _string, char * _string_size ) {
7859
7860 CRITICAL_UNIMPLEMENTED( "sc61860_float_double_to_string" );
7861
7862}
7863
7864void cpu_float_fast_from_16( Environment * _environment, char * _value, char * _result, int _signed ) {
7865
7866 CRITICAL_UNIMPLEMENTED( "sc61860_float_fast_from_16" );
7867
7868 // deploy( fp_fast_from_16, src_hw_sc61860_fp_fast_from_16_asm );
7869
7870 // outline1( "LD HL, (%s)", _value );
7871 if ( _signed ) {
7872 // outline0( "CALL FPFASTFROM16S");
7873 } else {
7874 // outline0( "CALL FPFASTFROM16U");
7875 }
7876 // outline1( "LD (%s), A", _result );
7877 // outline0( "LD A, H" );
7878 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+1" ) );
7879 // outline0( "LD A, L" );
7880 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+2" ) );
7881
7882}
7883
7884void cpu_float_fast_from_8( Environment * _environment, char * _value, char * _result, int _signed ) {
7885
7886 CRITICAL_UNIMPLEMENTED( "sc61860_float_fast_from_8" );
7887
7888 // deploy( fp_fast_from_8, src_hw_sc61860_fp_fast_from_8_asm );
7889
7890 // outline1( "LD A, (%s)", _value );
7891 if ( _signed ) {
7892 // outline0( "CALL FPFASTFROM8S");
7893 } else {
7894 // outline0( "CALL FPFASTFROM8U");
7895 }
7896 // outline1( "LD (%s), A", _result );
7897 // outline0( "LD A, H" );
7898 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+1" ) );
7899 // outline0( "LD A, L" );
7900 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+2" ) );
7901
7902}
7903
7904void cpu_float_fast_to_16( Environment * _environment, char * _value, char * _result, int _signed ) {
7905
7906 CRITICAL_UNIMPLEMENTED( "sc61860_float_fast_to_16" );
7907
7908 // deploy( fp_fast_to_16, src_hw_sc61860_fp_fast_to_16_asm );
7909
7910 // outline1( "LD A, (%s)", address_displacement( _environment, _value, "+2" ) );
7911 // outline0( "LD L, A" );
7912 // outline1( "LD A, (%s)", address_displacement( _environment, _value, "+1" ) );
7913 // outline0( "LD H, A" );
7914 // outline1( "LD A, (%s)", _value );
7915 if ( _signed ) {
7916 // outline0( "CALL FPFASTTOS16");
7917 } else {
7918 // outline0( "CALL FPFASTTOU16");
7919 }
7920 // outline1( "LD (%s), HL", _result );
7921
7922}
7923
7924void cpu_float_fast_to_8( Environment * _environment, char * _value, char * _result, int _signed ) {
7925
7926 CRITICAL_UNIMPLEMENTED( "sc61860_float_fast_to_8" );
7927
7928 // deploy( fp_fast_to_8, src_hw_sc61860_fp_fast_to_8_asm );
7929
7930 // outline1( "LD A, (%s)", address_displacement( _environment, _value, "+2" ) );
7931 // outline0( "LD L, A" );
7932 // outline1( "LD A, (%s)", address_displacement( _environment, _value, "+1" ) );
7933 // outline0( "LD H, A" );
7934 // outline1( "LD A, (%s)", _value );
7935 if ( _signed ) {
7936 // outline0( "CALL FPFASTTOS8");
7937 } else {
7938 // outline0( "CALL FPFASTTOU8");
7939 }
7940 // outline1( "LD (%s), A", _result );
7941
7942}
7943
7944void cpu_float_fast_add( Environment * _environment, char * _x, char * _y, char * _result ) {
7945
7946 CRITICAL_UNIMPLEMENTED( "sc61860_float_fast_add" );
7947
7948 // deploy( fp_fast_add, src_hw_sc61860_fp_fast_add_asm );
7949
7950 // outline1( "LD A, (%s)", address_displacement( _environment, _y, "+2" ) );
7951 // outline0( "LD E, A" );
7952 // outline1( "LD A, (%s)", address_displacement( _environment, _y, "+1" ) );
7953 // outline0( "LD D, A" );
7954 // outline1( "LD A, (%s)", _y );
7955 // outline0( "LD C, A" );
7956
7957 // outline1( "LD A, (%s)", address_displacement( _environment, _x, "+2" ) );
7958 // outline0( "LD L, A" );
7959 // outline1( "LD A, (%s)", address_displacement( _environment, _x, "+1" ) );
7960 // outline0( "LD H, A" );
7961 // outline1( "LD A, (%s)", _x );
7962 // outline0( "CALL FPFASTADD");
7963 // outline1( "LD (%s), A", _result );
7964 // outline0( "LD A, H" );
7965 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+1" ) );
7966 // outline0( "LD A, L" );
7967 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+2" ) );
7968
7969}
7970
7971void cpu_float_fast_sub( Environment * _environment, char * _x, char * _y, char * _result ) {
7972
7973 CRITICAL_UNIMPLEMENTED( "sc61860_float_fast_sub" );
7974
7975 // deploy( fp_fast_add, src_hw_sc61860_fp_fast_add_asm );
7976 // deploy( fp_fast_sub, src_hw_sc61860_fp_fast_sub_asm );
7977
7978 // outline1( "LD A, (%s)", address_displacement( _environment, _y, "+2" ) );
7979 // outline0( "LD E, A" );
7980 // outline1( "LD A, (%s)", address_displacement( _environment, _y, "+1" ) );
7981 // outline0( "LD D, A" );
7982 // outline1( "LD A, (%s)", _y );
7983 // outline0( "LD C, A" );
7984
7985 // outline1( "LD A, (%s)", address_displacement( _environment, _x, "+2" ) );
7986 // outline0( "LD L, A" );
7987 // outline1( "LD A, (%s)", address_displacement( _environment, _x, "+1" ) );
7988 // outline0( "LD H, A" );
7989 // outline1( "LD A, (%s)", _x );
7990 // outline0( "CALL FPFASTSUB");
7991 // outline1( "LD (%s), A", _result );
7992 // outline0( "LD A, H" );
7993 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+1" ) );
7994 // outline0( "LD A, L" );
7995 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+2" ) );
7996
7997}
7998
7999void cpu_float_fast_mul( Environment * _environment, char * _x, char * _y, char * _result ) {
8000
8001 CRITICAL_UNIMPLEMENTED( "sc61860_float_fast_mul" );
8002
8003 // deploy( fp_mul16, src_hw_sc61860_fp_mul16_asm );
8004 // deploy( fp_fast_mul, src_hw_sc61860_fp_fast_mul_asm );
8005
8006 // outline1( "LD A, (%s)", address_displacement( _environment, _y, "+2" ) );
8007 // outline0( "LD E, A" );
8008 // outline1( "LD A, (%s)", address_displacement( _environment, _y, "+1" ) );
8009 // outline0( "LD D, A" );
8010 // outline1( "LD A, (%s)", _y );
8011 // outline0( "LD C, A" );
8012 // outline1( "LD A, (%s)", address_displacement( _environment, _x, "+2" ) );
8013 // outline0( "LD L, A" );
8014 // outline1( "LD A, (%s)", address_displacement( _environment, _x, "+1" ) );
8015 // outline0( "LD H, A" );
8016 // outline1( "LD A, (%s)", _x );
8017 // outline0( "CALL FPFASTMUL");
8018 // outline1( "LD (%s), A", _result );
8019 // outline0( "LD A, H" );
8020 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+1" ) );
8021 // outline0( "LD A, L" );
8022 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+2" ) );
8023
8024}
8025
8026void cpu_float_fast_div( Environment * _environment, char * _x, char * _y, char * _result ) {
8027
8028 CRITICAL_UNIMPLEMENTED( "sc61860_float_fast_div" );
8029
8030 // deploy( fp_fast_div, src_hw_sc61860_fp_fast_div_asm );
8031
8032 // outline1( "LD A, (%s)", address_displacement( _environment, _y, "+2" ) );
8033 // outline0( "LD E, A" );
8034 // outline1( "LD A, (%s)", address_displacement( _environment, _y, "+1" ) );
8035 // outline0( "LD D, A" );
8036 // outline1( "LD A, (%s)", _y );
8037 // outline0( "LD C, A" );
8038 // outline1( "LD A, (%s)", address_displacement( _environment, _x, "+2" ) );
8039 // outline0( "LD L, A" );
8040 // outline1( "LD A, (%s)", address_displacement( _environment, _x, "+1" ) );
8041 // outline0( "LD H, A" );
8042 // outline1( "LD A, (%s)", _x );
8043 // outline0( "CALL FPFASTDIV");
8044 // outline1( "LD (%s), A", _result );
8045 // outline0( "LD A, H" );
8046 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+1" ) );
8047 // outline0( "LD A, L" );
8048 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+2" ) );
8049
8050}
8051
8052void cpu_float_fast_cmp( Environment * _environment, char * _x, char * _y, char * _result ) {
8053
8054 CRITICAL_UNIMPLEMENTED( "sc61860_float_fast_cmp" );
8055
8057
8058 // deploy( fp_fast_add, src_hw_sc61860_fp_fast_add_asm );
8059 // deploy( fp_fast_sub, src_hw_sc61860_fp_fast_sub_asm );
8060 // deploy( fp_fast_cmp, src_hw_sc61860_fp_fast_cmp_asm );
8061
8062 // outline1( "LD A, (%s)", address_displacement( _environment, _y, "+2" ) );
8063 // outline0( "LD E, A" );
8064 // outline1( "LD A, (%s)", address_displacement( _environment, _y, "+1" ) );
8065 // outline0( "LD D, A" );
8066 // outline1( "LD A, (%s)", _y );
8067 // outline0( "LD C, A" );
8068 // outline1( "LD A, (%s)", address_displacement( _environment, _x, "+2" ) );
8069 // outline0( "LD L, A" );
8070 // outline1( "LD A, (%s)", address_displacement( _environment, _x, "+1" ) );
8071 // outline0( "LD H, A" );
8072 // outline1( "LD A, (%s)", _x );
8073 // outline0( "CALL FPFASTCMP");
8074
8075 // outline1( "JR Z, %sequal", label );
8076 // outline1( "JR C, %sless", label );
8077 // outline0( "LD A, 1" );
8078 // outline1( "LD (%s), A", _result );
8079 // outline1( "JP %s// done", label );
8080 // outhead1( "%sequal:", label );
8081 // outline0( "LD A, 0" );
8082 // outline1( "LD (%s), A", _result );
8083 // outline1( "JP %s// done", label );
8084 // outhead1( "%sless:", label );
8085 // outline0( "LD A, 0xff" );
8086 // outline1( "LD (%s), A", _result );
8087 // outline1( "JP %s// done", label );
8088 // outhead1( "%s// done:", label );
8089
8090}
8091
8092void cpu_float_fast_sin( Environment * _environment, char * _angle, char * _result ) {
8093
8094 CRITICAL_UNIMPLEMENTED( "sc61860_float_fast_sin" );
8095
8097
8098 // deploy( fp_mul16, src_hw_sc61860_fp_mul16_asm );
8099 // deploy( fp_fast_add, src_hw_sc61860_fp_fast_add_asm );
8100 // deploy( fp_fast_sub, src_hw_sc61860_fp_fast_sub_asm );
8101 // deploy( fp_fast_mod1, src_hw_sc61860_fp_fast_mod1_asm );
8102 // deploy( fp_fast_sin, src_hw_sc61860_fp_fast_sin_asm );
8103 // deploy( fp_fast_mul, src_hw_sc61860_fp_fast_mul_asm );
8104 // deploy( fp_fast_sqr, src_hw_sc61860_fp_fast_sqr_asm );
8105 // deploy( fp_fast_cos, src_hw_sc61860_fp_fast_cos_asm );
8106 // deploy( fp_fast_div, src_hw_sc61860_fp_fast_div_asm );
8107
8108 // outline1( "LD A, (%s)", address_displacement( _environment, _angle, "+2" ) );
8109 // outline0( "LD L, A" );
8110 // outline1( "LD A, (%s)", address_displacement( _environment, _angle, "+1" ) );
8111 // outline0( "LD H, A" );
8112 // outline1( "LD A, (%s)", _angle );
8113
8114 // outline0( "CALL FPFASTSIN");
8115
8116 // outline1( "LD (%s), A", _result );
8117 // outline0( "LD A, H" );
8118 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+1" ) );
8119 // outline0( "LD A, L" );
8120 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+2" ) );
8121
8122}
8123
8124void cpu_float_fast_cos( Environment * _environment, char * _angle, char * _result ) {
8125
8126 CRITICAL_UNIMPLEMENTED( "sc61860_float_fast_cos" );
8127
8129
8130 // deploy( fp_mul16, src_hw_sc61860_fp_mul16_asm );
8131 // deploy( fp_fast_add, src_hw_sc61860_fp_fast_add_asm );
8132 // deploy( fp_fast_sub, src_hw_sc61860_fp_fast_sub_asm );
8133 // deploy( fp_fast_mod1, src_hw_sc61860_fp_fast_mod1_asm );
8134 // deploy( fp_fast_mul, src_hw_sc61860_fp_fast_mul_asm );
8135 // deploy( fp_fast_sqr, src_hw_sc61860_fp_fast_sqr_asm );
8136 // deploy( fp_fast_sin, src_hw_sc61860_fp_fast_cos_asm );
8137 // deploy( fp_fast_cos, src_hw_sc61860_fp_fast_sin_asm );
8138
8139 // outline1( "LD A, (%s)", address_displacement( _environment, _angle, "+2" ) );
8140 // outline0( "LD L, A" );
8141 // outline1( "LD A, (%s)", address_displacement( _environment, _angle, "+1" ) );
8142 // outline0( "LD H, A" );
8143 // outline1( "LD A, (%s)", _angle );
8144
8145 // outline0( "CALL FPFASTCOS");
8146
8147 // outline1( "LD (%s), A", _result );
8148 // outline0( "LD A, H" );
8149 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+1" ) );
8150 // outline0( "LD A, L" );
8151 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+2" ) );
8152
8153}
8154
8155void cpu_float_fast_tan( Environment * _environment, char * _angle, char * _result ) {
8156
8157 CRITICAL_UNIMPLEMENTED( "sc61860_float_fast_tan" );
8158
8160
8161 // deploy( fp_fast_tan, src_hw_sc61860_fp_fast_tan_asm );
8162 // deploy( fp_fast_sin, src_hw_sc61860_fp_fast_sin_asm );
8163 // deploy( fp_fast_cos, src_hw_sc61860_fp_fast_cos_asm );
8164 // deploy( fp_fast_div, src_hw_sc61860_fp_fast_div_asm );
8165
8166 // outline1( "LD A, (%s)", address_displacement( _environment, _angle, "+2" ) );
8167 // outline0( "LD L, A" );
8168 // outline1( "LD A, (%s)", address_displacement( _environment, _angle, "+1" ) );
8169 // outline0( "LD H, A" );
8170 // outline1( "LD A, (%s)", _angle );
8171
8172 // outline0( "CALL FPFASTTAN");
8173
8174 // outline1( "LD (%s), A", _result );
8175 // outline0( "LD A, H" );
8176 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+1" ) );
8177 // outline0( "LD A, L" );
8178 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+2" ) );
8179
8180}
8181
8182void cpu_float_fast_sqr( Environment * _environment, char * _value, char * _result ) {
8183
8184 CRITICAL_UNIMPLEMENTED( "sc61860_float_fast_sqr" );
8185
8187
8188 // deploy( fp_mul16, src_hw_sc61860_fp_mul16_asm );
8189 // deploy( fp_fast_mul, src_hw_sc61860_fp_fast_mul_asm );
8190 // deploy( fp_fast_sqr, src_hw_sc61860_fp_fast_sqr_asm );
8191
8192 // outline1( "LD A, (%s)", address_displacement( _environment, _value, "+2" ) );
8193 // outline0( "LD L, A" );
8194 // outline1( "LD A, (%s)", address_displacement( _environment, _value, "+1" ) );
8195 // outline0( "LD H, A" );
8196 // outline1( "LD A, (%s)", _value );
8197
8198 // outline0( "CALL FPFASTSQR");
8199
8200 // outline1( "LD (%s), A", _result );
8201 // outline0( "LD A, H" );
8202 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+1" ) );
8203 // outline0( "LD A, L" );
8204 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+2" ) );
8205
8206}
8207
8208void cpu_float_fast_mod1( Environment * _environment, char * _value, char * _result ) {
8209
8210 CRITICAL_UNIMPLEMENTED( "sc61860_float_fast_mod1" );
8211
8213
8214 // deploy( fp_fast_mod1, src_hw_sc61860_fp_fast_mod1_asm );
8215
8216 // outline1( "LD A, (%s)", address_displacement( _environment, _value, "+2" ) );
8217 // outline0( "LD L, A" );
8218 // outline1( "LD A, (%s)", address_displacement( _environment, _value, "+1" ) );
8219 // outline0( "LD H, A" );
8220 // outline1( "LD A, (%s)", _value );
8221
8222 // outline0( "CALL FPFASTMOD1");
8223
8224 // outline1( "LD (%s), A", _result );
8225 // outline0( "LD A, H" );
8226 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+1" ) );
8227 // outline0( "LD A, L" );
8228 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+2" ) );
8229
8230}
8231
8232void cpu_float_fast_neg( Environment * _environment, char * _value, char * _result ) {
8233
8234 CRITICAL_UNIMPLEMENTED( "sc61860_float_fast_neg" );
8235
8237
8238 // deploy( fp_fast_neg, src_hw_sc61860_fp_fast_neg_asm );
8239
8240 // outline1( "LD A, (%s)", address_displacement( _environment, _value, "+2" ) );
8241 // outline0( "LD L, A" );
8242 // outline1( "LD A, (%s)", address_displacement( _environment, _value, "+1" ) );
8243 // outline0( "LD H, A" );
8244 // outline1( "LD A, (%s)", _value );
8245
8246 // outline0( "CALL FPFASTNEG");
8247
8248 // outline1( "LD (%s), A", _result );
8249 // outline0( "LD A, H" );
8250 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+1" ) );
8251 // outline0( "LD A, L" );
8252 // outline1( "LD (%s), A", address_displacement( _environment, _result, "+2" ) );
8253
8254}
8255
8256void cpu_float_single_from_16( Environment * _environment, char * _value, char * _result, int _signed ) {
8257
8258 CRITICAL_UNIMPLEMENTED( "sc61860_float_single_from_16" );
8259
8260 // deploy( fp_pushpop, src_hw_sc61860_fp_pushpop_asm );
8261 // deploy( fp_single_from_16, src_hw_sc61860_fp_single_from_16_asm );
8262
8263 // outline1( "LD HL, (%s)", _value );
8264 // outline1( "LD BC, %s", _result );
8265 if ( _signed ) {
8266 // outline0( "CALL FPSINGLEFROM16S");
8267 } else {
8268 // outline0( "CALL FPSINGLEFROM16U");
8269 }
8270
8271}
8272
8273void cpu_float_single_from_8( Environment * _environment, char * _value, char * _result, int _signed ) {
8274
8275 CRITICAL_UNIMPLEMENTED( "sc61860_float_single_from_8" );
8276
8277 // deploy( fp_single_from_8, src_hw_sc61860_fp_single_from_8_asm );
8278
8279 // outline1( "LD A, (%s)", _value );
8280 // outline1( "LD BC, %s", _result );
8281 if ( _signed ) {
8282 // outline0( "CALL FPSINGLEFROM8S");
8283 } else {
8284 // outline0( "CALL FPSINGLEFROM8U");
8285 }
8286
8287}
8288
8289
8290void cpu_float_single_to_16( Environment * _environment, char * _value, char * _result, int _signed ) {
8291
8292 CRITICAL_UNIMPLEMENTED( "sc61860_float_single_to_16" );
8293
8294 // deploy( fp_single_to_16, src_hw_sc61860_fp_single_to_16_asm );
8295
8296 // outline1( "LD HL, %s", _value );
8297 if ( _signed ) {
8298 // outline0( "CALL FPSINGLETO16S");
8299 } else {
8300 // outline0( "CALL FPSINGLETO16U");
8301 }
8302 // outline1( "LD (%s), HL", _result );
8303
8304}
8305
8306void cpu_float_single_to_8( Environment * _environment, char * _value, char * _result, int _signed ) {
8307
8308 CRITICAL_UNIMPLEMENTED( "sc61860_float_single_to_8" );
8309
8310 // deploy( fp_single_to_8, src_hw_sc61860_fp_single_to_8_asm );
8311
8312 // outline1( "LD HL, %s", _value );
8313 if ( _signed ) {
8314 // outline0( "CALL FPSINGLETO8S");
8315 } else {
8316 // outline0( "CALL FPSINGLETO8U");
8317 }
8318 // outline1( "LD (%s), A", _result );
8319
8320}
8321
8322void cpu_float_single_add( Environment * _environment, char * _x, char * _y, char * _result ) {
8323
8324 CRITICAL_UNIMPLEMENTED( "sc61860_float_single_add" );
8325
8326 // deploy( fp_pushpop, src_hw_sc61860_fp_pushpop_asm );
8327 // deploy( fp_single_add, src_hw_sc61860_fp_single_add_asm );
8328
8329 // outline1( "LD DE, %s", _y );
8330 // outline1( "LD HL, %s", _x );
8331 // outline1( "LD BC, %s", _result );
8332 // outline0( "CALL FPSINGLEADD");
8333
8334}
8335
8336void cpu_float_single_sub( Environment * _environment, char * _x, char * _y, char * _result ) {
8337
8338 CRITICAL_UNIMPLEMENTED( "sc61860_float_single_sub" );
8339
8340 // deploy( fp_pushpop, src_hw_sc61860_fp_pushpop_asm );
8341 // deploy( fp_single_sub, src_hw_sc61860_fp_single_sub_asm );
8342 // deploy( fp_single_add, src_hw_sc61860_fp_single_add_asm );
8343
8344 // outline1( "LD DE, %s", _y );
8345 // outline1( "LD HL, %s", _x );
8346 // outline1( "LD BC, %s", _result );
8347 // outline0( "CALL FPSINGLESUB");
8348
8349}
8350
8351void cpu_float_single_mul( Environment * _environment, char * _x, char * _y, char * _result ) {
8352
8353 CRITICAL_UNIMPLEMENTED( "sc61860_float_single_mul" );
8354
8355 // deploy( fp_pushpop, src_hw_sc61860_fp_pushpop_asm );
8356 // deploy( fp_single_mul, src_hw_sc61860_fp_single_mul_asm );
8357
8358 // outline1( "LD DE, %s", _y );
8359 // outline1( "LD HL, %s", _x );
8360 // outline1( "LD BC, %s", _result );
8361 // outline0( "CALL FPSINGLEMUL");
8362
8363}
8364
8365void cpu_float_single_div( Environment * _environment, char * _x, char * _y, char * _result ) {
8366
8367 CRITICAL_UNIMPLEMENTED( "sc61860_float_single_div" );
8368
8369 // deploy( fp_pushpop, src_hw_sc61860_fp_pushpop_asm );
8370 // deploy( fp_div24_24, src_hw_sc61860_fp_div24_24_asm );
8371 // deploy( fp_single_div, src_hw_sc61860_fp_single_div_asm );
8372
8373 // outline1( "LD DE, %s", _y );
8374 // outline1( "LD HL, %s", _x );
8375 // outline1( "LD BC, %s", _result );
8376 // outline0( "CALL FPSINGLEDIV");
8377
8378}
8379
8380void cpu_float_single_cmp( Environment * _environment, char * _x, char * _y, char * _result ) {
8381
8382 CRITICAL_UNIMPLEMENTED( "sc61860_float_single_cmp" );
8383
8385
8386 // deploy( fp_pushpop, src_hw_sc61860_fp_pushpop_asm );
8387 // deploy( fp_single_sub, src_hw_sc61860_fp_single_sub_asm );
8388 // deploy( fp_single_cmp, src_hw_sc61860_fp_single_cmp_asm );
8389
8390 // outline1( "LD DE, %s", _y );
8391 // outline1( "LD HL, %s", _x );
8392 // outline0( "CALL FPSINGLECMP");
8393
8394 // outline1( "JR Z, %sequal", label );
8395 // outline1( "JR C, %sless", label );
8396 // outline0( "LD A, 1" );
8397 // outline1( "LD (%s), A", _result );
8398 // outline1( "JP %s// done", label );
8399 // outhead1( "%sequal:", label );
8400 // outline0( "LD A, 0" );
8401 // outline1( "LD (%s), A", _result );
8402 // outline1( "JP %s// done", label );
8403 // outhead1( "%sless:", label );
8404 // outline0( "LD A, 0xff" );
8405 // outline1( "LD (%s), A", _result );
8406 // outline1( "JP %s// done", label );
8407 // outhead1( "%s// done:", label );
8408
8409}
8410
8411void cpu_float_single_neg( Environment * _environment, char * _value, char * _result ) {
8412
8413 CRITICAL_UNIMPLEMENTED( "sc61860_float_single_neg" );
8414
8415 // MAKE_LABEL
8416
8417 // // deploy( fp_single_sub, src_hw_sc61860_fp_single_sub_asm );
8418 // // deploy( fp_single_mod1, src_hw_sc61860_fp_single_mod1_asm );
8419 // // deploy( fp_single_sin, src_hw_sc61860_fp_single_sin_asm );
8420 // // deploy( fp_single_mul, src_hw_sc61860_fp_single_mul_asm );
8421 // // deploy( fp_single_sqr, src_hw_sc61860_fp_single_sqr_asm );
8422 // // deploy( fp_single_cos, src_hw_sc61860_fp_single_cos_asm );
8423 // // deploy( fp_single_div, src_hw_sc61860_fp_single_div_asm );
8424
8425 // // outline1( "LD A, (%s)", address_displacement( _environment, _angle, "+2" ) );
8426 // // outline0( "LD L, A" );
8427 // // outline1( "LD A, (%s)", address_displacement( _environment, _angle, "+1" ) );
8428 // // outline0( "LD H, A" );
8429 // // outline1( "LD A, (%s)", _angle );
8430
8431 // // outline0( "CALL FPFSINGLESIN");
8432
8433 // // outline1( "LD (%s), A", _result );
8434 // // outline0( "LD A, H" );
8435 // // outline1( "LD (%s), A", address_displacement( _environment, _result, "+1" ) );
8436 // // outline0( "LD A, L" );
8437 // // outline1( "LD (%s), A", address_displacement( _environment, _result, "+2" ) );
8438
8439}
8440
8441void cpu_float_single_sin( Environment * _environment, char * _angle, char * _result ) {
8442
8443 CRITICAL_UNIMPLEMENTED( "sc61860_float_single_sin" );
8444
8446
8447 // deploy( fp_single_vars, src_hw_sc61860_fp_single_vars_asm );
8448 // deploy( fp_single_sin, src_hw_sc61860_fp_single_sin_asm );
8449 // deploy( fp_single_cos, src_hw_sc61860_fp_single_cos_asm );
8450 // deploy( fp_single_sub, src_hw_sc61860_fp_single_sub_asm );
8451 // deploy( fp_single_mul, src_hw_sc61860_fp_single_mul_asm );
8452 // deploy( fp_single_add, src_hw_sc61860_fp_single_add_asm );
8453 // deploy( fp_single_neg, src_hw_sc61860_fp_single_neg_asm );
8454 // deploy( fp_single_mod1, src_hw_sc61860_fp_single_mod1_asm );
8455 // deploy( fp_single_abs, src_hw_sc61860_fp_single_abs_asm );
8456 // deploy( fp_single_horner_step, src_hw_sc61860_fp_single_horner_step_asm );
8457
8458 // outline1( "LD HL, %s", _angle );
8459 // outline1( "LD BC, %s", _result );
8460 // outline0( "CALL FPSINGLESIN");
8461 // // outline0( "LD A, (HL)" );
8462 // // outline1( "LD (%s), A", _result );
8463 // // outline0( "INC HL" );
8464 // // outline0( "LD A, (HL)" );
8465 // // outline1( "LD (%s), A", _result );
8466 // // outline0( "INC HL" );
8467 // // outline0( "LD A, (HL)" );
8468 // // outline1( "LD (%s), A", _result );
8469 // // outline0( "INC HL" );
8470 // // outline0( "LD A, (HL)" );
8471 // // outline1( "LD (%s), A", _result );
8472 // // outline0( "INC HL" );
8473
8474}
8475
8476void cpu_float_single_cos( Environment * _environment, char * _angle, char * _result ) {
8477
8478 CRITICAL_UNIMPLEMENTED( "sc61860_float_single_cos" );
8479
8481
8482 // deploy( fp_mul24_stack_based, src_hw_sc61860_fp_mul24_stack_based_asm );
8483 // deploy( fp_mov4, src_hw_sc61860_fp_mov4_asm );
8484 // deploy( fp_c_times_bde, src_hw_sc61860_fp_c_times_bde_asm );
8485 // deploy( fp_single_vars, src_hw_sc61860_fp_single_vars_asm );
8486 // deploy( fp_single_sin, src_hw_sc61860_fp_single_sin_asm );
8487 // deploy( fp_single_cos, src_hw_sc61860_fp_single_cos_asm );
8488 // deploy( fp_single_sub, src_hw_sc61860_fp_single_sub_asm );
8489 // deploy( fp_single_mul, src_hw_sc61860_fp_single_mul_asm );
8490 // deploy( fp_single_add, src_hw_sc61860_fp_single_add_asm );
8491 // deploy( fp_single_neg, src_hw_sc61860_fp_single_neg_asm );
8492 // deploy( fp_single_mod1, src_hw_sc61860_fp_single_mod1_asm );
8493 // deploy( fp_single_abs, src_hw_sc61860_fp_single_abs_asm );
8494 // deploy( fp_single_horner_step, src_hw_sc61860_fp_single_horner_step_asm );
8495
8496 // outline1( "LD HL, %s", _angle );
8497 // outline1( "LD BC, %s", _result );
8498 // outline0( "CALL FPSINGLECOS");
8499 // outline0( "LD A, (HL)" );
8500 // outline1( "LD (%s), A", _result );
8501 // outline0( "INC HL" );
8502 // outline0( "LD A, (HL)" );
8503 // outline1( "LD (%s), A", _result );
8504 // outline0( "INC HL" );
8505 // outline0( "LD A, (HL)" );
8506 // outline1( "LD (%s), A", _result );
8507 // outline0( "INC HL" );
8508 // outline0( "LD A, (HL)" );
8509 // outline1( "LD (%s), A", _result );
8510 // outline0( "INC HL" );
8511
8512}
8513
8514void cpu_float_single_tan( Environment * _environment, char * _angle, char * _result ) {
8515
8516 CRITICAL_UNIMPLEMENTED( "sc61860_float_single_tan" );
8517
8519
8520 // deploy( fp_single_vars, src_hw_sc61860_fp_single_vars_asm );
8521 // deploy( fp_single_sin, src_hw_sc61860_fp_single_sin_asm );
8522 // deploy( fp_single_cos, src_hw_sc61860_fp_single_cos_asm );
8523 // deploy( fp_single_div, src_hw_sc61860_fp_single_div_asm );
8524 // deploy( fp_single_sin, src_hw_sc61860_fp_single_tan_asm );
8525 // deploy( fp_single_tan, src_hw_sc61860_fp_single_tan_asm );
8526 // deploy( fp_single_neg, src_hw_sc61860_fp_single_neg_asm );
8527 // deploy( fp_single_sub, src_hw_sc61860_fp_single_sub_asm );
8528 // deploy( fp_single_mul, src_hw_sc61860_fp_single_mul_asm );
8529 // deploy( fp_single_add, src_hw_sc61860_fp_single_add_asm );
8530 // deploy( fp_single_mod1, src_hw_sc61860_fp_single_mod1_asm );
8531 // deploy( fp_single_abs, src_hw_sc61860_fp_single_abs_asm );
8532 // deploy( fp_single_horner_step, src_hw_sc61860_fp_single_horner_step_asm );
8533
8534
8535 // outline1( "LD HL, %s", _angle );
8536 // outline1( "LD BC, %s", _result );
8537 // outline0( "CALL FPSINGLETAN");
8538 // // outline0( "LD A, (HL)" );
8539 // // outline1( "LD (%s), A", _result );
8540 // // outline0( "INC HL" );
8541 // // outline0( "LD A, (HL)" );
8542 // // outline1( "LD (%s), A", _result );
8543 // // outline0( "INC HL" );
8544 // // outline0( "LD A, (HL)" );
8545 // // outline1( "LD (%s), A", _result );
8546 // // outline0( "INC HL" );
8547 // // outline0( "LD A, (HL)" );
8548 // // outline1( "LD (%s), A", _result );
8549 // // outline0( "INC HL" );
8550
8551}
8552
8553void cpu_float_single_sqr( Environment * _environment, char * _value, char * _result ) {
8554
8555 CRITICAL_UNIMPLEMENTED( "sc61860_float_single_sqr" );
8556
8557 // MAKE_LABEL
8558
8559 // // deploy( fp_single_mul, src_hw_sc61860_fp_single_mul_asm );
8560 // // deploy( fp_single_sqr, src_hw_sc61860_fp_single_sqr_asm );
8561
8562 // // outline1( "LD A, (%s)", address_displacement( _environment, _value, "+2" ) );
8563 // // outline0( "LD L, A" );
8564 // // outline1( "LD A, (%s)", address_displacement( _environment, _value, "+1" ) );
8565 // // outline0( "LD H, A" );
8566 // // outline1( "LD A, (%s)", _value );
8567
8568 // // outline0( "CALL FPsingleSQR");
8569
8570 // // outline1( "LD (%s), A", _result );
8571 // // outline0( "LD A, H" );
8572 // // outline1( "LD (%s), A", address_displacement( _environment, _result, "+1" ) );
8573 // // outline0( "LD A, L" );
8574 // // outline1( "LD (%s), A", address_displacement( _environment, _result, "+2" ) );
8575
8576}
8577
8578void cpu_float_single_mod1( Environment * _environment, char * _value, char * _result ) {
8579
8580 CRITICAL_UNIMPLEMENTED( "sc61860_float_single_mod1" );
8581
8582 // MAKE_LABEL
8583
8584 // // deploy( fp_single_mod1, src_hw_sc61860_fp_single_mod1_asm );
8585
8586 // // outline1( "LD A, (%s)", address_displacement( _environment, _value, "+2" ) );
8587 // // outline0( "LD L, A" );
8588 // // outline1( "LD A, (%s)", address_displacement( _environment, _value, "+1" ) );
8589 // // outline0( "LD H, A" );
8590 // // outline1( "LD A, (%s)", _value );
8591
8592 // // outline0( "CALL FPsingleMOD1");
8593
8594 // // outline1( "LD (%s), A", _result );
8595 // // outline0( "LD A, H" );
8596 // // outline1( "LD (%s), A", address_displacement( _environment, _result, "+1" ) );
8597 // // outline0( "LD A, L" );
8598 // // outline1( "LD (%s), A", address_displacement( _environment, _result, "+2" ) );
8599
8600}
8601
8602void cpu_address_table_build( Environment * _environment, char * _table, int * _values, char *_address[], int _count ) {
8603
8604 CRITICAL_UNIMPLEMENTED( "sc61860_address_table_build" );
8605
8606 // outhead1("%s:", _table );
8607 for( int i=0; i<_count; ++i ) {
8608 // outline2("DEFW 0x%4.4x, %s", _values[i], _address[i] );
8609 }
8610
8611}
8612
8613void cpu_address_table_lookup( Environment * _environment, char * _table, int _count ) {
8614
8615 CRITICAL_UNIMPLEMENTED( "sc61860_address_table_lookup" );
8616
8617 // outhead1("LOOKFOR%s:", _table );
8618 if ( _count ) {
8619 // outline1("LD HL, %s", _table );
8620 // outline0("LD C, 0" );
8621 // outhead1("LOOKFOR%sL1:", _table );
8622 // outline0("LD A, (HL)" );
8623 // outline0("INC HL" );
8624 // outline0("LD B, A" );
8625 // outline0("LD A, E" );
8626 // outline0("CP B" );
8627 // outline1("JR NZ, LOOKFOR%sNEXT3", _table );
8628 // outline0("LD A, (HL)" );
8629 // outline0("INC HL" );
8630 // outline0("LD B, A" );
8631 // outline0("LD A, D" );
8632 // outline0("CP B" );
8633 // outline1("JR NZ, LOOKFOR%sNEXT2", _table );
8634 // outline0("LD A, (HL)" );
8635 // outline0("INC HL" );
8636 // outline0("LD E, A" );
8637 // outline0("LD A, (HL)" );
8638 // outline0("INC HL" );
8639 // outline0("LD D, A" );
8640 // outline0("RET" );
8641 // outhead1("LOOKFOR%sNEXT3:", _table );
8642 // outline0("INC HL" );
8643 // outhead1("LOOKFOR%sNEXT2:", _table );
8644 // outline0("INC HL" );
8645 // outline0("INC HL" );
8646 // outline0("INC C" );
8647 // outline0("LD A, C" );
8648 // outline1("CP 0x%4.4x", (_count+1) );
8649 // outline1("JR NZ, LOOKFOR%sL1", _table );
8650 }
8651 // outline0("RET" );
8652
8653}
8654
8655void cpu_address_table_call( Environment * _environment, char * _table, char * _value, char * _address ) {
8656
8657 CRITICAL_UNIMPLEMENTED( "sc61860_address_table_call" );
8658
8659 // outline1("LD DE, (%s)", _value );
8660 // outline1("CALL LOOKFOR%s", _table );
8661 // outline1("LD (%s), DE", _address );
8662
8663}
8664
8665void cpu_move_8bit_signed_16bit_signed( Environment * _environment, char *_source, char *_destination ) {
8666
8667 CRITICAL_UNIMPLEMENTED( "sc61860_move_8bit_signed_16bit_signed(signed)" );
8668
8669}
8670
8671void cpu_move_8bit_signed_16bit_unsigned( Environment * _environment, char *_source, char *_destination ){
8672
8673 CRITICAL_UNIMPLEMENTED( "sc61860_move_8bit_signed_16bit_unsigned(signed)" );
8674
8675}
8676
8677void cpu_move_8bit_unsigned_16bit_signed( Environment * _environment, char *_source, char *_destination ){
8678
8679 CRITICAL_UNIMPLEMENTED( "sc61860_move_8bit_unsigned_16bit_signed(signed)" );
8680
8681}
8682
8683void cpu_move_8bit_unsigned_16bit_unsigned( Environment * _environment, char *_source, char *_destination ){
8684
8685 op_lda( _environment, _source );
8686 op_xab( _environment );
8687 op_lda_direct( _environment, 0 );
8688 op_stab( _environment, _destination );
8689
8690}
8691
8692void cpu_move_8bit_signed_32bit_signed( Environment * _environment, char *_source, char *_destination ){
8693
8695
8696 char positiveLabel[MAX_TEMPORARY_STORAGE];
8697 sprintf(positiveLabel, "%spos", label );
8698
8699 op_lda(_environment, _source );
8700 op_sta(_environment, _destination );
8701 op_cp_direct(_environment, 0x80 );
8702 op_jc(_environment, positiveLabel );
8703 op_lda_direct( _environment, 0xff );
8704 op_jp( _environment, label );
8705 cpu_label(_environment, positiveLabel );
8706 op_lda_direct( _environment, 0x00 );
8707 cpu_label(_environment, label );
8708 op_sta(_environment, address_displacement( _environment, _destination, "1" ) );
8709 op_sta(_environment, address_displacement( _environment, _destination, "2" ) );
8710 op_sta(_environment, address_displacement( _environment, _destination, "3" ) );
8711
8712}
8713
8714void cpu_move_8bit_signed_32bit_unsigned( Environment * _environment, char *_source, char *_destination ){
8715
8716 CRITICAL_UNIMPLEMENTED( "sc61860_move_8bit_signed_32bit_unsigned(signed)" );
8717
8718}
8719
8720void cpu_move_8bit_unsigned_32bit_signed( Environment * _environment, char *_source, char *_destination ){
8721
8722 CRITICAL_UNIMPLEMENTED( "sc61860_move_8bit_unsigned_32bit_signed(signed)" );
8723
8724}
8725
8726void cpu_move_8bit_unsigned_32bit_unsigned( Environment * _environment, char *_source, char *_destination ){
8727
8728 CRITICAL_UNIMPLEMENTED( "sc61860_move_8bit_unsigned_32bit_unsigned" );
8729
8730}
8731
8732void cpu_move_16bit_signed_8bit_signed( Environment * _environment, char *_source, char *_destination ){
8733
8734 CRITICAL_UNIMPLEMENTED( "sc61860_move_16bit_signed_8bit_signed(signed)" );
8735
8736}
8737void cpu_move_16bit_signed_8bit_unsigned( Environment * _environment, char *_source, char *_destination ){
8738
8739 op_lda( _environment, _source );
8740 op_sta( _environment, _source );
8741
8742}
8743
8744void cpu_move_16bit_unsigned_8bit_signed( Environment * _environment, char *_source, char *_destination ){
8745
8746 op_lda( _environment, _source );
8747 op_sta( _environment, _source );
8748
8749}
8750
8751void cpu_move_16bit_unsigned_8bit_unsigned( Environment * _environment, char *_source, char *_destination ){
8752
8753 op_ldab( _environment, _source );
8754 op_xab( _environment );
8755 op_sta( _environment, _destination );
8756
8757}
8758
8759void cpu_move_16bit_signed_32bit_signed( Environment * _environment, char *_source, char *_destination ){
8760
8761 CRITICAL_UNIMPLEMENTED( "sc61860_move_16bit_signed_32bit_signed(signed)" );
8762
8763}
8764
8765void cpu_move_16bit_signed_32bit_unsigned( Environment * _environment, char *_source, char *_destination ){
8766
8767 CRITICAL_UNIMPLEMENTED( "sc61860_move_16bit_signed_32bit_unsigned(signed)" );
8768
8769}
8770
8771void cpu_move_16bit_unsigned_32bit_signed( Environment * _environment, char *_source, char *_destination ){
8772
8773 CRITICAL_UNIMPLEMENTED( "sc61860_move_16bit_unsigned_32bit_signed(signed)" );
8774
8775}
8776
8777void cpu_move_16bit_unsigned_32bit_unsigned( Environment * _environment, char *_source, char *_destination ){
8778
8779 op_ldab( _environment, _source );
8780 op_stab( _environment, _destination );
8781 op_ldab_direct( _environment, 0 );
8782 op_stab( _environment, address_displacement( _environment, _destination, "2" ) );
8783
8784}
8785
8786void cpu_move_32bit_signed_8bit_signed( Environment * _environment, char *_source, char *_destination ){
8787
8788 CRITICAL_UNIMPLEMENTED( "sc61860_move_32bit_signed_8bit_signed(signed)" );
8789
8790
8791}
8792void cpu_move_32bit_signed_8bit_unsigned( Environment * _environment, char *_source, char *_destination ){
8793
8794 CRITICAL_UNIMPLEMENTED( "sc61860_move_32bit_signed_8bit_unsigned(signed)" );
8795
8796}
8797void cpu_move_32bit_unsigned_8bit_signed( Environment * _environment, char *_source, char *_destination ){
8798
8799 CRITICAL_UNIMPLEMENTED( "sc61860_move_32bit_unsigned_8bit_signed(signed)" );
8800
8801}
8802
8803void cpu_move_32bit_unsigned_8bit_unsigned( Environment * _environment, char *_source, char *_destination ){
8804
8805 op_lda( _environment, _source );
8806 op_sta( _environment, _destination );
8807
8808}
8809
8810void cpu_move_32bit_signed_16bit_signed( Environment * _environment, char *_source, char *_destination ){
8811
8812 CRITICAL_UNIMPLEMENTED( "sc61860_move_32bit_signed_16bit_signed(signed)" );
8813
8814}
8815
8816void cpu_move_32bit_signed_16bit_unsigned( Environment * _environment, char *_source, char *_destination ){
8817
8818
8819 CRITICAL_UNIMPLEMENTED( "sc61860_move_32bit_signed_16bit_unsigned(signed)" );
8820
8821}
8822
8823void cpu_move_32bit_unsigned_16bit_signed( Environment * _environment, char *_source, char *_destination ){
8824
8825 CRITICAL_UNIMPLEMENTED( "sc61860_move_32bit_unsigned_16bit_signed(signed)" );
8826
8827}
8828
8829void cpu_move_32bit_unsigned_16bit_unsigned( Environment * _environment, char *_source, char *_destination ){
8830
8831 op_ldab( _environment, _source );
8832 op_stab( _environment, _destination );
8833
8834}
8835
8836void cpu_float_fast_log( Environment * _environment, char * _value, char * _result ) {
8837
8839
8840}
8841
8842void cpu_float_single_log( Environment * _environment, char * _value, char * _result ) {
8843
8845
8846}
8847
8848void cpu_float_fast_exp( Environment * _environment, char * _value, char * _result ) {
8849
8851
8852}
8853
8854void cpu_float_single_exp( Environment * _environment, char * _value, char * _result ) {
8855
8857
8858}
8859
8860
8861#endif
void cpu_math_mul2_const_16bit(Environment *_environment, char *_source, int _steps, int _signed)
CPU 6309: emit code to halves for several times a 8 bit value
Definition 6309.c:2461
void cpu_math_mul2_const_8bit(Environment *_environment, char *_source, int _steps, int _signed)
CPU 6309: emit code to double for several times a 8 bit value
Definition 6309.c:1397
void cpu_store_16bit(Environment *_environment, char *_destination, int _value)
CPU 6309: emit code to store 16 bit
Definition 6309.c:1503
void cpu_math_div2_const_8bit(Environment *_environment, char *_source, int _steps, int _signed, char *_remainder)
CPU 6309: emit code to halves for several times a 8 bit value
Definition 6309.c:1329
void cpu_math_and_const_32bit(Environment *_environment, char *_source, int _mask)
CPU 6309: emit code to mask with "and" a value of 32 bit
Definition 6309.c:3698
void cpu_addressof_16bit(Environment *_environment, char *_source, char *_destination)
Definition 6309.c:1485
void cpu_math_complement_const_8bit(Environment *_environment, char *_source, int _value)
CPU 6309: emit code to calculate an 8 bit complement of a number
Definition 6309.c:1432
void cpu_less_than_8bit(Environment *_environment, char *_source, char *_destination, char *_other, int _equal, int _signed)
CPU 6309: emit code to compare two 8 bit values
Definition 6309.c:950
void cpu_math_add_16bit(Environment *_environment, char *_source, char *_destination, char *_other)
CPU 6309: emit code to add two 16 bit values
Definition 6309.c:1661
void cpu_math_add_16bit_const(Environment *_environment, char *_source, int _destination, char *_other)
Definition 6309.c:1674
void cpu_protothread_vars(Environment *_environment)
Definition 6309.c:6143
void cpu_math_add_16bit_with_16bit(Environment *_environment, char *_source, char *_destination, char *_other)
CPU 6309: emit code to add two 16 bit values
Definition 6309.c:1696
void cpu_compare_and_branch_16bit_const(Environment *_environment, char *_source, int _destination, char *_label, int _positive)
CPU 6309: emit code to compare two 8 bit values and jump if they are equal/different
Definition 6309.c:1578
void cpu_math_mul_8bit_to_16bit(Environment *_environment, char *_source, char *_destination, char *_other, int _signed)
CPU 6309: emit code to multiply two 8bit values in a 16 bit register
Definition 6309.c:1088
void cpu_math_sub_16bit(Environment *_environment, char *_source, char *_destination, char *_other)
CPU 6309: emit code to subtract two 16 bit values
Definition 6309.c:2305
void cpu_math_and_const_16bit(Environment *_environment, char *_source, int _mask)
CPU 6309: emit code to mask with "and" a value of 16 bit
Definition 6309.c:2496
void cpu_move_16bit(Environment *_environment, char *_source, char *_destination)
CPU 6309: emit code to move 16 bit
Definition 6309.c:1474
void cpu_compare_32bit(Environment *_environment, char *_source, char *_destination, char *_other, int _positive)
CPU 6309: emit code to compare two 32 bit values
Definition 6309.c:2769
void cpu_compare_and_branch_16bit(Environment *_environment, char *_source, char *_destination, char *_label, int _positive)
Definition 6309.c:1552
void cpu_less_than_16bit(Environment *_environment, char *_source, char *_destination, char *_other, int _equal, int _signed)
CPU 6309: emit code to compare two 8 bit values
Definition 6309.c:1603
void cpu_math_and_const_8bit(Environment *_environment, char *_source, int _mask)
CPU 6309: emit code to mask with "and" a value of 8 bit
Definition 6309.c:1451
void cpu_math_div2_const_16bit(Environment *_environment, char *_source, int _steps, int _signed, char *_remainder)
CPU 6309: emit code to halves for several times a 16 bit value
Definition 6309.c:2356
void cpu_compare_16bit(Environment *_environment, char *_source, char *_destination, char *_other, int _positive)
CPU 6309: emit code to compare two 16 bit values
Definition 6309.c:1523
void cpu_less_than_32bit(Environment *_environment, char *_source, char *_destination, char *_other, int _equal, int _signed)
CPU 6309: emit code to compare two 32 bit values
Definition 6309.c:2949
#define IS_REGISTER(x)
Definition 6309.h:58
@ REGISTER_B
Definition 6309.h:64
@ REGISTER_A
Definition 6309.h:63
@ REGISTER_NONE
Definition 6309.h:62
@ STACK_NONE
Definition 6309.h:78
@ STACK_BYTE
Definition 6309.h:79
@ STACK_WORD
Definition 6309.h:80
@ STACK_DWORD
Definition 6309.h:81
Variable * variable_import(Environment *_environment, char *_name, VariableType _type, int _size_or_value)
Variable * variable_temporary(Environment *_environment, VariableType _type, char *_meaning)
Define a temporary variable.
char * address_displacement(Environment *_environment, char *_address, char *_displacement)
#define DSTRING_DEFAULT_SPACE
Definition atari.h:152
#define DSTRING_DEFAULT_COUNT
Definition atari.h:151
void cpu_and_32bit(Environment *_environment, char *_left, char *_right, char *_result)
Definition sc61860.c:4222
void cpu_float_single_cos(Environment *_environment, char *_angle, char *_result)
Definition sc61860.c:8476
void cpu_protothread_get_state(Environment *_environment, char *_index, char *_state)
Definition sc61860.c:6740
void cpu_float_fast_neg(Environment *_environment, char *_value, char *_result)
Definition sc61860.c:8232
void cpu_set_callback(Environment *_environment, char *_callback, char *_label)
Definition sc61860.c:6785
void cpu_move_32bit_indirect2(Environment *_environment, char *_value, char *_source)
Definition sc61860.c:5465
void cpu_dsfree(Environment *_environment, char *_index)
Definition sc61860.c:6378
void cpu_less_than_memory_size(Environment *_environment, char *_source, char *_destination, int _size, char *_result, int _equal)
Definition sc61860.c:4873
void cpu_dsresize_size(Environment *_environment, char *_index, int _resize)
Definition sc61860.c:6415
void cpu_move_8bit_signed_32bit_unsigned(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8714
void cpu_float_fast_from_8(Environment *_environment, char *_value, char *_result, int _signed)
Definition sc61860.c:7884
void cpu_in(Environment *_environment, char *_port, char *_value)
Definition sc61860.c:6880
void cpu_pokew(Environment *_environment, char *_address, char *_source)
Definition sc61860.c:1096
void cpu_move_32bit_signed_16bit_unsigned(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8816
void cpu_combine_nibbles(Environment *_environment, char *_low_nibble, char *_hi_nibble, char *_byte)
SC616860: emit code to combine nibbles
Definition sc61860.c:3656
char * cpu_blit_register_name(Environment *_environment, int _register)
Definition sc61860.c:6980
void cpu_di(Environment *_environment)
Definition sc61860.c:4494
void cpu_float_fast_tan(Environment *_environment, char *_angle, char *_result)
Definition sc61860.c:8155
void cpu_math_double_32bit(Environment *_environment, char *_source, char *_other, int _signed)
SC616860: emit code to double a 32 bit value
Definition sc61860.c:3343
void cpu_protothread_restore(Environment *_environment, char *_index, char *_step)
Definition sc61860.c:6709
void cpu_msc1_uncompress_indirect_indirect(Environment *_environment, char *_input, char *_output)
Definition sc61860.c:6852
void cpu_not_16bit(Environment *_environment, char *_value, char *_result)
Definition sc61860.c:4478
void cpu_move_8bit_unsigned_32bit_signed(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8720
void cpu_math_mul2_const_16bit(Environment *_environment, char *_source, int _steps, int _signed)
SC616860: emit code to halves for several times a 8 bit value
Definition sc61860.c:2888
void cpu_math_div_16bit_to_16bit(Environment *_environment, char *_source, char *_destination, char *_other, char *_other_remainder, int _signed)
Definition sc61860.c:5798
void cpu_move_16bit_signed_32bit_signed(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8759
void cpu_move_8bit_unsigned_16bit_signed(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8677
void cpu_compare_32bit_const(Environment *_environment, char *_source, int _destination, char *_other, int _positive)
SC616860: emit code to compare two 32 bit values
Definition sc61860.c:3056
void cpu_math_mul_16bit_to_32bit(Environment *_environment, char *_source, char *_destination, char *_other, int _signed)
SC616860: emit code to multiply two 16 bit values in a 32 bit register
Definition sc61860.c:2723
void cpu_swap_32bit(Environment *_environment, char *_left, char *_right)
Definition sc61860.c:4447
void cpu_float_fast_from_16(Environment *_environment, char *_value, char *_result, int _signed)
Definition sc61860.c:7864
void cpu_bveq(Environment *_environment, char *_value, char *_label)
Definition sc61860.c:1030
void cpu_dsresize(Environment *_environment, char *_index, char *_resize)
Definition sc61860.c:6400
void cpu_move_nbit_indirect(Environment *_environment, int _n, char *_source, char *_value)
Definition sc61860.c:5380
void cpu_math_div_8bit_to_8bit_const(Environment *_environment, char *_source, int _destination, char *_other, char *_other_remainder, int _signed)
Definition sc61860.c:5999
void cpu_bit_check_extended(Environment *_environment, char *_value, char *_position, char *_result, int _bitwidth)
Definition sc61860.c:6027
void cpu_math_div_32bit_to_16bit(Environment *_environment, char *_source, char *_destination, char *_other, char *_other_remainder, int _signed)
Definition sc61860.c:5573
void cpu_math_mul2_const_8bit(Environment *_environment, char *_source, int _steps, int _signed)
SC616860: emit code to double for several times a 8 bit value
Definition sc61860.c:2176
void cpu_float_fast_div(Environment *_environment, char *_x, char *_y, char *_result)
Definition sc61860.c:8026
void cpu_move_32bit_signed_16bit_signed(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8810
void cpu_move_32bit_unsigned_8bit_unsigned(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8803
void cpu_math_mul2_const_32bit(Environment *_environment, char *_source, int _steps, int _signed)
SC616860: emit code to double for several times a 32 bit value
Definition sc61860.c:3558
void cpu_uppercase(Environment *_environment, char *_source, char *_size, char *_result)
Definition sc61860.c:5028
void cpu_math_add_16bit_with_8bit(Environment *_environment, char *_source, char *_destination, char *_other)
Definition sc61860.c:4976
void cpu_address_table_build(Environment *_environment, char *_table, int *_values, char *_address[], int _count)
Definition sc61860.c:8602
void cpu_mem_move(Environment *_environment, char *_source, char *_destination, char *_size)
Definition sc61860.c:4618
void cpu_set_asmio_indirect(Environment *_environment, int _asmio, char *_value)
Definition sc61860.c:3846
void cpu_msc1_uncompress_direct_indirect(Environment *_environment, char *_input, char *_output)
Definition sc61860.c:6816
void cpu_math_sub_8bit(Environment *_environment, char *_source, char *_destination, char *_other)
SC616860: emit code to subtract two 8 bit values
Definition sc61860.c:2014
void cpu_xor_32bit_const(Environment *_environment, char *_left, int _right, char *_result)
Definition sc61860.c:4400
void cpu_math_add_32bit(Environment *_environment, char *_source, char *_destination, char *_other)
SC616860: emit code to add two 32 bit values
Definition sc61860.c:3220
void cpu_protothread_save(Environment *_environment, char *_index, int _step)
Definition sc61860.c:6694
void cpu_store_char(Environment *_environment, char *_destination, int _value)
SC616860: emit code to store 8 bit
Definition sc61860.c:1534
void cpu_math_complement_const_32bit(Environment *_environment, char *_source, int _value)
SC616860: emit code to calculate a 32 bit complement of a number
Definition sc61860.c:3434
void cpu_store_16bit(Environment *_environment, char *_destination, int _value)
SC616860: emit code to store 16 bit
Definition sc61860.c:2306
void cpu_poked(Environment *_environment, char *_address, char *_source)
Definition sc61860.c:1149
void cpu_and_8bit_const(Environment *_environment, char *_left, int _right, char *_result)
Definition sc61860.c:4206
void cpu_math_double_16bit(Environment *_environment, char *_source, char *_other, int _signed)
SC616860: emit code to double a 16 bit value
Definition sc61860.c:2681
void cpu_math_sub_32bit(Environment *_environment, char *_source, char *_destination, char *_other)
SC616860: emit code to subtract two 32 bit values
Definition sc61860.c:3361
void cpu_complement2_8bit(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:6482
void cpu_msc1_uncompress_indirect_direct(Environment *_environment, char *_input, char *_output)
Definition sc61860.c:6834
void cpu_math_div2_const_8bit(Environment *_environment, char *_source, int _steps, int _signed, char *_remainder)
SC616860: emit code to halves for several times a 8 bit value
Definition sc61860.c:2129
void cpu_less_than_memory(Environment *_environment, char *_source, char *_destination, char *_size, char *_result, int _equal)
Definition sc61860.c:4836
void cpu_dsalloc_size(Environment *_environment, int _size, char *_index)
Definition sc61860.c:6366
void cpu_get_asmio_indirect(Environment *_environment, int _asmio, char *_value)
Definition sc61860.c:3926
void cpu_move_16bit_unsigned_8bit_unsigned(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8751
void cpu_float_fast_cos(Environment *_environment, char *_angle, char *_result)
Definition sc61860.c:8124
void cpu_protothread_set_state(Environment *_environment, char *_index, int _state)
Definition sc61860.c:6725
void cpu_math_add_8bit(Environment *_environment, char *_source, char *_destination, char *_other)
SC616860: emit code to add two 8 bit values
Definition sc61860.c:1968
void cpu_float_single_add(Environment *_environment, char *_x, char *_y, char *_result)
Definition sc61860.c:8322
void cpu_float_single_sub(Environment *_environment, char *_x, char *_y, char *_result)
Definition sc61860.c:8336
void cpu_bit_inplace_8bit_extended_indirect(Environment *_environment, char *_address, char *_position, char *_bit)
Definition sc61860.c:6077
void cpu_move_8bit_unsigned_32bit_unsigned(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8726
void cpu_move_8bit_indirect(Environment *_environment, char *_source, char *_value)
Definition sc61860.c:5239
void cpu_string_sub(Environment *_environment, char *_source, char *_source_size, char *_pattern, char *_pattern_size, char *_destination, char *_destination_size)
Definition sc61860.c:6910
void cpu_compare_8bit(Environment *_environment, char *_source, char *_destination, char *_other, int _positive)
SC616860: emit code to compare two 8 bit values
Definition sc61860.c:1577
void cpu_math_and_const_32bit(Environment *_environment, char *_source, int _mask)
SC616860: emit code to mask with "and" a value of 32 bit
Definition sc61860.c:3621
void cpu_fill_direct_size(Environment *_environment, char *_address, int _bytes, char *_pattern)
SC616860: emit code to fill up a memory area
Definition sc61860.c:1429
void cpu_addressof_16bit(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:2283
void cpu_dec_16bit(Environment *_environment, char *_variable)
Definition sc61860.c:4568
void cpu_dsgc(Environment *_environment)
Definition sc61860.c:6436
void cpu_move_16bit_signed_32bit_unsigned(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8765
void cpu_inc(Environment *_environment, char *_variable)
Definition sc61860.c:4506
void cpu_poke_const(Environment *_environment, char *_address, int _source)
Definition sc61860.c:1072
void cpu_fill_direct(Environment *_environment, char *_address, char *_bytes, char *_pattern)
SC616860: emit code to fill up a memory area
Definition sc61860.c:1391
void cpu_jump_indirect(Environment *_environment, char *_value)
Definition sc61860.c:3696
void cpu_math_complement_const_8bit(Environment *_environment, char *_source, int _value)
SC616860: emit code to calculate an 8 bit complement of a number
Definition sc61860.c:2217
void cpu_dsdefine(Environment *_environment, char *_string, char *_index)
Definition sc61860.c:6334
void cpu_math_complement_const_16bit(Environment *_environment, char *_source, int _value)
SC616860: emit code to calculate a 16 bit complement of a number
Definition sc61860.c:2812
void cpu_move_16bit_unsigned_32bit_unsigned(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8777
void cpu_float_single_exp(Environment *_environment, char *_value, char *_result)
Definition sc61860.c:8854
void cpu_move_32bit(Environment *_environment, char *_source, char *_destination)
SC616860: emit code to move 32 bit
Definition sc61860.c:2959
void cpu_fill_size(Environment *_environment, char *_address, int _bytes, char *_pattern)
SC616860: emit code to fill up a memory area
Definition sc61860.c:1290
void cpu_less_than_8bit(Environment *_environment, char *_source, char *_destination, char *_other, int _equal, int _signed)
SC616860: emit code to compare two 8 bit values
Definition sc61860.c:1777
void cpu_fill_direct_size_value(Environment *_environment, char *_address, int _bytes, int _pattern)
SC616860: emit code to fill up a memory area
Definition sc61860.c:1468
void cpu_float_double_to_string(Environment *_environment, char *_x, char *_string, char *_string_size)
Definition sc61860.c:7858
void cpu_dec_32bit(Environment *_environment, char *_variable)
Definition sc61860.c:4588
void cpu_greater_than_16bit_const(Environment *_environment, char *_source, int _destination, char *_other, int _equal, int _signed)
Definition sc61860.c:2561
void cpu_protothread_get_address(Environment *_environment, char *_index, char *_address)
Definition sc61860.c:6767
void cpu_math_add_16bit(Environment *_environment, char *_source, char *_destination, char *_other)
SC616860: emit code to add two 16 bit values
Definition sc61860.c:2576
void cpu_greater_than_16bit(Environment *_environment, char *_source, char *_destination, char *_other, int _equal, int _signed)
SC616860: emit code to compare two 8 bit values
Definition sc61860.c:2550
void cpu_bit_inplace_8bit(Environment *_environment, char *_value, int _position, int *_bit)
Definition sc61860.c:6049
void cpu_math_add_16bit_const(Environment *_environment, char *_source, int _destination, char *_other)
CPU 6502: emit code to add two 16 bit values
Definition sc61860.c:2614
void cpu_protothread_vars(Environment *_environment)
Definition sc61860.c:6605
void cpu_poked_const(Environment *_environment, char *_address, int _source)
Definition sc61860.c:1171
void cpu_math_add_16bit_with_16bit(Environment *_environment, char *_source, char *_destination, char *_other)
CPU 6309: emit code to add two 16 bit values
Definition sc61860.c:2644
void cpu_compare_and_branch_16bit_const(Environment *_environment, char *_source, int _destination, char *_label, int _positive)
SC616860: emit code to compare two 16 bit values and jump if they are equal/different
Definition sc61860.c:2419
void cpu_move_32bit_indirect(Environment *_environment, char *_source, char *_value)
Definition sc61860.c:5358
void cpu_dswrite(Environment *_environment, char *_index)
Definition sc61860.c:6389
void cpu_greater_than_8bit(Environment *_environment, char *_source, char *_destination, char *_other, int _equal, int _signed)
SC616860: emit code to compare two 8 bit values
Definition sc61860.c:1942
void cpu_or_16bit(Environment *_environment, char *_left, char *_right, char *_result)
Definition sc61860.c:4276
void cpu_fill(Environment *_environment, char *_address, char *_bytes, int _bytes_width, char *_pattern)
SC616860: emit code to fill up a memory area
Definition sc61860.c:1237
void cpu_move_16bit_indirect(Environment *_environment, char *_source, char *_value)
Definition sc61860.c:5312
void cpu_limit_16bit(Environment *_environment, char *_variable, int _value)
Definition sc61860.c:4129
void cpu_move_8bit_indirect_with_offset2(Environment *_environment, char *_source, char *_value, char *_offset)
Definition sc61860.c:6467
void cpu_less_than_32bit_const(Environment *_environment, char *_source, int _destination, char *_other, int _equal, int _signed)
Definition sc61860.c:3153
void cpu_move_nbit_indirect2(Environment *_environment, int _n, char *_value, char *_source)
Definition sc61860.c:5487
void cpu_and_8bit(Environment *_environment, char *_left, char *_right, char *_result)
Definition sc61860.c:4197
void cpu_float_single_log(Environment *_environment, char *_value, char *_result)
Definition sc61860.c:8842
void cpu_math_mul_8bit_to_16bit(Environment *_environment, char *_source, char *_destination, char *_other, int _signed)
SC616860: emit code to multiply two 8bit values in a 16 bit register
Definition sc61860.c:2080
void cpu_compare_16bit_const(Environment *_environment, char *_source, int _destination, char *_other, int _positive)
SC616860: emit code to compare two 16 bit values
Definition sc61860.c:2364
void cpu_math_sub_16bit(Environment *_environment, char *_source, char *_destination, char *_other)
SC616860: emit code to subtract two 16 bit values
Definition sc61860.c:2767
void cpu_compare_and_branch_32bit_const(Environment *_environment, char *_source, int _destination, char *_label, int _positive)
SC616860: emit code to compare two 32 bit values and jump if they are equal/different
Definition sc61860.c:3085
void cpu_store_nbit(Environment *_environment, char *_destination, int _n, int _value[])
CPU SC616860: emit code to store n bit
Definition sc61860.c:7070
void cpu_mem_move_direct_indirect_size(Environment *_environment, char *_source, char *_destination, int _size)
Definition sc61860.c:4737
void cpu_math_and_const_16bit(Environment *_environment, char *_source, int _mask)
SC616860: emit code to mask with "and" a value of 16 bit
Definition sc61860.c:2928
void cpu_move_8bit_indirect2_8bit(Environment *_environment, char *_value, char *_offset, char *_source)
Definition sc61860.c:5285
void cpu_float_single_from_16(Environment *_environment, char *_value, char *_result, int _signed)
Definition sc61860.c:8256
void cpu_less_than_and_branch_8bit_const(Environment *_environment, char *_source, int _destination, char *_label, int _equal, int _signed)
Definition sc61860.c:1863
void cpu_fill_indirect(Environment *_environment, char *_address, char *_size, char *_pattern, int _size_size)
Definition sc61860.c:5185
void cpu_mem_move_indirect_direct_size(Environment *_environment, char *_source, char *_destination, int _size)
Definition sc61860.c:4755
void cpu_compare_and_branch_char_const(Environment *_environment, char *_source, int _destination, char *_label, int _positive)
SC616860: emit code to compare two 8 bit values and jump if they are equal/different
Definition sc61860.c:1762
void cpu_float_fast_sin(Environment *_environment, char *_angle, char *_result)
Definition sc61860.c:8092
void cpu_label(Environment *_environment, char *_label)
Definition sc61860.c:1048
void cpu_dec(Environment *_environment, char *_variable)
Definition sc61860.c:4514
void cpu_and_16bit(Environment *_environment, char *_left, char *_right, char *_result)
Definition sc61860.c:4215
void cpu_float_fast_log(Environment *_environment, char *_value, char *_result)
Definition sc61860.c:8836
void cpu_move_nbit(Environment *_environment, int _n, char *_source, char *_destination)
CPU SC616860: emit code to store n bit
Definition sc61860.c:7133
void cpu_address_table_call(Environment *_environment, char *_table, char *_value, char *_address)
Definition sc61860.c:8655
void cpu_logical_not_8bit(Environment *_environment, char *_value, char *_result)
Definition sc61860.c:4456
void cpu_pokew_const(Environment *_environment, char *_address, int _source)
Definition sc61860.c:1111
void cpu_logical_and_8bit(Environment *_environment, char *_left, char *_right, char *_result)
Definition sc61860.c:4174
void cpu_or_8bit_const(Environment *_environment, char *_left, int _right, char *_result)
Definition sc61860.c:4265
void cpu_math_div2_const_32bit(Environment *_environment, char *_source, int _steps, int _signed, char *_remainder)
SC616860: emit code to halves for several times a 32 bit value
Definition sc61860.c:3490
void cpu_halt(Environment *_environment)
Definition sc61860.c:4021
void cpu_end(Environment *_environment)
Definition sc61860.c:4030
void cpu_float_fast_from_double_to_int_array(Environment *_environment, double _value, int _result[])
Definition sc61860.c:7303
void cpu_compare_memory(Environment *_environment, char *_source, char *_destination, char *_size, char *_result, int _equal)
Definition sc61860.c:4773
void cpu_greater_than_8bit_const(Environment *_environment, char *_source, int _destination, char *_other, int _equal, int _signed)
Definition sc61860.c:1953
void cpu_complement2_16bit(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:6500
void cpu_dsinit(Environment *_environment)
Definition sc61860.c:6428
void cpu_xor_8bit(Environment *_environment, char *_left, char *_right, char *_result)
Definition sc61860.c:4296
void cpu_protothread_unregister(Environment *_environment, char *_index)
Definition sc61860.c:6682
void cpu_complement2_32bit(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:6525
void cpu_protothread_register_at(Environment *_environment, char *_index, char *_label)
Definition sc61860.c:6646
void cpu_blit_free_register(Environment *_environment, int _register)
Definition sc61860.c:7029
void cpu_lowercase(Environment *_environment, char *_source, char *_size, char *_result)
Definition sc61860.c:5067
void cpu_float_single_to_8(Environment *_environment, char *_value, char *_result, int _signed)
Definition sc61860.c:8306
void cpu_move_16bit(Environment *_environment, char *_source, char *_destination)
SC616860: emit code to move 16 bit
Definition sc61860.c:2267
void cpu_move_8bit_with_offset2(Environment *_environment, char *_source, char *_value, char *_offset)
Definition sc61860.c:5249
#define SC616860_BLII_REGISTER_COUNT
Definition sc61860.c:6954
void cpu_out(Environment *_environment, char *_port, char *_value)
Definition sc61860.c:6870
void cpu_move_16bit_unsigned_8bit_signed(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8744
void cpu_blit_finalize(Environment *_environment)
Definition sc61860.c:6968
void cpu_bneq(Environment *_environment, char *_label)
SC616860: emit code to make long conditional jump
Definition sc61860.c:1018
void cpu_float_single_mod1(Environment *_environment, char *_value, char *_result)
Definition sc61860.c:8578
void cpu_move_16bit_indirect2(Environment *_environment, char *_value, char *_source)
Definition sc61860.c:5326
void cpu_float_fast_cmp(Environment *_environment, char *_x, char *_y, char *_result)
Definition sc61860.c:8052
void cpu_math_double_8bit(Environment *_environment, char *_source, char *_other, int _signed)
SC616860: emit code to double a 8 bit value
Definition sc61860.c:2041
void cpu_float_fast_mul(Environment *_environment, char *_x, char *_y, char *_result)
Definition sc61860.c:7999
void cpu_bits_to_string(Environment *_environment, char *_number, char *_string, char *_string_size, int _bits, char *_zero, char *_one)
Definition sc61860.c:6238
void cpu_dsalloc(Environment *_environment, char *_size, char *_index)
Definition sc61860.c:6351
void cpu_port_out(Environment *_environment, char *_port, char *_value)
SC616860: emit code to send one byte throught a I/O port
Definition sc61860.c:4167
void cpu_not_32bit(Environment *_environment, char *_value, char *_result)
Definition sc61860.c:4485
void cpu_float_single_from_double_to_int_array(Environment *_environment, double _value, int _result[])
Definition sc61860.c:7522
void cpu_float_single_to_16(Environment *_environment, char *_value, char *_result, int _signed)
Definition sc61860.c:8290
void cpu_greater_than_memory_size(Environment *_environment, char *_source, char *_destination, int _size, char *_result, int _equal)
Definition sc61860.c:4943
void cpu_or_8bit(Environment *_environment, char *_left, char *_right, char *_result)
Definition sc61860.c:4254
void cpu_store_8bit_with_offset2(Environment *_environment, char *_destination, char *_offset, int _value)
Definition sc61860.c:1554
void cpu_move_8bit_indirect2_16bit(Environment *_environment, char *_value, char *_offset, char *_source)
Definition sc61860.c:5300
void cpu_math_add_32bit_const(Environment *_environment, char *_source, int _destination, char *_other)
Definition sc61860.c:3286
void cpu_move_8bit_indirect_with_offset(Environment *_environment, char *_source, char *_value, int _offset)
Definition sc61860.c:5263
void cpu_sqroot(Environment *_environment, char *_number, char *_result)
Definition sc61860.c:6564
void cpu_number_to_string(Environment *_environment, char *_number, char *_string, char *_string_size, int _bits, int _signed)
Definition sc61860.c:6109
void cpu_greater_than_32bit(Environment *_environment, char *_source, char *_destination, char *_other, int _equal, int _signed)
SC616860: emit code to compare two 8 bit values
Definition sc61860.c:3194
void cpu_peekd(Environment *_environment, char *_address, char *_target)
Definition sc61860.c:1126
void cpu_in_direct(Environment *_environment, char *_port, char *_value)
Definition sc61860.c:6900
void cpu_call_indirect(Environment *_environment, char *_value)
Definition sc61860.c:3680
void cpu_call(Environment *_environment, char *_label)
Definition sc61860.c:3674
void cpu_random_8bit(Environment *_environment, char *_entropy, char *_result)
Definition sc61860.c:4088
void cpu_xor_8bit_const(Environment *_environment, char *_left, int _right, char *_result)
Definition sc61860.c:4311
void cpu_move_16bit_signed_8bit_unsigned(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8737
void cpu_mem_move_direct(Environment *_environment, char *_source, char *_destination, char *_size)
Definition sc61860.c:4654
void cpu_store_8bit(Environment *_environment, char *_destination, int _value)
SC616860: emit code to store 8 bit
Definition sc61860.c:1519
void cpu_compare_nbit(Environment *_environment, int _n, char *_source, char *_destination, char *_name, int _positive)
CPU SC616860: emit code to compare n bit
Definition sc61860.c:7206
void cpu_swap_8bit(Environment *_environment, char *_left, char *_right)
Definition sc61860.c:4430
void cpu_float_fast_to_8(Environment *_environment, char *_value, char *_result, int _signed)
Definition sc61860.c:7924
void cpu_mem_move_direct2(Environment *_environment, char *_source, char *_destination, char *_size)
Definition sc61860.c:4669
void cpu_init(Environment *_environment)
Definition sc61860.c:953
void cpu_dstring_vars(Environment *_environment)
Definition sc61860.c:6578
void cpu_protothread_loop(Environment *_environment)
Definition sc61860.c:6638
void cpu_float_single_div(Environment *_environment, char *_x, char *_y, char *_result)
Definition sc61860.c:8365
void cpu_out_direct(Environment *_environment, char *_port, char *_value)
Definition sc61860.c:6890
void cpu_greater_than_32bit_const(Environment *_environment, char *_source, int _destination, char *_other, int _equal, int _signed)
Definition sc61860.c:3205
void cpu_protothread_current(Environment *_environment, char *_current)
Definition sc61860.c:6756
void cpu_float_fast_to_16(Environment *_environment, char *_value, char *_result, int _signed)
Definition sc61860.c:7904
void cpu_mem_move_16bit(Environment *_environment, char *_source, char *_destination, char *_size)
Definition sc61860.c:4636
void cpu_compare_32bit(Environment *_environment, char *_source, char *_destination, char *_other, int _positive)
SC616860: emit code to compare two 32 bit values
Definition sc61860.c:3023
void cpu_set_asmio(Environment *_environment, int _asmio, int _value)
Definition sc61860.c:3750
void cpu_float_fast_sqr(Environment *_environment, char *_value, char *_result)
Definition sc61860.c:8182
void cpu_jump(Environment *_environment, char *_label)
Definition sc61860.c:3662
void cpu_move_16bit_unsigned_32bit_signed(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8771
int cpu_blit_alloc_register(Environment *_environment)
Definition sc61860.c:6991
void cpu_move_32bit_signed_8bit_unsigned(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8792
void cpu_mem_move_size(Environment *_environment, char *_source, char *_destination, int _size)
Definition sc61860.c:4695
void cpu_fill_blocks(Environment *_environment, char *_address, char *_blocks, char *_pattern)
SC616860: emit code to fill up a memory area
Definition sc61860.c:1206
void cpu_bvneq(Environment *_environment, char *_value, char *_label)
Definition sc61860.c:1039
void cpu_float_single_mul(Environment *_environment, char *_x, char *_y, char *_result)
Definition sc61860.c:8351
void cpu_float_fast_exp(Environment *_environment, char *_value, char *_result)
Definition sc61860.c:8848
void cpu_move_16bit_signed_8bit_signed(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8732
void cpu_compare_and_branch_16bit(Environment *_environment, char *_source, char *_destination, char *_label, int _positive)
Definition sc61860.c:2387
void cpu_fill_size_value(Environment *_environment, char *_address, int _bytes, int _pattern)
SC616860: emit code to fill up a memory area
Definition sc61860.c:1341
void cpu_call_addr(Environment *_environment, int _address)
Definition sc61860.c:3668
void cpu_math_div_16bit_to_16bit_const(Environment *_environment, char *_source, int _destination, char *_other, char *_other_remainder, int _signed)
Definition sc61860.c:5901
void cpu_poke(Environment *_environment, char *_address, char *_source)
Definition sc61860.c:1062
void cpu_bit_check(Environment *_environment, char *_value, int _position, char *_result, int _bitwidth)
Definition sc61860.c:6007
void cpu_protothread_register(Environment *_environment, char *_label, char *_index)
Definition sc61860.c:6664
void cpu_move_32bit_signed_8bit_signed(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8786
void cpu_float_single_to_string(Environment *_environment, char *_x, char *_string, char *_string_size)
Definition sc61860.c:7813
void cpu_float_single_tan(Environment *_environment, char *_angle, char *_result)
Definition sc61860.c:8514
void cpu_nop(Environment *_environment)
Definition sc61860.c:947
void cpu_random_32bit(Environment *_environment, char *_entropy, char *_result)
Definition sc61860.c:4115
void cpu_move_32bit_unsigned_16bit_unsigned(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8829
void cpu_less_than_8bit_const(Environment *_environment, char *_source, int _destination, char *_other, int _equal, int _signed)
Definition sc61860.c:1821
void cpu_prepare_for_compare_and_branch_8bit(Environment *_environment, char *_source)
SC616860: emit code to compare two 8 bit values and jump if they are equal/different
Definition sc61860.c:1720
void cpu_less_than_16bit(Environment *_environment, char *_source, char *_destination, char *_other, int _equal, int _signed)
SC616860: emit code to compare two 8 bit values
Definition sc61860.c:2451
void cpu_mem_move_direct2_size(Environment *_environment, char *_source, char *_destination, int _size)
Definition sc61860.c:4682
void cpu_math_and_const_8bit(Environment *_environment, char *_source, int _mask)
SC616860: emit code to mask with "and" a value of 8 bit
Definition sc61860.c:2242
void cpu_move_32bit_unsigned_16bit_signed(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8823
void cpu_msc1_uncompress_direct_direct(Environment *_environment, char *_input, char *_output)
Definition sc61860.c:6798
void cpu_float_single_sqr(Environment *_environment, char *_value, char *_result)
Definition sc61860.c:8553
void cpu_inc_32bit(Environment *_environment, char *_variable)
Definition sc61860.c:4538
void cpu_move_8bit_signed_16bit_signed(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8665
void cpu_mem_move_direct_size(Environment *_environment, char *_source, char *_destination, int _size)
Definition sc61860.c:4719
void cpu_float_fast_sub(Environment *_environment, char *_x, char *_y, char *_result)
Definition sc61860.c:7971
void cpu_xor_32bit(Environment *_environment, char *_left, char *_right, char *_result)
Definition sc61860.c:4370
void cpu_return(Environment *_environment)
Definition sc61860.c:4009
void cpu_move_8bit_indirect2(Environment *_environment, char *_value, char *_source)
Definition sc61860.c:5275
void cpu_pop(Environment *_environment)
Definition sc61860.c:4015
void cpu_math_sub_16bit_with_8bit(Environment *_environment, char *_source, char *_destination, char *_other)
Definition sc61860.c:5011
void cpu_random_16bit(Environment *_environment, char *_entropy, char *_result)
Definition sc61860.c:4102
void cpu_ei(Environment *_environment)
Definition sc61860.c:4500
int cpu_register_decode(Environment *_environment, char *_register)
Definition sc61860.c:3714
void cpu_or_32bit(Environment *_environment, char *_left, char *_right, char *_result)
Definition sc61860.c:4285
void cpu_bits_to_string_vars(Environment *_environment)
Definition sc61860.c:6232
void cpu_math_div2_const_16bit(Environment *_environment, char *_source, int _steps, int _signed, char *_remainder)
SC616860: emit code to halves for several times a 16 bit value
Definition sc61860.c:2841
void cpu_convert_string_into_8bit(Environment *_environment, char *_string, char *_len, char *_value)
Definition sc61860.c:5105
void cpu_inc_16bit(Environment *_environment, char *_variable)
Definition sc61860.c:4522
void cpu_logical_or_8bit(Environment *_environment, char *_left, char *_right, char *_result)
Definition sc61860.c:4231
void cpu_address_table_lookup(Environment *_environment, char *_table, int _count)
Definition sc61860.c:8613
void cpu_ztoa(Environment *_environment)
Definition sc61860.c:960
void cpu_random(Environment *_environment, char *_entropy)
Definition sc61860.c:4036
void cpu_move_32bit_unsigned_8bit_signed(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8797
void cpu_compare_and_branch_8bit(Environment *_environment, char *_source, char *_destination, char *_label, int _positive)
Definition sc61860.c:1656
void cpu_execute_compare_and_branch_8bit_const(Environment *_environment, int _destination, char *_label, int _positive)
SC616860: emit code to compare two 8 bit values and jump if they are equal/different
Definition sc61860.c:1735
void cpu_ctoa(Environment *_environment)
Definition sc61860.c:973
void cpu_move_16bit_indirect2_8bit(Environment *_environment, char *_value, char *_offset, char *_source)
Definition sc61860.c:5339
void cpu_float_single_from_8(Environment *_environment, char *_value, char *_result, int _signed)
Definition sc61860.c:8273
void cpu_float_single_cmp(Environment *_environment, char *_x, char *_y, char *_result)
Definition sc61860.c:8380
void cpu_move_8bit_signed_32bit_signed(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8692
void cpu_store_8bit_with_offset(Environment *_environment, char *_destination, int _value, int _offset)
Definition sc61860.c:1542
void cpu_busy_wait(Environment *_environment, char *_timing)
Definition sc61860.c:4144
void cpu_greater_than_memory(Environment *_environment, char *_source, char *_destination, char *_size, char *_result, int _equal)
Definition sc61860.c:4910
void cpu_store_32bit(Environment *_environment, char *_destination, int _value)
SC616860: emit code to store 32 bit
Definition sc61860.c:2990
void cpu_peekw(Environment *_environment, char *_address, char *_target)
Definition sc61860.c:1082
void cpu_hex_to_string(Environment *_environment, char *_number, char *_string, char *_string_size, int _bits)
Definition sc61860.c:6277
void cpu_move_8bit(Environment *_environment, char *_source, char *_destination)
SC616860: emit code to move 8 bit
Definition sc61860.c:1504
void cpu_beq(Environment *_environment, char *_label)
SC616860: emit code to make long conditional jump
Definition sc61860.c:1000
void cpu_compare_16bit(Environment *_environment, char *_source, char *_destination, char *_other, int _positive)
SC616860: emit code to compare two 16 bit values
Definition sc61860.c:2330
void cpu_peek(Environment *_environment, char *_address, char *_target)
Definition sc61860.c:1052
void cpu_float_fast_add(Environment *_environment, char *_x, char *_y, char *_result)
Definition sc61860.c:7944
void cpu_convert_string_into_16bit(Environment *_environment, char *_string, char *_len, char *_value)
Definition sc61860.c:5115
void cpu_float_single_sin(Environment *_environment, char *_angle, char *_result)
Definition sc61860.c:8441
void cpu_not_8bit(Environment *_environment, char *_value, char *_result)
Definition sc61860.c:4468
void cpu_math_div_8bit_to_8bit(Environment *_environment, char *_source, char *_destination, char *_other, char *_other_remainder, int _signed)
Definition sc61860.c:5907
void cpu_dsdescriptor(Environment *_environment, char *_index, char *_address, char *_size)
Definition sc61860.c:6444
void cpu_compare_8bit_const(Environment *_environment, char *_source, int _destination, char *_other, int _positive)
SC616860: emit code to compare two 8 bit values
Definition sc61860.c:1625
void cpu_xor_16bit(Environment *_environment, char *_left, char *_right, char *_result)
Definition sc61860.c:4326
void cpu_xor_16bit_const(Environment *_environment, char *_left, int _right, char *_result)
Definition sc61860.c:4348
void cpu_float_single_neg(Environment *_environment, char *_value, char *_result)
Definition sc61860.c:8411
void cpu_float_double_from_double_to_int_array(Environment *_environment, double _value, int _result[])
Definition sc61860.c:7757
void cpu_swap_16bit(Environment *_environment, char *_left, char *_right)
Definition sc61860.c:4440
void cpu_compare_and_branch_8bit_const(Environment *_environment, char *_source, int _destination, char *_label, int _positive)
SC616860: emit code to compare two 8 bit values and jump if they are equal/different
Definition sc61860.c:1691
void cpu_math_div_32bit_to_16bit_const(Environment *_environment, char *_source, int _destination, char *_other, char *_other_remainder, int _signed)
Definition sc61860.c:5792
void cpu_number_to_string_vars(Environment *_environment)
Definition sc61860.c:6105
void cpu_float_fast_to_string(Environment *_environment, char *_x, char *_string, char *_string_size)
Definition sc61860.c:7763
void cpu_less_than_32bit(Environment *_environment, char *_source, char *_destination, char *_other, int _equal, int _signed)
SC616860: emit code to compare two 8 bit values
Definition sc61860.c:3117
void cpu_move_8bit_signed_16bit_unsigned(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8671
void cpu_move_8bit_unsigned_16bit_unsigned(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:8683
void cpu_compare_memory_size(Environment *_environment, char *_source, char *_destination, int _size, char *_result, int _equal)
Definition sc61860.c:4806
void cpu_float_fast_mod1(Environment *_environment, char *_value, char *_result)
Definition sc61860.c:8208
void cpu_math_add_8bit_const(Environment *_environment, char *_source, int _destination, char *_other)
CPU 6502: emit code to add two 8 bit values
Definition sc61860.c:1988
void cpu_flip_8bit(Environment *_environment, char *_source, char *_destination)
Definition sc61860.c:5222
void cpu_blit_initialize(Environment *_environment)
Definition sc61860.c:6956
void cpu_less_than_16bit_const(Environment *_environment, char *_source, int _destination, char *_other, int _equal, int _signed)
Definition sc61860.c:2499
enum _SC61860Stack SC61860Stack
enum _SC61860Register SC61860Register
@ REGISTER_I
Definition sc61860.h:62
@ REGISTER_N
Definition sc61860.h:73
@ REGISTER_XH
Definition sc61860.h:67
@ REGISTER_XL
Definition sc61860.h:66
@ REGISTER_K
Definition sc61860.h:70
@ REGISTER_YL
Definition sc61860.h:68
@ REGISTER_L
Definition sc61860.h:71
@ REGISTER_M
Definition sc61860.h:72
@ REGISTER_J
Definition sc61860.h:63
@ REGISTER_YH
Definition sc61860.h:69
Variable * sign(Environment *_environment, char *_value)
Return the sign of a variable.
Definition sgn.c:85
int usedMemory
Definition ugbc.h:2167
char * name
Definition ugbc.h:2164
int freeRegisters
Definition ugbc.h:2166
int space
Definition ugbc.h:1970
int count
Definition ugbc.h:1969
int stackStartAddress
Definition ugbc.h:3296
int bitmaskNeeded
Definition ugbc.h:2659
DString dstring
Definition ugbc.h:2405
Blit blit
Definition ugbc.h:2474
int stackSize
Definition ugbc.h:3294
ProtothreadConfig protothreadConfig
Definition ugbc.h:2430
int emptyProcedure
Definition ugbc.h:2932
char * realName
Definition ugbc.h:982
#define no_embedded(s)
Definition ugbc.h:4380
#define MAX_TEMPORARY_STORAGE
Definition ugbc.h:563
#define embedded(s, e)
Definition ugbc.h:4385
#define deploy_with_vars(s, e, v)
Definition ugbc.h:4320
#define no_inline(s)
Definition ugbc.h:4376
#define done()
Definition ugbc.h:4389
#define CRITICAL_BLIT_ALLOC_REGISTER_EXHAUSTED()
Definition ugbc.h:3610
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
#define CRITICAL_BLIT_INVALID_FREE_REGISTER(s, r)
Definition ugbc.h:3612
#define CRITICAL_BLIT_ALLOC_MEMORY_EXHAUSTED()
Definition ugbc.h:3611
@ VT_WORD
Definition ugbc.h:455
@ VT_BUFFER
Definition ugbc.h:477
#define CRITICAL_UNKNOWN_CPU_REGISTER()
Definition ugbc.h:3624
#define outhead0(s)
Definition ugbc.h:4246
#define out0(s)
Definition ugbc.h:4259
#define outline0(s)
Definition ugbc.h:4252
#define outline1(s, a)
Definition ugbc.h:4253
#define CRITICAL_UNIMPLEMENTED(v)
Definition ugbc.h:3444
#define deploy(s, e)
Definition ugbc.h:4288
#define MAKE_LABEL
Definition ugbc.h:3351
#define outhead1(s, a)
Definition ugbc.h:4247