Example #1
0
void MystScriptParser_Slides::setupOpcodes() {
	// "Stack-Specific" Opcodes
	OPCODE(100, o_returnToMenu);

	// "Init" Opcodes
	OPCODE(200, o_setCardSwap);
}
Example #2
0
OPCODE DecodeOpcode(const BYTE *pCode, DWORD *pdwLen)
{
    OPCODE opcode;

    *pdwLen = 1;
    opcode = OPCODE(pCode[0]);
    switch(opcode) {
        case CEE_PREFIX1:
            opcode = OPCODE(pCode[1] + 256);
            if (opcode < 0 || opcode >= CEE_COUNT)
                opcode = CEE_COUNT;
            *pdwLen = 2;
            break;
        case CEE_PREFIXREF:
        case CEE_PREFIX2:
        case CEE_PREFIX3:
        case CEE_PREFIX4:
        case CEE_PREFIX5:
        case CEE_PREFIX6:
        case CEE_PREFIX7:
            *pdwLen = 3;
            return CEE_COUNT;
        default:
            break;
        }
    return opcode;
}
Example #3
0
void Credits::setupOpcodes() {
	// "Stack-Specific" Opcodes
	OPCODE(100, o_quit);

	// "Init" Opcodes
	OPCODE(200, o_runCredits);
}
Example #4
0
static int
rvec_priv_inst( int dummy_rvec, ulong inst )
{
	int op, op_ext, b1, b2, b3;

	/* unhandled privileged instruction in supervisor mode */
	/* IMPORTANT: The GPRs are not available here! */

	op = OPCODE_PRIM( inst );
	op_ext = OPCODE_EXT( inst );
	b1 = B1( inst );	/* bit 6-10 */
	b2 = B2( inst );	/* bit 11-15 */
	b3 = B3( inst );	/* bit 16-20 */

	switch( OPCODE(op,op_ext) ) {
	case OPCODE( 31, 370 ):	/* tlbia (opt.) */
		/* not implemented on the 601,603,604,G3 (G4?) */
		break;
	case OPCODE( 31, 470 ):  /* dcbi rA,rB  -- rA=b2 rB=b3 */
		printm("dcbi treated as nop\n");
		mregs->nip += 4;
		return 0;
	default:
		printm("Unknown privileged instruction, opcode %lX\n", inst);
		stop_emulation();
		break;
	}
	mac_exception( 0x700, MOL_BIT(13) );
	return 0;
}
Example #5
0
static void handle_outbound(struct aura_node *node, struct aura_object *o, struct aura_buffer *buf)
{
	int ret = -EIO;

	if (OPCODE("export")) {
		int gpio = aura_buffer_get_u32(buf);
		slog(4, SLOG_DEBUG, "gpio: export %d", gpio);
		ret = gpio_export(gpio);
	} else if (OPCODE("write")) {
		int gpio = aura_buffer_get_u32(buf);
		int value = aura_buffer_get_u32(buf);
		slog(4, SLOG_DEBUG, "gpio: write gpio %d value %d", gpio, value);
		ret = gpio_write(gpio, value);
	} else if (OPCODE("in")) {
		int gpio = aura_buffer_get_u32(buf);
		ret = gpio_in(gpio);
	} else if (OPCODE("out")) {
		int gpio = aura_buffer_get_u32(buf);
		ret = gpio_out(gpio);
	} else if (OPCODE("read")) {
		int gpio = aura_buffer_get_u32(buf);
		ret = gpio_read(gpio, &gpio);
		aura_buffer_rewind(buf);
		aura_buffer_put_u32(buf, gpio);
	}
	slog(0, SLOG_DEBUG, "gpio ret = %d", ret);
	if (ret) {
		aura_call_fail(node, o);
		return;
	}
	aura_queue_buffer(&node->inbound_buffers, buf);
}
Example #6
0
void Demo::setupOpcodes() {
	// "Stack-Specific" Opcodes
	OVERRIDE_OPCODE(100, o_stopIntro);
	OPCODE(101, o_fadeFromBlack);
	OPCODE(102, o_fadeToBlack);

	// "Init" Opcodes
	OVERRIDE_OPCODE(201, o_returnToMenu_init);
}
Example #7
0
void Preview::setupOpcodes() {
	// "Stack-Specific" Opcodes
	OVERRIDE_OPCODE(196, opcode_196);
	OVERRIDE_OPCODE(197, opcode_197);
	OVERRIDE_OPCODE(198, opcode_198);
	OVERRIDE_OPCODE(199, opcode_199);

	// "Init" Opcodes
	OPCODE(298, opcode_298);
	OPCODE(299, opcode_299);
}
Example #8
0
void MystScriptParser_Dni::setupOpcodes() {
	// "Stack-Specific" Opcodes
	OPCODE(100, NOP);
	OPCODE(101, o_handPage);

	// "Init" Opcodes
	OPCODE(200, o_atrus_init);

	// "Exit" Opcodes
	OPCODE(300, NOP);
}
Example #9
0
void Intro::setupOpcodes() {
	// "Stack-Specific" Opcodes
	OPCODE(100, o_useLinkBook);

	// "Init" Opcodes
	OPCODE(200, o_playIntroMovies);
	OPCODE(201, o_mystLinkBook_init);

	// "Exit" Opcodes
	OPCODE(300, NOP);
}
Example #10
0
static void afterExec(const sEvArgs *args) {
	UNUSED(args);
	tetra raw = cpu_getCurInstrRaw();
	if(OPCODE(raw) == PUSHGO || OPCODE(raw) == PUSHGOI ||
		OPCODE(raw) == PUSHJ || OPCODE(raw) == PUSHJB)
		level++;
	else if(OPCODE(raw) == POP)
		level--;
	if(level <= 0)
		cpu_pause();
}
Example #11
0
void Demo::setupOpcodes() {
    // "Stack-Specific" Opcodes
    OVERRIDE_OPCODE(100, opcode_100);
    OPCODE(101, opcode_101);
    OPCODE(102, opcode_102);

    // "Init" Opcodes
    OVERRIDE_OPCODE(201, opcode_201);

    // "Exit" Opcodes
    OVERRIDE_OPCODE(300, opcode_300);
}
Example #12
0
int recieveDataPackage(unsigned short index, char data[RFC1350_BLOCKSIZE], struct sockaddr_in *destination_addr, int* sock, char verbose_text[LOG_INFO_SUBJECT_SIZE]) {

    char buffer[516];
    int recv_size;
    socklen_t destination_addr_len = sizeof(struct sockaddr_in);
    int rexmt = retransmission_time;

    int result;
    struct timeval t_retx;
    fd_set fds;

    FD_ZERO ( &fds ) ;
    FD_SET ( *sock, &fds ) ;

    t_retx.tv_sec = rexmt;
    t_retx.tv_usec = 0;

    result = select ( (*sock) + 1, &fds, NULL, NULL, &t_retx);
    printf("recieveDataPackage: RESULT form SELECT = %x\n", result); //debug

    if (result == 1) {
        recv_size = recvfrom(*sock, buffer, 516, 0, (struct sockaddr*)destination_addr, &destination_addr_len);

        if( verbose == 1 ) {
            log_info(&buffer, recv_size, verbose_text, VERBOSE_ACTION_RECIEVE);
        }

        printf("recieveDataPackage: OPCODE = %x\n", OPCODE(buffer)); //debug

        if (OPCODE(buffer) == RFC1350_OP_DATA) {
            tftp_data_hdr message_data;

            memcpy(&message_data, buffer, recv_size);

            if (ntohs(message_data.num_block) == index) {
                /* Expected DATA recieved. */
                memcpy(data, message_data.data, recv_size - 4);

                return recv_size;
            }
        } else if (OPCODE(buffer) == RFC1350_OP_ERROR) {
            printError(buffer, recv_size);
            /* We recieved an error message */
            return -1;
        }
    }

    /* DATA or message was unexpected. */
    return 0;
}
Example #13
0
void RA8(const Instr *instr, byte r8, word a16)
{
	memory->store(address++, OPCODE(instr, AM_RA8));
	memory->store(address++, r8);
	memory->store(address++, HIBYTE(a16));
	memory->store(address++, LOBYTE(a16));
}
Example #14
0
void process(Servo *servo, Instruction b) {
	enum opcode operation = OPCODE(b);
	int parameter = PARAM(b);

	switch(operation) {
		case MOV:
			mov(servo, parameter);
			break;
		case WAIT:
			wait(servo, parameter);
			break;
		case LOOP_START:
			loop_start(servo, parameter);
			execute(servo, servo->recipe[servo->pc]);
			break;
		case END_LOOP:
			end_loop(servo);
			execute(servo, servo->recipe[servo->pc]);
			break;
		case RECIPE_END:
			recipe_end(servo);
			break;
		default: /* Opcode not defined */
			break;
	}
}
Example #15
0
void A16I8(const Instr *instr, word a16, byte i8)
{
	memory->store(address++, OPCODE(instr, AM_A16I8));
	memory->store(address++, i8);
	memory->store(address++, HIBYTE(a16));
	memory->store(address++, LOBYTE(a16));
}
Example #16
0
void AR16(const Instr *instr, word a16, byte r16)
{
	memory->store(address++, OPCODE(instr, AM_AR16));
	memory->store(address++, r16);
	memory->store(address++, HIBYTE(a16));
	memory->store(address++, LOBYTE(a16));
}
Example #17
0
static int
xfrd_handle_notify_reply(struct notify_zone_t* zone, buffer_type* packet)
{
	if((OPCODE(packet) != OPCODE_NOTIFY) ||
		(QR(packet) == 0)) {
		log_msg(LOG_ERR, "xfrd: zone %s: received bad notify reply opcode/flags",
			zone->apex_str);
		return 0;
	}
	/* we know it is OPCODE NOTIFY, QUERY_REPLY and for this zone */
	if(ID(packet) != zone->notify_query_id) {
		log_msg(LOG_ERR, "xfrd: zone %s: received notify-ack with bad ID",
			zone->apex_str);
		return 0;
	}
	/* could check tsig, but why. The reply does not cause processing. */
	if(RCODE(packet) != RCODE_OK) {
		log_msg(LOG_ERR, "xfrd: zone %s: received notify response error %s from %s",
			zone->apex_str, rcode2str(RCODE(packet)),
			zone->notify_current->ip_address_spec);
		if(RCODE(packet) == RCODE_IMPL)
			return 1; /* rfc1996: notimpl notify reply: consider retries done */
		return 0;
	}
	DEBUG(DEBUG_XFRD,1, (LOG_INFO, "xfrd: zone %s: host %s acknowledges notify",
		zone->apex_str, zone->notify_current->ip_address_spec));
	return 1;
}
Example #18
0
void MI16(const Instr *instr, byte m16, word i16)
{
	memory->store(address++, OPCODE(instr, AM_MI16));
	memory->store(address++, m16);
	memory->store(address++, HIBYTE(i16));
	memory->store(address++, LOBYTE(i16));
}
Example #19
0
static void Otypei(char *line, int k, int *macode){

	int machCode = 0;
	machCode |= OPCODE(k);
	///itoa(machCode, *macode, 10);
	*macode = machCode;
}
Example #20
0
int _Dasm_ReadModRmAndSid (int nCur, BYTE * pInst)
{
  int nSize = 0 ;

  TRACE_INFO (TEXT("inst=0x%02X, mod=%d, opcode=%d, rm=%d\n"), 
	      pInst[0], OPCODE(pInst[nCur]), MOD(pInst[nCur]), RM(pInst[nCur])) ;
  
  switch( MOD(pInst[nCur]) )
    {
    case 0: // Mod==00 => No disp

      // /!\ not valid if R/M is 4
      switch( RM(pInst[nCur]) )
	{   
	case 4: // an SIB follows
	  nSize = nCur + 2 ;
	  break ;   
	case 5:  // has disp32
	  nSize = nCur + 5 ;
	  break ;
	default:
	  nSize = nCur + 1 ;
	}

      break ; 
      
    case 1: // Mod==01 => 8 bits disp

      switch( RM(pInst[nCur]) )
	{ 
	case 4: // an SIB follows
	  nSize = nCur + 3 ;
	  break ;

	default:
	  nSize = nCur + 2 ;
	}

      break ;
      
    case 2: // Mod==10 => 32 bits disp

      // /!\ not valid if R/M is 4
      nSize = nCur + 5 ;

      if( RM(pInst[nCur])==4 )
	TRACE_WARNING (TEXT("Not tested instruction decoding\n")) ;
      
      break ;
      
    case 3:

      nSize = nCur + 1 ;

      break ; 
    }

  return nSize ;
}
Example #21
0
void AI16(const Instr *instr, word a16, word i16)
{
	memory->store(address++, OPCODE(instr, AM_AI16));
	memory->store(address++, HIBYTE(i16));
	memory->store(address++, LOBYTE(i16));
	memory->store(address++, HIBYTE(a16));
	memory->store(address++, LOBYTE(a16));
}
Example #22
0
/*** ParseMemSpec - parse special memory instruction
*
*   Purpose:
*	Given the users input, create the memory instruction.
*
*   Input:
*	*inString - present input position
*	pEntry - pointer into the asmTable for this instr type
*
*   Output:
*	*outstring - update input position
*
*   Returns:
*	the instruction.
*
*   Format:
*	op 
*
*************************************************************************/
ULONG ParseMemSpec(PUCHAR inString,
                   PUCHAR *outString,
                   POPTBLENTRY pEntry,
                   PULONG poffset)
{
    return(OPCODE(pEntry->opCode) +
           MEM_FUNC(pEntry->funcCode));
}
Example #23
0
ANON_BEGIN

