Пример #1
0
void
fxch_i()
{
	/* fxch st(i) */
	FPU_REG t;
	register FPU_REG *sti_ptr = &st(FPU_rm);

	if (FPU_st0_tag == TW_Empty) {
		if (sti_ptr->tag == TW_Empty) {
			stack_underflow();
			stack_underflow_i(FPU_rm);
			return;
		}
		reg_move(sti_ptr, FPU_st0_ptr);
		stack_underflow_i(FPU_rm);
		return;
	}
	if (sti_ptr->tag == TW_Empty) {
		reg_move(FPU_st0_ptr, sti_ptr);
		stack_underflow();
		return;
	}
	reg_move(FPU_st0_ptr, &t);
	reg_move(sti_ptr, FPU_st0_ptr);
	reg_move(&t, sti_ptr);
}
char pop(void)
{
    if (is_empty())
        stack_underflow();
    else
        return contents[--top];
}
int pop(void)
{
  if(is_empty())
    stack_underflow();
  else
    return stack[--top];
}
Пример #4
0
int
pop(void)
{
	if (is_empty())
		stack_underflow();
	return *--top;
}
Пример #5
0
int pop(void) {
    if (is_empty()) {
        stack_underflow();
        return 0;
    } else {
        return contents[--top];
    }
}
Пример #6
0
int pop(void){
	if (is_empty()){
		stack_underflow();
		exit (EXIT_SUCCESS);
	}else{
		return contents[--top];
	}
}
Пример #7
0
int pop(void)
{
	if (is_empty()) {
		stack_underflow();
		exit(1);
	}
	return contents[--top];
}
Пример #8
0
int pop(void) {
    if (is_empty()) {
        stack_underflow();
        return -1;
    } else {
        top -= 1;
        return contents[top];
    }
}
Пример #9
0
static void
fabs(void)
{
	if (FPU_st0_tag ^ TW_Empty) {
		FPU_st0_ptr->sign = SIGN_POS;
		status_word &= ~SW_C1;
	} else
		stack_underflow();
}
Пример #10
0
static void
fchs(void)
{
	if (NOT_EMPTY_0) {
		FPU_st0_ptr->sign ^= SIGN_POS ^ SIGN_NEG;
		status_word &= ~SW_C1;
	} else
		stack_underflow();
}
Пример #11
0
int pop(void)
{
  if (is_empty()) {
    stack_underflow();
  }
  else {
    return content[--top];
  }

  return 0; /* get rid of compiler warning */
} 
Пример #12
0
state_t __DROP(context_t *ctx)
{
    int x;
    if (popnum(ctx->ds, &x))
    {
        return OK;
    }
    else
    {
        return stack_underflow(ctx);
    }
}
Пример #13
0
state_t __2DROP(context_t *ctx)
{
    int x1, x2;
    if (popnum(ctx->ds, &x2) && popnum(ctx->ds, &x1))
    {
        return OK;
    }
    else
    {
        return stack_underflow(ctx);
    }
}
Пример #14
0
state_t __QDUP(context_t *ctx)
{
    int x;
    if (peeknum(ctx->ds, &x))
    {
        if (x != 0) pushnum(ctx->ds, x);
        return OK;
    }
    else
    {
        return stack_underflow(ctx);
    }
}
Пример #15
0
state_t __TOR(context_t *ctx)
{
    int x1;
    if (popnum(ctx->ds, &x1))
    {
        pushnum(ctx->rs, x1);
        return OK;
    }
    else
    {
        return stack_underflow(ctx);
    }
}
Пример #16
0
state_t __SWAP(context_t *ctx)
{
    int x1, x2;
    if (popnum(ctx->ds, &x2) && popnum(ctx->ds, &x1))
    {
        pushnum(ctx->ds, x2);
        pushnum(ctx->ds, x1);
        return OK;
    }
    else
    {
        return stack_underflow(ctx);
    }
}
Пример #17
0
state_t __2OVER(context_t *ctx)
{
    int x1, x2, x3, x4;
    if (popnum(ctx->ds, &x4) && popnum(ctx->ds, &x3) && popnum(ctx->ds, &x2) && popnum(ctx->ds, &x1))
    {
        pushnum(ctx->ds, x1);
        pushnum(ctx->ds, x2);
        pushnum(ctx->ds, x3);
        pushnum(ctx->ds, x4);
        pushnum(ctx->ds, x1);
        pushnum(ctx->ds, x2);
        return OK;
    }
    else
    {
        return stack_underflow(ctx);
    }
}
Пример #18
0
static void
single_arg_error(void)
{
    switch (FPU_st0_tag) {
    case TW_NaN:
        if (!(FPU_st0_ptr->sigh & 0x40000000)) {	/* Signaling ? */
            EXCEPTION(EX_Invalid);
            /* Convert to a QNaN */
            FPU_st0_ptr->sigh |= 0x40000000;
        }
        break;		/* return with a NaN in st(0) */
    case TW_Empty:
        stack_underflow();	/* Puts a QNaN in st(0) */
        break;
#ifdef PARANOID
    default:
        EXCEPTION(EX_INTERNAL | 0x0112);
#endif				/* PARANOID */
    }
}
static void handle_0_opcode(opcode instr, chip_8_cpu cpu) {
    // 0nnn opcode not implemented
    switch (get_last_byte(instr)) {
        case 0xE0:
            clear_display();
            break;
        case 0xEE: {
            int8_t stack_pointer = cpu->stack_pointer - 1;
            if (stack_pointer == -1) {
                stack_underflow(cpu);
            }
            cpu->stack_pointer = stack_pointer;
            cpu->program_counter = cpu->stack[stack_pointer];
            cpu->performed_jump = true;
            break;
        }
        case 0xFD:
            cpu->halt = true;
            return;
        default:
            not_implemented(cpu, instr);
    }
}
Пример #20
0
void
fld_i_()
{
	FPU_REG *st_new_ptr;

	if (STACK_OVERFLOW) {
		stack_overflow();
		return;
	}
	/* fld st(i) */
	if (NOT_EMPTY(FPU_rm)) {
		reg_move(&st(FPU_rm), st_new_ptr);
		push();
	} else {
		if (control_word & EX_Invalid) {
			/* The masked response */
			push();
			stack_underflow();
		} else
			EXCEPTION(EX_StackUnder);
	}

}
Пример #21
0
 inline void pop()                     { 
     if (c.empty())
         throw stack_underflow();
     c.pop_front(); 
 }
