Rev | Line | |
---|
[9] | 1 | .sect .text; .sect .rom; .sect .data; .sect .bss
|
---|
| 2 | .define .fef4
|
---|
| 3 |
|
---|
| 4 | .sect .text
|
---|
| 5 | .fef4:
|
---|
| 6 | ! this could be simpler, if only the
|
---|
| 7 | ! fxtract instruction was emulated properly
|
---|
| 8 | mov bx,sp
|
---|
| 9 | mov ax,8(bx)
|
---|
| 10 | and ax,0x7f800000
|
---|
| 11 | je 1f ! zero exponent
|
---|
| 12 | shr ax,23
|
---|
| 13 | sub ax,126
|
---|
| 14 | mov cx,ax ! exponent in cx
|
---|
| 15 | mov ax,8(bx)
|
---|
| 16 | and ax,0x807fffff
|
---|
| 17 | or ax,0x3f000000 ! load -1 exponent
|
---|
| 18 | mov bx,4(bx)
|
---|
| 19 | mov 4(bx),ax
|
---|
| 20 | mov (bx),cx
|
---|
| 21 | ret
|
---|
| 22 | 1: ! we get here on zero exp
|
---|
| 23 | mov ax,8(bx)
|
---|
| 24 | and ax,0x007fffff
|
---|
| 25 | jne 1f ! zero result
|
---|
| 26 | mov bx,4(bx)
|
---|
| 27 | mov (bx),ax
|
---|
| 28 | mov 4(bx),ax
|
---|
| 29 | ret
|
---|
| 30 | 1: ! otherwise unnormalized number
|
---|
| 31 | mov cx,8(bx)
|
---|
| 32 | and cx,0x807fffff
|
---|
| 33 | mov dx,cx
|
---|
| 34 | and cx,0x80000000
|
---|
| 35 | mov ax,-125
|
---|
| 36 | 2:
|
---|
| 37 | test dx,0x800000
|
---|
| 38 | jne 1f
|
---|
| 39 | dec ax
|
---|
| 40 | shl dx,1
|
---|
| 41 | or dx,cx
|
---|
| 42 | jmp 2b
|
---|
| 43 | 1:
|
---|
| 44 | mov bx,4(bx)
|
---|
| 45 | mov (bx),ax
|
---|
| 46 | and dx,0x807fffff
|
---|
| 47 | or dx,0x3f000000 ! load -1 exponent
|
---|
| 48 | mov 4(bx),dx
|
---|
| 49 | ret
|
---|
Note:
See
TracBrowser
for help on using the repository browser.