Commit 3a4fab8b693e4afca6e3b83ff7afc9e15bc56358
authorMichel Pollet <buserror@gmail.com>
Wed, 10 Jun 2015 20:06:15 +0000 (21:06 +0100)
committerMichel Pollet <buserror@gmail.com>
Thu, 2 Jul 2015 18:02:54 +0000 (19:02 +0100)
Simplified a few expressions

Signed-off-by: Michel Pollet <buserror@gmail.com>
simavr/sim/sim_interrupts.c

index a5e96ff1d38e9a06c1711cbeacb5127d7f95788e..b1539075077ed6b4d07b70aa5018386b73a84626 100644 (file)
@@ -225,25 +225,21 @@ void
 avr_service_interrupts(
                avr_t * avr)
 {
-       if (!avr->sreg[S_I])
+       if (!avr->sreg[S_I] || !avr->interrupt_state)
                return;
 
-       if (avr->interrupt_state) {
-               if (avr->interrupt_state < 0) {
-                       avr->interrupt_state++;
-                       if (avr->interrupt_state == 0)
-                               avr->interrupt_state = avr_has_pending_interrupts(avr);
-                       return;
-               }
-       } else
+       if (avr->interrupt_state < 0) {
+               avr->interrupt_state++;
+               if (avr->interrupt_state == 0)
+                       avr->interrupt_state = avr_has_pending_interrupts(avr);
                return;
+       }
 
        avr_int_table_p table = &avr->interrupts;
 
        // how many are pending...
-       int cnt = table->pending_w > table->pending_r ?
-                       table->pending_w - table->pending_r :
-                       (table->pending_w + INT_FIFO_SIZE) - table->pending_r;
+       int cnt = INT_FIFO_MOD(
+                               (table->pending_w + INT_FIFO_SIZE) - table->pending_r);
        // locate the highest priority one
        int min = 0xff;
        int mini = 0;