* device/lib/printfl.c: 13 bytes less __data mem (12 more __idata)
[fw/sdcc] / device / lib / ds390 / tinibios.c
index 6be2f3671752a84271140ae3f306deeb756fd603..b9c89688d7baf3e8b768e4c4e4ff0f894d5c05a0 100755 (executable)
@@ -134,8 +134,10 @@ unsigned int cpuSpeed;
 
 void CpuSpeed(unsigned int speed) {
 
+  #if 0
   while (0 && (EXIF&0x04))
     ; // cpu operates from ring buffer
+  #endif
   PMR = 0x80; // div4, CTM off, multiplier 2x
   switch (speed) 
     {
@@ -487,37 +489,34 @@ void ClockInit() {
 // This needs to be SUPER fast. What we really want is:
 
 #if 0
-void ClockIrqHandler (void) interrupt 1 {
+void junk_ClockIrqHandler (void) interrupt 10 {
   TL0=timer0ReloadValue&0xff;
   TH0=timer0ReloadValue>>8;
   milliSeconds++;
 }
 #else
 // but look at the code, and the pushes and pops, so:
-#pragma EXCLUDE b,dpl,dph,dpx
-void ClockIrqHandler (void) interrupt 1 {
+void ClockIrqHandler (void) interrupt 1 _naked
+{
   _asm
+    push acc
+    push psw
     mov _TL0,_timer0ReloadValue
     mov _TH0,_timer0ReloadValue+1
-    mov a,#0x01
-    add a,_milliSeconds+0
-    mov _milliSeconds+0,a
-    jnc _ClockIrqHandlerDone
-    clr a
-    addc a,_milliSeconds+1
-    mov _milliSeconds+1,a
-    jnc _ClockIrqHandlerDone
-    clr a
-    addc a,_milliSeconds+2
-    mov _milliSeconds+2,a
-    jnc _ClockIrqHandlerDone
     clr a
-    addc a,_milliSeconds+3
-    mov _milliSeconds+3,a
+    inc _milliSeconds+0
+    cjne a,_milliSeconds+0,_ClockIrqHandlerDone
+    inc _milliSeconds+1
+    cjne a,_milliSeconds+1,_ClockIrqHandlerDone
+    inc _milliSeconds+2
+    cjne a,_milliSeconds+2,_ClockIrqHandlerDone
+    inc _milliSeconds+3
    _ClockIrqHandlerDone:
+    pop psw
+    pop acc
+    reti
   _endasm;
 }
-#pragma EXCLUDE NONE
 #endif
 
 // we can't just use milliSeconds