target/whirl.c
static void emit_one(WhirlCodeSegment *segment, RingState *state) {
    if (state->active_ring == MATH_RING) {
        if (state->math_dir == CLOCKWISE) {
            state->cur_math_pos++;
            if (state->cur_math_pos == NUM_CMDS_PER_RING) {
                state->cur_math_pos = 0;
            }
        }
        else {
            if (state->cur_math_pos == 0) {
                state->cur_math_pos = NUM_CMDS_PER_RING;
            }
            state->cur_math_pos--;
        }
    }
    else {
        if (state->op_dir == CLOCKWISE) {
            state->cur_op_pos++;
            if (state->cur_op_pos == NUM_CMDS_PER_RING) {
                state->cur_op_pos = 0;
            }
        }
        else {
            if (state->cur_op_pos == 0) {
                state->cur_op_pos = NUM_CMDS_PER_RING;
            }
            state->cur_op_pos--;
        }
    }

    state->last_is_zero = false;
    emit_instruction(segment, '1');    
}
// Adds a 1 instruction to the current code segment, and update the current
// ring state to account for it
Adds a 1 instruction to the current code segment, and update the current
ring state to account for it
Adds a 1 instruction to the current code segment and update the current ring state to account for it
static void emit_one(WhirlCodeSegment *segment, RingState *state) {
    if (state->active_ring == MATH_RING) {
        if (state->math_dir == CLOCKWISE) {
            state->cur_math_pos++;
            if (state->cur_math_pos == NUM_CMDS_PER_RING) {
                state->cur_math_pos = 0;
            }
        }
        else {
            if (state->cur_math_pos == 0) {
                state->cur_math_pos = NUM_CMDS_PER_RING;
            }
            state->cur_math_pos--;
        }
    }
    else {
        if (state->op_dir == CLOCKWISE) {
            state->cur_op_pos++;
            if (state->cur_op_pos == NUM_CMDS_PER_RING) {
                state->cur_op_pos = 0;
            }
        }
        else {
            if (state->cur_op_pos == 0) {
                state->cur_op_pos = NUM_CMDS_PER_RING;
            }
            state->cur_op_pos--;
        }
    }
    state->last_is_zero = false;
    emit_instruction(segment, '1');    
}
static void emit_one ( WhirlCodeSegment * segment , RingState * state ) { if ( state -> active_ring == MATH_RING ) { if ( state -> math_dir == CLOCKWISE ) { state -> cur_math_pos ++ ; if ( state -> cur_math_pos == NUM_CMDS_PER_RING ) { state -> cur_math_pos = 0 ; } } else { if ( state -> cur_math_pos == 0 ) { state -> cur_math_pos = NUM_CMDS_PER_RING ; } state -> cur_math_pos -- ; } } else { if ( state -> op_dir == CLOCKWISE ) { state -> cur_op_pos ++ ; if ( state -> cur_op_pos == NUM_CMDS_PER_RING ) { state -> cur_op_pos = 0 ; } } else { if ( state -> cur_op_pos == 0 ) { state -> cur_op_pos = NUM_CMDS_PER_RING ; } state -> cur_op_pos -- ; } } state -> last_is_zero = false ; emit_instruction ( segment , ' ' ) ; }
Adds a 1 instruction to the current code segment, and update the current
ring state to account for it
Adds a 1 instruction to the current code segment and update the current ring state to account for it