home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 42 / Amiga Format AFCD42 (Issue 126, Aug 1999).iso / -serious- / programming / basic / blitzandpieces / showcpu.asc < prev    next >
Encoding:
Text File  |  1999-05-14  |  2.1 KB  |  130 lines

  1. ; jamesboyd@all-hail.freeserve.co.uk
  2.  
  3. .GetCPU
  4.  
  5. ; Returns :
  6.  
  7. ; 0 = 68000
  8. ; 1 = 68010
  9. ; 2 = 68020
  10. ; 3 = 68030
  11. ; 4 = 68040
  12. ; 6 = 68060
  13.  
  14. Function.b GetCPU {}
  15.  
  16. cpu.b=0
  17.  
  18. *e.ExecBase = Peek.l(4)
  19.  
  20. #AFF_68060=(1 LSL 7)
  21.  
  22. If *e\AttnFlags & #AFF_68010
  23.   If *e\AttnFlags & #AFF_68020
  24.     If *e\AttnFlags & #AFF_68030
  25.       If *e\AttnFlags & #AFF_68040
  26.         If *e\AttnFlags & #AFF_68060
  27.           cpu=6
  28.         Else cpu=4
  29.         EndIf
  30.       Else cpu=3
  31.       EndIf
  32.     Else cpu=2
  33.     EndIf
  34.   Else cpu=1
  35.   EndIf
  36. Else cpu=0
  37. EndIf
  38.  
  39. Function Return cpu
  40. End Function
  41.  
  42. ;-----------------------------------------------------------------
  43.  
  44. .GetFPU
  45.  
  46. ; Returns :
  47.  
  48. ; 0 = No FPU
  49. ; 1 = 68881 FPU
  50. ; 2 = 68882 FPU
  51. ; 3 = 68040 FPU (no math emulation)
  52. ; 4 = 68040 FPU (math emulation)
  53. ; 5 = 68060 FPU (no math emulation)
  54. ; 6 = 68060 FPU (math emulation)
  55.  
  56. Function.b GetFPU {}
  57.  
  58. fpu.b=0
  59.  
  60. *e.ExecBase = Peek.l(4)
  61.  
  62. #AFF_68060=(1 LSL 7)
  63.  
  64. If *e\AttnFlags & #AFF_68881
  65.   If *e\AttnFlags & #AFF_68882
  66.     fpu=2
  67.   Else fpu=1
  68.   EndIf
  69.  
  70.   If *e\AttnFlags & #AFF_FPU40
  71.     fpu=4                         ; 68040 FPU (math emulation)
  72.     If *e\AttnFlags & #AFF_68060  ; check for 060...
  73.       fpu=6                       ; 68060 FPU (math emulation)
  74.     EndIf
  75.   EndIf
  76.  
  77. Else fpu=0                        ; No 68881 or 68882
  78.  
  79.   If *e\AttnFlags & #AFF_FPU40    ; check if it's an 040 without 6888x emulation...
  80.     fpu=3                         ; 68040 FPU (no math emulation)
  81.     If *e\AttnFlags & #AFF_68060  ; check for 060...
  82.       fpu=5                       ; 68060 FPU (no math emulation)
  83.     EndIf
  84.   EndIf
  85.  
  86. EndIf
  87.  
  88. Function Return fpu
  89. End Function
  90.  
  91. ; demo :
  92.  
  93. WBStartup
  94.  
  95. Select GetCPU{}
  96.   Case 0
  97.     cpu$="68000"
  98.   Case 1
  99.     cpu$="68010"
  100.   Case 2
  101.     cpu$="68020"
  102.   Case 3
  103.     cpu$="68030"
  104.   Case 4
  105.     cpu$="68040"
  106.   Case 6
  107.     cpu$="68060"
  108. End Select
  109.  
  110. Select GetFPU{}
  111.   Case 0
  112.     fpu$="None"
  113.   Case 1
  114.     fpu$="68881"
  115.   Case 2
  116.     fpu$="68882"
  117.   Case 3
  118.     fpu$="68040 FPU (no math emulation)"
  119.   Case 4
  120.     fpu$="68040 FPU (math emulation)"
  121.   Case 5
  122.     fpu$="68060 FPU (no math emulation)"
  123.   Case 6
  124.     fpu$="68060 FPU (math emulation)"
  125. End Select
  126.  
  127. r.b=RTEZRequest ("ShowCPU","CPU : "+cpu$+Chr$(10)+"FPU : "+fpu$,"Perfect!")
  128. End
  129.  
  130.