home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / t / turbors.zip / EXAMPLES.S next >
Text File  |  1993-02-19  |  3KB  |  78 lines

  1. ;    --------------------------------------------------------
  2. ;    Detect_TurboRS - Will set Tbrs_Flag if TurboRS is found
  3. ;       will also set Tbrs_Struct to point to TurboRS control
  4. ;       structure if found via software
  5. ;    --------------------------------------------------------
  6. Detect_TurboRS:
  7.     clr    Tbrs_Flag    ; Assume TurboRS not present
  8.     pea    .work        ; Run detection code in
  9.     move    #38,-(sp)    ;  Supervisor mode
  10.     trap    #14        ; Xbios : Supexec( .work )
  11.     addq.l    #6,sp
  12.     rts
  13.  
  14. ;    Software Detection Code -- Run from Supervisor mode
  15. ;     - Will set Tbrs_Flag if TurboRS is active
  16. ;     - Will set Tbrs_Struct to the address of control structure
  17. ;
  18. ;    This code scans the cookie jar for the TBRS cookie
  19. ;    created by the driver and checks it for validity
  20. ;
  21. ;    ! THIS IS THE PREFERRED METHOD OF DETECTING TURBORS !
  22.  
  23. .work:    move.l    $5A0.w,a0    ; Get cookie jar pointer
  24.     tst.l    a0        ; Cookie jar present?
  25.     beq    .done        ;  if not, we're done
  26. .loop:    tst.l    (a0)        ; At end of cookie jar?
  27.     beq    .done        ;  if so, we're done
  28.     cmp.l    #'TBRS',(a0)+    ; TurboRS cookie found?
  29.     beq    .found        ;  if so, validate it
  30.     addq.l    #4,a0        ; Skip value of current cookie
  31.     bra    .loop        ; Keep Searching
  32.  
  33. .found: move.l    (a0)+,a1    ; Valid TurboRS cookie?
  34.     cmp.l    #$31415926,(a1) ;  if not, keep searching
  35.     bne    .loop
  36.     move.l    a1,Tbrs_Struct    ; Save Structure Pointer
  37.     move    #1,Tbrs_Flag    ; Set Tbrs_Flag = Found
  38. .done:    rts
  39.  
  40. ;    Hardware Detection Code -- Run from Supervisor mode
  41. ;     - Will set Tbrs_Flag if TurboRS is present
  42. ;
  43. ;    This codes detects the hardware by attempting to set it
  44. ;    to 115200 baud then verifying the set by counting the
  45. ;    number of characters it can send
  46. ;
  47. ;    ! USE ONLY IF YOUR PROGRAM MUST DIRECTLY ACCESS THE ACIAS !
  48.  
  49. .work:    move.b    $FA07.w,d2    ; Preserve MFP Interrupt State
  50.     move.b    $FA13.w,d3
  51.     and.b    #$E1,$FA07.w    ; Mask Off Modem1 Interrupts
  52.     and.b    #$E1,$FA13.w
  53.     and.b    #$F0,$FA1D.w    ; Set Timer D for 9600 Baud
  54.     or.b    #1,$FA1D.w
  55.     move.b    #2,$FA25.w
  56.     move.b    #$D6,$FC00.w    ; Set ACIAs for 115200 clock
  57.     move.b    #$D5,$FC04.w
  58.     bset    #0,$FA2D.w    ; Ensure Transmitter Enabled
  59.     move.l    $4BA.w,d1    ; Set d1 = 1/10s from now
  60.     add.l    #20,d1
  61.     clr    d0        ; Use d0 = character count
  62.  
  63. .loop:    move.b    #-1,$FA2F.w    ; Transmit $FF
  64.     addq    #1,d0        ; Count Character
  65. .flush:    btst    #7,$FA2D.w    ; Character Transmitted?
  66.     beq    .flush        ;  nope, wait till it is
  67.     cmp.l    $4BA.w,d1    ; Time Expired?
  68.     bgt    .loop        ;  if not, transmit again
  69.  
  70.     move.b    #$96,$FC00.w    ; Reset ACIAs for Timer D clock
  71.     move.b    #$95,$FC04.w
  72.     move.b    d2,$FA07.w    ; Restore MFP Interrupt State
  73.     move.b    d3,$FA13.w
  74.     cmp    #200,d0     ; 200 or more characters sent?
  75.     blt    .done        ;  if not, we're done
  76.     move    #1,Tbrs_Flag    ; Set Tbrs_Flag = found
  77. .done:    rts
  78.