home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 378.lha / cvbr / Vbr.Asm < prev    next >
Assembly Source File  |  1990-05-02  |  3KB  |  152 lines

  1. *
  2. * Change the vector base register on 68010+
  3. *
  4. * by Martin J. Laubach
  5. *
  6.  
  7. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8.  
  9.     incdir "inc:include.i"
  10.  
  11.     include "exec/execbase.i"
  12.     include "exec/libraries.i"
  13.     include "exec/tasks.i"
  14.  
  15. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  16.  
  17.     xdef    main
  18.  
  19.     xref    _AbsExecBase
  20.  
  21. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  22.  
  23. call    macro
  24.     xref    _LVO\1
  25.     jsr     _LVO\1(a6)
  26.     endm
  27.  
  28. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  29.  
  30. stdout    equr    d7
  31. DosBase    equr    a5
  32. Task    equr    a4
  33.  
  34. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  35.  
  36. main:    move.l    _AbsExecBase,a6
  37.     lea    DosName,a1
  38.     moveq    #0,d0
  39.     call    OpenLibrary        ; Open DOSBase to chat with user
  40.     move.l    d0,DosBase
  41.     tst.l    d0
  42.     beq    exit
  43.  
  44.     move.l    d0,a6
  45.     call    Output            ; get stdout
  46.     move.l    d0,stdout
  47.  
  48.     move.l    d0,d1
  49.     move.l    #SignOn,d2
  50.     moveq    #SignOnEnd-SignOn,d3
  51.     call    Write            ; say hello
  52.  
  53.     move.l    _AbsExecBase,a6
  54.     cmp.w    #33,LIB_VERSION(a6)
  55.     bls    noversion        ; check for the right kickstart
  56.  
  57.     btst.b    #AFB_68010,AttnFlags+1(a6)
  58.     beq    novbr            ; and the right processor
  59.  
  60.     move.l    a5,a0
  61.     lea    getvbr,a5
  62.     call    Supervisor        ; become SUPERMAN!
  63.  
  64.     tst.l    d4
  65.     bne.s    already            ; vbr already set
  66.  
  67.     move.l    #$400,d0
  68.     moveq    #0,d1
  69.     call    AllocMem        ; get memory block for vectors
  70.     move.l    d0,Memory
  71.     beq.s    nomem
  72.  
  73.     sub.l    a0,a0
  74.     move.l    Memory,a1
  75.     move.l    #$400,d0
  76.     call    CopyMem            ; now copy the exception vectors
  77.  
  78.     move.l    Memory,d4
  79.     move.l    a5,a0
  80.     lea    setvbr,a5
  81.     call    Supervisor
  82.  
  83. exit0:    move.l    DosBase,a1
  84.     move.l    _AbsExecBase,a6
  85.     call    CloseLibrary        ; clean up
  86.  
  87. exit:    moveq    #0,d0
  88.     rts
  89.  
  90. getvbr:    move.l    a0,a5
  91.     movec.l    vbr,d4
  92.     rte
  93.  
  94. setvbr:    move.l    a0,a5
  95.     movec.l    d4,vbr
  96.     rte
  97.  
  98. already:
  99.     move.l    d4,d5
  100.  
  101.     moveq    #0,d4
  102.     move.l    a5,a0
  103.     lea    setvbr,a5
  104.     call    Supervisor
  105.  
  106.     move.l    d5,a0
  107.     sub.l    a1,a1
  108.     move.l    #$400,d0
  109.     call    CopyMem
  110.  
  111.     move.l    d5,a1
  112.     move.l    #$400,d0
  113.     call    FreeMem
  114.  
  115.     move.l    #Already,d2
  116.     moveq    #AlreadyEnd-Already,d3
  117.     bra.s    Panic
  118.  
  119. nomem:    move.l    #NoMem,d2
  120.     moveq    #NoMemEnd-NoMem,d3
  121.     bra.s    Panic
  122.  
  123. novbr:    move.l    #ProcErr,d2
  124.     moveq    #ProcErrEnd-ProcErr,d3
  125.     bra.s    Panic
  126.  
  127. noversion:
  128.     move.l    #VerErr,d2
  129.     moveq    #VerErrEnd-VerErr,d3
  130. Panic:    move.l    DosBase,a6
  131.     move.l    stdout,d1
  132.     call    Write
  133.     bra.s    exit0
  134.  
  135. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  136.  
  137. Memory:        dc.l 0
  138. OldTrap:    dc.l 0
  139.  
  140. DosName:    dc.b 'dos.library',0
  141. SignOn:        dc.b 'cVBR (c) Copyright 1989 by Martin J. Laubach',10
  142. SignOnEnd:
  143. VerErr:        dc.b '*** You need at least version 1.2 of the OS '
  144.         dc.b 'to use cVBR',10
  145. VerErrEnd:
  146. ProcErr:    dc.b '*** You really should have an 68010 to run cVBR',10
  147. ProcErrEnd:
  148. NoMem:        dc.b '*** You haven't got $400 more bytes...',10
  149. NoMemEnd:
  150. Already:    dc.b '*** VBR already changed, reverting to normal',10
  151. AlreadyEnd:
  152.