source: buchla-68k/rom/romp.c@ b28a12e

Last change on this file since b28a12e was b28a12e, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Zero redundant declarations.

  • Property mode set to 100644
File size: 68.8 KB
Line 
1/*
2 ============================================================================
3 romp.c -- ROMP debug monitor
4 (c) Copyright 1987,1988 -- D.N. Lynx Crowe
5
6 See ROMPVER, below, for version number and date.
7
8 CAUTION: This code is designed to live in PROM, so initialized
9 variables are PERMANENTLY initialized, since the compiler assigns
10 initialized variables to the data segment, which ends up in PROM.
11
12 Un-initialized variables go into the bss segment, which ends up in RAM.
13
14 Set ON_B700 non-zero to get a Buchla 700 PROM,
15 or zero to get a NASA 3D Helmet Display PROM.
16 ============================================================================
17*/
18
19#define ROMPVER "22.00 -- 1988-06-20"
20
21#define TINYMSG 0 /* 1 for short messages, 0 for normal ones */
22
23#define ON_B700 1 /* 1 for Buchla 700, 0 for NASA */
24#define ONEMEG 1 /* 1 if 1024K, 0 if 512K RAM space (Buchla 700) */
25
26#include "rom.h"
27
28/*
29
30*/
31
32#if ON_B700
33#define USER_RAM 0x00010000L /* Start of user RAM (TPA) */
34#if ONEMEG
35#define RAM_TOP 0x000FFFFEL /* Default top word of memory */
36#define ISTACK 0x000FFFFEL /* Default initial stack */
37#else
38#define RAM_TOP 0x0007FFFEL /* Default top word of memory */
39#define ISTACK 0x0007FFFEL /* Default initial stack */
40#endif
41#define KB_EI 2 /* Enable level for panel */
42#define DEFIPL 2 /* Default internal processor level */
43#define INITSR 0x2200 /* Default initial status register */
44#define BOOTFILE "midas.abs" /* Boot file name */
45#define BOOTKEY 39 /* Boot panel key */
46#define ROMPKEY 40 /* ROMP panel key */
47#define FIFOLIM 60000 /* FIFO clear limit */
48#define I_TABX 53 /* Tablet X */
49#define I_TABY 54 /* Tablet Y */
50#define I_CURX 55 /* Cursor X */
51#define I_CURY 56 /* Cursor Y */
52#define I_LONGL 57 /* LongPot Left */
53#define I_LONGR 58 /* LongPot Right */
54#define I_SCROLL 59 /* Scroll */
55#define I_TEMPO 73 /* Tempo Multiplier */
56#define I_TIME 74 /* Time Scaling */
57#define I_TUNE 75 /* Fine Tuning */
58#define I_LEVEL 76 /* Amplitude */
59#define BARBASE 5120L /* Base of bars in VSDD RAM */
60#define SWBASE 38400L /* Base of switches in VSDD RAM */
61#define MARGIN 4 /* Offset from left edge of screen */
62#else
63#define DEFIPL 3
64#define USER_RAM 0x00008000L
65#define RAM_TOP 0x0001FFFEL
66#define ISTACK 0x0001FFFEL
67#define INITSR 0x2300
68#endif
69
70#define ROMADDR 0x00100000L
71
72#define MAXFNLN 13 /* xxxxxxxx.xxx + CR */
73#define MAXARGLN 80 /* maximum argument length */
74#define MAXCMDLN 128 /* maximum command line length */
75#define MAXHS 80 /* maximum help string length */
76#define MAXID 90 /* maximum ID string length */
77
78#define PDATELN 14
79#define PRM_DATE 0x0100008L
80#define PRM_VERS 0x0100002L
81
82#define BPINST 0x4E4F /* breakpoint instruction */
83
84#define CRLF "\r\n"
85
86#define TACK "K\r" /* good response from load command */
87#define NACK "?\r" /* bad response from load command */
88
89#define SREC9 "04000000FB" /* tail of a type 9 Motorola S-Record */
90
91#define MON_C 1 /* monitor character code */
92#define MON_S 2 /* monitor short code */
93#define MON_L 4 /* monitor long code */
94
95/*
96
97*/
98
99/*
100 ============================================================================
101 error message string definitions
102 ============================================================================
103*/
104
105#define EMSG1 "\r\n** Command error **\r\n"
106#define EMSG2 "\r\n** Invalid parameter **\r\n"
107#define EMSG3 "\r\n** Unrecognized command **\r\n"
108
109#define EMSG5 "\r\n** Command not repeatable **\r\n"
110#define EMSG6 "\r\n** Invalid line terminator **\r\n"
111#define EMSG7 "\r\n** do_cmd() switch failed **\r\n"
112
113#define CANNED "\r\n----- Cancelled -----\r\n"
114
115/*
116
117*/
118
119/*
120 ============================================================================
121 initialized variables (These end up in the data segment in PROM)
122 ============================================================================
123*/
124
125struct cmdent { /* command table entry */
126
127 int8_t *cname; /* command name pointer */
128 int16_t (*cp)(); /* command parser function pointer */
129 int16_t (*cx)(); /* command execution function pointer */
130 int8_t *hstr; /* help string pointer */
131};
132
133static struct cmdent cmtab[] = {
134
135#if ON_B700
136 {"adisp", cp_null, cx_adsp, ""},
137 {"boot", cp_boot, cx_boot, ""},
138 {"bpb", cp_null, cx_bpb, ""},
139#endif
140
141 {"check", cp_chek, cx_chek, "start,end"},
142 {"copy", cp_copy, cx_copy, "from,to,len"},
143
144#if ON_B700
145 {"crash", cp_null, cx_crsh, ""},
146 {"dinit", cp_null, cx_dini, ""},
147#endif
148
149 {"dump", cp_dump, cx_dump, "from[,[to=from][,width=16]]"},
150 {"exit", cp_null, cx_exit, ""},
151 {"fill", cp_fill, cx_fill, "loc,count,byte"},
152 {"go", cp_go, cx_go, "[addr][,[brk1][,brk2]]"},
153 {"help", cp_null, cx_help, ""},
154 {"ipl", cp_ilev, cx_ilev, "level"},
155 {"ldump", cp_ldmp, cx_ldmp, "from[,[to=from][,width=4]]"},
156 {"load", cp_null, cx_load, ""},
157
158#if ON_B700
159 {"midas", cp_null, cx_mlod, ""},
160#endif
161
162 {"monc", cp_monc, cx_mon, "addr"},
163 {"mons", cp_mons, cx_mon, "addr"},
164 {"monl", cp_monl, cx_mon, "addr"},
165 {"mset", cp_mset, cx_mset, "addr,b1[,...,bn]"},
166 {"mtest", cp_mtst, cx_mtst, hs_mtst},
167 {"next", cp_null, cx_next, ""},
168 {"obmap", cp_null, cx_omap, ""},
169
170#if ON_B700
171 {"read", cp_read, cx_read, "sector,buffer,count"},
172#endif
173
174 {"regs", cp_null, cx_regs, ""},
175 {"reset", cp_null, cx_rest, ""},
176 {"rset", cp_rset, cx_rset, "register,value"},
177 {"vregs", cp_null, cx_vreg, ""},
178 {"vrset", cp_vrst, cx_vrst, "register,value"},
179 {"wdump", cp_wdmp, cx_wdmp, "from[,[to=from][,width=8]]"},
180 {"wfill", cp_wfil, cx_wfil, "loc,count,word"},
181
182#if ON_B700
183 {"write", cp_read, cx_writ, "sector,buffer,count"},
184#endif
185
186 {"wset", cp_wset, cx_wset, "addr,w1[,...,wn]"},
187 {"zap", cp_null, cx_zap, ""}
188};
189
190#define NCMDS ((sizeof cmtab) / (sizeof cmtab[0]))
191
192/*
193
194*/
195
196int8_t ahex[] = "0123456789abcdefABCDEF";
197
198int8_t *rlist[] = { /* register name list */
199
200 "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
201 "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
202 "sr", "pc", "sp",
203 (int8_t *)0
204};
205
206int8_t *vrlist[] = { /* video register name list */
207
208 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
209 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
210 "h0", "h1", "h2", "h3", "v0", "v1", "v2", "v3",
211 (int8_t *)0
212};
213
214#if ON_B700
215int16_t sigadr[] = { /* display offsets for signals */
216
217 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, /* keys */
218 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
219 4, 4, 4, 4,
220 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, /* sliders */
221 9, 9, 9, 9,
222 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, /* switches */
223 14, 14, 14, 14,
224 17, 17, /* tablet */
225 20, 20, /* cursor */
226 23, 23, /* longpot */
227 26, /* scrollpot */
228 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, /* digits */
229 32, 32, 32, /* x, e, m */
230 35, 35, 35, 35, /* pots */
231 37, 37, /* pedals */
232 39, 39, 39, 39 /* analog in */
233};
234#endif
235
236/*
237
238*/
239
240/*
241 ============================================================================
242 un-initialized variables (These end up in the bss segment in RAM)
243 ============================================================================
244*/
245
246int8_t argsep; /* argument separator */
247
248int8_t *aptr, /* argument pointer */
249 *monptr, /* monitored variable pointer */
250 *d_cur, /* dump current from */
251 *d_next, /* dump next from */
252 *d_last, /* dump next to */
253 *p_end, /* end parameter */
254 *p_from, /* from parameter */
255 *p_goto, /* goto parameter */
256 *p_to, /* to parameter */
257 *sptr; /* string scan pointer */
258
259int16_t argln, /* argument length */
260 b0flag, /* breakpoint 0 flag */
261 b1flag, /* breakpoint 1 flag */
262 cmdunit, /* command unit */
263 dflag, /* dump limit flag */
264 exflag, /* exit do_cmd flag */
265 first1, /* first time flag */
266 goflag, /* pc set flag */
267 ilast, /* index of last command */
268 inext, /* command index for "next" command */
269 iplev, /* ROMP IPL level */
270 monsw, /* monitor switch */
271 redo, /* re-doable command flag */
272 rnum, /* register number */
273 vrnum; /* video register number */
274
275/*
276
277*/
278
279#if ON_B700
280int16_t asig, /* signal number */
281 aval, /* signal value */
282 astat, /* signal status */
283 aflag, /* signal activity flag */
284 baseled, /* base LED for scan */
285 ledcntr; /* LED scan counter */
286
287int16_t sigtab[128][2]; /* signal table */
288
289int32_t afi, /* analog FIFO input */
290 ftimer; /* analog FIFO clear timer */
291
292uint16_t baron, /* bar 'on' color */
293 baroff, /* bar 'off' color */
294 swon, /* switch 'on' color */
295 swoff, /* switch 'off' color */
296 *obj0; /* object pointer */
297#endif
298
299uint16_t *tba0, /* breakpoint 0 temporary */
300 *tba1; /* breakpoint 1 temporary */
301
302uint16_t p_bv0, /* breakpoint 0 value */
303 p_bv1; /* breakpoint 1 value */
304
305uint16_t *p_ba0, /* breakpoint 0 address */
306 *p_ba1; /* breakpoint 1 address */
307
308jmp_buf restart; /* jmp environment */
309
310int32_t p_len, /* length parameter */
311 p_value, /* value parameter */
312 p_width; /* width parameter */
313
314struct regs *regptr; /* register save area pointer */
315
316int8_t argstr[MAXARGLN+1], /* argument string */
317 cmdline[MAXCMDLN+1], /* command line */
318 bfname[MAXFNLN+1], /* boot file name */
319 hs_mtst[MAXHS+1], /* mtest help string */
320 idbuf[MAXID+1], /* ID string */
321 promdate[PDATELN+1]; /* PROM date area */
322
323/*
324
325*/
326
327/*
328 ============================================================================
329 cx_exit -- restart ROMP
330 ============================================================================
331*/
332
333void cx_exit(void)
334{
335 longjmp(&restart, 1); /* restart ROMP */
336}
337
338/*
339 ============================================================================
340 cx_rest -- execute the reset command
341 ============================================================================
342*/
343
344void cx_rest(void)
345{
346 rjumpto(ROMADDR);
347}
348
349/*
350 ============================================================================
351 cx_mlod() -- execute the midas command
352 ============================================================================
353*/
354
355int16_t cx_mlod(void)
356{
357 register int16_t i;
358
359 B_log_s = TRUE;
360 B_dbg_s = FALSE;
361 redo = FALSE;
362
363 hdvini();
364 _bpbin = FALSE;
365
366 if (booter("midas.abs", 0L)) {
367
368 return(FALSE);
369
370 } else {
371
372 for (i = 0; i < 8; i++) /* clear d0..d7 */
373 regptr->d_reg[i] = 0L;
374
375 for (i = 0; i < 7; i++) /* clear a0..a6 */
376 regptr->a_reg[i] = (int8_t *)0L;
377
378 regptr->a_reg[7] = ISTACK; /* setup initial stack */
379
380 regptr->reg_sr = INITSR; /* setup sr */
381 regptr->reg_pc = B_buf_a; /* setup pc */
382
383 return(TRUE);
384 }
385}
386
387/*
388
389*/
390
391/*
392 ============================================================================
393 cp_boot() -- parse boot command
394 ============================================================================
395*/
396
397int16_t cp_boot(void)
398{
399 register int16_t i;
400 register int8_t endc;
401
402 redo = FALSE;
403
404 for (;;) {
405
406 writeln(cmdunit, "File name: ");
407 endc = getln(cmdunit, MAXFNLN+1, bfname);
408 writeln(cmdunit, CRLF);
409
410 if (endc EQ A_CR)
411 break;
412
413 if (endc EQ CTL('X')) {
414
415 writeln(cmdunit, CANNED);
416 return(FALSE);
417 }
418
419 if (endc EQ ERR01)
420 writeln(cmdunit, EMSG2);
421 }
422
423 for (i = 0; i < MAXFNLN+1; i++)
424 if (bfname[i] EQ A_CR)
425 bfname[i] = '\0';
426
427 return(TRUE);
428}
429
430/*
431
432*/
433
434/*
435 ============================================================================
436 cx_boot() -- execute boot command
437 ============================================================================
438*/
439
440int16_t cx_boot(void)
441{
442 register int16_t i;
443
444 B_log_s = TRUE;
445 B_dbg_s = FALSE;
446
447 hdvini();
448 _bpbin = FALSE;
449
450 if (booter(bfname, 0L)) {
451
452 return(FALSE);
453
454 } else {
455
456 for (i = 0; i < 8; i++) /* clear d0..d7 */
457 regptr->d_reg[i] = 0L;
458
459 for (i = 0; i < 7; i++) /* clear a0..a6 */
460 regptr->a_reg[i] = (int8_t *)0L;
461
462 regptr->a_reg[7] = ISTACK; /* setup initial stack */
463
464 regptr->reg_sr = INITSR; /* setup sr */
465 regptr->reg_pc = B_buf_a; /* setup pc */
466
467 return(TRUE);
468 }
469}
470
471/*
472
473*/
474
475/*
476 =============================================================================
477 dobar(nb, bv) -- draw bar 'nb' with value 'bv'
478 =============================================================================
479*/
480
481void dobar(int16_t nb, int16_t bv)
482{
483 register uint16_t *bp;
484 register int16_t i;
485
486 if ((nb LT 1) OR (nb GT 82))
487 return;
488
489 --nb;
490 bp = obj0 + BARBASE + (int32_t)(sigadr[nb] + MARGIN + nb);
491
492 for (i = 127; i GE 0; --i) {
493
494 if (i GT bv) {
495
496 *bp = baroff;
497 bp += 128L;
498 *bp = baroff;
499
500 } else {
501
502 *bp = baron;
503 bp += 128L;
504 *bp = baron;
505 }
506
507 bp += 128L;
508 }
509}
510
511/*
512
513*/
514
515/*
516 =============================================================================
517 dosw(nb, sv) -- display value 'sv' of switch 'nb'
518 =============================================================================
519*/
520
521void dosw(int16_t nb, int16_t sv)
522{
523 register uint16_t *bp;
524 register int16_t i, j;
525
526 if ((nb LT 1) OR (nb GT 82))
527 return;
528
529 --nb;
530 bp = obj0 + SWBASE + (int32_t)(sigadr[nb] + MARGIN + nb);
531
532 if (sv)
533 j = swon;
534 else
535 j = swoff;
536
537 for (i = 0; i < 8; i++) {
538
539 *bp = j;
540 bp += 128L;
541 }
542}
543
544/*
545
546*/
547
548/*
549 =============================================================================
550 exp_c() -- expand a 4 bit color into a 16 bit word
551 =============================================================================
552*/
553
554uint16_t exp_c(uint16_t c)
555{
556 c &= 0x000F;
557 c |= c << 4;
558 c |= c << 8;
559
560 return(c);
561}
562
563/*
564
565*/
566
567/*
568 =============================================================================
569 cx_adsp() -- display values of analog processor variables as a bar graph
570 =============================================================================
571*/
572
573int16_t cx_adsp(void)
574{
575 register int16_t xasig, xastat, xaval;
576 register int32_t xafi;
577 register int32_t lc;
578 register uint16_t *bp;
579 int16_t i, j, k;
580 int16_t oldi;
581
582 memsetw(sigtab, 0, sizeof sigtab / 2);
583
584 VHinit();
585 VSinit();
586 vsndpal(dfltpal);
587
588 obj0 = 0x200400L;
589
590 SetObj(0, 0, 0, obj0, 512, 350, 0, 0, (V_RES3 | V_TDE), -1);
591
592 bp = obj0;
593
594 for (lc = 0; lc < 44800; lc++)
595 *bp++ = 0x0000;
596
597 baron = 0x0FFF & exp_c(P_WHT);
598 baroff = 0x0FFF & exp_c(P_DKGRY);
599 swon = 0x0FFF & exp_c(P_YEL);
600 swoff = 0x0FFF & exp_c(P_DKGRY);
601
602 SetPri(0, 7);
603
604 for (i = 1; i < 83; i++) {
605
606 dobar(i, 0);
607 dosw(i, 0);
608 }
609
610 oldi = setipl(2);
611
612/*
613
614*/
615
616 while (0L EQ BIOS(B_RDAV, CON_DEV)) {
617
618 if (-1L NE (xafi = XBIOS(X_ANALOG))) {
619
620 xasig = 0x007F & (xafi >> 8);
621 xastat = 0x0001 & (xafi >> 7);
622 xaval = 0x007F & xafi;
623
624 if (xasig) {
625
626 sigtab[xasig][0] = xaval;
627 sigtab[xasig][1] = xastat;
628
629 if (xasig LT 83) {
630
631 dobar(xasig, xaval);
632 dosw(xasig, xastat);
633 }
634
635 } else {
636
637 for (i = 0; i < 83; i++)
638 sigtab[i][1] = 0;
639 }
640 }
641 }
642
643/*
644
645*/
646
647 BIOS(B_GETC, CON_DEV);
648
649 for (j = 1; j < 83; j++) {
650
651 dobar(j, sigtab[j][0]);
652 dosw(j, sigtab[j][1]);
653 }
654
655 k = 0;
656
657 printf("\n");
658 printf(" x0 x1 x2 x3 x4 x5 x6 x7 x8 x9\r\n");
659 printf(" ----- ----- ----- ----- ----- ----- ----- ----- ----- -----\r\n");
660
661 for (i = 0; i < 9; i++ ) {
662
663 printf("%01dx ", k/10);
664
665 for (j = 0; j < 10; j++) {
666
667 if (k)
668 printf("%1d:%3d ", sigtab[k][1], sigtab[k][0]);
669 else
670 printf(" ");
671
672 if (++k EQ 83)
673 goto outofit;
674 }
675
676 printf("\n");
677 }
678
679outofit:
680
681 printf("\nTempo = %3d, Time = %3d, Tuning = %3d, Level = %3d\n",
682 sigtab[I_TEMPO][0], sigtab[I_TIME][0],
683 sigtab[I_TUNE][0], sigtab[I_LEVEL][0]);
684
685 printf("LongPot L = %3d, LongPot R = %3d, Scroll = %3d\n",
686 sigtab[I_LONGL][0], sigtab[I_LONGR][0],
687 sigtab[I_SCROLL][0]);
688
689 printf("Tablet X = %3d, Tablet Y = %3d\n",
690 sigtab[I_TABX][0], sigtab[I_TABY][0]);
691
692 printf("Cursor X = %3d, Cursor Y = %3d\n",
693 sigtab[I_CURX][0], sigtab[I_CURY][0]);
694
695 setipl(oldi);
696 return(TRUE);
697}
698
699/*
700
701*/
702
703/*
704 =============================================================================
705 waitcr2() -- wait for a CR from CON_DEV
706 Returns: 0 = continue
707 1 = ^G hit - abort
708 =============================================================================
709*/
710
711int16_t waitcr2(void)
712{
713 int8_t c;
714
715 BIOS(B_PUTC, CON_DEV, '\007');
716
717 while ('\r' NE (c = (0x7F & BIOS(B_GETC, CON_DEV)))) {
718
719 if (c EQ '\007')
720 return(1);
721 }
722
723 return(0);
724}
725
726/*
727
728*/
729
730/*
731 ============================================================================
732 xdtoi -- convert hex ASCII to an int digit
733 ============================================================================
734*/
735
736int16_t xdtoi(int16_t c)
737{
738 register int16_t i;
739 register int8_t *ap = &ahex[0];
740
741 for (i = 0; i < 22; i++)
742 if (c EQ *ap++)
743 if (i >15)
744 return(i - 6);
745 else
746 return(i);
747
748 return(-1);
749}
750
751/*
752
753*/
754
755/*
756 ============================================================================
757 getcmd -- parse command from input line
758 ============================================================================
759*/
760
761int16_t getcmd(void)
762{
763 register int16_t c;
764
765 sptr = cmdline;
766 argln = 0;
767 aptr = argstr;
768 memset(argstr, 0, MAXARGLN+1);
769
770 do {
771
772 switch (c = 0x00FF & *sptr) {
773
774 case '\0':
775 case A_CR:
776 case A_LF:
777
778 argsep = c;
779 return(argln);
780
781 case ' ':
782
783 ++sptr;
784
785 while (*sptr EQ ' ')
786 ++sptr;
787
788 if (*sptr EQ A_CR OR *sptr EQ A_LF OR *sptr EQ '\0')
789 c = 0x00FF & *sptr;
790
791 argsep = c;
792 return(argln);
793
794/*
795
796*/
797
798 default:
799
800 if (isupper(c))
801 c = _tolower(c);
802
803 *aptr++ = c;
804 ++sptr;
805 ++argln;
806 }
807
808 } while (*sptr);
809
810 argsep = 0;
811 return(argln);
812}
813
814/*
815
816*/
817
818/*
819 ============================================================================
820 getarg -- parse out an argument to analyze
821 ============================================================================
822*/
823
824int16_t getarg(void)
825{
826 register int16_t c;
827
828 argln = 0;
829 aptr = argstr;
830 memset(argstr, 0, MAXARGLN+1);
831
832 do {
833
834 switch (c = 0x00FF & *sptr) {
835
836 case '\0':
837 case A_CR:
838 case A_LF:
839
840 argsep = c;
841 return(argln);
842
843 case ' ':
844
845 ++sptr;
846
847 while (*sptr EQ ' ')
848 ++sptr;
849
850 if (*sptr EQ A_CR OR *sptr EQ A_LF OR *sptr EQ '\0')
851 c = 0x00FF & *sptr;
852
853 argsep = c;
854 return(argln);
855
856 case ',':
857
858 ++sptr;
859 argsep = c;
860 return(argln);
861
862/*
863
864*/
865
866 default:
867
868 *aptr++ = c;
869 ++sptr;
870 ++argln;
871 }
872
873 } while (*sptr);
874
875 argsep = 0;
876 return(argln);
877}
878
879/*
880
881*/
882
883/*
884 ============================================================================
885 getlong -- get a long integer (either hex or decimal)
886 ============================================================================
887*/
888
889int16_t getlong(int32_t *var)
890{
891 register int32_t temp = 0L;
892 register int16_t csw = FALSE,
893 c;
894
895 if (*aptr EQ '$') {
896
897 ++aptr;
898
899 while (isxdigit(c = *aptr++)) {
900
901 temp = (temp << 4) + xdtoi(c);
902 csw = TRUE;
903 }
904
905 } else {
906
907 while (isdigit(c = *aptr++)) {
908
909 temp = (temp * 10) + (c - '0');
910 csw = TRUE;
911 }
912 }
913
914 if (csw)
915 *var = temp;
916
917 return(c);
918}
919
920/*
921
922*/
923
924/*
925 ============================================================================
926 setvar -- parse an expression and set a long variable
927 ============================================================================
928*/
929
930int16_t setvar(int32_t *var, int32_t deflt)
931{
932 int16_t rc;
933 int32_t temp;
934
935 *var = deflt;
936 aptr = argstr;
937
938 rc = getlong(var);
939
940 if (rc) {
941
942 do {
943
944 switch (rc) {
945
946 case '+':
947
948 temp = 0L;
949 rc = getlong(&temp);
950 *var = *var + temp;
951 continue;
952
953 case '-':
954
955 temp = 0L;
956 rc = getlong(&temp);
957 *var = *var - temp;
958 continue;
959
960 default:
961
962 *var = deflt;
963 return(FALSE);
964 }
965
966 } while (rc);
967
968 return(TRUE);
969 }
970
971 return(TRUE);
972}
973
974/*
975
976*/
977
978/*
979 ============================================================================
980 putn -- output a decimal number
981 ============================================================================
982*/
983
984void putn(int32_t num, int16_t cw, int16_t unit)
985{
986 register int16_t d;
987
988 if (!cw)
989 return;
990
991 putn(num/10, cw-1, unit);
992
993 d = num % 10;
994
995 BIOS(B_PUTC, unit, (d + '0'));
996
997 return;
998}
999
1000/*
1001
1002*/
1003
1004/*
1005 ============================================================================
1006 puthn -- output a hex number
1007 ============================================================================
1008*/
1009
1010void puthn(int32_t num, int16_t cw, int16_t unit)
1011{
1012 register int16_t d;
1013
1014 if (!cw)
1015 return;
1016
1017 puthn(num >> 4, cw-1, unit);
1018
1019 d = 0x0F & num;
1020
1021 if (d > 9)
1022 BIOS(B_PUTC, unit, (d - 10 + 'A'));
1023 else
1024 BIOS(B_PUTC, unit, (d + '0'));
1025
1026 return;
1027}
1028
1029/*
1030
1031*/
1032
1033/*
1034 ============================================================================
1035 ddump -- do the hex portion of a dump
1036 ============================================================================
1037*/
1038
1039int16_t ddump(int8_t *loc, int8_t *lastloc, int16_t nwide, int16_t unit)
1040{
1041 while (nwide--) {
1042
1043 puthn((int32_t)(0xFF & *loc), 2, unit);
1044 BIOS(B_PUTC, unit, ' ');
1045
1046 if (BIOS(B_RDAV, unit)) {
1047
1048 BIOS(B_GETC, unit);
1049 return(TRUE);
1050 }
1051
1052 if (loc EQ lastloc) {
1053
1054 dflag = TRUE;
1055 return(FALSE);
1056 }
1057
1058 ++loc;
1059 }
1060
1061
1062 return(FALSE);
1063}
1064
1065/*
1066
1067*/
1068
1069/*
1070 ============================================================================
1071 padr -- print dump address
1072 ============================================================================
1073*/
1074
1075void padr(int32_t adr, int16_t unit)
1076{
1077 puthn(adr, 8, unit);
1078 BIOS(B_PUTC, unit, ' ');
1079 BIOS(B_PUTC, unit, '-');
1080 BIOS(B_PUTC, unit, ' ');
1081}
1082
1083/*
1084
1085*/
1086
1087/*
1088 ============================================================================
1089 dtext -- do the text portion of a dump
1090 ============================================================================
1091*/
1092
1093int16_t dtext(int8_t *loc, int8_t *lastloc, int16_t nwide, int16_t unit)
1094{
1095 register int16_t c;
1096
1097 BIOS(B_PUTC, unit, ' ');
1098 BIOS(B_PUTC, unit, '|');
1099
1100 while (nwide--) {
1101
1102 c = 0xFF & *loc;
1103
1104 if (isascii(c) AND isprint(c))
1105 BIOS(B_PUTC, unit, c);
1106 else
1107 BIOS(B_PUTC, unit, '.');
1108
1109 if (BIOS(B_RDAV, unit)) {
1110
1111 BIOS(B_GETC, unit);
1112 BIOS(B_PUTC, unit, '|');
1113 return(TRUE);
1114 }
1115
1116 if (loc EQ lastloc) {
1117
1118 BIOS(B_PUTC, unit, '|');
1119 return(FALSE);
1120 }
1121
1122 ++loc;
1123 }
1124
1125 BIOS(B_PUTC, unit, '|');
1126 return(FALSE);
1127}
1128
1129/*
1130
1131*/
1132
1133/*
1134 ============================================================================
1135 cp_mset -- parse parameters for mset command
1136 ============================================================================
1137*/
1138
1139int16_t cp_mset(void)
1140{
1141 redo = FALSE;
1142
1143 if (0 EQ getarg())
1144 return(FALSE);
1145
1146 if (argsep NE ',')
1147 return(FALSE);
1148
1149 if (setvar(&p_from, p_from) EQ FALSE)
1150 return(FALSE);
1151
1152 return(TRUE);
1153}
1154
1155/*
1156 ============================================================================
1157 cx_mset -- execute the mset command
1158 ============================================================================
1159*/
1160
1161int16_t cx_mset(void)
1162{
1163 while (TRUE) {
1164
1165 if (getarg())
1166 if (setvar(&p_value, p_value) EQ FALSE)
1167 return(FALSE);
1168
1169 if (p_value & ~0xFFL)
1170 return(FALSE);
1171
1172 *p_from++ = 0xFF & p_value;
1173
1174 if (argsep EQ A_CR)
1175 return(TRUE);
1176 }
1177}
1178/*
1179
1180*/
1181
1182/*
1183 ============================================================================
1184 cp_wset -- parse parameters for wset command
1185 ============================================================================
1186*/
1187
1188int16_t cp_wset(void)
1189{
1190 redo = FALSE;
1191
1192 if (0 EQ getarg())
1193 return(FALSE);
1194
1195 if (argsep NE ',')
1196 return(FALSE);
1197
1198 if (setvar(&p_from, p_from) EQ FALSE)
1199 return(FALSE);
1200
1201 if ((int32_t)p_from & 1L)
1202 return(FALSE);
1203
1204 return(TRUE);
1205}
1206
1207/*
1208
1209*/
1210
1211/*
1212 ============================================================================
1213 cx_wset -- execute the wset command
1214 ============================================================================
1215*/
1216
1217int16_t cx_wset(void)
1218{
1219 uint16_t *p_uint;
1220
1221 p_uint = (uint16_t *)p_from;
1222
1223 while (TRUE) {
1224
1225 if (getarg())
1226 if (setvar(&p_value, p_value) EQ FALSE)
1227 return(FALSE);
1228
1229 if (p_value & ~0xFFFFL)
1230 return(FALSE);
1231
1232 *p_uint++ = 0xFFFF & p_value;
1233
1234 if (argsep EQ A_CR)
1235 return(TRUE);
1236 }
1237}
1238
1239/*
1240
1241*/
1242
1243/*
1244 ============================================================================
1245 cp_mtst -- parse mtest command arguments
1246 ============================================================================
1247*/
1248
1249int16_t cp_mtst(void)
1250{
1251 inext = ilast;
1252
1253 if (argsep EQ A_CR OR argsep EQ '\0') {
1254
1255 p_from = (int8_t *)0x00000008L;
1256 p_to = (int8_t *)USER_RAM - 2L;
1257 return(TRUE);
1258 }
1259
1260 if (getarg())
1261 if (setvar(&p_from, USER_RAM) EQ FALSE)
1262 return(FALSE);
1263
1264 if (argsep NE ',')
1265 return(FALSE);
1266
1267 if (getarg())
1268 if (setvar(&p_to, RAM_TOP) EQ FALSE)
1269 return(FALSE);
1270
1271 if ((int32_t)p_from & 1L)
1272 return(FALSE);
1273
1274 if ((int32_t)p_to & 1L)
1275 return(FALSE);
1276
1277 if (p_from GT p_to)
1278 return(FALSE);
1279
1280 return(TRUE);
1281}
1282
1283/*
1284
1285*/
1286
1287/*
1288 ============================================================================
1289 cx_mtst -- execute the mtest command
1290 ============================================================================
1291*/
1292
1293int16_t cx_mtst(void)
1294{
1295 register int16_t mask, was, *loc, *eloc, *oldloc;
1296
1297 mask = 0x0001;
1298 loc = (int16_t *)p_from;
1299 eloc = (int16_t *)p_to;
1300 oldloc = loc;
1301
1302 if (p_from LT (int8_t *)USER_RAM)
1303 setipl(7);
1304
1305 do {
1306
1307 while (mask) {
1308
1309 *loc = mask;
1310
1311 if (mask NE (was = *loc))
1312 if (p_from LT (int8_t *)USER_RAM)
1313 halt();
1314 else
1315 printf("%08lX was %04X, expected %04X\r\n",
1316 loc, was, mask);
1317
1318 *loc = ~mask;
1319
1320 if (~mask NE (was = *loc))
1321 if (p_from LT (int8_t *)USER_RAM)
1322 halt();
1323 else
1324 printf("%08lX was %04X, expected %04X\r\n",
1325 loc, was, ~mask);
1326
1327 mask <<= 1;
1328 }
1329
1330 mask = 0x0001;
1331 loc++;
1332
1333 } while (loc LE eloc);
1334
1335 if (oldloc LT (int16_t *)USER_RAM)
1336 rjumpto((int32_t)ROMADDR);
1337
1338 return(TRUE);
1339}
1340
1341/*
1342
1343*/
1344
1345/*
1346 ============================================================================
1347 cp_go -- parse parameters for go command
1348 ============================================================================
1349*/
1350
1351int16_t cp_go(void)
1352{
1353 redo = FALSE;
1354 b0flag = FALSE;
1355 b1flag = FALSE;
1356 goflag = FALSE;
1357
1358 if (getarg()) {
1359
1360 if (setvar(&p_goto, p_goto) EQ FALSE)
1361 return(FALSE);
1362
1363 if (1L & (int32_t)p_goto)
1364 return(FALSE);
1365
1366 goflag = TRUE;
1367
1368 }
1369
1370 if (getarg()) {
1371
1372 if (setvar(&tba0, 0L) EQ FALSE)
1373 return(FALSE);
1374
1375 if (1L & (int32_t)tba0)
1376 return(FALSE);
1377
1378 b0flag = TRUE;
1379 }
1380
1381 if (getarg()) {
1382
1383 if (setvar(&tba1, 0L) EQ FALSE)
1384 return(FALSE);
1385
1386 if (1L & (int32_t)tba1)
1387 return(FALSE);
1388
1389 b1flag = TRUE;
1390 }
1391
1392 return(TRUE);
1393}
1394
1395/*
1396
1397*/
1398
1399#if ON_B700
1400
1401/*
1402 ============================================================================
1403 cx_dini() -- execute the dinit command
1404 ============================================================================
1405*/
1406
1407int16_t cx_dini(void)
1408{
1409 redo = TRUE;
1410 hdvini();
1411 return(TRUE);
1412}
1413
1414#endif
1415
1416/*
1417 ============================================================================
1418 cx_zap -- execute the zap command
1419 ============================================================================
1420*/
1421
1422void cx_zap(void)
1423{
1424 register int16_t *p, *q;
1425
1426 p = (int16_t *)USER_RAM;
1427 q = (int16_t *)RAM_TOP;
1428
1429 setipl(7);
1430
1431 while (p LE q)
1432 *p++ = 0;
1433
1434 rjumpto(ROMADDR);
1435}
1436
1437/*
1438
1439*/
1440
1441/*
1442 ============================================================================
1443 cx_omap() -- execute the omap command
1444 ============================================================================
1445*/
1446
1447int16_t cx_omap(void)
1448{
1449 register int16_t i, width, xloc;
1450
1451 printf("Pr B/C Locn Wd Xloc Flags\r\n");
1452
1453 for (i = 0; i < 16; i++) {
1454
1455 xloc = v_odtab[i][1] & 0x03FF;
1456
1457 if (xloc & 0x0200) /* sign extend xloc */
1458 xloc |= 0xFC00;
1459
1460 width = (v_odtab[i][1] >> 10) & 0x003F;
1461
1462 printf("%2d %s ",
1463 i, ((v_odtab[i][0] & V_CBS) ? "Chr" : "Bit"));
1464
1465 printf("$%08lX %2d %4d ",
1466 ((int32_t)v_odtab[i][2] << 1), width, xloc);
1467
1468 printf("$%04X\r\n", v_odtab[i][0]);
1469 }
1470
1471 return(TRUE);
1472}
1473
1474/*
1475
1476*/
1477
1478/*
1479 ============================================================================
1480 cx_help -- execute the help command
1481 ============================================================================
1482*/
1483
1484int16_t cx_help(void)
1485{
1486 int16_t i, j;
1487
1488 j = 0;
1489
1490 writeln(cmdunit, CRLF);
1491
1492 for (i = 0; i < NCMDS; i++) {
1493
1494 if (j++ EQ 22) {
1495
1496 j = 0;
1497
1498 if (waitcr2())
1499 return(TRUE);
1500 }
1501
1502 writeln(cmdunit, " ");
1503 writeln(cmdunit, cmtab[i].cname);
1504 writeln(cmdunit, " ");
1505 writeln(cmdunit, cmtab[i].hstr);
1506 writeln(cmdunit, CRLF);
1507 }
1508
1509 writeln(cmdunit, CRLF);
1510 return(TRUE);
1511}
1512
1513/*
1514
1515* /
1516
1517/*
1518 ============================================================================
1519 cx_bpb -- execute bpb command
1520 ============================================================================
1521*/
1522
1523int16_t cx_bpb(void)
1524{
1525 register struct bpb *bpp;
1526
1527 if (0L EQ (bpp = (struct bpb *)BIOS(B_GBPB, 0) ) ) {
1528
1529 writeln(cmdunit, "\r\n\nERROR -- Unable to read BPB\r\n\n");
1530 return(FALSE);
1531
1532 } else {
1533
1534 writeln(cmdunit, "\r\n\nBPB values:\r\n");
1535 writeln(cmdunit, "\r\n recsiz ");
1536 putn((int32_t)bpp->recsiz, 5, cmdunit);
1537 writeln(cmdunit, "\r\n clsiz ");
1538 putn((int32_t)bpp->clsiz, 4, cmdunit);
1539 writeln(cmdunit, "\r\n clsizb ");
1540 putn((int32_t)bpp->clsizb, 5, cmdunit);
1541 writeln(cmdunit, "\r\n rdlen ");
1542 putn((int32_t)bpp->rdlen, 4, cmdunit);
1543 writeln(cmdunit, "\r\n fsiz ");
1544 putn((int32_t)bpp->fsiz, 4, cmdunit);
1545 writeln(cmdunit, "\r\n fatrec ");
1546 putn((int32_t)bpp->fatrec, 5, cmdunit);
1547 writeln(cmdunit, "\r\n datrec ");
1548 putn((int32_t)bpp->datrec, 5, cmdunit);
1549 writeln(cmdunit, "\r\n numcl ");
1550 putn((int32_t)bpp->numcl, 5, cmdunit);
1551 writeln(cmdunit, "\r\n bflags ");
1552 puthn((int32_t)bpp->bflags, 4, cmdunit);
1553 writeln(cmdunit, "\r\n ntracks ");
1554 putn((int32_t)bpp->ntracks, 4, cmdunit);
1555 writeln(cmdunit, "\r\n nsides ");
1556 putn((int32_t)bpp->nsides, 4, cmdunit);
1557 writeln(cmdunit, "\r\n sec/cyl ");
1558 putn((int32_t)bpp->dspc, 5, cmdunit);
1559 writeln(cmdunit, "\r\n sec/trk ");
1560 putn((int32_t)bpp->dspt, 5, cmdunit);
1561 writeln(cmdunit, "\r\n hidden ");
1562 putn((int32_t)bpp->hidden, 4, cmdunit);
1563 writeln(cmdunit, "\r\n\n");
1564 return(TRUE);
1565 }
1566}
1567
1568/*
1569
1570*/
1571
1572/*
1573 ============================================================================
1574 cx_go -- execute the go command
1575 ============================================================================
1576*/
1577
1578int16_t cx_go(void)
1579{
1580 redo = FALSE;
1581 exflag = TRUE;
1582 wzcrsh = FALSE;
1583
1584 if (goflag)
1585 regptr->reg_pc = p_goto;
1586
1587 if (b0flag ) {
1588
1589 if (p_ba0) {
1590
1591 if (*p_ba0 NE (uint16_t)BPINST) {
1592
1593 writeln(cmdunit, "\r\n\n** Breakpoint 0 at ");
1594 puthn((int32_t)p_ba0, 8, cmdunit);
1595 writeln(cmdunit, " was ");
1596 puthn(0xFFFFL & (int32_t)(*p_ba0), 4, cmdunit);
1597 writeln(cmdunit, " instead of ");
1598 puthn(0xFFFFL & (int32_t)BPINST, 4, cmdunit);
1599 writeln(cmdunit, " **\r\n\n");
1600 }
1601
1602 *p_ba0 = p_bv0;
1603 }
1604
1605 p_ba0 = tba0;
1606 p_bv0 = *p_ba0;
1607 *p_ba0 = (uint16_t)BPINST;
1608 }
1609
1610/*
1611
1612*/
1613
1614 if (b1flag ) {
1615
1616 if (p_ba1) {
1617
1618 if (*p_ba1 NE (uint16_t)BPINST) {
1619
1620 writeln(cmdunit, "\r\n\n** Breakpoint 1 at ");
1621 puthn((int32_t)p_ba1, 8, cmdunit);
1622 writeln(cmdunit, " was ");
1623 puthn(0xFFFFL & (int32_t)(*p_ba1), 4, cmdunit);
1624 writeln(cmdunit, " instead of ");
1625 puthn(0xFFFFL & (int32_t)BPINST, 4, cmdunit);
1626 writeln(cmdunit, " **\r\n\n");
1627 }
1628
1629 *p_ba1 = p_bv1;
1630 }
1631
1632 p_ba1 = tba1;
1633 p_bv1 = *p_ba1;
1634 *p_ba1 = (uint16_t)BPINST;
1635 }
1636
1637 return(TRUE);
1638}
1639
1640/*
1641
1642*/
1643
1644/*
1645 ============================================================================
1646 cp_dump -- parse dump parameters
1647 ============================================================================
1648*/
1649
1650int16_t cp_dump(void)
1651{
1652 inext = ilast;
1653
1654 if (getarg())
1655 if (setvar(&p_from, p_from) EQ FALSE) {
1656
1657 redo = FALSE;
1658 return(FALSE);
1659 }
1660
1661 if (argsep EQ A_CR OR argsep EQ '\0') {
1662
1663 p_to = p_from;
1664 p_width = 16L;
1665 redo = TRUE;
1666 return(TRUE);
1667 }
1668
1669 if (getarg())
1670 if (setvar(&p_to, p_to) EQ FALSE) {
1671
1672 redo = FALSE;
1673 return(FALSE);
1674 }
1675
1676 if (argsep EQ A_CR OR argsep EQ '\0') {
1677
1678 p_width = 16L;
1679 redo = TRUE;
1680 return(TRUE);
1681 }
1682
1683 if (getarg())
1684 if (setvar(&p_width, p_width) EQ FALSE) {
1685
1686 redo = FALSE;
1687 return(FALSE);
1688 }
1689
1690 if ((p_width LE 0L) OR (p_width GT 16L)) {
1691
1692 p_width = 16L;
1693 redo = FALSE;
1694 return(FALSE);
1695 }
1696
1697 redo = TRUE;
1698 return(TRUE);
1699}
1700
1701/*
1702
1703*/
1704
1705/*
1706 ============================================================================
1707 cp_fill -- parse parameters for fill command
1708 ============================================================================
1709*/
1710
1711int16_t cp_fill(void)
1712{
1713 redo = FALSE;
1714
1715 if (getarg())
1716 if (setvar(&p_from, p_from) EQ FALSE)
1717 return(FALSE);
1718
1719 if (getarg())
1720 if (setvar(&p_len, p_len) EQ FALSE)
1721 return(FALSE);
1722
1723 if (getarg())
1724 if (setvar(&p_value, p_value) EQ FALSE)
1725 return(FALSE);
1726
1727 if (p_value & ~0xFFL)
1728 return(FALSE);
1729
1730 return(TRUE);
1731}
1732
1733/*
1734
1735*/
1736
1737/*
1738 ============================================================================
1739 cp_wfil -- parse parameters for wfill command
1740 ============================================================================
1741*/
1742
1743int16_t cp_wfil(void)
1744{
1745 redo = FALSE;
1746
1747 if (getarg())
1748 if (setvar(&p_from, p_from) EQ FALSE)
1749 return(FALSE);
1750
1751 if (getarg())
1752 if (setvar(&p_len, p_len) EQ FALSE)
1753 return(FALSE);
1754
1755 if (getarg())
1756 if (setvar(&p_value, p_value) EQ FALSE)
1757 return(FALSE);
1758
1759 if ((int32_t)p_from & 1L)
1760 return(FALSE);
1761
1762 if (p_value & ~0xFFFFL)
1763 return(FALSE);
1764
1765 return(TRUE);
1766}
1767
1768/*
1769
1770*/
1771
1772/*
1773 ============================================================================
1774 cp_copy -- parse parameters for copy command
1775 ============================================================================
1776*/
1777
1778int16_t cp_copy(void)
1779{
1780 redo = FALSE;
1781
1782 if (getarg())
1783 if (setvar(&p_from, p_from) EQ FALSE)
1784 return(FALSE);
1785
1786 if (getarg())
1787 if (setvar(&p_to, p_to) EQ FALSE)
1788 return(FALSE);
1789
1790 if (getarg())
1791 if (setvar(&p_len, p_len) EQ FALSE)
1792 return(FALSE);
1793
1794 return(TRUE);
1795}
1796/*
1797
1798*/
1799
1800/*
1801 ============================================================================
1802 cp_chek -- parse parameters for chek command
1803 ============================================================================
1804*/
1805
1806int16_t cp_chek(void)
1807{
1808 redo = FALSE;
1809
1810 if (getarg())
1811 if (setvar(&p_from, p_from) EQ FALSE)
1812 return(FALSE);
1813
1814 if (getarg())
1815 if (setvar(&p_to, p_to) EQ FALSE)
1816 return(FALSE);
1817
1818 return(TRUE);
1819}
1820
1821/*
1822
1823*/
1824
1825/*
1826 ============================================================================
1827 cp_read -- parse parameters for read command
1828 ============================================================================
1829*/
1830
1831int16_t cp_read(void)
1832{
1833 redo = FALSE;
1834
1835 if (getarg())
1836 if (setvar(&p_from, p_from) EQ FALSE)
1837 return(FALSE);
1838
1839 if (getarg())
1840 if (setvar(&p_to, p_to) EQ FALSE)
1841 return(FALSE);
1842
1843 if (getarg())
1844 if (setvar(&p_len, p_len) EQ FALSE)
1845 return(FALSE);
1846
1847 if ((~0x7FFFL) & p_len)
1848 return(FALSE);
1849
1850 if ((~0xFFFFL) & (int32_t)p_from)
1851 return(FALSE);
1852
1853 return(TRUE);
1854}
1855
1856/*
1857 ============================================================================
1858 cp_null -- parse null parameter line
1859 ============================================================================
1860*/
1861
1862int16_t cp_null(void)
1863{
1864 return(TRUE);
1865}
1866
1867/*
1868
1869*/
1870
1871/*
1872 ============================================================================
1873 cp_rset -- parse rset command parameters
1874 ============================================================================
1875*/
1876
1877int16_t cp_rset(void)
1878{
1879 int16_t rc;
1880
1881 rc = 0;
1882 redo = FALSE;
1883
1884 if (0 EQ getarg())
1885 return(FALSE);
1886
1887 str2lc(argstr);
1888
1889 if (0 EQ (rc = strlcmp(argstr, rlist)))
1890 return(FALSE);
1891
1892 if (0 EQ getarg())
1893 return(FALSE);
1894
1895 if (FALSE EQ setvar(&p_value, 0L))
1896 return(FALSE);
1897
1898 rnum = rc;
1899 return(TRUE);
1900}
1901
1902/*
1903
1904*/
1905/*
1906 ============================================================================
1907 cx_chek -- process chek command
1908 ============================================================================
1909*/
1910
1911int16_t cx_chek(void)
1912{
1913 register int32_t csum;
1914 register int8_t *cp;
1915
1916 redo = FALSE;
1917 csum = 0L;
1918
1919 for (cp = p_from; cp LE p_to; cp++)
1920 csum += 0x000000FFL & *cp;
1921
1922 printf("Checksum = 0x%08lX\r\n", csum);
1923
1924 return(TRUE);
1925}
1926
1927/*
1928
1929*/
1930
1931/*
1932 ============================================================================
1933 cx_rset -- process rset command
1934 ============================================================================
1935*/
1936
1937int16_t cx_rset(void)
1938{
1939 redo = FALSE;
1940
1941 if (rnum < 1)
1942 return(FALSE);
1943
1944 if (rnum < 9) { /* d0..d7 -- data register */
1945
1946 regptr->d_reg[rnum-1] = p_value;
1947 return(TRUE);
1948 }
1949
1950 if (rnum < 17) { /* a0..a7 -- address register */
1951
1952 regptr->a_reg[rnum-9] = (int8_t *)p_value;
1953 return(TRUE);
1954 }
1955
1956/*
1957
1958*/
1959
1960 if (rnum EQ 17) { /* sr -- status register */
1961
1962 if ((~0xFFFFL) & p_value)
1963 return(FALSE);
1964
1965 regptr->reg_sr = (uint16_t)p_value;
1966 return(TRUE);
1967 }
1968
1969 if (rnum EQ 18) { /* pc -- program counter */
1970
1971 if (1L & p_value)
1972 return(FALSE);
1973
1974 regptr->reg_pc = (int8_t *)p_value;
1975 return(TRUE);
1976 }
1977
1978 if (rnum EQ 19) { /* sp -- stack pointer */
1979
1980 if (1L & p_value)
1981 return(FALSE);
1982
1983 regptr->a_reg[7] = (int8_t *)p_value;
1984 return(TRUE);
1985 }
1986
1987 return(FALSE);
1988}
1989
1990/*
1991
1992*/
1993
1994/*
1995 ============================================================================
1996 cp_vrst -- parse vrset command parameters
1997 ============================================================================
1998*/
1999
2000int16_t cp_vrst(void)
2001{
2002 int16_t rc;
2003
2004 rc = 0;
2005 redo = FALSE;
2006
2007 if (0 EQ getarg())
2008 return(FALSE);
2009
2010 str2lc(argstr);
2011
2012 if (0 EQ (rc = strlcmp(argstr, vrlist)))
2013 return(FALSE);
2014
2015 if (0 EQ getarg())
2016 return(FALSE);
2017
2018 if (FALSE EQ setvar(&p_value, 0L))
2019 return(FALSE);
2020
2021 if (vrnum < 17) { /* complete register */
2022
2023 vrnum = rc;
2024 return(TRUE);
2025 }
2026
2027 if (vrnum < 21) { /* horizontal register */
2028
2029 if (p_value & ~0x003F)
2030 return(FALSE);
2031
2032 vrnum = rc;
2033 return(TRUE);
2034 }
2035
2036 if (vrnum < 25) { /* vertical register */
2037
2038 if (p_value & ~0x03FF)
2039 return(FALSE);
2040
2041 vrnum = rc;
2042 return(TRUE);
2043 }
2044
2045 return(FALSE);
2046}
2047
2048/*
2049
2050*/
2051
2052/*
2053 ============================================================================
2054 cx_vrst -- process vrset command
2055 ============================================================================
2056*/
2057
2058int16_t cx_vrst(void)
2059{
2060 redo = FALSE;
2061
2062 if (vrnum < 1)
2063 return(FALSE);
2064
2065 if (vrnum < 17) { /* 1..16 -- r0..r15 -- complete register */
2066
2067 v_regs[vrnum-1] = p_value;
2068 return(TRUE);
2069 }
2070
2071 if (vrnum < 21) { /* 17..20 -- h0..h3 -- horizontal register */
2072
2073 v_regs[vrnum-5] = (v_regs[vrnum-5] & 0x03FF) |
2074 ((p_value << 10) & 0xFC00);
2075 return(TRUE);
2076 }
2077
2078 if (vrnum < 25) { /* 21..24 -- v0..v3 -- vertical register */
2079
2080 v_regs[vrnum-9] = (v_regs[vrnum-9] & 0xFC00) | p_value;
2081 return(TRUE);
2082 }
2083
2084 return(FALSE);
2085}
2086
2087/*
2088
2089*/
2090
2091/*
2092 ============================================================================
2093 cx_vreg -- process vregs command
2094 ============================================================================
2095*/
2096
2097int16_t cx_vreg(void)
2098{
2099 register int16_t i, j, k, l;
2100 register uint16_t *rp;
2101
2102 rp = &v_regs[0];
2103 l = 0;
2104
2105 for (i = 0; i < 2; i++) {
2106
2107 for (j = 0; j < 2; j++) {
2108
2109 for (k = 0; k < 4; k++) {
2110
2111 writeln(cmdunit, " ");
2112 putn((int32_t)l++, 2, cmdunit);
2113 writeln(cmdunit, ":");
2114 puthn((int32_t)*rp++, 4, cmdunit);
2115 }
2116
2117 writeln(cmdunit, " ");
2118 }
2119
2120 writeln(cmdunit, "\r\n");
2121 }
2122
2123 return(TRUE);
2124}
2125
2126/*
2127
2128*/
2129
2130/*
2131 ============================================================================
2132 do_srec -- load a Motorola S record
2133 ============================================================================
2134*/
2135
2136int16_t do_srec(int8_t *line)
2137{
2138 register int8_t *ldadr;
2139 register int16_t c, csum, i, len;
2140 register uint16_t val;
2141
2142 if ('S' NE (c = *line++))
2143 return(-1); /* error 1 = missing initial S */
2144
2145 switch (c = *line++) {
2146
2147 case '2':
2148
2149 csum = 0;
2150
2151 if (isxdigit(c = *line++))
2152 len = xdtoi(c);
2153 else
2154 return(-2); /* error 2 = bad length byte */
2155
2156 if (isxdigit(c = *line++))
2157 len = (len << 4) + xdtoi(c);
2158 else
2159 return(-2);
2160
2161 csum += (len & 0xFF);
2162 ldadr = (int8_t *)0;
2163 len -= 4;
2164
2165 for (i = 0; i < 3; i++) {
2166
2167 if (isxdigit(c = *line++))
2168 val = xdtoi(c);
2169 else
2170 return(-3); /* error 3 = bad address byte */
2171
2172 if (isxdigit(c = *line++))
2173 val = (val << 4) + xdtoi(c);
2174 else
2175 return(-3);
2176
2177 ldadr = (int8_t *)(((int32_t)ldadr << 8) + (int32_t)val);
2178 csum += (val & 0xFF);
2179 }
2180
2181 for (i = 0; i < len; i++) {
2182
2183 if (isxdigit(c = *line++))
2184 val = xdtoi(c);
2185 else
2186 return(-4); /* error 4 = bad data byte */
2187
2188 if (isxdigit(c = *line++))
2189 val = (val << 4) + xdtoi(c);
2190 else
2191 return(-4);
2192
2193 csum += (val & 0xFF);
2194 *ldadr = val & 0xFF;
2195
2196 if ((*ldadr & 0xFF) NE (val & 0xFF))
2197 return(-5); /* error 5 = store failed */
2198
2199 ldadr++;
2200 }
2201
2202 csum = 0xFF & ~csum;
2203
2204 if (isxdigit(c = *line++))
2205 val = xdtoi(c);
2206 else
2207 return(-6); /* error 6 = bad checksum byte */
2208
2209 if (isxdigit(c = *line++))
2210 val = (val << 4) + xdtoi(c);
2211 else
2212 return(-6);
2213
2214 if (csum NE (val & 0xFF))
2215 return(-7); /* error 7 = bad checksum */
2216
2217 return(1);
2218
2219 case '9':
2220
2221 if (memcmpu(line, SREC9, 10) EQ 0)
2222 return(0);
2223 else
2224 return(-8); /* error 8 = bad end record */
2225
2226 default:
2227
2228 return(-9); /* error 9 = unknown s type */
2229 }
2230
2231 return(-10); /* error 10 = switch failed */
2232}
2233
2234/*
2235
2236*/
2237
2238/*
2239 ============================================================================
2240 cx_load -- process load command
2241 ============================================================================
2242*/
2243
2244int16_t cx_load(void)
2245{
2246 register int16_t rc;
2247
2248 do {
2249
2250 rc = getrln(cmdunit, MAXCMDLN, cmdline);
2251
2252 switch (rc) {
2253
2254 case A_CR:
2255
2256 rc = do_srec(cmdline);
2257
2258 if (rc LT 0) {
2259
2260 rc = -rc;
2261 writeln(cmdunit, NACK);
2262 writeln(cmdunit, "** Load error ");
2263 putn((int32_t)rc, 3, cmdunit);
2264 writeln(cmdunit, " **\r\n\n");
2265 return(FALSE);
2266
2267 } else {
2268
2269 writeln(cmdunit, TACK);
2270 }
2271
2272 continue;
2273
2274 case CTL('X'):
2275
2276 rc = 1;
2277 writeln(cmdunit, TACK);
2278 continue;
2279
2280/*
2281
2282*/
2283
2284 default:
2285
2286 writeln(cmdunit, NACK);
2287 writeln(cmdunit, "** Load aborted on ");
2288 puthn(rc, 2, cmdunit);
2289 writeln(cmdunit, " **\r\n\n");
2290 return(FALSE);
2291 }
2292
2293 } while (rc);
2294
2295 return(TRUE);
2296}
2297
2298/*
2299
2300*/
2301
2302/*
2303 ============================================================================
2304 cx_fill -- execute the fill command
2305 ============================================================================
2306*/
2307
2308int16_t cx_fill(void)
2309{
2310 register int8_t *cp = p_from;
2311 register int32_t count;
2312
2313 redo = FALSE;
2314
2315 for (count = p_len; count > 0L; count--) {
2316
2317 *cp = (int8_t)(0xFFL & p_value);
2318
2319 if (*cp NE (int8_t)(0xFFL & p_value)) {
2320
2321 writeln(cmdunit, "\r\n** FILL failed at ");
2322 puthn((int32_t)cp, 8, cmdunit);
2323 writeln(cmdunit, " **\r\n");
2324 return(FALSE);
2325 }
2326
2327 ++cp;
2328 }
2329
2330 return(TRUE);
2331}
2332
2333/*
2334
2335*/
2336
2337/*
2338 ============================================================================
2339 cx_wfill -- execute the wfill command
2340 ============================================================================
2341*/
2342
2343int16_t cx_wfil(void)
2344{
2345 register uint16_t *cp = (uint16_t *)p_from;
2346 register int32_t count;
2347
2348 redo = FALSE;
2349
2350 for (count = p_len; count > 0L; count--)
2351 *cp++ = (uint16_t)(0xFFFFL & p_value);
2352
2353 return(TRUE);
2354}
2355
2356/*
2357
2358*/
2359
2360/*
2361 ============================================================================
2362 cx_copy -- execute the copy command
2363 ============================================================================
2364*/
2365
2366int16_t cx_copy(void)
2367{
2368 register int8_t *from = p_from,
2369 *to = p_to;
2370 register int32_t count = p_len;
2371
2372 redo = FALSE;
2373
2374 if (to GT from) {
2375
2376 from = from + count;
2377 to = to + count;
2378
2379 while (count--) {
2380
2381 --from;
2382 --to;
2383 *to = *from;
2384
2385 if (*from NE *to) {
2386
2387 writeln(cmdunit, "\r\n** COPY failed from ");
2388 puthn((int32_t)from, 8, cmdunit);
2389 writeln(cmdunit, " to ");
2390 puthn((int32_t)to, 8, cmdunit);
2391 writeln(cmdunit, " with (from) = ");
2392 puthn((int32_t)(*from), 2, cmdunit);
2393 writeln(cmdunit, " and (to) = ");
2394 puthn((int32_t)(*to), 2, cmdunit);
2395 writeln(cmdunit, " **\r\n");
2396 return(FALSE);
2397 }
2398 }
2399
2400/*
2401
2402*/
2403
2404 } else {
2405
2406 while (count--) {
2407
2408 *to = *from;
2409
2410 if (*from NE *to) {
2411
2412 writeln(cmdunit, "\r\n** COPY failed from ");
2413 puthn((int32_t)from, 8, cmdunit);
2414 writeln(cmdunit, " to ");
2415 puthn((int32_t)to, 8, cmdunit);
2416 writeln(cmdunit, " with (from) = ");
2417 puthn((int32_t)(*from), 2, cmdunit);
2418 writeln(cmdunit, " and (to) = ");
2419 puthn((int32_t)(*to), 2, cmdunit);
2420 writeln(cmdunit, " **\r\n");
2421 return(FALSE);
2422 }
2423
2424 ++from;
2425 ++to;
2426 }
2427 }
2428
2429 return(TRUE);
2430}
2431
2432/*
2433
2434*/
2435
2436/*
2437 ============================================================================
2438 cx_dump -- execute the dump command
2439 ============================================================================
2440*/
2441
2442int16_t cx_dump(void)
2443{
2444 register int16_t nw, rc;
2445
2446 redo= TRUE;
2447 d_cur = p_from;
2448 d_next = p_to + 1;
2449 d_last = ((int32_t)p_to - (int32_t)p_from) + d_next;
2450 nw = p_width;
2451 rc = TRUE;
2452
2453 do {
2454
2455 writeln(cmdunit, CRLF);
2456 padr(p_from, cmdunit);
2457
2458 dflag = FALSE;
2459
2460 if (ddump(p_from, p_to, nw, cmdunit))
2461 rc = FALSE;
2462
2463 if (rc)
2464 if (dtext(p_from, p_to, nw, cmdunit))
2465 rc = FALSE;
2466
2467 p_from = p_from + p_width;
2468
2469 if (dflag)
2470 rc = FALSE;
2471
2472 } while (rc);
2473
2474 p_from = d_cur;
2475
2476 writeln(cmdunit, CRLF);
2477 writeln(cmdunit, CRLF);
2478
2479 return(TRUE);
2480}
2481
2482/*
2483
2484*/
2485
2486/*
2487 ============================================================================
2488 wdump -- dump words in hex (no ASCII)
2489 ============================================================================
2490*/
2491
2492int16_t wdump(uint16_t *loc, uint16_t *lastloc, int16_t nwide, int16_t unit)
2493{
2494 while (nwide--) {
2495
2496 puthn((int32_t)(0xFFFFL & *loc), 4, unit);
2497 BIOS(B_PUTC,unit, ' ');
2498
2499 if (BIOS(B_RDAV, unit))
2500 return(TRUE);
2501
2502 if (loc EQ lastloc) {
2503
2504 dflag = TRUE;
2505 return(FALSE);
2506 }
2507
2508 ++loc;
2509 }
2510
2511 return(FALSE);
2512}
2513
2514/*
2515
2516*/
2517
2518/*
2519 ============================================================================
2520 ldump -- dump longs in hex (no ASCII)
2521 ============================================================================
2522*/
2523
2524int16_t ldump(int32_t *loc, int32_t *lastloc, int16_t nwide, int16_t unit)
2525{
2526 while (nwide--) {
2527
2528 puthn(*loc, 8, unit);
2529 BIOS(B_PUTC,unit, ' ');
2530
2531 if (BIOS(B_RDAV, unit))
2532 return(TRUE);
2533
2534 if (loc EQ lastloc) {
2535
2536 dflag = TRUE;
2537 return(FALSE);
2538 }
2539
2540 ++loc;
2541 }
2542
2543 return(FALSE);
2544}
2545
2546/*
2547
2548*/
2549
2550/*
2551 ============================================================================
2552 cp_wdmp -- process parameters for wdump command
2553 ============================================================================
2554*/
2555
2556int16_t cp_wdmp(void)
2557{
2558 inext = ilast;
2559
2560 if (getarg())
2561 if (setvar(&p_from, p_from) EQ FALSE) {
2562
2563 redo = FALSE;
2564 return(FALSE);
2565 }
2566
2567 if ((int32_t)p_from & 1L) {
2568
2569 redo = FALSE;
2570 return(FALSE);
2571 }
2572
2573 if (argsep EQ A_CR OR argsep EQ '\0') {
2574
2575 p_to = p_from;
2576 p_width = 8;
2577 redo = TRUE;
2578 return(TRUE);
2579 }
2580
2581 if (getarg())
2582 if (setvar(&p_to, p_to) EQ FALSE) {
2583
2584 redo = FALSE;
2585 return(FALSE);
2586 }
2587
2588 if ((int32_t)p_to & 1L) {
2589
2590 redo = FALSE;
2591 return(FALSE);
2592 }
2593
2594 if (argsep EQ A_CR OR argsep EQ '\0') {
2595
2596 p_width = 8;
2597 redo = TRUE;
2598 return(TRUE);
2599 }
2600
2601 if (getarg())
2602 if (setvar(&p_width, p_width) EQ FALSE) {
2603
2604 redo = FALSE;
2605 return(FALSE);
2606 }
2607
2608 redo = TRUE;
2609 return(TRUE);
2610}
2611
2612/*
2613
2614*/
2615
2616/*
2617 ============================================================================
2618 cp_ldmp -- process parameters for ldump command
2619 ============================================================================
2620*/
2621
2622int16_t cp_ldmp(void)
2623{
2624 inext = ilast;
2625
2626 if (getarg())
2627 if (setvar(&p_from, p_from) EQ FALSE) {
2628
2629 redo = FALSE;
2630 return(FALSE);
2631 }
2632
2633 if ((int32_t)p_from & 1L) {
2634
2635 redo = FALSE;
2636 return(FALSE);
2637 }
2638
2639 if (argsep EQ A_CR OR argsep EQ '\0') {
2640
2641 p_to = p_from;
2642 p_width = 4;
2643 redo = TRUE;
2644 return(TRUE);
2645 }
2646
2647 if (getarg())
2648 if (setvar(&p_to, p_to) EQ FALSE) {
2649
2650 redo = FALSE;
2651 return(FALSE);
2652 }
2653
2654 if ((int32_t)p_to & 1L) {
2655
2656 redo = FALSE;
2657 return(FALSE);
2658 }
2659
2660 if (argsep EQ A_CR OR argsep EQ '\0') {
2661
2662 p_width = 4;
2663 redo = TRUE;
2664 return(TRUE);
2665 }
2666
2667 if (getarg())
2668 if (setvar(&p_width, p_width) EQ FALSE) {
2669
2670 redo = FALSE;
2671 return(FALSE);
2672 }
2673
2674 redo = TRUE;
2675 return(TRUE);
2676}
2677
2678/*
2679
2680*/
2681
2682/*
2683 ============================================================================
2684 cp_ilev -- parse the ipl command
2685 ============================================================================
2686*/
2687
2688int16_t cp_ilev(void)
2689{
2690 int32_t iplevl;
2691
2692 if (argsep EQ A_CR OR argsep EQ '\0')
2693 return(TRUE);
2694
2695 if (getarg())
2696 if (setvar(&iplevl, iplevl) EQ FALSE)
2697 return(FALSE);
2698
2699 if (iplevl GT 7)
2700 return(FALSE);
2701
2702 iplev = iplevl;
2703
2704 return(TRUE);
2705}
2706
2707/*
2708 ============================================================================
2709 cx_ilev -- execute ipl command
2710 ============================================================================
2711*/
2712
2713int16_t cx_ilev(void)
2714{
2715 if (-1 EQ setipl(iplev)) {
2716
2717 printf("ERROR -- Could not set IPL to %d\r\n", iplev);
2718 return(FALSE);
2719 } else
2720 printf("ROMP IPL now set to %d\r\n", iplev);
2721
2722 return(TRUE);
2723}
2724
2725/*
2726
2727*/
2728
2729/*
2730 ============================================================================
2731 cp_monc() -- parse the monc command
2732 ============================================================================
2733*/
2734
2735int16_t cp_monc(void)
2736{
2737 if (getarg())
2738 if (setvar(&monptr, monptr) EQ FALSE)
2739 return(FALSE);
2740
2741 monsw = MON_C;
2742 redo = TRUE;
2743 return(TRUE);
2744}
2745
2746/*
2747 ============================================================================
2748 cp_mons() -- parse the mons command
2749 ============================================================================
2750*/
2751
2752int16_t cp_mons(void)
2753{
2754 if (getarg())
2755 if (setvar(&monptr, monptr) EQ FALSE)
2756 return(FALSE);
2757
2758 monsw = MON_S;
2759 redo = TRUE;
2760 return(TRUE);
2761}
2762
2763/*
2764
2765*/
2766
2767/*
2768 ============================================================================
2769 cp_monl() -- parse the monl command
2770 ============================================================================
2771*/
2772
2773int16_t cp_monl(void)
2774{
2775 if (getarg())
2776 if (setvar(&monptr, monptr) EQ FALSE)
2777 return(FALSE);
2778
2779 monsw = MON_L;
2780 redo = TRUE;
2781 return(TRUE);
2782}
2783
2784/*
2785
2786*/
2787
2788/*
2789 ============================================================================
2790 cx_mon() -- process the mon commands
2791 ============================================================================
2792*/
2793
2794int16_t cx_mon(void)
2795{
2796 register int8_t vc, vcc;
2797 register int16_t vs, vss, *vsp;
2798 register int32_t vl, vll, *vlp;
2799
2800 switch (monsw) {
2801
2802 case MON_C:
2803
2804 vc = *monptr & 0x0FF;
2805 puthn((int32_t)vc, 2, cmdunit);
2806 writeln(cmdunit, "\r\n");
2807
2808 while (!(0xFFFFL & BIOS(B_RDAV, CON_DEV))) {
2809
2810 vcc = *monptr & 0x0FF;
2811
2812 if (vc NE vcc) {
2813
2814 vc = vcc;
2815 puthn((int32_t)vc, 2, cmdunit);
2816 writeln(cmdunit, "\r\n");
2817 }
2818 }
2819
2820 BIOS(B_GETC, CON_DEV);
2821 return(TRUE);
2822
2823 case MON_S:
2824
2825 vsp = (int16_t *)monptr;
2826 vs = *vsp;
2827 puthn((int32_t)vs, 4, cmdunit);
2828 writeln(cmdunit, "\r\n");
2829
2830 while (!(0xFFFFL & BIOS(B_RDAV, CON_DEV))) {
2831
2832 vss = *vsp;
2833
2834 if (vs NE vss) {
2835
2836 vs = vss;
2837 puthn((int32_t)vs, 4, cmdunit);
2838 writeln(cmdunit, "\r\n");
2839 }
2840 }
2841
2842 BIOS(B_GETC, CON_DEV);
2843 return(TRUE);
2844
2845/*
2846
2847*/
2848 case MON_L:
2849
2850 vlp = (int32_t *)monptr;
2851 vl = *vlp;
2852 puthn(vl, 8, cmdunit);
2853 writeln(cmdunit, "\r\n");
2854
2855 while (!(0xFFFFL & BIOS(B_RDAV, CON_DEV))) {
2856
2857 vll = *vlp;
2858
2859 if (vl NE vll) {
2860
2861 vl = vll;
2862 puthn(vl, 8, cmdunit);
2863 writeln(cmdunit, "\r\n");
2864 }
2865 }
2866
2867 BIOS(B_GETC, CON_DEV);
2868 return(TRUE);
2869
2870 default:
2871 return(FALSE);
2872 }
2873}
2874
2875/*
2876
2877*/
2878
2879/*
2880 ============================================================================
2881 cx_wdmp -- process wdump command
2882 ============================================================================
2883*/
2884
2885int16_t cx_wdmp(void)
2886{
2887 int16_t nw, rc;
2888
2889 d_cur = p_from;
2890 d_next = p_to + 2;
2891 d_last = ((int32_t)p_to - (int32_t)p_from) + d_next;
2892 nw = p_width;
2893 rc = TRUE;
2894
2895 do {
2896
2897 writeln(cmdunit, CRLF);
2898 padr(p_from, cmdunit);
2899 dflag = FALSE;
2900
2901 if (wdump(p_from, p_to, nw, cmdunit))
2902 rc = FALSE;
2903
2904 p_from = p_from + (p_width << 1);
2905
2906 if (dflag)
2907 rc = FALSE;
2908
2909 } while (rc);
2910
2911 p_from = d_cur;
2912
2913 writeln(cmdunit, CRLF);
2914 writeln(cmdunit, CRLF);
2915 return(TRUE);
2916}
2917
2918/*
2919
2920*/
2921
2922/*
2923 ============================================================================
2924 cx_ldmp -- process ldump command
2925 ============================================================================
2926*/
2927
2928int16_t cx_ldmp(void)
2929{
2930 int16_t nw, rc;
2931
2932 d_cur = p_from;
2933 d_next = p_to + 4;
2934 d_last = ((int32_t)p_to - (int32_t)p_from) + d_next;
2935 nw = p_width;
2936 rc = TRUE;
2937
2938 do {
2939
2940 writeln(cmdunit, CRLF);
2941 padr(p_from, cmdunit);
2942 dflag = FALSE;
2943
2944 if (ldump(p_from, p_to, nw, cmdunit))
2945 rc = FALSE;
2946
2947 p_from = p_from + (p_width << 2);
2948
2949 if (dflag)
2950 rc = FALSE;
2951
2952 } while (rc);
2953
2954 p_from = d_cur;
2955
2956 writeln(cmdunit, CRLF);
2957 writeln(cmdunit, CRLF);
2958 return(TRUE);
2959}
2960
2961/*
2962
2963*/
2964
2965/*
2966 ============================================================================
2967 do_cmd -- process a command line
2968 ============================================================================
2969*/
2970
2971void do_cmd(void)
2972{
2973 int16_t rc, i;
2974
2975 /* prompt for a command line */
2976
2977#if TINYMSG
2978 writeln(cmdunit, "R: ");
2979#else
2980 writeln(cmdunit, "ROMP: ");
2981#endif
2982
2983 /* get a command line */
2984
2985 rc = getln(cmdunit, MAXCMDLN, cmdline);
2986
2987/*
2988
2989*/
2990
2991 /* dispatch based on rc */
2992
2993 switch (rc) {
2994
2995 case A_CR:
2996
2997 writeln(cmdunit, CRLF);
2998
2999 if (getcmd()) {
3000
3001 for (i = 0; i < NCMDS; i++) {
3002
3003 if (0 EQ strcmp(argstr, cmtab[i].cname)) {
3004
3005 ilast = i;
3006
3007 if ((*cmtab[i].cp)()) {
3008
3009 if (FALSE EQ (*cmtab[i].cx)())
3010 writeln(cmdunit, EMSG1);
3011
3012 } else {
3013
3014 writeln(cmdunit, EMSG2);
3015 }
3016
3017 return;
3018 }
3019 }
3020
3021 writeln(cmdunit, EMSG3);
3022 return;
3023
3024 } else {
3025
3026/*
3027
3028*/
3029
3030 if (redo) {
3031
3032 if (FALSE EQ (*cmtab[ilast].cx)())
3033 writeln(cmdunit, EMSG1);
3034
3035 } else {
3036
3037 writeln(cmdunit, EMSG5);
3038 }
3039
3040 return;
3041 }
3042
3043 case CTL('X'):
3044
3045 writeln(cmdunit, CANNED);
3046 return;
3047
3048 default:
3049
3050 writeln(cmdunit, EMSG6);
3051 return;
3052 }
3053
3054 writeln(cmdunit, EMSG7);
3055 return;
3056}
3057
3058/*
3059
3060*/
3061
3062/*
3063 ============================================================================
3064 cx_next -- process the next command
3065 ============================================================================
3066*/
3067
3068int16_t cx_next(void)
3069{
3070 p_to = d_last;
3071 p_from = d_next;
3072 return((*cmtab[inext].cx)());
3073}
3074
3075/*
3076
3077*/
3078
3079/*
3080 ============================================================================
3081 cx_read() -- process the read command
3082 ============================================================================
3083*/
3084
3085int16_t cx_read(void)
3086{
3087 int32_t rc;
3088 int16_t ns, recno;
3089
3090 ns = p_len & 0x7FFFL;
3091 recno = (int32_t)p_from & 0xFFFFL;
3092
3093 rc = BIOS(B_RDWR, 2, p_to, ns, recno, 0);
3094
3095 if (rc & 0xFFFFL) {
3096
3097 writeln(cmdunit, "\r\nERROR reading disk: ");
3098 puthn(rc, 8, cmdunit);
3099 writeln(cmdunit, "\r\n\n");
3100 return(FALSE);
3101
3102 } else {
3103
3104 return(TRUE);
3105 }
3106}
3107
3108/*
3109
3110*/
3111
3112/*
3113 ============================================================================
3114 cx_writ() -- process the write command
3115 ============================================================================
3116*/
3117
3118int16_t cx_writ(void)
3119{
3120 int32_t rc;
3121 int16_t ns, recno;
3122
3123 ns = p_len & 0x7FFFL;
3124 recno = (int32_t)p_from & 0xFFFFL;
3125
3126 rc = BIOS(B_RDWR, 3, p_to, ns, recno, 0);
3127
3128 if (rc & 0xFFFFL) {
3129
3130 writeln(cmdunit, "\r\nERROR writing disk: ");
3131 puthn(rc, 8, cmdunit);
3132 writeln(cmdunit, "\r\n\n");
3133 return(FALSE);
3134
3135 } else {
3136
3137 return(TRUE);
3138 }
3139}
3140
3141/*
3142
3143*/
3144
3145/*
3146 ============================================================================
3147 showrs() -- show registers
3148 ============================================================================
3149*/
3150
3151void showrs(struct regs *rp)
3152{
3153 int16_t i;
3154 uint16_t srtemp;
3155
3156 writeln(cmdunit, " ");
3157
3158 for (i = 0; i < 8; i++) {
3159
3160 BIOS(B_PUTC, cmdunit, ' ');
3161 BIOS(B_PUTC, cmdunit, '0'+i);
3162 writeln(cmdunit, "_______");
3163 }
3164
3165 writeln(cmdunit, "\r\nd0..d7 ");
3166
3167 for (i = 0; i < 8; i++) {
3168
3169 BIOS(B_PUTC, cmdunit, ' ');
3170 puthn(rp->d_reg[i], 8, cmdunit);
3171 }
3172
3173 writeln(cmdunit, "\r\na0..a7 ");
3174
3175 for (i = 0; i < 8; i++) {
3176
3177 BIOS(B_PUTC, cmdunit, ' ');
3178 puthn(rp->a_reg[i], 8, cmdunit);
3179 }
3180
3181 writeln(cmdunit, "\r\nPC = ");
3182 puthn((int32_t)rp->reg_pc, 8, cmdunit);
3183
3184 srtemp = rp->reg_sr;
3185 writeln(cmdunit, ", SR = ");
3186 puthn( (int32_t)srtemp & 0xFFFFL, 4, cmdunit);
3187
3188/*
3189
3190*/
3191
3192 writeln(cmdunit, " (IPL = ");
3193 puthn( (int32_t)(srtemp >> 8) & 0x7L, 1, cmdunit);
3194 writeln(cmdunit, ", ");
3195
3196 if (srtemp & 0x8000)
3197 BIOS(B_PUTC, cmdunit, 'T');
3198 else
3199 BIOS(B_PUTC, cmdunit, '-');
3200
3201 if (srtemp & 0x2000)
3202 BIOS(B_PUTC, cmdunit, 'S');
3203 else
3204 BIOS(B_PUTC, cmdunit, '-');
3205
3206 BIOS(B_PUTC, cmdunit, ' ');
3207
3208 if (srtemp & 0x10)
3209 BIOS(B_PUTC, cmdunit, 'X');
3210 else
3211 BIOS(B_PUTC, cmdunit, '-');
3212
3213 if (srtemp & 0x8)
3214 BIOS(B_PUTC, cmdunit, 'N');
3215 else
3216 BIOS(B_PUTC, cmdunit, '-');
3217
3218 if (srtemp & 0x4)
3219 BIOS(B_PUTC, cmdunit, 'Z');
3220 else
3221 BIOS(B_PUTC, cmdunit, '-');
3222
3223 if (srtemp & 0x2)
3224 BIOS(B_PUTC, cmdunit, 'V');
3225 else
3226 BIOS(B_PUTC, cmdunit, '-');
3227
3228 if (srtemp & 0x1)
3229 BIOS(B_PUTC, cmdunit, 'C');
3230 else
3231 BIOS(B_PUTC, cmdunit, '-');
3232
3233 writeln(cmdunit, " )\r\n");
3234}
3235
3236/*
3237
3238*/
3239
3240/*
3241 ============================================================================
3242 showcr() -- show crash registers
3243 ============================================================================
3244*/
3245
3246void showcr(void)
3247{
3248 register int16_t i;
3249 register int8_t *cause;
3250 register uint16_t srtemp;
3251
3252 writeln(cmdunit, "BIOS Crash Area Dump\r\n");
3253 writeln(cmdunit, " ");
3254
3255 for (i = 0; i < 8; i++) {
3256
3257 BIOS(B_PUTC, cmdunit, ' ');
3258 BIOS(B_PUTC, cmdunit, '0'+i);
3259 writeln(cmdunit, "_______");
3260 }
3261
3262 writeln(cmdunit, "\r\nd0..d7 ");
3263
3264 for (i = 0; i < 8; i++) {
3265
3266 BIOS(B_PUTC, cmdunit, ' ');
3267 puthn(crshrg[i], 8, cmdunit);
3268 }
3269
3270 writeln(cmdunit, "\r\na0..a7 ");
3271
3272 for (i = 8; i < 16; i++) {
3273
3274 BIOS(B_PUTC, cmdunit, ' ');
3275 puthn(crshrg[i], 8, cmdunit);
3276 }
3277
3278 writeln(cmdunit, "\r\n\nPC = ");
3279 puthn((int32_t)crshpc, 8, cmdunit);
3280
3281 srtemp = crshsr;
3282 writeln(cmdunit, ", SR = ");
3283 puthn((int32_t)srtemp & 0xFFFFL, 4, cmdunit);
3284
3285/*
3286
3287*/
3288
3289 writeln(cmdunit, " (IPL = ");
3290 puthn((int32_t)(srtemp >> 8) & 0x7L, 1, cmdunit);
3291 writeln(cmdunit, ", ");
3292
3293 if (srtemp & 0x8000)
3294 BIOS(B_PUTC, cmdunit, 'T');
3295 else
3296 BIOS(B_PUTC, cmdunit, '-');
3297
3298 if (srtemp & 0x2000)
3299 BIOS(B_PUTC, cmdunit, 'S');
3300 else
3301 BIOS(B_PUTC, cmdunit, '-');
3302
3303 BIOS(B_PUTC, cmdunit, ' ');
3304
3305 if (srtemp & 0x10)
3306 BIOS(B_PUTC, cmdunit, 'X');
3307 else
3308 BIOS(B_PUTC, cmdunit, '-');
3309
3310 if (srtemp & 0x8)
3311 BIOS(B_PUTC, cmdunit, 'N');
3312 else
3313 BIOS(B_PUTC, cmdunit, '-');
3314
3315 if (srtemp & 0x4)
3316 BIOS(B_PUTC, cmdunit, 'Z');
3317 else
3318 BIOS(B_PUTC, cmdunit, '-');
3319
3320 if (srtemp & 0x2)
3321 BIOS(B_PUTC, cmdunit, 'V');
3322 else
3323 BIOS(B_PUTC, cmdunit, '-');
3324
3325 if (srtemp & 0x1)
3326 BIOS(B_PUTC, cmdunit, 'C');
3327 else
3328 BIOS(B_PUTC, cmdunit, '-');
3329
3330 writeln(cmdunit, " )\r\n");
3331
3332/*
3333
3334*/
3335 writeln(cmdunit, "TRAP vector number = ");
3336 putn((int32_t)crshvc[0], 2, cmdunit);
3337
3338 cause = " (no handler for interrupt)";
3339
3340 switch (crshvc[0] & 0xFF) {
3341
3342 case 2: /* 2: bus error */
3343
3344 cause = " (Bus error)";
3345 break;
3346
3347 case 3: /* 3: address error */
3348
3349 cause = " (Address error)";
3350 break;
3351
3352 case 4: /* 4: illegal instruction */
3353
3354 cause = " (Illegal instruction)";
3355 break;
3356
3357 case 5: /* 5: zero divide */
3358
3359 cause = " (Zero divide)";
3360 break;
3361
3362 case 6: /* 6: CHK instruction */
3363
3364 cause = " (CHK instruction)";
3365 break;
3366
3367 case 7: /* 7: TRAPV instruction */
3368
3369 cause = " (TRAPV instruction)";
3370 break;
3371
3372 case 8: /* 8: privilege violation */
3373
3374 cause = " (Privilege violation)";
3375 break;
3376
3377 case 9: /* 9: trace */
3378
3379 cause = " (Trace -- not implemented)";
3380 break;
3381
3382 case 10: /* 10: line 1010 emulator */
3383
3384 cause = " (Line 1010 Emulator -- not implemented)";
3385 break;
3386
3387 case 11: /* 11: line 1111 emulator */
3388
3389 cause = " (Line 1111 Emulator -- not implemented";
3390 break;
3391
3392 case 15: /* 15: uninitialized interrupt vector */
3393
3394 cause = " (Uninitialized interrupt)";
3395 break;
3396
3397 case 24: /* 24: spurious interrupt */
3398
3399 cause = " (Spurious interrupt)";
3400 break;
3401
3402 case 25: /* 25: Autovector Level 1*/
3403
3404 cause = " (Level 1 Interrupt -- unimplmented)";
3405 break;
3406
3407 case 26: /* 26: Autovector Level 2 */
3408
3409 cause = " (Level 2 Interrupt -- unimplmented)";
3410 break;
3411
3412 case 27: /* 27: Autovector Level 3 */
3413
3414 cause = " (Level 3 Interrupt -- unimplmented)";
3415 break;
3416
3417 case 28: /* 28: Autovector Level 4 */
3418
3419 cause = " (Level 4 Interrupt -- unimplmented)";
3420 break;
3421
3422 case 29: /* 29: Autovector Level 5 */
3423
3424 cause = " (Level 5 Interrupt -- unimplmented)";
3425 break;
3426
3427 case 30: /* 30: Autovector Level 6 */
3428
3429 cause = " (Level 6 Interrupt -- unimplmented)";
3430 break;
3431
3432 case 31: /* 31: Autovector Level 7 */
3433
3434 cause = " (Level 7 Interrupt -- unimplmented)";
3435 break;
3436
3437 }
3438
3439 writeln(cmdunit, cause);
3440 writeln(cmdunit, "\r\n");
3441}
3442
3443/*
3444
3445*/
3446
3447/*
3448 ============================================================================
3449 cx_crsh -- process the crash command
3450 ============================================================================
3451*/
3452
3453int16_t cx_crsh(void)
3454{
3455 if (!wzcrsh)
3456 printf("** Crash switch NOT set **\r\n");
3457
3458 redo = FALSE;
3459 showcr();
3460 return(TRUE);
3461}
3462
3463/*
3464
3465*/
3466
3467/*
3468 ============================================================================
3469 bphit -- clear breakpoints, see if any were hit
3470 ============================================================================
3471*/
3472
3473int16_t bphit(void)
3474{
3475 int16_t rc;
3476
3477 rc = FALSE;
3478
3479 if ((int8_t *)p_ba0 EQ regptr->reg_pc) {
3480
3481 if (*p_ba0 EQ BPINST) {
3482
3483 *p_ba0 = p_bv0;
3484 p_ba0 = 0L;
3485 p_bv0 = BPINST;
3486 rc = TRUE;
3487
3488 } else {
3489
3490 writeln(cmdunit, "** Breakpoint word at ");
3491 puthn(p_ba0, 8 , cmdunit);
3492 writeln(cmdunit, " was ");
3493 puthn(0xFFFFL & (int32_t)(*p_ba0), 4, cmdunit);
3494 writeln(cmdunit, " instead of ");
3495 puthn((int32_t)BPINST, 4, cmdunit);
3496 writeln(cmdunit, " **\r\n\n");
3497 rc = TRUE;
3498 }
3499 }
3500
3501/*
3502
3503*/
3504
3505 if ((int8_t *)p_ba1 EQ regptr->reg_pc) {
3506
3507 if (*p_ba1 EQ BPINST) {
3508
3509 *p_ba1 = p_bv1;
3510 p_ba1 = 0L;
3511 p_bv1 = BPINST;
3512 rc = TRUE;
3513
3514 } else {
3515
3516 writeln(cmdunit, "** Breakpoint word at ");
3517 puthn((int32_t)p_ba0, 8 , cmdunit);
3518 writeln(cmdunit, " was ");
3519 puthn(0xFFFFL & (int32_t)(*p_ba1), 4, cmdunit);
3520 writeln(cmdunit, " instead of ");
3521 puthn((int32_t)BPINST, 4, cmdunit);
3522 writeln(cmdunit, " **\r\n\n");
3523 rc = TRUE;
3524 }
3525 }
3526/*
3527
3528*/
3529 if (p_ba0) {
3530
3531 if (*p_ba0 EQ BPINST) {
3532
3533 *p_ba0 = p_bv0;
3534 p_ba0 = 0L;
3535 p_bv0 = BPINST;
3536 rc = TRUE;
3537
3538 } else {
3539
3540 writeln(cmdunit, "** Breakpoint word at ");
3541 puthn(p_ba0, 8 , cmdunit);
3542 writeln(cmdunit, " was ");
3543 puthn(0xFFFFL & (int32_t)(*p_ba0), 4, cmdunit);
3544 writeln(cmdunit, " instead of ");
3545 puthn((int32_t)BPINST, 4, cmdunit);
3546 writeln(cmdunit, " **\r\n\n");
3547 rc = TRUE;
3548 }
3549 }
3550
3551/*
3552
3553*/
3554
3555 if (p_ba1) {
3556
3557 if (*p_ba1 EQ BPINST) {
3558
3559 *p_ba1 = p_bv1;
3560 p_ba1 = 0L;
3561 p_bv1 = BPINST;
3562 rc = TRUE;
3563
3564 } else {
3565
3566 writeln(cmdunit, "** Breakpoint word at ");
3567 puthn((int32_t)p_ba0, 8 , cmdunit);
3568 writeln(cmdunit, " was ");
3569 puthn(0xFFFFL & (int32_t)(*p_ba1), 4, cmdunit);
3570 writeln(cmdunit, " instead of ");
3571 puthn((int32_t)BPINST, 4, cmdunit);
3572 writeln(cmdunit, " **\r\n\n");
3573 rc = TRUE;
3574 }
3575 }
3576
3577 if (rc)
3578 return(rc);
3579
3580 writeln(cmdunit, "\r\n** Program invoked ROMP trap **\r\n");
3581 return(FALSE);
3582}
3583
3584/*
3585
3586*/
3587
3588/*
3589 ============================================================================
3590 cx_regs() -- process the regs command
3591 ============================================================================
3592*/
3593
3594int16_t cx_regs(void)
3595{
3596 showrs(regptr);
3597 return(TRUE);
3598}
3599
3600/*
3601
3602*/
3603
3604/*
3605 ============================================================================
3606 rompbp() -- process a breakpoint for ROMP
3607 ============================================================================
3608*/
3609
3610void rompbp(int32_t d0, int32_t d1, int32_t d2, int32_t d3, int32_t d4, int32_t d5, int32_t d6, int32_t d7, int8_t *a0, int8_t *a1, int8_t *a2, int8_t *a3, int8_t *a4, int8_t *a5, int8_t *a6, int8_t *a7, int8_t *pc, uint16_t sr0, uint16_t sr)
3611{
3612 register int16_t i;
3613
3614 regptr = (struct regs *)&d0; /* make registers accessable */
3615 pc -= 2L; /* adjust pc */
3616
3617 if (-1 EQ setipl(iplev)) /* enable interrupts */
3618 writeln(cmdunit, "\r\n\n***** setipl() failed *****\r\n\n");
3619
3620 if (first1) { /* initial entry from xtrap15() */
3621
3622 for (i = 0; i < 8; i++) /* clear d0..d7 */
3623 regptr->d_reg[i] = 0L;
3624
3625 for (i = 0; i < 7; i++) /* clear a0..a6 */
3626 regptr->a_reg[i] = (int8_t *)0L;
3627
3628 regptr->a_reg[7] = ISTACK; /* setup initial stack */
3629
3630 sr = INITSR; /* setup sr */
3631 pc += 2L; /* adjust pc past TRAP 15 */
3632
3633 } else { /* breakpoint */
3634
3635 writeln(cmdunit, "\r\n\n** ROMP Breakpoint TRAP **\r\n");
3636
3637 showrs(regptr); /* show registers */
3638
3639 if (bphit() EQ FALSE) /* fixup breakpoints */
3640 pc += 2L; /* and maybe the pc */
3641
3642 }
3643
3644 first1 = FALSE; /* not first time any more */
3645 exflag = FALSE; /* clear exit flag */
3646
3647 do {
3648
3649 do_cmd(); /* process commands ... */
3650
3651 } while (!exflag); /* ... until exit flag is set */
3652
3653 return; /* return to xtrap15 */
3654}
3655
3656/*
3657
3658*/
3659
3660/*
3661 ============================================================================
3662 progid() -- identify the program
3663 ============================================================================
3664*/
3665
3666void progid(void)
3667{
3668 register int8_t *pcptr;
3669
3670#if TINYMSG
3671
3672#if ON_B700
3673 writeln(cmdunit, "\r\n\nB\r\n");
3674#else
3675 writeln(cmdunit, "\r\n\nN\r\n");
3676#endif
3677
3678#else
3679
3680#if ON_B700
3681 writeln(cmdunit, "\r\n\nBuchla 700 BIOS / Debug PROM\r\n");
3682#else
3683 writeln(cmdunit, "\r\n\nNASA 3D Helmet Display BIOS / Debug PROM\r\n");
3684#endif
3685
3686 writeln(cmdunit, " ROMP Version ");
3687 writeln(cmdunit, ROMPVER);
3688
3689 writeln(cmdunit, "\r\n BIOS Version ");
3690 pcptr = (int8_t *)PRM_VERS;
3691 putn((int32_t)*pcptr++, 2, cmdunit);
3692 BIOS(B_PUTC, cmdunit, '.');
3693 putn((int32_t)*pcptr++, 2, cmdunit);
3694 writeln(cmdunit, promdate);
3695
3696#endif
3697}
3698
3699/*
3700
3701*/
3702
3703#if ON_B700
3704
3705
3706/*
3707 ============================================================================
3708 pclr() -- clear the panel FIFO
3709 ============================================================================
3710*/
3711
3712int16_t pclr(void)
3713{
3714 register int16_t i;
3715
3716 ftimer = FIFOLIM;
3717
3718 while (-1L NE (afi = XBIOS(X_ANALOG))) { /* check panel inputs */
3719
3720 asig = 0x007F & (afi >> 8); /* signal number */
3721
3722 if (0 EQ asig) {
3723
3724 /* all keys up */
3725
3726 for (i = 0; i < 128; i++) {
3727
3728 sigtab[i][0] = 0;
3729 sigtab[i][1] = 0;
3730 }
3731
3732 break;
3733 }
3734
3735 if (ftimer-- < 0)
3736 return(FAILURE);
3737 }
3738
3739 return(SUCCESS);
3740}
3741
3742/*
3743
3744*/
3745
3746/*
3747 ============================================================================
3748 pscan() -- scan the panel and maybe even load a program from diskette
3749 ============================================================================
3750*/
3751
3752int16_t pscan(void)
3753{
3754 register int16_t i, c;
3755
3756 if (0 EQ ledcntr--) {
3757
3758 if ((baseled + 3) > 23) /* turn on a LED */
3759 io_leds = baseled - 21;
3760 else
3761 io_leds = baseled + 3;
3762
3763 io_leds = 0x80 + baseled; /* turn off a LED */
3764
3765 if (++baseled > 23) /* update LED number */
3766 baseled = 0;
3767
3768 ledcntr = 200;
3769 }
3770
3771 aflag = FALSE;
3772
3773 if (-1L NE (afi = XBIOS(X_ANALOG))) { /* check panel inputs */
3774
3775 asig = 0x007F & (afi >> 8); /* signal number */
3776 astat = 0x0001 & (afi >> 7); /* status */
3777 aval = 0x007F & afi; /* value */
3778
3779 if (asig) { /* active signal */
3780
3781 aflag = TRUE;
3782
3783 sigtab[asig][0] = aval;
3784 sigtab[asig][1] = astat;
3785
3786 } else { /* all keys up */
3787
3788 aflag = FALSE;
3789
3790 for (i = 0; i < 128; i++)
3791 sigtab[i][1] = 0;
3792 }
3793 }
3794/*
3795
3796*/
3797 if (aflag) { /* anything changed ? */
3798
3799 if (astat AND (asig EQ BOOTKEY)) { /* BOOT key */
3800
3801 for (i = 0; i < 24; i++) /* turn off LEDs */
3802 io_leds = 0x80 + i;
3803
3804 io_leds = 0x1F; /* turn off LCD lamp */
3805
3806 /* load and run BOOTFILE */
3807
3808 B_log_s = FALSE;
3809 B_dbg_s = FALSE;
3810
3811 hdvini();
3812 _bpbin = FALSE;
3813
3814 if (booter(BOOTFILE, 0L))
3815 return(FALSE);
3816 else
3817 sjumpto(B_buf_a, ISTACK);
3818
3819 } else if (astat AND (asig EQ ROMPKEY)) { /* ROMP key */
3820
3821 for (i = 0; i < 24; i++) /* turn off LEDs */
3822 io_leds = 0x80 + i;
3823
3824 return(TRUE);
3825 }
3826 }
3827
3828/*
3829
3830*/
3831
3832 if (BIOS(B_RDAV, CON_DEV)) {
3833
3834 c = 0x007F & BIOS(B_GETC, CON_DEV);
3835
3836 if ((c EQ 'r') OR (c EQ 'R'))
3837 return(TRUE);
3838 }
3839
3840 return(FALSE);
3841}
3842#endif
3843
3844/*
3845
3846*/
3847
3848/*
3849 ============================================================================
3850 romp main routine
3851 ============================================================================
3852*/
3853
3854void main(void)
3855{
3856 register int16_t i;
3857 register int8_t *pdptr, *pcptr;
3858
3859 /* unpack PROM date */
3860
3861 pcptr = (int8_t *)PRM_DATE; /* prom date: yyyymmdd */
3862 pdptr = promdate; /* -- yyyy-mm-dd */
3863 *pdptr++ = ' ';
3864 *pdptr++ = '-';
3865 *pdptr++ = '-';
3866 *pdptr++ = ' ';
3867 *pdptr++ = ((*pcptr >> 4) & 0x0F) + '0';
3868 *pdptr++ = (*pcptr++ & 0x0F) + '0';
3869 *pdptr++ = ((*pcptr >> 4) & 0x0F) + '0';
3870 *pdptr++ = (*pcptr++ & 0x0F) + '0';
3871 *pdptr++ = '-';
3872 *pdptr++ = ((*pcptr >> 4) & 0x0F) + '0';
3873 *pdptr++ = (*pcptr++ & 0x0F) + '0';
3874 *pdptr++ = '-';
3875 *pdptr++ = ((*pcptr >> 4) & 0x0F) + '0';
3876 *pdptr++ = (*pcptr++ & 0x0F) + '0';
3877 *pdptr++ = '\0';
3878
3879 /* initialize variables */
3880
3881 sprintf(hs_mtst, "[[start=$%lX],[end=$%lx]] (or $8..$%lX)",
3882 USER_RAM, RAM_TOP, (USER_RAM - 2L));
3883
3884 cmdunit = CON_DEV;
3885
3886 ilast = 0;
3887 inext = 0;
3888 iplev = DEFIPL;
3889
3890 dflag = FALSE;
3891 exflag = FALSE;
3892 redo = FALSE;
3893 goflag = FALSE;
3894 b0flag = FALSE;
3895 b1flag = FALSE;
3896
3897 p_goto = (int8_t *)ROMADDR;
3898 p_len = 0L;
3899 p_width = 16L;
3900 p_value = 0L;
3901
3902 p_ba0 = 0L;
3903 p_bv0 = BPINST;
3904
3905 p_ba1 = 0L;
3906 p_bv1 = BPINST;
3907
3908 tba0 = 0L;
3909 tba1 = 0L;
3910
3911 inext = 0;
3912
3913 tsetup(); /* patch the timer interrupt code */
3914
3915#if ON_B700
3916 baseled = 21; /* setup LED scan */
3917 ledcntr = 0; /* ... */
3918 io_leds = 0x9F; /* turn on LCD lamp */
3919 GLCinit(); /* reset LCD display */
3920
3921 GLCtext(0, 1, "Load GoTo");
3922 GLCtext(1, 1, "Disk ROMP");
3923
3924 GLCtext(3, 15, "Buchla 700 -- BIOS/ROMP Firmware by D.N. Lynx Crowe");
3925
3926 sprintf(idbuf, "BIOS Version %02d.%02d%s",
3927 *(int8_t *)PRM_VERS, *(int8_t *)(PRM_VERS+1), promdate);
3928 GLCtext(5, 30, idbuf);
3929
3930 sprintf(idbuf, "ROMP Version %s", ROMPVER);
3931 GLCtext(6, 30, idbuf);
3932 GLCcrc(0, 0);
3933
3934 (int8_t *)BIOS(B_SETV, 47, trap15); /* set ROMP trap vec */
3935
3936 for (i = 0; i < 128; i++) {
3937
3938 sigtab[i][0] = 0;
3939 sigtab[i][1] = 0;
3940 }
3941
3942 XBIOS(X_CLRAFI); /* clear the panel FIFO */
3943 setipl(KB_EI); /* enable interrupts */
3944 pclr(); /* empty the panel FIFO */
3945 XBIOS(X_CLRAFI); /* clear the panel FIFO */
3946
3947 while (FALSE EQ pscan()) ; /* do the panel scan */
3948#endif
3949
3950/*
3951
3952*/
3953 if (setjmp(&restart)) /* setup restart point */
3954 writeln(cmdunit, "\r\n***** ROMP Re-starting *****\r\n\n");
3955
3956 tsetup(); /* patch the timer interrupt code */
3957 progid(); /* identify the program */
3958
3959 (int8_t *)BIOS(B_SETV, 47, trap15); /* set ROMP trap vec */
3960 writeln(cmdunit, "\r\n\n");
3961
3962 /* process commands */
3963
3964 first1 = TRUE; /* set break init flag */
3965
3966 while (TRUE) {
3967
3968 xtrap15(); /* trap into ROMP bp processor */
3969 writeln(cmdunit, "\r\n** xtrap15() returned to ROMP **\r\n\n");
3970 }
3971}
3972
Note: See TracBrowser for help on using the repository browser.