home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / ip / ppp / mac / macppp2.0.1-src.hqx / MacPPP 2.0.1 src / asmutil.c next >
Encoding:
C/C++ Source or Header  |  1993-07-30  |  1.6 KB  |  95 lines

  1. /*
  2.  *    Utility assembly routines.
  3.  *
  4.  * Copyright 1992-1993 Merit Network, Inc. and The Regents of the
  5.  *  University of Michigan.  Usage of this source code is restricted
  6.  *  to non-profit, non-commercial purposes.  The source is provided
  7.  *  "as-is", without warranty.
  8.  */
  9.  
  10. #include "ppp.h"
  11.  
  12. /*  SetLAPPtr and  GetLAPPtr store and return lap pointer */
  13.  
  14. LapInfo *GetLAPPtr();
  15.  
  16. void SetLAPPtr(LapInfo *lap) {
  17.     asm {
  18.         lea.l    @LapPtr,a0
  19.         move.l    lap,(a0)
  20.         bra.s    @1
  21.  
  22. extern GetLAPPtr:
  23.         move.l    @LapPtr,d0
  24.         rts
  25.  
  26. @LapPtr        dc.l    0    /* pointer to LAP variable storage */
  27. @1
  28.     }
  29. }
  30.  
  31.  /* Clear a block of memory starting from "ptr" (a0)  */
  32.  /* with size "cnt" bytes (d0) */
  33.  
  34. void bzero(b_8 *ptr, short cnt) {
  35.     asm {
  36.         movea.l    ptr,a0        ;get pointer to area to zero
  37.         move.w    cnt,d0        ;and its length in bytes
  38.         bra.s    @20
  39.         
  40. @10        clr.b    (a0)+        ;clear a byte
  41. @20        dbra    d0, @10
  42.     }
  43. }
  44.  
  45. /* Return the current value of A5, and set A5 to the passed value */
  46. long seta5(long v)
  47. {
  48.     asm {
  49.     move.l    a5,d0    ; return current a5 value
  50.     movea.l    v,a5    ; set a5 to new value
  51.     }
  52. }
  53.  
  54. /* return the current value of A5 */
  55. long geta5(void)
  56. {
  57.     asm {
  58.     move.l    a5,d0    ; return current a5
  59.     }
  60. }
  61.  
  62. /* Return the current value of A4, and set A4 to the passed value */
  63. long seta4(long v)
  64. {
  65.     asm {
  66.     move.l    a4,d0    ; return current a4 value
  67.     movea.l    v,a4    ; set a4 to new value
  68.     }
  69. }
  70.  
  71. /* just return the current value of A4 */
  72. long geta4(void)
  73. {
  74.     asm {
  75.     move.l    a4,d0    ; return current a4
  76.     }
  77. }
  78.  
  79. /* set interrupt level */
  80. short set_sr(short    v)
  81. {
  82.     asm {
  83.     move    sr,d0        ; return current sr value
  84.     move    v,sr        ; set sr to mask interrupts
  85.     }
  86. }
  87.  
  88. /* get status register */
  89. short get_sr(void)
  90. {
  91.     asm {
  92.     move    sr,d0        ; get sr value
  93.     }
  94. }
  95.