home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / software / testi / corsoasm / sorgenti7 / lezione11n1.s < prev    next >
Text File  |  1995-09-29  |  3KB  |  103 lines

  1.  
  2. ; Lezione11n1.s -Routine di temporizzazione che permette di attendere un
  3. ;         certo numero di microsecondi usando un timer A del CIAA/B
  4.  
  5. ; Questa routine di test permette di verificare a quante linee video
  6. ; corrispondono un certo un certo numero di microsecondi.
  7. ; (la parte ROSSA dello schermo e' quella in cui viene eseguita la routine)
  8.  
  9.  
  10. MICS:    equ    2000        ; ~2000 microsecondi = ~2 millisecondi
  11.                 ; valore = mics/1,4096837
  12.                 ; 1 microsecondo = 1 sec/1 milione
  13.                 ; NOTA: per raffrontare questa routine con
  14.                 ; quella che attende le linee raster, fate
  15.                 ; conto che 200 millisecondi corrispondono
  16.                 ; circa a 5 linee di raster, 400 millisecondi
  17.                 ; a 9,5 linee, 600 millis. a 14 linee eccetera
  18.  
  19. Start:
  20.     move.l    4.w,a6        ; Execbase in a6
  21.     jsr    -$84(a6)    ; forbid
  22.     jsr    -$78(a6)    ; disable
  23.     LEA    $DFF000,A5
  24.  
  25. WBLANNY:
  26.     MOVE.L    4(A5),D0    ; $dff004 - VPOSR/VHPOSR
  27.     ANDI.L    #$1FF00,D0    ; con interessano solo i bit della linea vert.
  28.     CMPI.L    #$08000,D0    ; aspetta la linea $080
  29.     BNE.S    WBLANNY
  30.  
  31.     move.w    #$f00,$180(a5)    ; Colore zero ROSSO
  32.  
  33.     bsr.s    CIAMIC
  34.  
  35.     move.w    #$0f0,$180(a5)    ; Colore zero VERDE
  36.  
  37.     btst    #6,$bfe001
  38.     bne.s    WBLANNY
  39.  
  40.  
  41.     move.l    4.w,a6        ; Execbase in a6
  42.     jsr    -$7e(a6)    ; enable
  43.     jsr    -$8a(a6)    ; permit
  44.     rts
  45.  
  46. ;    Ecco la routine che aspetta un numero specifico di MICROSECONDI,
  47. ;    usando il timer A del CIAB. Per usare il timer A del CIAA basta
  48. ;    sostituire il "lea $bfd000,a4" con un "lea $bfe001,a4". Nel listato
  49. ;    e' gia' presente, basta togliere il punto e virgola, e metterlo
  50. ;    invece al CIAB base. Comunque e' meglio usare il CIAB perche' il
  51. ;    timer CIAA e' usato dal sistema operativo per vari compiti.
  52.  
  53. CIAMIC:
  54.     movem.l    d0/a4,-(sp)        ; salviamo i registri usati
  55.     lea    $bfd000,a4        ; CIAB base
  56.      lea    $bfe001,a4        ; CIAA base (se volete usare il B)
  57.     move.b  $e00(a4),d0        ; $bfde00 - CRA, CIAB control reg. A
  58.     andi.b   #%11000000,d0        ; azzera i bit 0-5
  59.     ori.b    #%00001000,d0        ; One-Shot mode (runmode singolo)
  60.     move.b  d0,$e00(a4)        ; CRA - Setta il registro di controllo
  61.     move.b  #%01111110,$d00(a4)    ; ICR - cancella gli interrupts CIA
  62.     move.b  #(MICS&$FF),$400(a4)    ; TALO - metti il byte basso del time
  63.     move.b  #(MICS>>8),$500(a4)    ; TAHI - metti il byte alto del time
  64.     bset.b  #0,$e00(a4)        ; CRA - Start timer!!
  65. wait:
  66.     btst.b  #0,$d00(a4)    ; ICR - Attendiamo che il tempo sia scaduto
  67.     beq.s   wait
  68.     movem.l    (sp)+,d0/a4        ; ripristiniamo i registri
  69.     rts
  70.  
  71.     end
  72.  
  73. ; CIA:    ICR  (Interrupt Control Register)                [d]
  74. ;
  75. ; 0    TA        underflow
  76. ; 1    TB        underflow
  77. ; 2    ALARM        TOD alarm
  78. ; 3    SP        serial port full/empty
  79. ; 4    FLAG        flag
  80. ; 5-6    unused
  81. ; 7  R    IR
  82. ; 7  W    set/clear
  83. ;
  84. ; CIA:  CRA, CRB  (Control Register)                    [e-f]
  85. ;
  86. ; 0    START        0 = stop / 1 = start TA; {0}=0 when TA underflow
  87. ; 1    PBON        1 = TA output on PB / 0 = normal mode
  88. ; 2    OUTMODE        1 = toggle / 0 = pulse
  89. ; 3    RUNMODE        1 = one-shot / 0 = continous mode
  90. ; 4  S    LOAD        1 = force load (strobe, always 0)
  91. ; 5   A    INMODE        1 = TA counts positive CNT transition
  92. ;            0 = TA counts 02 pulses
  93. ; 6   A    SPMODE        serial port....
  94. ; 7   A    unused
  95. ; 6-5 B    INMODE        00 = TB counts 02 pulses
  96. ;            01 = TB counts positive CNT transition
  97. ;            10 = TB counts TA underflow pulses
  98. ;            11 = TB counts TA underflow pulses while CNT is high
  99. ; 7   B    ALARM        1 = writing TOD sets alarm
  100. ;            0 = writing TOD sets clock
  101. ;            Reading TOD always reads TOD clock
  102.  
  103.