/////////////////////////////////////////////////////////////////////////////
void RR8(const Instr *instr, byte dest, byte src)
{
	memory->store(address++, OPCODE(instr, AM_RR8));
	memory->store(address++, MAKEREG(dest, src));
}
Example #24
0
void
xfrd_handle_passed_packet(buffer_type* packet, int acl_num)
{
	uint8_t qnamebuf[MAXDOMAINLEN];
	uint16_t qtype, qclass;
	const dname_type* dname;
	region_type* tempregion = region_create(xalloc, free);
	xfrd_zone_t* zone;

	buffer_skip(packet, QHEADERSZ);
	if(!packet_read_query_section(packet, qnamebuf, &qtype, &qclass)) {
		region_destroy(tempregion);
		return; /* drop bad packet */
	}

	dname = dname_make(tempregion, qnamebuf, 1);
	DEBUG(DEBUG_XFRD,1, (LOG_INFO, "xfrd: got passed packet for %s, acl "
					   "%d", dname_to_string(dname,0), acl_num));

	/* find the zone */
	zone = (xfrd_zone_t*)rbtree_search(xfrd->zones, dname);
	if(!zone) {
		log_msg(LOG_INFO, "xfrd: incoming packet for unknown zone %s",
			dname_to_string(dname,0));
		region_destroy(tempregion);
		return; /* drop packet for unknown zone */
	}
	region_destroy(tempregion);

	/* handle */
	if(OPCODE(packet) == OPCODE_NOTIFY) {
		xfrd_soa_t soa;
		int have_soa = 0;
		int next;
		/* get serial from a SOA */
		if(ANCOUNT(packet) == 1 && packet_skip_dname(packet) &&
			xfrd_parse_soa_info(packet, &soa)) {
				have_soa = 1;
		}
		if(xfrd_handle_incoming_notify(zone, have_soa?&soa:NULL)) {
			if(zone->zone_handler.fd == -1
				&& zone->tcp_conn == -1 &&
				!zone->tcp_waiting && !zone->udp_waiting) {
					xfrd_set_refresh_now(zone);
			}
		}
		next = find_same_master_notify(zone, acl_num);
		if(next != -1) {
			zone->next_master = next;
			DEBUG(DEBUG_XFRD,1, (LOG_INFO,
				"xfrd: notify set next master to query %d",
				next));
		}
	}
	else {
		/* TODO handle incoming IXFR udp reply via port 53 */
	}
}
Example #25
0
int recieveACK(unsigned short index, struct sockaddr_in *destination_addr, int* sock, char verbose_text[LOG_INFO_SUBJECT_SIZE]) {

    char buffer[516];
    int recv_size;
    socklen_t destination_addr_len = sizeof(struct sockaddr_in);
    int rexmt = retransmission_time;

    int result;
    struct timeval t_retx;
    fd_set fds;

    FD_ZERO ( &fds ) ;
    FD_SET ( *sock, &fds ) ;

    t_retx.tv_sec = rexmt;
    t_retx.tv_usec = 0;

    result = select ( (*sock) + 1, &fds, NULL, NULL, &t_retx);
    printf("recieveACK: RESULT from SELECT = %x\n", result); //debug

    if (result == 1) {
        recv_size = recvfrom(*sock, buffer, 516, 0, (struct sockaddr*)destination_addr, &destination_addr_len);

        if( verbose == 1 ) {
            log_info(&buffer, recv_size, verbose_text, VERBOSE_ACTION_RECIEVE);
        }

        if (OPCODE(buffer) == RFC1350_OP_ERROR) {
            printError(buffer, recv_size);
            /* We recieved an error message */
            return -1;

        } else if (OPCODE(buffer) == RFC1350_OP_ACK) {
            tftp_ack_hdr message_ack;
            memcpy(&message_ack, buffer, recv_size);
            if (ntohs(message_ack.num_block) == index) {
                /* Expected ACK recieved. Send next data package */
                return 1;
            }
        }
    }

    /* ACK or message was unexpected. Package must be resent */
    return 0;
}
Example #26
0
ULONG ParseIntOp(PUCHAR inString,
                 PUCHAR *outString,
                 POPTBLENTRY pEntry,
                 PULONG poffset)
{
    ULONG instruction;
    ULONG Ra, Rb, Rc;
    ULONG lit;
    ULONG Format;	// Whether there is a literal or 3rd reg

    instruction = OPCODE(pEntry->opCode) +
                  OP_FNC(pEntry->funcCode);

    Ra = GetIntReg(inString, &inString);

    if (!TestCharacter(inString, &inString, ','))
 	error(OPERAND);

    if (TestCharacter(inString, &inString, '#')) {

        //
        // User is giving us a literal value

        lit = GetValue(inString, &inString, TRUE, WIDTH_LIT);
        Format = RBV_LITERAL_FORMAT;

    } else {

        //
        // using a third register value

        Rb = GetIntReg(inString, &inString);
        Format = RBV_REGISTER_FORMAT;
    }

    if (!TestCharacter(inString, &inString, ','))
 	error(OPERAND);

    Rc = GetIntReg(inString, &inString);

    if (!TestCharacter(inString, &inString, '\0'))
 	error(EXTRACHARS);

    instruction = instruction +
                  REG_A(Ra) +
                  RBV_TYPE(Format) +
                  REG_C(Rc);

    if (Format == RBV_REGISTER_FORMAT) {
        instruction = instruction + REG_B(Rb);
    } else {
        instruction = instruction + LIT(lit);
    }

    return(instruction);
}
Example #27
0
void end_loop(Servo *servo) {
	if (servo->loopsRemaining) { /* Jump back to start of loop */
		while ( OPCODE(servo->recipe[servo->pc]) != LOOP_START )
			servo->pc--;
		servo->loopsRemaining--;
	}

	/* Increment the PC */
	servo->pc++;
}
Example #28
0
static void Jtypei(char *line, int k, int *macode){

	int machCode = 0;
	int regA = line[REGAF] - '0';
	int regB = line[REGBF] - '0';
	machCode |= OPCODE(k)|REGA(regA)|REGB(regB);

	///itoa(machCode, *macode, 10);
	*macode = machCode;
}
Example #29
0
File: compile.c Project: xiaq/ngs
void compile_attr_name(COMPILATION_CONTEXT *ctx, ast_node *node, char **buf, size_t *idx, size_t *allocated, int need_result) {
	if(!need_result) {
		return;
	}
	if(node->type != IDENTIFIER_NODE) {
		compile_main_section(ctx, node, buf, idx, allocated, NEED_RESULT);
		return;
	}
	OPCODE(*buf, OP_PUSH_L_STR);
	L_STR(*buf, node->name);
}
Example #30
0
ULONG ParsePal(PUCHAR inString,
               PUCHAR *outString,
               POPTBLENTRY pEntry,
               PULONG poffset)
{
    if (!TestCharacter(inString, &inString, '\0'))
	error(EXTRACHARS);

    return(OPCODE(pEntry->opCode) +
           PAL_FNC(pEntry->funcCode));
}