buserror/simavr — pull request #95 by bsekisser (2014-10-16 19:57:10+00:00)
Title: modify handling of interrupt state & remove duplicate code.

Interrupt state edge detection and wait states combined into multi
function variable. Enabling the removal of edge detection
code in the run loop and determining simplifying need to
service interrupts by placing the burden on code directly
influencing the interrupt handling state.

This also removes functionally duplicate code clause for BSET/BCLR.

modified: simavr/sim/sim_avr.c
edge detection code removed from both run loops... non
gdb loop does precheck of interrupt state, while not
necessary potentially saves a few cycles.
remove duplicate code BSET/BCLR.

modified: simavr/sim/sim_avr.h
uint8_t i_shadow changed to int8_t interrupt_state.

modified: simavr/sim/sim_core.c
changes to interrupt state are trapped and sent to be
handled by avr_sreg_set_s_i().
multi-cycle loop simplified to check avr->interrupt_state.

modified: simavr/sim/sim_core.h
static inline avr_sreg_set_s_i() - handles changes to global
interrupt state and ensures wait states if I
flag changes from 0 -> 1. superfluous 1 -> 1
states are ignored should they occur. and
disabling interrupts clears avr->interrupt_state.
interrupt state changes from SET_SREG_FROM directed to
avr_sreg_set_s_i();

modified: simavr/sim/sim_interrupts.c
avr_interrupt_reset()
interrupt_state cleared during reset.
avr_raise_intrrupt()
check interrupts enabled and no pending
interrupt_state before marking pending interrupt state.
avr_service_interrupts()
servicing code changed to tick pending wait state then
mark for any pending interrupts or set to zero
if none waiting.
on interrupt, direct interrupt state change to
avr_sreg_set_s_i();

modified: simavr/sim/sim_interrupts.h
remove pending_wait.

modified: tests/tests.c
interrupt edge dectection code removed from test run loop.