1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482
|
Description: Import diff into quilt format
---
--- nitpic-0.1.orig/16c84.cc
+++ nitpic-0.1/16c84.cc
@@ -3,6 +3,7 @@
*/
#include "picsim.hh"
#include <ctype.h>
+#include <stdlib.h>
info_reg pic16c84_info[]={
{"STATUS",{"IRP","RP1","RP0","TO","PD","Z","DC","C"},0,0},
@@ -56,7 +57,7 @@ typedef struct {
#define RP1 0100 // Page select bit 1 (not used)
#define IRP 0200 // Indirect addressing page select (not used)
-static pic16c84_instr PIC16C84_INSTR[];
+extern pic16c84_instr PIC16C84_INSTR[];
static int match_instr( u_int instr );
static void use_a_cycle( Boolean no_ints = False );
static void sleep_a_cycle( void );
@@ -440,7 +441,7 @@ get_f( u_int instr, int *p, int *r )
if (d) {
if (Pic.reg_file[c][d].hook) {
- return Pic.reg_file[c][d].hook( &Pic.reg_file[c][d], False );
+ return Pic.reg_file[c][d].hook( &Pic.reg_file[c][d], False, 0 );
} else {
return Pic.reg_file[c][d].value & 0xff;
}
@@ -532,7 +533,7 @@ disasm_pic16c84( u_int instr )
strcpy( reg, "@FSR" );
} else
if (Pic.reg_file[p][r].name) {
- char *cp = Pic.reg_file[p][r].name;
+ const char *cp = Pic.reg_file[p][r].name;
while (isspace(*cp)) ++cp;
strcpy( reg, cp );
} else
@@ -597,18 +598,18 @@ exANDWF( void )
{
int instr = Pic.uinfo.picmemmap[ Pic.pc ];
int p, r;
- int w, f, and;
+ int w, f, nitpic_and;
int d, dc;
w = get_w( );
f = get_f( instr, &p, &r );
- and = w & f;
+ nitpic_and = w & f;
if (instr & 0x80)
- set_f( p, r, and, True );
+ set_f( p, r, nitpic_and, True );
else
- set_w( and, True );
+ set_w( nitpic_and, True );
}
static void
@@ -709,18 +710,18 @@ exIORWF( void )
{
int instr = Pic.uinfo.picmemmap[ Pic.pc ];
int p, r;
- int w, f, or;
+ int w, f, nitpic_or;
int c, dc;
w = get_w( );
f = get_f( instr, &p, &r );
- or = w | f;
+ nitpic_or = w | f;
if (instr & 0x80)
- set_f( p, r, or, True );
+ set_f( p, r, nitpic_or, True );
else
- set_w( or, True );
+ set_w( nitpic_or, True );
}
static void
@@ -841,17 +842,17 @@ exXORWF( void )
{
int instr = Pic.uinfo.picmemmap[ Pic.pc ];
int p, r;
- int w, f, xor;
+ int w, f, nitpic_xor;
w = get_w( );
f = get_f( instr, &p, &r );
- xor = w ^ f;
+ nitpic_xor = w ^ f;
if (instr & 0x80)
- set_f( p, r, xor, True );
+ set_f( p, r, nitpic_xor, True );
else
- set_w( xor, True );
+ set_w( nitpic_xor, True );
}
static void
@@ -920,13 +921,13 @@ static void
exANDLW( void )
{
int instr = Pic.uinfo.picmemmap[ Pic.pc ];
- int w, l, and;
+ int w, l, nitpic_and;
w = get_w( );
l = instr & 0xff;
- and = w & l;
+ nitpic_and = w & l;
- set_w( and, True );
+ set_w( nitpic_and, True );
}
static void
@@ -967,13 +968,13 @@ static void
exIORLW( void )
{
int instr = Pic.uinfo.picmemmap[ Pic.pc ];
- int w, l, or;
+ int w, l, nitpic_or;
w = get_w( );
l = instr & 0xff;
- or = w & l;
+ nitpic_or = w & l;
- set_w( or, True );
+ set_w( nitpic_or, True );
}
static void
@@ -1053,13 +1054,13 @@ static void
exXORLW( void )
{
int instr = Pic.uinfo.picmemmap[ Pic.pc ];
- int w, l, xor;
+ int w, l, nitpic_xor;
w = get_w( );
l = instr & 0xff;
- xor = w ^ l;
+ nitpic_xor = w ^ l;
- set_w( xor, True );
+ set_w( nitpic_xor, True );
}
static void
@@ -1084,7 +1085,7 @@ exTRIS( void )
}
}
-static pic16c84_instr
+pic16c84_instr
PIC16C84_INSTR[] = {
{ 0x3f00, 0x0000, 0x0700, 0x0000, 1, 1, 0, "ADDWF ", exADDWF },
{ 0x3f00, 0x0000, 0x0500, 0x0000, 1, 1, 0, "ANDWF ", exANDWF },
--- nitpic-0.1.orig/Imakefile
+++ nitpic-0.1/Imakefile
@@ -1,49 +1,19 @@
-/*
- * Imakefile for picsim
- */
- SRCS = main.cc \
- ic.cc \
- info.cc \
- instr.cc \
- pu_lib.c \
- reg.cc \
- sim.cc \
- util.cc \
- 16c84.cc
+SRCS = main.cc ic.cc info.cc instr.cc pu_lib.c reg.cc sim.cc util.cc 16c84.cc
+OBJS = main.o ic.o info.o instr.o pu_lib.o reg.o sim.o util.o 16c84.o
- OBJS = main.o \
- ic.o \
- info.o \
- instr.o \
- pu_lib.o \
- reg.o \
- sim.o \
- util.o \
- 16c84.o
+EXTRA_INCLUDES =
+CDEBUGFLAGS = -g -O2 -Wall
+CCOPTIONS =
+C++FLAGS = $(CFLAGS) $(CDEBUGFLAGS)
+CXXFLAGS = $(C++FLAGS)
+LDFLAGS = -static
- EXTRA_INCLUDES = -I./lib/X11
- CDEBUGFLAGS =
- CCOPTIONS =
- C++FLAGS = $(CFLAGS) $(CDEBUGFLAGS)
- CXXFLAGS = $(C++FLAGS)
- LDFLAGS = $(CDEBUGFLAGS)
-
- INCLUDES = -I$(TOP) -I$(TOOLKITSRC)
+INCLUDES = -I$(TOP) -I$(TOOLKITSRC)
LOCAL_LIBRARIES = $(XAWLIB) $(XEXTLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
- SYS_LIBRARIES = -lm -lc
+SYS_LIBRARIES = -Wl,-Bstatic -lbfd -lopcodes -lsframe -Wl,-Bdynamic -lz -lzstd -liberty -lm -lc -ldl
- GCC_INCLUDE = $(shell dirname `gcc -print-libgcc-file-name`)/include
+DEPENDFLAGS = $(EXTRA_INCLUDES)
- DEPENDFLAGS = -I/usr/local/lib/g++-include \
- -I/usr/lib/g++-include \
- -I$(GCC_INCLUDE) \
- $(EXTRA_INCLUDES)
all:: nitpic
-ComplexProgramTarget(nitpic)
-/*
- * The following is a matter of preference:
- *
- * InstallManPage(template,$(MANDIR))
- * InstallProgram(template,$(BINDIR))
- */
+ComplexCplusplusProgramTarget (nitpic)
--- nitpic-0.1.orig/XPICsim
+++ nitpic-0.1/XPICsim
@@ -1,6 +1,13 @@
!
! App defaults file for X PIC simulator
!
+
+*XPICsim.left-pointer: /usr/share/nitpic/lsolid.xbm
+*XPICsim.left-hollow: /usr/share/nitpic/lhollow.xbm
+*XPICsim.right-pointer: /usr/share/nitpic/rsolid.xbm
+*XPICsim.right-hollow: /usr/share/nitpic/rhollow.xbm
+
+
*XPICsim.nitpic-resources: true
*XPICsim.synchronous: true
*XPICsim*background: gray90
@@ -64,7 +71,7 @@
*XPICsim.main.instr.ipointer.height: 396
*XPICsim.main.instr.ipointer.width: 20
*XPICsim.main.instr.ipointer.borderWidth: 0
-*XPICsim.main.instr.ipointer.bitmap: pointer.xbm
+*XPICsim.main.instr.ipointer.bitmap: /usr/share/nitpic/pointer.xbm
*XPICsim.main.instr.ipointer.label:
*XPICsim.main.instr.ipointer.translations: #replace \n\
<Expose>: ipointer-refresh() \n\
@@ -84,7 +91,7 @@
*XPICsim.main.regs.width: 150
*XPICsim.main.regs.rprev.width: 22
*XPICsim.main.regs.rprev.height: 20
-*XPICsim.main.regs.rprev.bitmap: larrow.xbm
+*XPICsim.main.regs.rprev.bitmap: /usr/share/nitpic/larrow.xbm
*XPICsim.main.regs.rprev.translations: #override \n\
<Btn1Up>: reg-switch( prev ) notify() unset()
*XPICsim.main.regs.rpage.width: 90
@@ -92,7 +99,7 @@
*XPICsim.main.regs.rnext.width: 22
*XPICsim.main.regs.rnext.height: 20
-*XPICsim.main.regs.rnext.bitmap: rarrow.xbm
+*XPICsim.main.regs.rnext.bitmap: /usr/share/nitpic/rarrow.xbm
*XPICsim.main.regs.rnext.translations: #override \n\
<Btn1Up>: reg-switch( next ) notify() unset()
*XPICsim.main.regs.rdata.width: 146
--- nitpic-0.1.orig/ic.cc
+++ nitpic-0.1/ic.cc
@@ -36,7 +36,7 @@ ic_refresh( Widget w, XEvent *ev, String
a = Pic.simulate( GetPins, a );
p = (pins_info *)a.p;
- if (!p->npins) return;
+ if (!p || !p->npins) return;
XtVaGetValues( W.ic,
XtNheight, &w_height,
--- nitpic-0.1.orig/instr.cc
+++ nitpic-0.1/instr.cc
@@ -76,7 +76,7 @@ instr_scroll( Widget w, XtPointer client
lines = w_height / dv;
- top = Pic.itop + lines * (int)position / w_height;
+ top = Pic.itop + lines * (long)position / w_height;
if (top < 0)
top = 0;
else
--- nitpic-0.1.orig/main.cc
+++ nitpic-0.1/main.cc
@@ -2,6 +2,7 @@
* main.cc -- PIC simulator main routine
*/
#define __main__
+#include <stdlib.h>
#include "picsim.hh"
static String fallback_resources[] = {
--- /dev/null
+++ nitpic-0.1/nitpic.man
@@ -0,0 +1,39 @@
+.TH NITPIC 1
+.SH NAME
+nitpic \- a Microchip PIC simulator
+.SH DESCRIPTION
+.B nitpic
+is an X Window System-based simulator for the Microchip PIC series of
+microcontrollers.
+It currently supports the PIC16C84 only, but it should be trivial to
+add support for the rest of the PIC family, and pretty easy even for
+unrelated CPUs.
+.SH "KNOWN SHORTCOMINGS"
+.IP \(bu
+The 16C84 EEPROM data memory is not implemented.
+.IP \(bu
+Writing PCL doesn't cause a jump.
+.IP \(bu
+Interrupts, including RTCC rollover, don't work.
+.IP \(bu
+The "File" button doesn't let you load a new object file.
+.IP \(bu
+No warning on stack overflow.
+.IP \(bu
+The I/O ports aren't handled properly (there's something screwy about
+read/modify/write instructions that I don't understand yet).
+.IP \(bu
+I'm not sure the ADD and SUB instructions set C and DC properly.
+.SH BUGS
+.IP \(bu
+Sometimes the instruction pointer gets screwed up (graphics only \(em
+the simulator keeps working).
+.SH AUTHOR
+dave madden <dhm@vheissu.net.dcl.co.jp>
+.PP
+This manual page was written by Colin Watson for Debian because the original
+program does not have a manual page.
+It is a simple translation of parts of
+.BR nitpic 's
+.I README
+into the manual page format; see that file for more information.
--- nitpic-0.1.orig/picsim.hh
+++ nitpic-0.1/picsim.hh
@@ -2,7 +2,8 @@
* picsim.hh -- X PIC simulator
*/
#include "patchlevel.h"
-#include <std.h>
+/*#include <std.h>*/
+#include <stdio.h>
#include <ctype.h>
#include <sys/types.h>
#include <stdarg.h>
@@ -27,14 +28,14 @@ extern "C" {
#endif
typedef struct reg { /* Info about each register in register file */
- char *name;
+ const char *name;
unsigned modified : 1;
unsigned modified_last : 1;
char redirect_page;
char redirect_reg;
char implemented;
char value;
- char (*hook)( struct reg *r, Boolean write, char v = 0 );
+ char (*hook)( struct reg *r, Boolean write, char v );
} reg;
typedef struct {
@@ -166,7 +167,7 @@ extern void instr_jump( Widget w, XtPoi
# define GLOBAL extern
#endif
-GLOBAL struct {
+GLOBAL struct Widgets {
Widget toplevel;
Widget main;
Widget title;
--- nitpic-0.1.orig/pu_defs.h
+++ nitpic-0.1/pu_defs.h
@@ -2,7 +2,7 @@
/* definitions for the pic read/write routines */
/* I.King 1994 */
-#define MAXPICSIZE 8192
+#define MAXPICSIZE 32768
typedef struct picdefn
{
--- nitpic-0.1.orig/pu_lib.c
+++ nitpic-0.1/pu_lib.c
@@ -6,18 +6,22 @@
#include <stdio.h>
#include <ctype.h>
+#define PARAMS(x) x
+
+#include <bfd.h>
+
void PU_Clear(PICDEFN *pic)
{
int i;
for(i=0; i<MAXPICSIZE; i++)
- pic->picmemmap[i] = 0xffff;
+ pic->picmemmap[i] = 0x0;
- pic->pictype = 54;
- pic->picid[0] = 0xffff;
- pic->picid[1] = 0xffff;
- pic->picid[2] = 0xffff;
- pic->picid[3] = 0xffff;
+ pic->pictype = 84;
+ pic->picid[0] = 0x00;
+ pic->picid[1] = 0x00;
+ pic->picid[2] = 0x00;
+ pic->picid[3] = 0x00;
pic->osctype = 3;
pic->clock = 1.0e6;
pic->cp_fuse = 1;
@@ -25,7 +29,38 @@ void PU_Clear(PICDEFN *pic)
pic->pu_fuse = 1;
}
-int PU_Read(const char *filename, PICDEFN *pic, int *top)
+int PU_Read (const char *filename, PICDEFN *pic, int *top)
+{
+ bfd *file = NULL;
+ asection *section = NULL;
+
+ PU_Clear (pic);
+
+ file = bfd_openr (filename, "ihex");
+ if (file == NULL) {
+ fprintf (stderr, "unable to open file\n");
+ return PU_FAIL;
+ }
+
+ {
+ char **matching;
+ bfd_check_format_matches (file, bfd_object, &matching);
+ }
+
+ for (section = file->sections; section != NULL; section = section->next) {
+ bfd_size_type sz = bfd_section_size (file, section);
+ if ((section->vma % 2) != 0) {
+ fprintf (stderr, "section not on 16-bit boundary: ignoring");
+ break;
+ }
+ bfd_get_section_contents (file, section, pic->picmemmap + (section->vma / 2), 0, sz);
+ }
+
+ bfd_close (file);
+ return PU_OK;
+}
+
+int PU_Read_Orig(const char *filename, PICDEFN *pic, int *top)
{
FILE *filehandle;
int ch;
--- nitpic-0.1.orig/sim.cc
+++ nitpic-0.1/sim.cc
@@ -160,6 +160,9 @@ sim_nil( SimFunc func, SimAR arg )
case GetInfo:
a.p = NULL;
return a;
+ case GetPins:
+ a.p = NULL;
+ return a;
case Disassemble:
sprintf( buf, "PICx%d unsupported", Pic.uinfo.pictype );
a.p = buf;
|