Пример #22
0
static void
fxtract(void)
{
    FPU_REG *st_new_ptr;
    register FPU_REG *st1_ptr = FPU_st0_ptr;	/* anticipate */

    if (STACK_OVERFLOW) {
        stack_overflow();
        return;
    }
    if (!(FPU_st0_tag ^ TW_Valid)) {
        long    e;

#ifdef DENORM_OPERAND
        if ((FPU_st0_ptr->exp <= EXP_UNDER) && (denormal_operand()))
            return;
#endif				/* DENORM_OPERAND */

        push();
        reg_move(st1_ptr, FPU_st0_ptr);
        FPU_st0_ptr->exp = EXP_BIAS;
        e = st1_ptr->exp - EXP_BIAS;
        convert_l2reg(&e, st1_ptr);
        return;
    } else if (FPU_st0_tag == TW_Zero) {
        char    sign = FPU_st0_ptr->sign;
        divide_by_zero(SIGN_NEG, FPU_st0_ptr);
        push();
        reg_move(&CONST_Z, FPU_st0_ptr);
        FPU_st0_ptr->sign = sign;
        return;
    } else if (FPU_st0_tag == TW_Infinity) {
        char    sign = FPU_st0_ptr->sign;
        FPU_st0_ptr->sign = SIGN_POS;
        push();
        reg_move(&CONST_INF, FPU_st0_ptr);
        FPU_st0_ptr->sign = sign;
        return;
    } else if (FPU_st0_tag == TW_NaN) {
        if (!(FPU_st0_ptr->sigh & 0x40000000)) {	/* Signaling ? */
            EXCEPTION(EX_Invalid);
            /* Convert to a QNaN */
            FPU_st0_ptr->sigh |= 0x40000000;
        }
        push();
        reg_move(st1_ptr, FPU_st0_ptr);
        return;
    } else if (FPU_st0_tag == TW_Empty) {
        /* Is this the correct
         * behaviour? */
        if (control_word & EX_Invalid) {
            stack_underflow();
            push();
            stack_underflow();
        } else
            EXCEPTION(EX_StackUnder);
    }
#ifdef PARANOID
    else
        EXCEPTION(EX_INTERNAL | 0x119);
#endif				/* PARANOID */
}
Пример #23
0
 inline const value_type& top() const  { 
     if (c.empty())
         throw stack_underflow();
     return c.front();
 }