User Tools

Site Tools



by Zed Yago

When stabilizing a IRQ, you often need a subroutine or macro which can delay a given amount of cycles.

delay:            ;delay 84-accu cycles, 0<=accu<=65
  lsr             ;2 cycles akku=akku/2 carry=1 if accu was odd, 0 otherwise
  bcc waste1cycle ;2/3 cycles, depending on lowest bit, same operation for both
  sta smod+1      ;4 cycles selfmodifies the argument of branch
  clc             ;2 cycles 
;now we have burned 10/11 cycles.. and jumping into a nopfield 
  bcc *+10        ;3 cycles
  .buf 32 $EA     ;just type 32x nop if your assembler doesnt support this command
                  ;  or type "!fill 32, $ea" if you are using ACME
  rts             ;6 cycles
base/delay.txt · Last modified: 2015-04-17 04:31 by