Exemplo n.º 1
0
Arquivo: code.c Projeto: BlockoS/pceas
void
class6(int *ip)
{
	int	i;
	int addr[3];

	/* update location counter */
	loccnt +=7;

	/* get operands */
    for (i = 0; i < 3; i++) {
		if (!evaluate(ip, (i < 2) ? ',' : ';'))
			return;
		if (pass == LAST_PASS) {
			if (value & 0xFFFF0000) {
				error("Operand size error!");
				return;
			}
		}
	    addr[i] = value;
	}

	/* generate code */
	if (pass == LAST_PASS) {
		/* opcodes */
		putbyte(data_loccnt, opval);
		putword(data_loccnt+1, addr[0]);
		putword(data_loccnt+3, addr[1]);
		putword(data_loccnt+5, addr[2]);

		/* output line */
		println();
	}
}
Exemplo n.º 2
0
Arquivo: as6.c Projeto: aap/pdp6
/* Emit a relocated word at dot and advance dot */
void
putv(word w, int rel)
{
	if(pass2){
		fprintf(lstfp, "%06o%c\t%06o%c%06o%c\t",
			right(dot->v.val), dot->v.rel ? '\'' : ' ',
			left(w), rel & 2 ? '\'' : ' ',
			right(w), rel & 1 ? '\'' : ' ');
		listline();

		if(dot->v.rel != lastdot.rel ||
		   dot->v.val != lastdot.val+1){
			startitem(Code);
			putword(dot->v.val, dot->v.rel);
		}
		putword(w, rel);
	}else{
//		printf("\t%06o%c\t%06o%c%06o%c\n",
//			right(dot->v.val), dot->v.rel ? '\'' : ' ',
//			left(w), rel & 2 ? '\'' : ' ',
//			right(w), rel & 1 ? '\'' : ' ');
	}
	lastdot = dot->v;
	dot->v.val++;
	if(dot->v.rel){
		if(dot->v.val > relbreak)
			relbreak = dot->v.val;
	}else{
		if(dot->v.val > absbreak)
			absbreak = dot->v.val;
	}
}
Exemplo n.º 3
0
int
main(int argc, char *argv[])
{
	struct utsname u;
	int mflag = 0, nflag = 0, rflag = 0, sflag = 0, vflag = 0;

	ARGBEGIN {
	case 'a':
		mflag = nflag = rflag = sflag = vflag = 1;
		break;
	case 'm':
		mflag = 1;
		break;
	case 'n':
		nflag = 1;
		break;
	case 'r':
		rflag = 1;
		break;
	case 's':
		sflag = 1;
		break;
	case 'v':
		vflag = 1;
		break;
	default:
		usage();
	} ARGEND

	if (uname(&u) < 0)
		eprintf("uname:");

	if (sflag || !(nflag || rflag || vflag || mflag))
		putword(stdout, u.sysname);
	if (nflag)
		putword(stdout, u.nodename);
	if (rflag)
		putword(stdout, u.release);
	if (vflag)
		putword(stdout, u.version);
	if (mflag)
		putword(stdout, u.machine);
	putchar('\n');

	return fshut(stdout, "<stdout>");
}
Exemplo n.º 4
0
Arquivo: code.c Projeto: BlockoS/pceas
void
class7(int *ip)
{
	int mode;
	int addr, imm;

	/* get first operand */
	mode = getoperand(ip, IMM, ',');
	imm  = value;
	if (!mode)
		return;

	/* get second operand */
	mode = getoperand(ip, (ZP | ZP_X | ABS | ABS_X), ';');
	addr = value;
	if (!mode)
		return;

	/* make opcode */
	if (mode & (ZP | ZP_X))
		opval = 0x83;
	if (mode & (ABS | ABS_X))
		opval = 0x93;
	if (mode & (ZP_X | ABS_X))
		opval+= 0x20;

	/* generate code */
	if (pass == LAST_PASS) {
		/* opcodes */
		putbyte(loccnt, opval);
		putbyte(loccnt+1, imm);

		if (mode & (ZP | ZP_X))
			/* zero page */
			putbyte(loccnt+2, addr);
		else
			/* absolute */
			putword(loccnt+2, addr);
	}

	/* update location counter */ 
	if (mode & (ZP | ZP_X))
		loccnt += 3;
	else
		loccnt += 4;

	/* auto-increment */
	if (auto_inc) {
		if (pass == LAST_PASS)
			putbyte(loccnt, auto_inc);

		loccnt += 1;
	}

	/* output line */
	if (pass == LAST_PASS)
		println();
}
Exemplo n.º 5
0
/*
 * 8x8のピースをVRAMから作成する:VramLockしない事に注意
 */
