/*
 * input_int.c
 *
 *  Created on: 2016/11/24
 *      Author: takayun
 */
#include "hex_out.h"
#include <stdio.h>

#include "input_int.h"
#include "sys_register.h"

unsigned char PUSH_EVENT = 0;

void in_int() {
	push_int();
}

static void update_sw_reg(sw_t s) {
	global_registers[Ssw_data];
	global_registers[Ssw_inst];
	global_registers[Ssw_memi];
	global_registers[Ssw_regi];
	global_registers[Ssw_psel];
	global_registers[Ssw_rw];
	global_registers[Ssw_run];
}

void push_int() {
	char buf[12];
	static unsigned char status = 0;
	sw_t s;
	s.data = *switches;

	switch (status) {
	case 0:
		PUSH_EVENT = 0;
		if (*push_switches != 7) status = 1;
		//update_sw_reg(s);	// スイッチレジスタ更新
		sprintf(buf, "%x", s.sw.instruction_code);
		print_block(buf, 4, HEX0_3);
		break;
	case 1:
		if (*push_switches == 7) status = 2;
		break;
	case 2:
		PUSH_EVENT = 1;
		status = 0;
		break;
	default:
		status = 0;
		break;
	}
}
