home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / phxass-4.00.lha / PhxAss / Examples / vbr.asm < prev    next >
Assembly Source File  |  1994-12-28  |  3KB  |  152 lines

  1. **
  2. **    VBR - Revision 2
  3. ** Switches the Vector Base to
  4. **    Chip- or Fast-RAM
  5. **
  6. **  Coded by Frank Wille 1994
  7. **
  8. **   Assembler: PhxAss V4.xx
  9. **
  10.  
  11.     machine 68010            ; 'cause of VBR
  12.  
  13.     include "lib/exec.i"
  14.     include "lib/dos.i"
  15.     include "exec/execbase.i"
  16.     include "exec/memory.i"
  17.  
  18. VBR_SIZE    = $400            ; size of vector base area in bytes
  19.  
  20.  
  21.  
  22.     code
  23.  
  24.  
  25.     move.l    ExecBase.w,a6
  26.     lea    DosName(pc),a1
  27.     moveq    #37,d0
  28.     jsr    OpenLibrary(a6)     ; open dos.library (OS2.04)
  29.     tst.l    d0
  30.     beq    error
  31.     move.l    d0,a4            ; a4 DOSBase
  32.     moveq    #0,d6            ; d6 Quiet-Flag
  33.     moveq    #0,d7            ; d7 VBR-Flag (1=Zero, -1=Fast)
  34.     exg    a4,a6
  35.     lea    cmd_template(pc),a0
  36.     move.l    a0,d1
  37.     clr.l    -(sp)
  38.     clr.l    -(sp)
  39.     clr.l    -(sp)
  40.     move.l    sp,d2
  41.     moveq    #0,d3
  42.     jsr    ReadArgs(a6)
  43.     move.l    d0,d1            ; ReadArgs-Error?
  44.     bne.s    1$
  45.     lea    12(sp),sp
  46.     jsr    IoErr(a6)
  47.     move.l    d0,d1
  48.     moveq    #0,d2
  49.     jsr    PrintFault(a6)        ; print error message
  50.     exg    a4,a6
  51.     bra    exit
  52. 1$:    jsr    FreeArgs(a6)
  53.     tst.l    (sp)+            ; VBR ZERO?
  54.     beq.s    2$
  55.     moveq    #1,d7            ; d7 Zero-VBR
  56.     addq.l    #4,sp
  57.     bra.s    3$
  58. 2$:    tst.l    (sp)+            ; VBR FAST?
  59.     sne    d7
  60. 3$:    tst.l    (sp)+            ; QUIET-Mode?
  61.     sne    d6
  62.     exg    a4,a6
  63.     moveq    #0,d5
  64.     move.b    AttnFlags+1(a6),d0    ; which processor is installed?
  65.     moveq    #3,d1
  66. 4$:    lsr.b    #1,d0
  67.     bcc.s    5$
  68.     add.w    #10,d5
  69.     dbf    d1,4$
  70.     tst.b    AttnFlags+1(a6)     ; 68060?
  71.     bpl.s    5$
  72.     add.w    #20,d5
  73. 5$:    sub.l    a2,a2
  74.     tst.w    d5            ; 68000? (no VBR available)
  75.     beq.s    6$
  76.     lea    getVBR(pc),a5
  77.     jsr    Supervisor(a6)        ; read VBR -> a2
  78.     move.l    #VBR_SIZE,d2
  79.     tst.b    d7            ; change it?
  80.     beq.s    6$
  81.     bsr.s    changeVBR
  82. 6$:    tst.b    d6            ; print new VBR and processor type
  83.     bne.s    exit
  84.     exg    a4,a6
  85.     move.l    a2,-(sp)
  86.     add.l    #68000,d5
  87.     move.l    d5,-(sp)
  88.     lea    vbr_info(pc),a0
  89.     move.l    a0,d1
  90.     move.l    sp,d2
  91.     jsr    VPrintf(a6)
  92.     addq.l    #8,sp
  93.     exg    a4,a6
  94. exit:    move.l    a4,a1
  95.     jsr    CloseLibrary(a6)
  96.     moveq    #0,d0
  97.     rts
  98. error:    moveq    #20,d0            ; Error!
  99.     rts
  100.  
  101.  
  102. changeVBR:
  103.     bmi.s    1$
  104.     move.l    a2,d0            ; copy VBR to $00000000
  105.     beq.s    3$            ; already there?
  106.     moveq    #0,d0
  107.     bra.s    2$
  108. 1$:    move.l    a2,a1            ; copy VBR to FAST-Ram
  109.     jsr    TypeOfMem(a6)
  110.     btst    #MEMB_FAST,d0        ; already located in FAST-Ram?
  111.     bne.s    3$
  112.     move.l    d2,d0
  113.     moveq    #MEMF_FAST|MEMF_PUBLIC,d1
  114.     jsr    AllocMem(a6)        ; allocate Fast-Ram for VBR
  115.     tst.l    d0
  116.     beq.s    3$            ; out of memory?
  117. 2$:    move.l    d0,a3
  118.     move.l    a2,a0
  119.     move.l    d0,a1
  120.     move.l    d2,d0
  121.     jsr    CopyMem(a6)
  122.     move.l    a2,-(sp)
  123.     move.l    a3,a2
  124.     lea    setVBR(pc),a5
  125.     jsr    Supervisor(a6)        ; activate new VBR
  126.     jsr    CacheClearU(a6)
  127.     move.l    (sp)+,d0
  128.     bne.s    4$
  129. 3$:    rts
  130. 4$:    move.l    d0,a1            ; free old VBR (except for Zero-VBRs)
  131.     move.l    d2,d0
  132.     jmp    FreeMem(a6)
  133.  
  134.  
  135. getVBR:
  136.     movec    VBR,a2
  137.     rte
  138.  
  139. setVBR:
  140.     movec    a2,VBR
  141.     rte
  142.  
  143.  
  144. DosName:
  145.     dc.b    "dos.library",0
  146. cmd_template:
  147.     dc.b    "ZERO/S,FAST/S,QUIET/S",0
  148. vbr_info:
  149.     dc.b    "cpu: %ld  vbr: $%08lx\n",0
  150.  
  151.     end
  152.