void CreateVirtualVram256k_1Pcs_SSE2(Uint32 *p, int x, int y, int pitch, int mpage)
{
    register v8hi_t c;
    register Uint32 *disp = p;
    register Uint32 addr;
   
    addr = y * 40 + x;
    // Loop廃止(高速化)
    
    c = getvram_256k(addr, mpage);
    putword((Uint32 *)disp, c);
    addr += 40;
    disp += pitch;

    c = getvram_256k(addr, mpage);
    putword((Uint32 *)disp, c);
    addr += 40;
    disp += pitch;

    c = getvram_256k(addr, mpage);
    putword((Uint32 *)disp, c);
    addr += 40;
    disp += pitch;

    c = getvram_256k(addr, mpage);
    putword((Uint32 *)disp, c);
    addr += 40;
    disp += pitch;

    c = getvram_256k(addr, mpage);
    putword((Uint32 *)disp, c);
    addr += 40;
    disp += pitch;

    c = getvram_256k(addr, mpage);
    putword((Uint32 *)disp, c);
    addr += 40;
    disp += pitch;

    c = getvram_256k(addr, mpage);
    putword((Uint32 *)disp, c);
    addr += 40;
    disp += pitch;

    c = getvram_256k(addr, mpage);
    putword((Uint32 *)disp, c);

}
Exemplo n.º 6
0
int
main(int argc, char *argv[])
{
	int nflag = 0;

	argv0 = argv[0], argc--, argv++;

	if (*argv && !strcmp(*argv, "-n")) {
		nflag = 1;
		argc--, argv++;
	}

	for (; *argv; argc--, argv++)
		putword(stdout, *argv);
	if (!nflag)
		putchar('\n');

	return fshut(stdout, "<stdout>");
}
Exemplo n.º 7
0
errval_t flounder_stub_lmp_recv_buf(struct lmp_recv_msg *msg, void **bufp,
                                    size_t *len, size_t *pos)
{
    int msgpos;

    // is this the first fragment?
    // if so, unmarshall the length and allocate a buffer
    if (*pos == 0) {
        if (msg->buf.msglen == 0) {
            return FLOUNDER_ERR_RX_INVALID_LENGTH;
        }

        *len = msg->words[0];
        if (*len == 0) {
            *bufp = NULL;
        } else {
            *bufp = malloc(*len);
            if (*bufp == NULL) {
                return LIB_ERR_MALLOC_FAIL;
            }
        }
        msgpos = 1;
    } else {
        msgpos = 0;
    }

    uint8_t *buf = *bufp;

    // copy remainder of fragment to buffer
    for (; msgpos < msg->buf.msglen && *pos < *len; msgpos++) {
        putword(msg->words[msgpos], buf, pos, *len);
    }

    // are we done?
    if (*pos < *len) {
        return FLOUNDER_ERR_BUF_RECV_MORE;
    } else {
        // reset state for next buffer
        *pos = 0;
        return SYS_ERR_OK;
    }
}
Exemplo n.º 8
0
errval_t flounder_stub_ump_recv_buf(volatile struct ump_message *msg,
                                    void **bufp, size_t *len, size_t *pos)
{
    int msgpos;

    // is this the first fragment?
    // if so, unmarshall the length and allocate a buffer
    if (*pos == 0) {
        *len = msg->data[0];
        if (*len == 0) {
            *bufp = NULL;
        } else {
            *bufp = malloc(*len);
            if (*bufp == NULL) {
                return LIB_ERR_MALLOC_FAIL;
            }
        }

        // XXX: skip as many words as the largest word size
        msgpos = (sizeof(uint64_t) / sizeof(uintptr_t));
    } else {
        msgpos = 0;
    }

    uint8_t *buf = *bufp;

    // copy remainder of fragment to buffer
    for (; msgpos < UMP_PAYLOAD_WORDS && *pos < *len; msgpos++) {
        putword(msg->data[msgpos], buf, pos, *len);
    }

    // are we done?
    if (*pos < *len) {
        return FLOUNDER_ERR_BUF_RECV_MORE;
    } else {
        // reset state for next buffer
        *pos = 0;
        return SYS_ERR_OK;
    }
}
Exemplo n.º 9
0
Arquivo: proc.c Projeto: m6502/pceas
void
do_call(int *ip)
{
	struct t_proc *ptr;
	int value;

	/* define label */
	labldef(loccnt, 1);

	/* update location counter */
	data_loccnt = loccnt;
	loccnt += 3;

	/* generate code */
	if (pass == LAST_PASS) {
		/* skip spaces */
		while (isspace(prlnbuf[*ip]))
			(*ip)++;

		/* extract name */
		if (!colsym(ip)) {
			if (symbol[0] == 0)
				fatal_error("Syntax error!");
			return;
		}

		/* check end of line */
		check_eol(ip);

		/* lookup proc table */
		if((ptr = proc_look())) {
			/* check banks */
			if (bank == ptr->bank)
				value = ptr->org + 0xA000;
			else {
				/* different */
				if (ptr->call)
					value = ptr->call;
				else {
					/* new call */
					value = call_ptr + 0x8000;
					ptr->call = value;

					/* init */
					if (call_ptr == 0) {
						call_bank = ++max_bank;
					}

					/* install */
					poke(call_ptr++, 0xA8);			// tay
					poke(call_ptr++, 0x43);			// tma #5
					poke(call_ptr++, 0x20);
					poke(call_ptr++, 0x48);			// pha
					poke(call_ptr++, 0xA9);			// lda #...
					poke(call_ptr++, ptr->bank+bank_base);
					poke(call_ptr++, 0x53);			// tam #5
					poke(call_ptr++, 0x20);
					poke(call_ptr++, 0x98);			// tya
					poke(call_ptr++, 0x20);			// jsr ...
					poke(call_ptr++, (ptr->org & 0xFF));
					poke(call_ptr++, (ptr->org >> 8) + 0xA0);
					poke(call_ptr++, 0xA8);			// tay
					poke(call_ptr++, 0x68);			// pla
					poke(call_ptr++, 0x53);			// tam #5
					poke(call_ptr++, 0x20);
					poke(call_ptr++, 0x98);			// tya
					poke(call_ptr++, 0x60);			// rts
				}
			}
		}
		else {
			/* lookup symbol table */
			if ((lablptr = stlook(0)) == NULL) {
				fatal_error("Undefined destination!");
				return;
			}

			/* get symbol value */
			value = lablptr->value;
		}

		/* opcode */
		putbyte(data_loccnt, 0x20);
		putword(data_loccnt+1, value);

		/* output line */
		println();
	}
Exemplo n.º 10
0
int
main(int argc, char *argv[])
{
	DIR *dp;
	struct dirent *entry;
	pid_t pid;
	struct procstat ps;
	char cmdline[BUFSIZ], *cmd, *cmdbase = NULL, *p, *arg = NULL;
	int i, found = 0;
	int sflag = 0, oflag = 0;
	struct pidentry *pe, *tmp;

	ARGBEGIN {
	case 's':
		sflag = 1;
		break;
	case 'o':
		oflag = 1;
		arg = EARGF(usage());
		break;
	default:
		usage();
	} ARGEND;

	if (!argc)
		return 1;

	TAILQ_INIT(&omitpid_head);

	for (p = strtok(arg, ","); p; p = strtok(NULL, ",")) {
		pe = emalloc(sizeof(*pe));
		if (strcmp(p, "%PPID") == 0)
			pe->pid = getppid();
		else
			pe->pid = estrtol(p, 10);
		TAILQ_INSERT_TAIL(&omitpid_head, pe, entry);
	}

	if (!(dp = opendir("/proc")))
		eprintf("opendir /proc:");

	while ((entry = readdir(dp))) {
		if (!pidfile(entry->d_name))
			continue;
		pid = estrtol(entry->d_name, 10);
		if (oflag) {
			TAILQ_FOREACH(pe, &omitpid_head, entry)
				if (pe->pid == pid)
					break;
			if (pe)
				continue;
		}
		if (parsestat(pid, &ps) < 0)
			continue;
		if (parsecmdline(ps.pid, cmdline,
				 sizeof(cmdline)) < 0) {
			cmd = ps.comm;
			cmdbase = cmd;
		} else {
			if ((p = strchr(cmdline, ' ')))
				*p = '\0';
			cmd = cmdline;
			cmdbase = basename(cmdline);
		}
		/* Workaround for login shells */
		if (cmd[0] == '-')
			cmd++;
		for (i = 0; i < argc; i++) {
			if (strcmp(cmd, argv[i]) == 0 ||
			    strcmp(cmdbase, argv[i]) == 0) {
				putword(entry->d_name);
				found++;
				if (sflag)
					goto out;
			}
		}
	}

out:
	if (found)
		putchar('\n');

	closedir(dp);

	for (pe = TAILQ_FIRST(&omitpid_head); pe; pe = tmp) {
		tmp = TAILQ_NEXT(pe, entry);
		TAILQ_REMOVE(&omitpid_head, pe, entry);
		free(pe);
	}

	return 0;
}
Exemplo n.º 11
0
int main(int argc , char **argv)
{
    BYTE *Image;

    /* compression structs */
    CHAR *HDFName = NULL;
    CHAR *GIFName = NULL;

    BYTE* b;

    BYTE  GlobalPalette[256][3];
    BYTE  Red[256];
    BYTE  Green[256];
    BYTE  Blue[256];

    int   RWidth, RHeight;
    int   ColorMapSize, InitCodeSize, Background, BitsPerPixel;
    int   j,nc;
    int   i;
    int   numcols;

    BYTE pc2nc[256] , r1[256] , g1[256] , b1[256];

    int arg_index = 2;
    int bool_is_image = 0; /* 0 = false , 1 = true */
    char *image_name = NULL;
    int idx;
    
    if ( argv[1] && (strcmp("-V",argv[1])==0) )
    {
        print_version("gif2h5");
        exit(EXIT_SUCCESS);
        
    }


    if (argc < 4) 
    {
        /* they didn't supply at least one image -- bail */
        usage();
        return 1;
    }

    HDFName = argv[1];
    GIFName = argv[2];

    /* get the options */
    while (arg_index++ < argc - 1) 
    {
        if (!strcmp(argv[arg_index] , "-i")) {
            bool_is_image = 1;
            continue;
        }

        if (bool_is_image) 
        {
            /* allocate space to store the image name */
            size_t len = strlen(argv[arg_index]);
            image_name = (CHAR*) malloc( len + 1);
            strcpy(image_name , argv[arg_index]);

            bool_is_image = 0;
            continue;
        }

        /* oops. This was not meant to happen */
        usage();

        goto out;
    }

   /* Do Endian Order testing and set Endian Order */
    idx = 0x0001;
    b = (BYTE *) &idx;
    EndianOrder = (b[0] ? 1:0);

    if (!(fpGif = fopen(GIFName , "wb"))) 
    {
        printf("Error opening gif file for output. Aborting.\n");
        goto out;
    }

    Background = 0;
    {
        hsize_t       width, height, planes;
        hid_t         fid;
        char          interlace[20];
        hssize_t      npals;
        hsize_t       pal_dims[2];
        unsigned char *pal;
       
        if ((fid = H5Fopen(HDFName , H5F_ACC_RDONLY , H5P_DEFAULT)) < 0) 
        {
            fprintf(stderr , "Unable to open HDF file for input. Aborting.\n");
            goto out;
        }
        
        /* read image */
        if ( H5IMget_image_info( fid, image_name, &width, &height, &planes, interlace, &npals ) < 0 )
            goto out;

        Image = (BYTE*) malloc( (size_t) width * (size_t) height );
        
        if ( H5IMread_image( fid, image_name, Image ) < 0 )
            goto out;

        if (npals)
        {
            if ( H5IMget_palette_info( fid, image_name, 0, pal_dims ) < 0 )
                goto out;

            pal = (BYTE*) malloc( (size_t) pal_dims[0] * (size_t) pal_dims[1] );
            
            if ( H5IMget_palette( fid, image_name, 0, pal ) < 0 )
                goto out;

            numcols = (int) pal_dims[0];

            for (i = 0, j = 0 ; i < numcols ; j+=3, i++)
            {
                GlobalPalette[i][0] = pal[j];
                GlobalPalette[i][1] = pal[j+1];
                GlobalPalette[i][2] = pal[j+2];
            }

            free(pal);
        }
        
        H5Fclose(fid);
        
        RWidth  = (int)width;
        RHeight = (int)height;


        /*
         * If the first image does not have a palette, I make my own global
         * color table Obviously this is not the best thing to do, better
         * steps would be:
         *
         *   1. Check for either a global palette or a global attribute called
         *      palette
         *   2. Check for palettes in any of the other images.
         */
        if (!npals) 
        {
            numcols = 256;
            for (i = 0 ; i < numcols ; i++) 
            {
                Red[i] = 255 - i;
                Green[i] = 255 - i;
                Blue[i] = 255 - i;
            }
        } 
        else 
        {
            for (i = 0 ; i < numcols ; i++)
            {
                Red[i] = GlobalPalette[i][0];
                Green[i] = GlobalPalette[i][1];
                Blue[i] = GlobalPalette[i][2];
            }
        }

        for (i = 0; i < numcols; i++) 
        {
            pc2nc[i] = r1[i] = g1[i] = b1[i] = 0;
        }

        /* compute number of unique colors */
        nc = 0;

        for (i = 0; i < numcols; i++) 
        {
            /* see if color #i is already used */
            for (j = 0; j < i; j++) 
            {
                if (Red[i] == Red[j] && Green[i] == Green[j] && Blue[i] == Blue[j])
                    break;
            }
            
            if (j==i) 
            {
                /* wasn't found */
                pc2nc[i] = nc;
                r1[nc] = Red[i];
                g1[nc] = Green[i];
                b1[nc] = Blue[i];
                nc++;
            } 
            else 
            {
                pc2nc[i] = pc2nc[j];
            }
        }

        /* figure out 'BitsPerPixel' */
        for (i = 1; i < 8; i++) 
        {
            if ((1<<i) >= nc)
                break;
        }

        BitsPerPixel = i;
        ColorMapSize = 1 << BitsPerPixel;

        if (BitsPerPixel <= 1)
            InitCodeSize = 2;
        else
            InitCodeSize = BitsPerPixel;

        if (!fpGif) 
        {
            fprintf(stderr,  "WriteGIF: file not open for writing\n" );
            goto out;
        }

      
        fwrite("GIF87a", sizeof( char ), 6, fpGif);  /* the GIF magic number */
        
        putword(RWidth, fpGif);             /* screen descriptor */
        putword(RHeight, fpGif);
        
        i = 0x00;                   /* No, there is no color map */
        i |= (8-1)<<4;              /* OR in the color resolution (hardwired 8) */
        i |= (BitsPerPixel - 1);    /* OR in the # of bits per pixel */
        fputc(i,fpGif);
        
        fputc(Background,fpGif);    /* background color */
        fputc(0, fpGif);            /* future expansion byte */


        /*
         * Put Image Descriptor
         * Hardwiring Left Offset and Top Offset to 0x00
         */
        fputc(0x2c , fpGif);
        putword(0x00 , fpGif);
        putword(0x00  , fpGif);
        putword(RWidth   , fpGif);
        putword(RHeight  , fpGif);

        /* since we always have a local color palette ... */
        fputc((0x80 | (BitsPerPixel - 1)) , fpGif);

        for (i = 0; i < ColorMapSize; i++) 
        {
            /* write out Global colormap */
            fputc(r1[i], fpGif);
            fputc(g1[i], fpGif);
            fputc(b1[i], fpGif);
        }

        fputc(InitCodeSize , fpGif);

        i = hdfWriteGIF(fpGif , Image , 0 , RHeight , RWidth , r1, g1 , b1 , pc2nc , 256 , 8 , BitsPerPixel);
        fputc(0x00, fpGif);
        free(Image);
    }

    if (fputc(';',fpGif) == EOF) 
    {
        /* Write GIF file terminator */
        fprintf(stderr , "Error!");
        goto out;
    }

    if (fpGif != NULL)
        fclose(fpGif);
    if (image_name != NULL)
        free(image_name);

    return 0;


out:

    if (fpGif != NULL)
        fclose(fpGif);
    if (image_name != NULL)
        free(image_name);

    return 1;
}
Exemplo n.º 12
0
/*
 * Handle a GP fault that occurred while in VM86 mode.  Things that are easy
 * to handle here are done here (much more efficient than trapping to 32-bit
 * handler code and then having it restart VM86 mode).
 */
void
vm86_gpfault(struct proc *p, int type)
{
	struct trapframe *tf = p->p_md.md_regs;
	union sigval sv;

	/*
	 * we want to fetch some stuff from the current user virtual
	 * address space for checking.  remember that the frame's
	 * segment selectors are real-mode style selectors.
	 */
	u_long cs, ip, ss, sp;
	u_char tmpbyte;
	int trace;

	cs = CS(tf) << 4;
	ip = IP(tf);
	ss = SS(tf) << 4;
	sp = SP(tf);

	trace = tf->tf_eflags & PSL_T;

	/*
	 * For most of these, we must set all the registers before calling
	 * macros/functions which might do a vm86_return.
	 */
	tmpbyte = getbyte(cs, ip);
	IP(tf) = ip;
	switch (tmpbyte) {
	case CLI:
		/* simulate handling of IF */
		clr_vif(p);
		break;

	case STI:
		/* simulate handling of IF.
		 * XXX the i386 enables interrupts one instruction later.
		 * code here is wrong, but much simpler than doing it Right.
		 */
		set_vif(p);
		break;

	case INTxx:
		/* try fast intxx, or return to 32bit mode to handle it. */
		tmpbyte = getbyte(cs, ip);
		IP(tf) = ip;
		fast_intxx(p, tmpbyte);
		break;

	case INTO:
		if (tf->tf_eflags & PSL_V)
			fast_intxx(p, 4);
		break;

	case PUSHF:
		putword(ss, sp, get_vflags_short(p));
		SP(tf) = sp;
		break;

	case IRET:
		IP(tf) = getword(ss, sp);
		CS(tf) = getword(ss, sp);
	case POPF:
		set_vflags_short(p, getword(ss, sp));
		SP(tf) = sp;
		break;

	case OPSIZ:
		tmpbyte = getbyte(cs, ip);
		IP(tf) = ip;
		switch (tmpbyte) {
		case PUSHF:
			putdword(ss, sp, get_vflags(p) & ~PSL_VM);
			SP(tf) = sp;
			break;

		case IRET:
			IP(tf) = getdword(ss, sp);
			CS(tf) = getdword(ss, sp);
		case POPF:
			set_vflags(p, getdword(ss, sp) | PSL_VM);
			SP(tf) = sp;
			break;

		default:
			IP(tf) -= 2;
			goto bad;
		}
		break;

	case LOCK:
	default:
		IP(tf) -= 1;
		goto bad;
	}

	if (trace && tf->tf_eflags & PSL_VM) {
		sv.sival_int = 0;
		trapsignal(p, SIGTRAP, T_TRCTRAP, TRAP_TRACE, sv);
	}
	return;

bad:
	vm86_return(p, VM86_UNKNOWN);
	return;
}
Exemplo n.º 13
0
static void
fast_intxx(struct proc *p, int intrno)
{
	struct trapframe *tf = p->p_md.md_regs;
	/*
	 * handle certain interrupts directly by pushing the interrupt
	 * frame and resetting registers, but only if user said that's ok
	 * (i.e. not revectored.)  Otherwise bump to 32-bit user handler.
	 */
	struct vm86_struct *u_vm86p;
	struct { u_short ip, cs; } ihand;

	u_long ss, sp;

	/*
	 * Note: u_vm86p points to user-space, we only compute offsets
	 * and don't deref it. is_revectored() above does copyin() to
	 * get stuff from it
	 */
	u_vm86p = (struct vm86_struct *)p->p_addr->u_pcb.vm86_userp;

	/*
	 * If user requested special handling, return to user space with
	 * indication of which INT was requested.
	 */
	if (is_bitset(intrno, &u_vm86p->int_byuser[0]))
		goto vector;

	/*
	 * If it's interrupt 0x21 (special in the DOS world) and the
	 * sub-command (in AH) was requested for special handling,
	 * return to user mode.
	 */
	if (intrno == 0x21 && is_bitset(V86_AH(tf), &u_vm86p->int21_byuser[0]))
		goto vector;

	/*
	 * Fetch intr handler info from "real-mode" IDT based at addr 0 in
	 * the user address space.
	 */
	if (copyin((caddr_t)(intrno * sizeof(ihand)), &ihand, sizeof(ihand)))
		goto bad;

	/*
	 * Otherwise, push flags, cs, eip, and jump to handler to
	 * simulate direct INT call.
	 */
	ss = SS(tf) << 4;
	sp = SP(tf);

	putword(ss, sp, get_vflags_short(p));
	putword(ss, sp, CS(tf));
	putword(ss, sp, IP(tf));
	SP(tf) = sp;

	IP(tf) = ihand.ip;
	CS(tf) = ihand.cs;

	return;

vector:
	vm86_return(p, VM86_MAKEVAL(VM86_INTx, intrno));
	return;

bad:
	vm86_return(p, VM86_UNKNOWN);
	return;
}
Exemplo n.º 14
0
Arquivo: code.c Projeto: BlockoS/pceas
void
class4(int *ip)
{
	char buffer[32];
	char c;
	int len, mode;
	int	i;

	/* skip spaces */
	while (isspace(prlnbuf[*ip]))
		(*ip)++;

	/* low/high byte prefix string */
	if (isalpha(prlnbuf[*ip])) {
		len = 0;
		i = *ip;

		/* extract string */
		for (;;) {
			c = prlnbuf[i];
			if (c == '\0' || c == ' ' || c == '\t' || c == ';')
				break;
			if ((!isalpha(c) && c != '_') || (len == 31)) {
				len = 0;
				break;
			}
			buffer[len++] = c;
			i++;
		}

		/* check */
		if (len) {
			buffer[len] = '\0';

			if (strcasecmp(buffer, "low_byte") == 0) {
				opext = 'L';
				*ip = i;
			}
			if (strcasecmp(buffer, "high_byte") == 0) {
				opext = 'H';
				*ip = i;
			}
		}
	}

	/* get operand */
	mode = getoperand(ip, opflg, ';');
	if (!mode)
		return;

	/* make opcode */
	if (pass == LAST_PASS) {
		for (i = 0; i < 32; i++) {
			if (mode & (1 << i))
				break;
		}
		opval += opvaltab[optype][i];
	}

	/* auto-tag */
	if (auto_tag) {
		if (pass == LAST_PASS) {
			putbyte(loccnt, 0xA0);
			putbyte(loccnt+1, auto_tag_value);
		}
		loccnt += 2;
	}

	/* generate code */
	switch(mode) {
	case ACC:
		/* one byte */
		if (pass == LAST_PASS)
			putbyte(loccnt, opval);

		loccnt++;
		break;

	case IMM:
	case ZP:
	case ZP_X:
	case ZP_Y:
	case ZP_IND:
	case ZP_IND_X:
	case ZP_IND_Y:
		/* two bytes */
		if (pass == LAST_PASS) {
			putbyte(loccnt, opval);
			putbyte(loccnt+1, value);
		}
		loccnt += 2;
		break;

	case ABS:
	case ABS_X:
	case ABS_Y:
	case ABS_IND:
	case ABS_IND_X:
		/* three bytes */
		if (pass == LAST_PASS) {
			putbyte(loccnt, opval);
			putword(loccnt+1, value);
		}
		loccnt += 3;
		break;
	}

	/* auto-increment */
	if (auto_inc) {
		if (pass == LAST_PASS)
			putbyte(loccnt, auto_inc);

		loccnt += 1;
	}

	/* output line */
	if (pass == LAST_PASS)
		println();
}
Exemplo n.º 15
0
int WriteGIF(FILE *fp, unsigned char *pic, int ptype, int w, int h, 
             unsigned char *rmap, unsigned char *gmap, 
             unsigned char *bmap, int numcols, int colorstyle, 
	     const char *comment)
{ int   RWidth, RHeight;
  int   LeftOfs, TopOfs;
  int   ColorMapSize, InitCodeSize, Background, BitsPerPixel;
  int   i,j,nc;
  byte *pic8;
//  byte  rtemp[256],gtemp[256],btemp[256];
  int   Interlace;

  struct aap *a = (struct aap *)malloc(sizeof(struct aap));
  memset(a, 0, sizeof(struct aap));

  UNUSED_ARGUMENT(ptype);
//  if (ptype == PIC24) {  /* have to quantize down to 8 bits */
//    pic8 = Conv24to8(pic, w, h, 256, rtemp,gtemp,btemp);
//    if (!pic8) FatalError("Unable to malloc in WriteGIF()");
//    rmap = rtemp;  gmap = gtemp;  bmap = btemp;  numcols=256;
//  }
//  else 
    pic8 = pic;

  Interlace = 0;
  Background = 0;

  for (i=0; i<256; i++) { a->pc2nc[i] = a->r1[i] = a->g1[i] = a->b1[i] = 0; }

  /* compute number of unique colors */
  nc = 0;

  for (i=0; i<numcols; i++) {
    /* see if color #i is already used */
    for (j=0; j<i; j++) {
      if (rmap[i] == rmap[j] && gmap[i] == gmap[j] && 
	  bmap[i] == bmap[j]) break;
    }

    if (j==i) {  /* wasn't found */
      a->pc2nc[i] = nc;
      a->r1[nc] = rmap[i];
      a->g1[nc] = gmap[i];
      a->b1[nc] = bmap[i];
      nc++;
    }
    else a->pc2nc[i] = a->pc2nc[j];
  }


  /* figure out 'BitsPerPixel' */
  for (i=1; i<8; i++)
    if ( (1<<i) >= nc) break;
  
  BitsPerPixel = i;

  ColorMapSize = 1 << BitsPerPixel;
	
  RWidth  = w;
  RHeight = h;
  LeftOfs = TopOfs = 0;
	
  if (BitsPerPixel <= 1) InitCodeSize = 2;
                    else InitCodeSize = BitsPerPixel;

  if (!fp) {
    fprintf(stderr,  "WriteGIF: file not open for writing\n" );
//    if (ptype == PIC24) free(pic8);
    free(a);
    return (1);
  }

//  if (DEBUG) 
//    fprintf(stderr,"WrGIF: pic=%lx, w,h=%dx%d, numcols=%d, Bits%d,Cmap=%d\n",
//	    (u_long) pic8, w,h,numcols,BitsPerPixel,ColorMapSize);

  if (comment && strlen(comment) > (size_t) 0)
    fwrite("GIF89a", (size_t) 1, (size_t) 6, fp);    /* the GIF magic number */
  else
    fwrite("GIF87a", (size_t) 1, (size_t) 6, fp);    /* the GIF magic number */

  putword(RWidth, fp);           /* screen descriptor */
  putword(RHeight, fp);

  i = 0x80;	                 /* Yes, there is a color map */
  i |= (8-1)<<4;                 /* OR in the color resolution (hardwired 8) */
  i |= (BitsPerPixel - 1);       /* OR in the # of bits per pixel */
  fputc(i,fp);          

  fputc(Background, fp);         /* background color */

  fputc(0, fp);                  /* future expansion byte */


  if (colorstyle == 1) {         /* greyscale */
    for (i=0; i<ColorMapSize; i++) {
      j = MONO(a->r1[i], a->g1[i], a->b1[i]);
      fputc(j, fp);
      fputc(j, fp);
      fputc(j, fp);
    }
  }
  else {
    for (i=0; i<ColorMapSize; i++) {       /* write out Global colormap */
      fputc(a->r1[i], fp);
      fputc(a->g1[i], fp);
      fputc(a->b1[i], fp);
    }
  }

  if (comment && strlen(comment) > (size_t) 0) {   /* write comment blocks */
    const char *sp;
    int   k, blen;

    fputc(0x21, fp);     /* EXTENSION block */
    fputc(0xFE, fp);     /* comment extension */

    sp = comment;
    while ( (blen=strlen(sp)) > 0) {
      if (blen>255) blen = 255;
      fputc(blen, fp);
      for (k=0; k<blen; k++, sp++) fputc(*sp, fp);
    }
    fputc(0, fp);    /* zero-length data subblock to end extension */
  }


  fputc( ',', fp );              /* image separator */

  /* Write the Image header */
  putword(LeftOfs, fp);
  putword(TopOfs,  fp);
  putword(RWidth,   fp);
  putword(RHeight,  fp);
  if (Interlace) fputc(0x40, fp);   /* Use Global Colormap, maybe Interlace */
            else fputc(0x00, fp);

  fputc(InitCodeSize, fp);
  compress(InitCodeSize+1, fp, pic8, w*h, a);

  fputc(0,fp);                      /* Write out a Zero-length packet (EOF) */
  fputc(';',fp);                    /* Write GIF file terminator */

//  if (ptype == PIC24) free(pic8);

  free(a);
  if (ferror(fp)) return -1;
  return (0);
}
Exemplo n.º 16
0
/* putofield - put a field into an object */
int putofield(int obj,int off,int val)
{
    return (putword(getoloc(obj)+off,val));
}
Exemplo n.º 17
0
void CreateVirtualVram256k_Line_SSE2(Uint32 *p, int ybegin, int yend, int mpage)
{
    register v8hi_t c;
    register v8hi_t *disp;
    register Uint32 addr;
    int yy;
    int xx;
    const int pitch = sizeof(Uint32) * 8;
    // Loop廃止(高速化)
    if(aPlanes == NULL) {
       c.v = (v8si){0,0,0,0,0,0,0,0};
       for(yy = ybegin; yy < yend; yy++) {
	  addr = yy * 40;
	  disp = (v8hi_t *)((Uint8 *)p + (pitch * addr));
	  for(xx = 0; xx < (40 / 8); xx++) {
	     putword((Uint32 *)disp,  c);
	     disp++;
	     putword((Uint32 *)disp,  c);
	     disp++;
	     putword((Uint32 *)disp,  c);
	     disp++;
	     putword((Uint32 *)disp,  c);
	     disp++;
	     putword((Uint32 *)disp,  c);
	     disp++;
	     putword((Uint32 *)disp,  c);
	     disp++;
	     putword((Uint32 *)disp,  c);
	     disp++;
	     putword((Uint32 *)disp,  c);
	     disp++;
	  }
       }
    } else {
       for(yy = ybegin; yy < yend; yy++) {
	  addr = yy * 40;
	  disp = (v8hi_t *)((Uint8 *)p + (pitch * addr));
	  for(xx = 0; xx < (40 / 8); xx++) {
	     c = getvram_256k(addr, mpage);
	     putword((Uint32 *)disp,  c);
	     disp++;
	     addr++;
	     c = getvram_256k(addr, mpage);
	     putword((Uint32 *)disp,  c);
	     disp++;
	     addr++;
	     c = getvram_256k(addr, mpage);
	     putword((Uint32 *)disp,  c);
	     disp++;
	     addr++;
	     c = getvram_256k(addr, mpage);
	     putword((Uint32 *)disp,  c);
	     disp++;
	     addr++;
	     c = getvram_256k(addr, mpage);
	     putword((Uint32 *)disp,  c);
	     disp++;
	     addr++;
	     c = getvram_256k(addr, mpage);
	     putword((Uint32 *)disp,  c);
	     disp++;
	     addr++;
	     c = getvram_256k(addr, mpage);
	     putword((Uint32 *)disp,  c);
	     disp++;
	     addr++;
	     c = getvram_256k(addr, mpage);
	     putword((Uint32 *)disp,  c);
	     disp++;
	     addr++;
	  }
       }
    } 
}