home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / VP2SRC.ZIP / LOWLEVEL.ASM < prev    next >
Assembly Source File  |  1989-06-06  |  7KB  |  468 lines

  1. ;
  2. ;  $Header: LOWLEVEL.ASM 3.3 87/12/12 00:47:46 Bob Exp $
  3. ;
  4. ;                           The Conference Mail System
  5. ;
  6. ;               This module was originally written by Bob Hartman
  7. ;                        Sysop of FidoNet node 1:132/101
  8. ;
  9. ;    Spark Software, 427-3 Amherst St, CS 2032, Suite 232, Nashua, NH 03061
  10. ;
  11. ; The Conference Mail System  is a    complete Echomail processing package.  It
  12. ; is a superset of the original  Echomail utilities created by Jeff Rush, and
  13. ; also contains ideas gleaned from the    ARCmail,  Renum,  oMMM, MGM, and Opus
  14. ; programs that were created by various software authors.
  15. ;
  16. ; This program source code is being released with the following provisions:
  17. ;
  18. ; 1.  You are  free to make  changes to this source  code for use on your own
  19. ; machine,    however,  altered source files may not be distributed without the
  20. ; consent of Spark Software.
  21. ;
  22. ; 2.  You may distribute "patches"  or  "diff" files for any changes that you
  23. ; have made, provided that the "patch" or "diff" files are also sent to Spark
  24. ; Software for inclusion in future releases of the entire package.     A "diff"
  25. ; file for the source archives may also contain a compiled version,  provided
  26. ; it is  clearly marked as not    being created  from the original source code.
  27. ; No other    executable    versions may be  distributed without  the  consent of
  28. ; Spark Software.
  29. ;
  30. ; 3.  You are free to include portions of this source code in any program you
  31. ; develop, providing:  a) Credit is given to Spark Software for any code that
  32. ; may is used, and    b) The resulting program is free to anyone wanting to use
  33. ; it, including commercial and government users.
  34. ;
  35. ; 4.  There is    NO    technical support  available for dealing with this source
  36. ; code, or the accompanying executable files.  This source    code  is provided
  37. ; as is, with no warranty expressed or implied (I hate legalease).     In other
  38. ; words, if you don't know what to do with it,  don't use it,  and if you are
  39. ; brave enough to use it, you're on your own.
  40. ;
  41. ; Spark Software may be contacted by modem at (603) 888-8179 (node 1:132/101)
  42. ; on the public FidoNet network, or at the address given above.
  43. ;
  44. ; To use this code you will need Microsoft C version 4.0, and also Microsoft
  45. ; Macro Assembler version 4.0.
  46. ;
  47.  
  48. ;
  49. ;
  50. ;    $Log:    LOWLEVEL.ASM $
  51. ; Revision 3.3    87/12/12  00:47:46    Bob
  52. ; Source code release
  53. ;
  54. ;
  55.  
  56. ; This modules looks really strange because it was originally created
  57. ; from a mixed C/ASM listing and converted over to straight ASM for speed.
  58. ;
  59.  
  60.  
  61. .xlist
  62.         page    64,132
  63.  
  64.         title    LowLevel
  65.         subttl    by Bob Hartman
  66.  
  67.         name    LowLevel
  68.         ;
  69.         ;
  70.         ;
  71.         ; The following macro files come with the MicroSoft "C" compiler
  72.         ;
  73.         include version.inc
  74.         include msdos.inc
  75.         include cmacros.inc
  76.  
  77.         .sall
  78. .list
  79. ;
  80. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  81.  
  82. sBegin     code
  83.  
  84.         assumes  cs,code
  85.         assumes  ds,data
  86.  
  87. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  88.  
  89. cProc    fast_open,<PUBLIC>
  90.  
  91.         parmDP    fname
  92.         parmB    mode
  93.  
  94. cBegin
  95.  
  96. ; Set-up for the DOS open file call
  97.  
  98. if sizeD
  99.         push    ds
  100.         lds     dx,fname
  101. else
  102.     mov dx,fname
  103. endif
  104.  
  105.     mov al,mode
  106.         callos    open
  107.     jnc fo_no_err
  108.  
  109.     test    BYTE PTR mode,1
  110.     jne fo_creat
  111.     test    BYTE PTR mode,2
  112.     je    fo_err
  113.  
  114. fo_creat:
  115.  
  116. if sizeD
  117.         lds     dx,fname
  118. else
  119.     mov dx,fname
  120. endif
  121.  
  122.     sub cx,cx
  123.         callos    create
  124.  
  125.     jnc fo_no_err
  126.  
  127. fo_err:
  128.     mov ax,-1
  129.  
  130. fo_no_err:
  131.  
  132. if sizeD
  133.         pop     ds
  134. endif
  135.  
  136. cEnd
  137.  
  138. cProc    ofast_close,<PUBLIC>
  139.  
  140.         parmW    handle
  141.  
  142. cBegin
  143.  
  144.     mov bx,handle
  145.         callos    close
  146.     jnc fc_no_err
  147.     mov ax,-1
  148.     jmp SHORT fc_out
  149.  
  150. fc_no_err:
  151.     sub ax,ax
  152.  
  153. fc_out:
  154.  
  155. cEnd
  156.  
  157. cProc    ofast_read,<PUBLIC>
  158.  
  159.         parmW    handle
  160.         parmDP    string
  161.         parmW    len
  162.  
  163. cBegin
  164.  
  165.     mov bx,handle
  166.  
  167. if sizeD
  168.         push    ds
  169.         lds     dx,string
  170. else
  171.     mov dx,string
  172. endif
  173.     mov cx,len
  174.         callos    read
  175.     jnc fr_no_err
  176.     mov ax,-1
  177.  
  178. fr_no_err:
  179.  
  180. if sizeD
  181.         pop     ds
  182. endif
  183.  
  184. cEnd
  185.  
  186. cProc    o1fast_read,<PUBLIC>,<ds>
  187.  
  188.         parmW    handle
  189.         parmD    string
  190.         parmW    len
  191.  
  192. cBegin
  193.  
  194.     mov bx,handle
  195.     lds dx,string
  196.     mov cx,len
  197.         callos    read
  198.     jnc fr1_no_err
  199.     mov ax,-1
  200.  
  201. fr1_no_err:
  202.  
  203. cEnd
  204.  
  205. cProc    ofast_write,<PUBLIC>
  206.  
  207.         parmW    handle
  208.         parmDP    string
  209.         parmW    len
  210.  
  211. cBegin
  212.  
  213.     mov bx,handle
  214.  
  215. if sizeD
  216.         push    ds
  217.         lds     dx,string
  218. else
  219.     mov dx,string
  220. endif
  221.  
  222.     mov cx,len
  223.         callos    write
  224.     jnc fw_no_err
  225.     mov ax,-1
  226.  
  227. fw_no_err:
  228.  
  229. if sizeD
  230.         pop     ds
  231. endif
  232.  
  233. cEnd
  234.  
  235. cProc    o1fast_write,<PUBLIC>,<ds>
  236.  
  237.         parmW    handle
  238.         parmD    string
  239.         parmW    len
  240.  
  241. cBegin
  242.  
  243.     mov bx,handle
  244.     lds dx,string
  245.     mov cx,len
  246.         callos    write
  247.     jnc fw1_no_err
  248.     mov ax,-1
  249.  
  250. fw1_no_err:
  251.  
  252. cEnd
  253.  
  254. cProc    ofast_lseek,<PUBLIC>
  255.  
  256.         parmW    handle
  257.         parmW    offset1
  258.         parmW    offset2
  259.         parmW    where
  260.  
  261. cBegin
  262.  
  263.         mov     ax,where
  264.     mov bx,handle
  265.     mov dx,offset1
  266.     mov cx,offset2
  267.         callos    lseek
  268.     jnc fl_no_err
  269.     mov ax,-1
  270.         mov     dx,-1
  271.  
  272. fl_no_err:
  273.  
  274. cEnd
  275.  
  276. cProc    mem1cpy,<PUBLIC>,<es,si,di>
  277.  
  278.         parmD    dest
  279.         parmDP    src
  280.         parmW    len
  281.  
  282. cBegin
  283.  
  284.         mov     cx,len
  285.  
  286. if sizeD
  287.         push    ds
  288.         lds     si,src
  289. else
  290.         mov     si,src
  291. endif
  292.  
  293.         les     di,dest
  294.         rep     movsb
  295.  
  296. if sizeD
  297.         pop     ds
  298. endif
  299.  
  300. cEnd
  301.  
  302. cProc    mem2cpy,<PUBLIC>,<ds,si,di>
  303.  
  304.         parmDP     dest
  305.         parmD    src
  306.         parmW    len
  307.  
  308. cBegin
  309.  
  310.         mov     cx,len
  311.         lds     si,src
  312.  
  313. if sizeD
  314.         push    es
  315.         les     di,dest
  316. else
  317.         mov     di,dest
  318. endif
  319.         rep     movsb
  320.  
  321. if sizeD
  322.         pop     es
  323. endif
  324.  
  325. cEnd
  326.  
  327. cProc    mem1set,<PUBLIC>,<es,si,di>
  328.  
  329.         parmD    dest
  330.         parmW    val
  331.         parmW    len
  332.  
  333. cBegin
  334.  
  335.         mov     cx,len
  336.         mov     ax,val
  337.         les     di,dest
  338.         rep     stosb
  339.  
  340. cEnd
  341.  
  342. cProc    _fmalloc1,<PUBLIC>
  343.  
  344.         parmW    len
  345.  
  346. cBegin
  347.  
  348.         mov     ax,len
  349.         add     ax,16
  350.         shr     ax,1
  351.         shr     ax,1
  352.         shr     ax,1
  353.         shr     ax,1
  354.  
  355.         mov     bx,ax
  356.         callos    allocmem
  357.         jnc     fmout
  358.         mov     ax,0
  359.         mov     dx,0
  360.         jmp     short fmout1
  361.  
  362. fmout:
  363.         mov     dx,ax
  364.         mov     ax,0
  365.  
  366. fmout1:
  367.  
  368. cEnd
  369.  
  370. cProc    _ffree1,<PUBLIC>,<es>
  371.  
  372.         parmD    str
  373.  
  374. cBegin
  375.  
  376.         les     ax,str
  377.         callos    freemem
  378.  
  379. cEnd
  380.  
  381. cProc    chdir,<PUBLIC>
  382.  
  383.         parmDP    dir
  384.  
  385. cBegin
  386.  
  387. if sizeD
  388.         push    ds
  389.         lds     dx,dir
  390. else
  391.     mov dx,dir
  392. endif
  393.  
  394.         callos    chdir
  395.     jc    ch_err
  396.     xor ax,ax
  397.  
  398. ch_err:
  399.  
  400. if sizeD
  401.         pop     ds
  402. endif
  403.  
  404. cEnd
  405.  
  406. cProc    match_byte,<PUBLIC>,<di>
  407.  
  408.         parmDP    str
  409.         parmW    mbyte
  410.         parmW    len
  411.  
  412. cBegin
  413.  
  414. if sizeD
  415.         push    ds
  416.         push    es
  417.         les     di,str
  418.         mov     ax,es
  419.         mov     ds,ax
  420.         mov     dx,ds
  421. else
  422.         mov     di,str
  423. endif
  424.  
  425.         mov     ax,mbyte
  426.         mov     cx,len
  427.         repne    scasb
  428.         dec     di
  429.         cmp     BYTE PTR [di],al
  430.         mov     ax,di
  431.         je        get_out
  432.  
  433. if sizeD
  434.         mov     dx,0
  435. endif
  436.  
  437.         mov     ax,0
  438. get_out:
  439.  
  440. if sizeD
  441.         pop     es
  442.         pop     ds
  443. endif
  444.  
  445. cEnd
  446.  
  447. cProc    go_directory,<PUBLIC>
  448.  
  449.         parmDP    dir
  450.  
  451. cBegin
  452.  
  453. cEnd
  454.  
  455. cProc    change_disk,<PUBLIC>
  456.  
  457.         parmW    disk
  458.  
  459. cBegin
  460.  
  461.     mov dx,disk
  462.         callos    selectdisk
  463.  
  464. cEnd
  465.  
  466. sEnd
  467.         end
  468.