Commit d5f01a7dbdeaac43d37a76ee22494b7b917b452a
authorMichel Pollet <buserror@gmail.com>
Wed, 10 Jun 2015 20:06:15 +0000 (21:06 +0100)
committerMichel Pollet <buserror@gmail.com>
Wed, 10 Jun 2015 20:06:15 +0000 (21:06 +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;