| Line |   | 
|---|
| 1 | .define .dvi4
 | 
|---|
| 2 | 
 | 
|---|
| 3 | yl=6
 | 
|---|
| 4 | yh=8
 | 
|---|
| 5 | xl=10
 | 
|---|
| 6 | xh=12
 | 
|---|
| 7 | 
 | 
|---|
| 8 | .text
 | 
|---|
| 9 | .dvi4:
 | 
|---|
| 10 |         push    si
 | 
|---|
| 11 |         push    di
 | 
|---|
| 12 |         mov     si,sp           ! copy of sp
 | 
|---|
| 13 |         mov     bx,yl(si)
 | 
|---|
| 14 |         mov     ax,yh(si)
 | 
|---|
| 15 |         cwd
 | 
|---|
| 16 |         mov     di,dx
 | 
|---|
| 17 |         cmp     dx,ax
 | 
|---|
| 18 |         jne     7f
 | 
|---|
| 19 |         and     dx,dx
 | 
|---|
| 20 |         jge     1f
 | 
|---|
| 21 |         neg     bx
 | 
|---|
| 22 |         je      7f
 | 
|---|
| 23 | 1:
 | 
|---|
| 24 |         xor     dx,dx
 | 
|---|
| 25 |         mov     cx,xl(si)
 | 
|---|
| 26 |         mov     ax,xh(si)
 | 
|---|
| 27 |         and     ax,ax
 | 
|---|
| 28 |         jge     2f
 | 
|---|
| 29 |         neg     ax
 | 
|---|
| 30 |         neg     cx
 | 
|---|
| 31 |         sbb     ax,dx
 | 
|---|
| 32 |         not     di
 | 
|---|
| 33 | 2:
 | 
|---|
| 34 |         div     bx
 | 
|---|
| 35 |         xchg    ax,cx
 | 
|---|
| 36 |         div     bx              ! cx = high abs(result), ax=low abs(result)
 | 
|---|
| 37 | 9:
 | 
|---|
| 38 |         and     di,di
 | 
|---|
| 39 |         jge     1f
 | 
|---|
| 40 |         neg     cx
 | 
|---|
| 41 |         neg     ax
 | 
|---|
| 42 |         sbb     cx,#0
 | 
|---|
| 43 | 1:
 | 
|---|
| 44 |                         ! cx is high order result
 | 
|---|
| 45 |                         ! ax is low order result
 | 
|---|
| 46 |         mov     dx,cx
 | 
|---|
| 47 |         pop     di
 | 
|---|
| 48 |         pop     si
 | 
|---|
| 49 |         ret     8       ! result in ax/dx
 | 
|---|
| 50 | 
 | 
|---|
| 51 | 7:
 | 
|---|
| 52 |         push    dx              ! sign of y
 | 
|---|
| 53 |         mov     di,ax
 | 
|---|
| 54 |         xor     bx,bx
 | 
|---|
| 55 |         and     di,di
 | 
|---|
| 56 |         jge     1f
 | 
|---|
| 57 |         neg     di
 | 
|---|
| 58 |         neg     yl(si)
 | 
|---|
| 59 |         sbb     di,bx
 | 
|---|
| 60 | 1:
 | 
|---|
| 61 |         mov     ax,xl(si)
 | 
|---|
| 62 |         mov     dx,xh(si)
 | 
|---|
| 63 |         and     dx,dx
 | 
|---|
| 64 |         jge     1f
 | 
|---|
| 65 |         neg     dx
 | 
|---|
| 66 |         neg     ax
 | 
|---|
| 67 |         sbb     dx,bx
 | 
|---|
| 68 |         not     -2(si)
 | 
|---|
| 69 | 1:
 | 
|---|
| 70 |         mov     cx,#16
 | 
|---|
| 71 | 1:
 | 
|---|
| 72 |         shl     ax,#1
 | 
|---|
| 73 |         rcl     dx,#1
 | 
|---|
| 74 |         rcl     bx,#1
 | 
|---|
| 75 |         cmp     di,bx
 | 
|---|
| 76 |         ja      3f
 | 
|---|
| 77 |         jb      2f
 | 
|---|
| 78 |         cmp     yl(si),dx
 | 
|---|
| 79 |         jbe     2f
 | 
|---|
| 80 | 3:
 | 
|---|
| 81 |         loop    1b
 | 
|---|
| 82 |         jmp     1f
 | 
|---|
| 83 | 2:
 | 
|---|
| 84 |         sub     dx,yl(si)
 | 
|---|
| 85 |         sbb     bx,di
 | 
|---|
| 86 |         inc     ax
 | 
|---|
| 87 |         loop    1b
 | 
|---|
| 88 | 1:
 | 
|---|
| 89 |         pop     di              ! di=sign of result,ax= result
 | 
|---|
| 90 |         jmp     9b
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.