Index: rom/romp.c
===================================================================
--- rom/romp.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ rom/romp.c	(revision 4cfe69aa0cc00430379e3934cf85c7a661bf1769)
@@ -266,11 +266,11 @@
 
 uint16_t	*tba0,		/* breakpoint 0 temporary */
-	*tba1;		/* breakpoint 1 temporary */
+		*tba1;		/* breakpoint 1 temporary */
 
 uint16_t	p_bv0,		/* breakpoint 0 value */
-	p_bv1;		/* breakpoint 1 value */
+		p_bv1;		/* breakpoint 1 value */
 
 uint16_t	*p_ba0,		/* breakpoint 0 address */
-	*p_ba1;		/* breakpoint 1 address */
+		*p_ba1;		/* breakpoint 1 address */
 
 jmp_buf	restart;	/* jmp environment */
@@ -368,5 +368,5 @@
 
 		writeln(cmdunit, "File name: ");
-		endc = getln(cmdunit, MAXFNLN+1, bfname);
+		endc = (int8_t)getln(cmdunit, MAXFNLN+1, bfname);
 		writeln(cmdunit, CRLF);
 
@@ -472,6 +472,6 @@
 void dosw(int16_t nb, int16_t sv)
 {
-	register uint16_t *bp;
-	register int16_t i, j;
+	register uint16_t *bp, j;
+	register int16_t i;
 
 	if ((nb LT 1) OR (nb GT 82))
@@ -667,9 +667,10 @@
 
 	for (i = 0; i < 22; i++)
-		if (c EQ *ap++)
+		if (c EQ *ap++) {
 			if (i >15)
 				return(i - 6);
 			else
 				return(i);
+		}
 
 	return(-1);
@@ -699,5 +700,5 @@
 		case A_LF:
 
-			argsep = c;
+			argsep = (int8_t)c;
 			return(argln);
 
@@ -712,5 +713,5 @@
 				c = 0x00FF & *sptr;
 
-			argsep = c;
+			argsep = (int8_t)c;
 			return(argln);
 
@@ -720,5 +721,5 @@
 				c = _tolower(c);
 
-			*aptr++ = c;
+			*aptr++ = (int8_t)c;
 			++sptr;
 			++argln;
@@ -753,5 +754,5 @@
 		case A_LF:
 
-			argsep = c;
+			argsep = (int8_t)c;
 			return(argln);
 
@@ -766,5 +767,5 @@
 				c = 0x00FF & *sptr;
 
-			argsep = c;
+			argsep = (int8_t)c;
 			return(argln);
 
@@ -772,10 +773,10 @@
 
 			++sptr;
-			argsep = c;
+			argsep = (int8_t)c;
 			return(argln);
 
 		default:
 
-			*aptr++ = c;
+			*aptr++ = (int8_t)c;
 			++sptr;
 			++argln;
@@ -901,5 +902,5 @@
 	putn(num/10, cw-1, unit);
 
-	d =  num % 10;
+	d =  (int16_t)(num % 10);
 
 	BIOS(B_PUTC, unit, (d + '0'));	
@@ -1060,5 +1061,5 @@
 			return(FALSE);
 
-		*p_from++ = 0xFF & p_value;
+		*p_from++ = (int8_t)(0xFF & p_value);
 
 		if (argsep EQ A_CR)
@@ -1113,5 +1114,5 @@
 			return(FALSE);
 
-		*p_uint++ = 0xFFFF & p_value;
+		*p_uint++ = (uint16_t)(0xFFFF & p_value);
 
 		if (argsep EQ A_CR)
@@ -1184,5 +1185,5 @@
 			*loc = mask;
 
-			if (mask NE (was = *loc))
+			if (mask NE (was = *loc)) {
 				if (p_from LT (int8_t *)USER_RAM)
 					halt();
@@ -1190,8 +1191,9 @@
 					printf("%08lX was %04X, expected %04X\r\n",
 						loc, was, mask);
+			}
 
 			*loc = ~mask;
 
-			if (~mask NE (was = *loc))
+			if (~mask NE (was = *loc)) {
 				if (p_from LT (int8_t *)USER_RAM)
 					halt();
@@ -1199,4 +1201,5 @@
 					printf("%08lX was %04X, expected %04X\r\n",
 						loc, was, ~mask);
+			}
 
 			mask <<= 1;
@@ -1317,10 +1320,10 @@
 	for (i = 0; i < 16; i++) {
 
-		xloc = v_odtab[i][1] & 0x03FF;
+		xloc = (int16_t)(v_odtab[i][1] & 0x03FF);
 
 		if (xloc & 0x0200)		/* sign extend xloc */
-			xloc |= 0xFC00;
-
-		width = (v_odtab[i][1] >> 10) & 0x003F;
+			xloc = xloc - 0x400;
+
+		width = (int16_t)((v_odtab[i][1] >> 10) & 0x003F);
 
 		printf("%2d %s ",
@@ -1350,5 +1353,5 @@
 	writeln(cmdunit, CRLF);
 
-	for (i = 0; i < NCMDS; i++) {
+	for (i = 0; i < (int16_t)NCMDS; i++) {
 
 		if (j++ EQ 22) {
@@ -1435,5 +1438,5 @@
 
 	if (goflag)
-		regptr->reg_pc = p_goto;
+		regptr->reg_pc = (uint32_t)p_goto;
 
 	if (b0flag ) {
@@ -1759,5 +1762,5 @@
 	if (rnum < 9) {		/* d0..d7 -- data register */
 
-		regptr->d_reg[rnum-1] = p_value;
+		regptr->d_reg[rnum-1] = (uint32_t)p_value;
 		return(TRUE);
 	}
@@ -1765,5 +1768,5 @@
 	if (rnum < 17) {	/* a0..a7 -- address register */
 
-		regptr->a_reg[rnum-9] = p_value;
+		regptr->a_reg[rnum-9] = (uint32_t)p_value;
 		return(TRUE);
 	}
@@ -1783,5 +1786,5 @@
 			return(FALSE);
 
-		regptr->reg_pc = p_value;
+		regptr->reg_pc = (uint32_t)p_value;
 		return(TRUE);
 	}
@@ -1792,5 +1795,5 @@
 			return(FALSE);
 
-		regptr->a_reg[7] = p_value;
+		regptr->a_reg[7] = (uint32_t)p_value;
 		return(TRUE);
 	}
@@ -1868,5 +1871,5 @@
 	if (vrnum < 17) {	/* 1..16 -- r0..r15 -- complete register */
 
-		v_regs[vrnum-1] = p_value;
+		v_regs[vrnum-1] = (uint16_t)p_value;
 		return(TRUE);
 	}
@@ -1875,5 +1878,5 @@
 
 		v_regs[vrnum-5] = (v_regs[vrnum-5] & 0x03FF) |
-			((p_value << 10) & 0xFC00);
+			(((uint16_t)p_value << 10) & 0xFC00);
 		return(TRUE);
 	}
@@ -1881,5 +1884,5 @@
 	if (vrnum < 25) {	/* 21..24 -- v0..v3 -- vertical register */
 
-		v_regs[vrnum-9] = (v_regs[vrnum-9] & 0xFC00) | p_value;
+		v_regs[vrnum-9] = (v_regs[vrnum-9] & 0xFC00) | (uint16_t)p_value;
 		return(TRUE);
 	}
@@ -1932,6 +1935,6 @@
 {
 	register int8_t *ldadr;
-	register int16_t c, csum, i, len;
-	register uint16_t val;
+	register int16_t c, i, len;
+	register uint16_t val, csum;
 
 	if ('S' NE (c = *line++))
@@ -1961,10 +1964,10 @@
 
 			if (isxdigit(c = *line++))
-				val = xdtoi(c);
+				val = (uint16_t)xdtoi(c);
 			else
 				return(-3);	/* error 3 = bad address byte */
 
 			if (isxdigit(c = *line++))
-				val = (val << 4) + xdtoi(c);
+				val = (val << 4) + (uint16_t)xdtoi(c);
 			else
 				return(-3);
@@ -1977,15 +1980,15 @@
 
 			if (isxdigit(c = *line++))
-				val = xdtoi(c);
+				val = (uint16_t)xdtoi(c);
 			else
 				return(-4);	/* error 4 = bad data byte */
 
 			if (isxdigit(c = *line++))
-				val = (val << 4) + xdtoi(c);
+				val = (val << 4) + (uint16_t)xdtoi(c);
 			else
 				return(-4);
 
 			csum += (val & 0xFF);
-			*ldadr = val & 0xFF;
+			*ldadr = (int8_t)(val & 0xFF);
 
 			if ((*ldadr & 0xFF) NE (val & 0xFF))
@@ -1998,10 +2001,10 @@
 
 		if (isxdigit(c = *line++))
-			val = xdtoi(c);
+			val = (uint16_t)xdtoi(c);
 		else
 			return(-6);		/* error 6 = bad checksum byte */
 
 		if (isxdigit(c = *line++))
-			val = (val << 4) + xdtoi(c);
+			val = (val << 4) + (uint16_t)xdtoi(c);
 		else
 			return(-6);
@@ -2216,5 +2219,5 @@
 	d_next = p_to + 1;
 	d_last = ((int32_t)p_to - (int32_t)p_from) + d_next;
-	nw = p_width;
+	nw = (int16_t)p_width;
 	rc = TRUE;
 
@@ -2282,9 +2285,9 @@
 */
 
-int16_t ldump(int32_t *loc, int32_t *lastloc, int16_t nwide, int16_t unit)
+int16_t ldump(uint32_t *loc, uint32_t *lastloc, int16_t nwide, int16_t unit)
 {
 	while (nwide--) {
 
-		puthn((uint32_t)*loc, 8, unit);
+		puthn(*loc, 8, unit);
 		BIOS(B_PUTC,unit, ' ');
 
@@ -2448,5 +2451,5 @@
 		return(FALSE);
 
-	iplev = iplevl;
+	iplev = (int16_t)iplevl;
 
 	return(TRUE);
@@ -2538,5 +2541,5 @@
 	case MON_C:
 
-		vc = *monptr & 0x0FF;
+		vc = (int8_t)(*monptr & 0x0FF);
 		puthn((uint32_t)vc, 2, cmdunit);
 		writeln(cmdunit, "\r\n");
@@ -2544,5 +2547,5 @@
 		while (!(0xFFFFL & BIOS(B_RDAV, CON_DEV))) {
 
-			vcc = *monptr & 0x0FF;
+			vcc = (int8_t)(*monptr & 0x0FF);
 
 			if (vc NE vcc) {
@@ -2621,5 +2624,5 @@
 	d_next = p_to + 2;
 	d_last = ((int32_t)p_to - (int32_t)p_from) + d_next;
-	nw = p_width;
+	nw = (int16_t)p_width;
 	rc = TRUE;
 
@@ -2630,5 +2633,5 @@
 		dflag = FALSE;
 
-		if (wdump(p_from, p_to, nw, cmdunit))
+		if (wdump((uint16_t *)p_from, (uint16_t *)p_to, nw, cmdunit))
 			rc = FALSE;
 
@@ -2660,5 +2663,5 @@
 	d_next = p_to + 4;
 	d_last = ((int32_t)p_to - (int32_t)p_from) + d_next;
-	nw = p_width;
+	nw = (int16_t)p_width;
 	rc = TRUE;
 
@@ -2669,5 +2672,5 @@
 		dflag = FALSE;
 
-		if (ldump(p_from, p_to, nw, cmdunit))
+		if (ldump((uint32_t *)p_from, (uint32_t *)p_to, nw, cmdunit))
 			rc = FALSE;
 
@@ -2718,5 +2721,5 @@
 		if (getcmd()) {
 
-			for (i = 0; i < NCMDS; i++) {
+			for (i = 0; i < (int16_t)NCMDS; i++) {
 
 				if (0 EQ strcmp(argstr, cmtab[i].cname)) {
@@ -2796,5 +2799,5 @@
 
 	ns = p_len & 0x7FFFL;
-	recno = (int32_t)p_from & 0xFFFFL;
+	recno = (int16_t)((int32_t)p_from & 0xFFFFL);
 
 	rc = BIOS(B_RDWR, 2, p_to, ns, recno, 0);
@@ -2825,5 +2828,5 @@
 
 	ns = p_len & 0x7FFFL;
-	recno = (int32_t)p_from & 0xFFFFL;
+	recno = (int16_t)((int32_t)p_from & 0xFFFFL);
 
 	rc = BIOS(B_RDWR, 3, p_to, ns, recno, 0);
@@ -3154,5 +3157,5 @@
 	rc = FALSE;
 
-	if (p_ba0 EQ regptr->reg_pc) {
+	if ((uint32_t)p_ba0 EQ regptr->reg_pc) {
 
 		if (*p_ba0 EQ BPINST) {
@@ -3176,5 +3179,5 @@
 	}
 
-	if (p_ba1 EQ regptr->reg_pc) {
+	if ((uint32_t)p_ba1 EQ regptr->reg_pc) {
 
 		if (*p_ba1 EQ BPINST) {
@@ -3404,9 +3407,9 @@
 
 		if ((baseled + 3) > 23)			/* turn on a LED */
-			io_leds = baseled - 21;
+			io_leds = (uint8_t)(baseled - 21);
 		else
-			io_leds = baseled + 3;
-
-		io_leds = 0x80 + baseled;		/* turn off a LED */
+			io_leds = (uint8_t)(baseled + 3);
+
+		io_leds = (uint8_t)(0x80 + baseled);	/* turn off a LED */
 
 		if (++baseled > 23)			/* update LED number */
@@ -3445,5 +3448,5 @@
 
 			for (i = 0; i < 24; i++)	/* turn off LEDs */
-				io_leds = 0x80 + i;
+				io_leds = (uint8_t)(0x80 + i);
 
 			io_leds = 0x1F;			/* turn off LCD lamp */
@@ -3465,5 +3468,5 @@
 
 			for (i = 0; i < 24; i++)	/* turn off LEDs */
-				io_leds = 0x80 + i;
+				io_leds = (uint8_t)(0x80 + i);
 
 			return(TRUE);
@@ -3502,14 +3505,14 @@
 	*pdptr++ = '-';
 	*pdptr++ = ' ';
-	*pdptr++ = ((*pcptr >> 4) & 0x0F) + '0';
-	*pdptr++ = (*pcptr++ & 0x0F) + '0';
-	*pdptr++ = ((*pcptr >> 4) & 0x0F) + '0';
-	*pdptr++ = (*pcptr++ & 0x0F) + '0';
+	*pdptr++ = (int8_t)(((*pcptr >> 4) & 0x0F) + '0');
+	*pdptr++ = (int8_t)((*pcptr++ & 0x0F) + '0');
+	*pdptr++ = (int8_t)(((*pcptr >> 4) & 0x0F) + '0');
+	*pdptr++ = (int8_t)((*pcptr++ & 0x0F) + '0');
 	*pdptr++ = '-';
-	*pdptr++ = ((*pcptr >> 4) & 0x0F) + '0';
-	*pdptr++ = (*pcptr++ & 0x0F) + '0';
+	*pdptr++ = (int8_t)(((*pcptr >> 4) & 0x0F) + '0');
+	*pdptr++ = (int8_t)((*pcptr++ & 0x0F) + '0');
 	*pdptr++ = '-';
-	*pdptr++ = ((*pcptr >> 4) & 0x0F) + '0';
-	*pdptr++ = (*pcptr++ & 0x0F) + '0';
+	*pdptr++ = (int8_t)(((*pcptr >> 4) & 0x0F) + '0');
+	*pdptr++ = (int8_t)((*pcptr++ & 0x0F) + '0');
 	*pdptr++ = '\0';
 
