source: buchla-68k/orig/ROM/ROMP.C@ f7c91fc

Last change on this file since f7c91fc was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

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