home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 2.ddi / OWLSRC.EXE / CSCAPE / SOURCE / PCBUNRUN.ASM < prev    next >
Encoding:
Assembly Source File  |  1989-07-23  |  3.0 KB  |  138 lines

  1. ; pcbunrun.asm
  2. ;
  3. ; 5/5/88 by Ted
  4. ;
  5. ; Splash-style image unrunner for OWL
  6. ; THIS FILE IS FOR LARGE-DATA MODELS ONLY
  7. ;
  8. ; Copyright (c) 1988, 1989 Oakland Group Inc.
  9. ; ALL RIGHTS RESERVED
  10. ;
  11. ;------------------------REVISION HISTORY--------------------------------------;
  12. ;------------------------------------------------------------------------------;
  13. include    PCDECL.MAC
  14.  
  15.     PSEG
  16. ; ---------------------------------------------------------------------------- ;
  17. ; int bunrun(dest_addr, nbytes, runcode)
  18. ;
  19. ;    Unrun in place into max nbytes bytes at addr
  20. ;    firstrun and runsize describe the runned data
  21. ;    dest_addr is a doubleword in form seg, offset
  22. ;  - runcode is runsize and firstrun as lo and hi of long value
  23. ;  - returns outsize, -1 if overflow
  24.  
  25. pubproc    DIGPRIV bunrun <daddr, dptr, nbytes, runsize, firstrun>
  26.     push bp
  27.     mov  bp, sp
  28.     pushm <ds, es, si, di>
  29.  
  30.     lds si, [bp].daddr            ; reg. ds = saddr seg
  31.     les    di, [bp].daddr            ; reg. es = daddr seg
  32.     mov bx, [bp].firstrun
  33.  
  34. ; move runned stuff from soff to runstart = soff+nbytes - runsize
  35.     add di, [bp].nbytes
  36.      mov dx, di                ; dx = end of runbuf and outbuf
  37.     mov cx, [bp].runsize
  38.     sub di, cx
  39.     mov [bp].firstrun, di    ; firstrun is now runstart address
  40.  
  41.     push bx        ; save bx for later
  42.     push dx        ; save dx for later
  43.  
  44. ; di > si : negative move
  45.     add    si, cx        ; point si and di to end of area
  46.     dec    si
  47.     add    di, cx
  48.     dec    di
  49.  
  50.     std
  51.     shr cx, 1
  52.     jnc ndow
  53.     movsb
  54.     jcxz ndone
  55. ndow:
  56.     dec    si
  57.     dec    di
  58.     rep    movsw
  59. ndone:
  60.     cld
  61.  
  62.     pop  dx        ; restore end address of runbuf and outbuf
  63.     pop  bx        ; restore address of first run
  64.  
  65. ; set up si and di to start
  66.     mov si, [bp].firstrun
  67.     les    di, [bp].daddr            ; reg. es = daddr seg
  68.  
  69. NEWMOV:
  70.     cmp si, dx            ; see if we are done
  71.     jz done
  72.     cmp di, dx            ; see if we have overflowed
  73.     jae overflow
  74.  
  75. ; find count of bytes until next run and blast them out
  76.     mov cx, bx
  77.     cmp cx, -1
  78.     jne nosubs
  79.     mov cx, [bp].runsize    ; substitute buf end for next-run start
  80. nosubs:
  81.     add cx, [bp].firstrun    ; cx = nextrun - curpos
  82.     sub cx, si
  83.     jcxz NEWRUN
  84.  
  85. ; test for error of run too big
  86.     mov ax, dx
  87.     sub ax, di
  88.     cmp cx, ax
  89.     jbe okmov
  90.     mov cx, ax
  91.     jcxz overflow
  92. okmov:
  93.     rep movsb            ; blast out bytes until next run
  94.  
  95. NEWRUN:
  96.     mov ax, dx
  97.     sub ax, si
  98.     jz done                ; test for all done
  99.     cmp ax, 2            ; test for error of incomplete run code
  100.     jb abort            ; allow no next-run ptr because it's redundant
  101. ; load up run data
  102.     mov bx, ds:[si+2]    ; get next run ptr
  103.     mov cl, ds:[si+1]    ; get run count
  104.     mov ch, 0
  105.  
  106. ; test for error of run too big
  107.     mov ax, dx
  108.     sub ax, di
  109.     cmp cx, ax
  110.     jbe okrun
  111.     mov cx, ax
  112.     jcxz overflow
  113. okrun:
  114.     mov al, ds:[si]        ; get run byte
  115.     add si, 4
  116.  
  117.     rep stosb            ; blast out the run
  118.     jmp NEWMOV
  119.  
  120. overflow:
  121.     mov ax, -1
  122.     jmp short fini
  123. done:
  124. abort:
  125.     mov ax, di
  126.     les    di, [bp].daddr            ; reg. es = daddr seg
  127.     sub ax, di
  128. fini:
  129.     popm <di, si, es, ds>
  130.     pop    bp
  131.     ret
  132. endproc bunrun
  133. ; ---------------------------------------------------------------------------- ;
  134.     ENDPS
  135.     end
  136. ; ---------------------------------------------------------------------------- ;
  137.  
  138.