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

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

Regenerate global headers.

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