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]; }
int pop(void) { if (is_empty()) stack_underflow(); return *--top; }
int pop(void) { if (is_empty()) { stack_underflow(); return 0; } else { return contents[--top]; } }
int pop(void){ if (is_empty()){ stack_underflow(); exit (EXIT_SUCCESS); }else{ return contents[--top]; } }
int pop(void) { if (is_empty()) { stack_underflow(); exit(1); } return contents[--top]; }
int pop(void) { if (is_empty()) { stack_underflow(); return -1; } else { top -= 1; return contents[top]; } }
static void fabs(void) { if (FPU_st0_tag ^ TW_Empty) { FPU_st0_ptr->sign = SIGN_POS; status_word &= ~SW_C1; } else stack_underflow(); }
static void fchs(void) { if (NOT_EMPTY_0) { FPU_st0_ptr->sign ^= SIGN_POS ^ SIGN_NEG; status_word &= ~SW_C1; } else stack_underflow(); }
int pop(void) { if (is_empty()) { stack_underflow(); } else { return content[--top]; } return 0; /* get rid of compiler warning */ }
state_t __DROP(context_t *ctx) { int x; if (popnum(ctx->ds, &x)) { return OK; } else { return stack_underflow(ctx); } }
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); } }
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); } }
state_t __TOR(context_t *ctx) { int x1; if (popnum(ctx->ds, &x1)) { pushnum(ctx->rs, x1); return OK; } else { return stack_underflow(ctx); } }
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); } }
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); } }
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); } }
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); } }
inline void pop() { if (c.empty()) throw stack_underflow(); c.pop_front(); }
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 */ }
inline const value_type& top() const { if (c.empty()) throw stack_underflow(); return c.front(); }