home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / basic / mbextend.lbr / DEMO.AZM / DEMO.ASM
Encoding:
Assembly Source File  |  1988-01-24  |  2.1 KB  |  91 lines

  1. ; Reprinted from Micro/Systems Journal, Vol. 1, No. 1, March-
  2. ; April 1985, article titled "Assembly Language Extensions for
  3. ; MS-Basic" by Ron Kreymborg.  
  4. ;
  5. ;***************************************************************;
  6. ; Sample module.  Preamble begins..                             ;
  7. ;***************************************************************;
  8.  
  9. bdos:    jmp    0        ; bdos vector
  10.     db    (j-$)/2        ; routine count
  11.  
  12.     dw    split        ; split an integer
  13.     dw    get1st        ; BDOS call 17
  14.     dw    getnxt        ; BDOS call 18
  15.     dw    setdma        ; BDOS call 26
  16.  
  17. j    equ    $
  18.  
  19. ;***************************************************************
  20. è; Split an integer into its seperate bytes.
  21. ;     Basic call syntax is:
  22. ;        CALL SPLIT% (SORCE%, LBYT%, RBYT%)
  23.  
  24. split:    mov    a,m        ; get right byte
  25.     push    psw        ;   and save it
  26.  
  27.     inx    h        ; get left byte
  28.     mov    a,m
  29.     xchg            ; and put in LBYT
  30.     mov    m,a
  31.     inx    h
  32.     xra    a
  33.     mov    m,a
  34.  
  35.     mov    h,b        ; right byte pointer into HL
  36.     mov    l,c
  37.     pop    psw        ; restore right byte
  38.     mov    m,a        ;   and put in RBYT
  39.     inx    h
  40.     xra    a
  41.     mov    m,a
  42.     ret
  43.  
  44.  
  45. ;***************************************************************
  46. ; BDOS call 17 - search for first matching entry in the disc
  47. è; directory.  Must be preceded by a set dma call. Call with
  48. ; the syntax:
  49. ;    CALL GET1ST% (FCB%(0), PTR%)
  50. ; Returns:
  51. ;    PTR = 0 thru 3    ; PTR*32 -> directory entry in DMA.
  52. ;        = FF    ; no match found.
  53.  
  54. get1st:    push    d    ; save flag address
  55.     xchg        ; pointer into DE
  56.     mvi    c,17
  57.     call    bdos
  58.     pop    h
  59.     mov    m,a    ; return flag
  60.     inx    h
  61.     xra    a
  62.     mov    m,a
  63.     ret
  64.  
  65.  
  66. ;***************************************************************
  67. ; BDOS call 18 - search for next matching entry.  Call and
  68. ; return as for <get1st>.
  69.  
  70. getnxt:    push    d    ; save flag address
  71.     xchg        ; pointer into DE
  72.     mvi    c,18
  73.     call    bdos
  74. è    pop    h
  75.     mov    m,a    ; return flag
  76.     inx    h
  77.     xra    a
  78.     mov    m,a
  79.     ret
  80.  
  81.  
  82. ;***************************************************************
  83. ; BDOS call 26 - set DMA address.  Call with the syntax:
  84. ;    CALL SETDMA% (DMABUFF%(0))
  85. ; where DMABUFF is the first entry in a 128 byte array, ie set
  86. ;   with a DIM DMABUFF%(64) statement.
  87.  
  88. setdma:    xchg        ; pointer into DE
  89.     mvi    c,26
  90.     call    bdos
  91.     ret
  92.  
  93.     end
  94.