home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / os2md6.zip / mdsubs.asm < prev    next >
Assembly Source File  |  1995-03-22  |  3KB  |  90 lines

  1. ;
  2. ; mdsubs.asm - OS/2 Mime decoder subroutines
  3. ; Copyright (C) 1994, Richard Curry Consulting: trindflo@rain.org
  4. ; All Rights Reserved
  5. ;
  6. ; This program is free software; you can redistribute it and/or modify
  7. ; it under the terms of the GNU General Public License as published by
  8. ; the Free Software Foundation.
  9. ;
  10. ; This program is distributed in the hope that it will be useful,
  11. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ; GNU General Public License for more details.
  14. ;
  15. ; You should have received a copy of the GNU General Public License
  16. ; along with this program in a file name 'COPYING'; if not, write to the
  17. ; Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. ;
  19.  
  20.  
  21.         TITLE   mdsubs.asm
  22.     .386
  23.     .387
  24. ;        INCLUDELIB os2386.lib
  25. ;        INCLUDELIB dde4sbs.lib
  26. CODE32    SEGMENT DWORD USE32 PUBLIC 'CODE'
  27. CODE32    ENDS
  28. DATA32    SEGMENT DWORD USE32 PUBLIC 'DATA'
  29. DATA32    ENDS
  30. CONST32    SEGMENT DWORD USE32 PUBLIC 'CONST'
  31. CONST32    ENDS
  32. BSS32    SEGMENT DWORD USE32 PUBLIC 'BSS'
  33. BSS32    ENDS
  34. DGROUP    GROUP CONST32, BSS32, DATA32
  35.     ASSUME    CS:FLAT, DS:FLAT, SS:FLAT, ES:FLAT
  36. DATA32    SEGMENT
  37. DATA32    ENDS
  38. BSS32    SEGMENT
  39. BSS32    ENDS
  40. CONST32    SEGMENT
  41. CONST32    ENDS
  42. CODE32    SEGMENT
  43.  
  44. ;
  45. ; int xlatblk(char *bufr, char *xlatab, int count);
  46. ;
  47. ; Translate count chars in bufr using xlatab
  48. ;
  49.     ALIGN 04H
  50.         PUBLIC xlatblk
  51. xlatblk         PROC
  52.         PUSH    EDI             ; Save so we can use
  53.         XCHG    EBX, EDX        ; Need to use EBX for xlation
  54.         MOV     EDI, EAX        ; Load bufr adrs into destination index
  55. xlaloop:
  56.         MOV     AL, [EDI]       ; Load a byte
  57.         XLATB                   ; Translate the byte
  58.         STOSB                   ; Store byte and increment index
  59.         LOOP    xlaloop
  60.  
  61.         XCHG    EBX, EDX        ; Restore EBX
  62.         POP     EDI             ; Restore
  63.         RET     
  64. xlatblk         ENDP
  65.  
  66. ;
  67. ; int Pack4to3(char *sp, char *dp);
  68. ;
  69. ; Pack 4 6-bit bytes from sp into 3 8-bit bytes in dp
  70. ;       WARNING: wipes out 4 bytes at dp!
  71. ;
  72.     ALIGN 04H
  73.         PUBLIC Pack4to3
  74. Pack4to3        PROC
  75.         MOV     CX, [EAX]       ; Pick up first two bytes
  76.         SHL     CH, 2           ; Make 1st two bytes adjacent
  77.         ROL     CX, 2           ; Then move them to ls 12 bits
  78.         MOV     AX, [EAX+2]     ; Pick up next two bytes
  79.         SHL     AH, 2           ; Make 2nd two bytes adjacent
  80.         ROR     AX, 2           ; Align bits in the proper bytes
  81.         SHL     EAX, 8          ; And move to next 12 bits
  82.         OR      AX, CX          ; Combine
  83.         MOV     [EDX], EAX      ; Store 4 bytes (4th byte is garbage)
  84.         RET     
  85. Pack4to3        ENDP
  86.  
  87. CODE32  ENDS
  88. END
  89.  
  90.