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

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

Fixed argument order.

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