Guest User

Untitled

a guest
Feb 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;--------------------------------------------------------------------------
  2. ;
  3. ;   Program:   dcomp
  4. ;   Author:    Ty Devries
  5. ;              Clint Fitch
  6. ;   Date:      26 October, 2011
  7. ;
  8. ;   Function:  Dcomp decompresses ASCII text.
  9. ;
  10. ;   Input:
  11. ;   - si points to the string of compressed data
  12. ;   - di points to the empty list into which the decompressed data is stored
  13. ;
  14. ;   Output:
  15. ;
  16. ;   - The compressed data in inlist is decompressed into output list
  17. ;   - The compressed data is not modified
  18. ;   - All registers contain their original value except ax
  19. ;     ax = 0        Invalid compressed bit pattern found
  20. ;     ax = 1...n    Okay and n = size of decompressed data
  21. ;
  22. ;--------------------------------------------------------------------------
  23.  
  24.  
  25. ;----------------------------------
  26.          .model    small          ;64k code and 64k data
  27.          .8086                    ;only allow 8086 instructions
  28.          public    dcomp          ;allow linker to access  dcomp
  29.          public    getbit         ;allow linker to access  getbit
  30. ;----------------------------------
  31.  
  32.  
  33.         .data
  34. ;-------------------------------------------------------------
  35. ;
  36. ;-------------------------------------------------------------
  37.  
  38.  
  39.          .code
  40. ;----------------------------------
  41. ;
  42. ;----------------------------------
  43. dcomp:
  44.                                   ;
  45.          ret                      ; return
  46. ;---------------------------------;
  47.  
  48.  
  49.          .data
  50. ;----------------------------------
  51. ;
  52. ;----------------------------------
  53. eight   db  8         ; mothafuckin 8
  54. ;----------------------------------
  55. ; GETBIT
  56. ;
  57. ; Input:
  58. ; - ax contains  the bit number requested ( 0 to 1783 are valid)
  59. ; - si points to the input compressed data string 1 to 223 bytes
  60. ;
  61. ; Output
  62. ; - if the requested bit number is valid (0 to 1783) then
  63. ;   ax contains the bit value 0 - 1
  64. ; - if the requested bit number is invalid  (greater than 1783)  then
  65. ;   ax is unchanged
  66. ; - the subroutine must save and restore any other used register
  67. ; - the input compressed data may not be changed
  68. ;----------------------------------
  69.          .code                    ;
  70. ;----------------------------------
  71. ; Prepare bit to be got
  72. ;----------------------------------
  73. getbit:                           ;
  74.      cmp    ax,1783       ; compare ax to 1783
  75.      ja return        ; if ax > 1783, return
  76.      push   bx        ; store bx
  77.      push   cx        ; store cx
  78.      div    [eight]       ; ah = remainder, al = quotient
  79.      mov    bl,al         ; bl is byte offset
  80.      mov    bh,0          ; convert bl to word
  81.      mov    al,[bx+si]    ; looking at correct byte
  82.          mov    cl,ah         ; cl is bit offset
  83.      inc    cl        ; always loop once more
  84. ;----------------------------------
  85. ; Shift bitwise to the desired bit
  86. ;----------------------------------
  87. shift:                ;
  88.      shl    al,cl         ; shift left once
  89. ;----------------------------------
  90. ; Move the registers back to their
  91. ; former values
  92. ;----------------------------------
  93. restore:              ;
  94.      pop    cx        ; restore cx
  95.      pop    bx        ; restore bx
  96. ;----------------------------------
  97. ; Set ax to 1 if CF is 1
  98. ;----------------------------------
  99. getflag:              ;
  100.      jnc    zero          ; check the carry flag
  101.      mov    ax,1          ; bit is a 1
  102.      ret              ; return to main
  103. ;----------------------------------
  104. ; Otherwise set ax to 0
  105. ;----------------------------------
  106. zero:                 ;
  107.      mov    ax,0          ; bit is a 0
  108. ;----------------------------------
  109. ; Exit subroutine and return to
  110. ; main
  111. ;----------------------------------
  112. return:               ;
  113.          ret                      ; return bit
  114. ;----------------------------------
  115.          end
  116. 
Add Comment
Please, Sign In to add comment