⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lib86.txt

📁 操作系统设计与实现源码
💻 TXT
📖 第 1 页 / 共 5 页
字号:
01430	        sbb     ax,dx
01431	        not     di
01432	2:
01433	        div     bx
01434	        xchg    ax,cx
01435	        div     bx              ! cx = high abs(result), ax=low abs(result)
01436	9:
01437	        and     di,di
01438	        jge     1f
01439	        neg     cx
01440	        neg     ax
01441	        sbb     cx,#0
01442	1:
01443	                        ! cx is high order result
01444	                        ! ax is low order result
01445	        mov     dx,cx
01446	        pop     di
01447	        pop     si
01448	        ret     8       ! result in ax/dx
01449	
01450	7:
01451	        push    dx              ! sign of y
01452	        mov     di,ax
01453	        xor     bx,bx
01454	        and     di,di
01455	        jge     1f
01456	        neg     di
01457	        neg     yl(si)
01458	        sbb     di,bx
01459	1:
01460	        mov     ax,xl(si)
01461	        mov     dx,xh(si)
01462	        and     dx,dx
01463	        jge     1f
01464	        neg     dx
01465	        neg     ax
01466	        sbb     dx,bx
01467	        not     -2(si)
01468	1:
01469	        mov     cx,#16
01470	1:
01471	        shl     ax,#1
01472	        rcl     dx,#1
01473	        rcl     bx,#1
01474	        cmp     di,bx
01475	        ja      3f
01476	        jb      2f
01477	        cmp     yl(si),dx
01478	        jbe     2f
01479	3:
01480	        loop    1b
01481	        jmp     1f
01482	2:
01483	        sub     dx,yl(si)
01484	        sbb     bx,di
01485	        inc     ax
01486	        loop    1b
01487	1:
01488	        pop     di              ! di=sign of result,ax= result
01489	        jmp     9b

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			src/lib/i86/em/dvu4.s	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

01500	.define .dvu4
01501	
01502	yl=6
01503	yh=8
01504	xl=10
01505	xh=12
01506	
01507	.text
01508	.dvu4:
01509	        push    si
01510	        push    di
01511	        mov     si,sp           ! copy of sp
01512	        mov     bx,yl(si)
01513	        mov     ax,yh(si)
01514	        or      ax,ax
01515	        jne     7f
01516	        xor     dx,dx
01517	        mov     cx,xl(si)
01518	        mov     ax,xh(si)
01519	        div     bx
01520	        xchg    ax,cx
01521	        div     bx
01522	9:
01523	                        ! cx is high order result
01524	                        ! ax is low order result
01525	        mov     dx,cx
01526	        pop     di
01527	        pop     si
01528	        ret     8       ! result in ax/dx
01529	
01530	7:
01531	        mov     di,ax
01532	        xor     bx,bx
01533	        mov     ax,xl(si)
01534	        mov     dx,xh(si)
01535	        mov     cx,#16
01536	1:
01537	        shl     ax,#1
01538	        rcl     dx,#1
01539	        rcl     bx,#1
01540	        cmp     di,bx
01541	        ja      3f
01542	        jb      2f
01543	        cmp     yl(si),dx
01544	        jbe     2f
01545	3:
01546	        loop    1b
01547	        jmp     9b
01548	2:
01549	        sub     dx,yl(si)
01550	        sbb     bx,di
01551	        inc     ax
01552	        loop    1b
01553	        jmp     9b

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			src/lib/i86/em/error.s	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

01600	.define .error
01601	.define .Xtrp
01602	
01603	        ! ax is trap number
01604	        ! all registers must be saved
01605	        ! because return is possible
01606	        ! May only be called with error no's <16
01607	.text
01608	.error:
01609	        push bp
01610	        push si
01611	        push di
01612	        push dx
01613	        push cx
01614	        push bx
01615	        push ax
01616	        mov  cx,ax
01617	        mov  bx,#1
01618	        sal  bx,cl
01619	.extern .ignmask
01620	.extern .trp
01621	        test bx,.ignmask
01622	        jne  2f
01623	        call    .trp
01624	2:
01625	        pop  ax
01626	        pop  bx
01627	        pop  cx
01628	        pop  dx
01629	        pop  di
01630	        pop  si
01631	        pop  bp
01632	        ret
01633	
01634	.Xtrp:
01635	        cmp     ax,#16
01636	        jge     1f
01637	        call    .error
01638	        ret
01639	1:
01640	        jmp     .trp

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			src/lib/i86/em/exg.s	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

01700	.define .exg
01701	
01702	        ! #bytes in cx
01703	.text
01704	.exg:
01705	        push    di
01706	        mov     sp,di
01707	        add     di,#4
01708	        mov     bx,di
01709	        add     bx,cx
01710	        sar     cx,#1
01711	1:
01712	        mov     ax,(bx)
01713	        xchg    ax,(di)
01714	        mov     (bx),ax
01715	        add     di,#2
01716	        add     bx,#2
01717	        loop    1b
01718	2:
01719	        pop     di
01720	        ret

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			src/lib/i86/em/fat.s	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

01800	.define .fat
01801	.text
01802	
01803	.fat:
01804	.extern .trp
01805	.extern .stop
01806	        call    .trp
01807	        call    .stop
01808	        ! no return

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			src/lib/i86/em/fp8087.s	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

01900	.define .adf4, .adf8, .sbf4, .sbf8, .mlf4, .mlf8, .dvf4, .dvf8
01901	.define .ngf4, .ngf8, .fif4, .fif8, .fef4, .fef8
01902	.define .cif4, .cif8, .cuf4, .cuf8, .cfi, .cfu, .cff4, .cff8
01903	.define .cmf4, .cmf8
01904	.sect .text; .sect .rom; .sect .data; .sect .bss
01905	
01906	!       $Header: fp8087.s,v 1.2 89/11/28 12:51:35 ceriel Exp $
01907	
01908	!       Implement interface to floating point package for Intel 8087
01909	
01910	        .sect .rom
01911	one:
01912	        .data2  1
01913	two:
01914	        .data2  2
01915	bigmin:
01916	        .data2  0, -32768
01917	
01918	        .sect .text
01919	.adf4:
01920	        mov     bx,sp
01921	        wait
01922	        flds    2(bx)
01923	        wait
01924	        fadds   6(bx)
01925	        wait
01926	        fstps   6(bx)
01927	        wait
01928	        ret
01929	.adf8:
01930	        mov     bx,sp
01931	        wait
01932	        fldd    2(bx)
01933	        wait
01934	        faddd   10(bx)
01935	        wait
01936	        fstpd   10(bx)
01937	        wait
01938	        ret
01939	
01940	.sbf4:
01941	        mov     bx,sp
01942	        wait
01943	        flds    6(bx)
01944	        wait
01945	        fsubs   2(bx)
01946	        wait
01947	        fstps   6(bx)
01948	        wait
01949	        ret
01950	
01951	.sbf8:
01952	        mov     bx,sp
01953	        wait
01954	        fldd    10(bx)
01955	        wait
01956	        fsubd   2(bx)
01957	        wait
01958	        fstpd   10(bx)
01959	        wait
01960	        ret
01961	
01962	.mlf4:
01963	        mov     bx,sp
01964	        wait
01965	        flds    2(bx)
01966	        wait
01967	        fmuls   6(bx)
01968	        wait
01969	        fstps   6(bx)
01970	        wait
01971	        ret
01972	.mlf8:
01973	        mov     bx,sp
01974	        wait
01975	        fldd    2(bx)
01976	        wait
01977	        fmuld   10(bx)
01978	        wait
01979	        fstpd   10(bx)
01980	        wait
01981	        ret
01982	
01983	.dvf4:
01984	        mov     bx,sp
01985	        wait
01986	        flds    6(bx)
01987	        wait
01988	        fdivs   2(bx)
01989	        wait
01990	        fstps   6(bx)
01991	        wait
01992	        ret
01993	
01994	.dvf8:
01995	        mov     bx,sp
01996	        wait
01997	        fldd    10(bx)
01998	        wait
01999	        fdivd   2(bx)
02000	        wait
02001	        fstpd   10(bx)
02002	        wait
02003	        ret
02004	
02005	.ngf4:
02006	        mov     bx,sp
02007	        wait
02008	        flds    2(bx)
02009	        wait
02010	        fchs
02011	        wait
02012	        fstps   2(bx)
02013	        wait
02014	        ret
02015	
02016	.ngf8:
02017	        mov     bx,sp
02018	        wait
02019	        fldd    2(bx)
02020	        wait
02021	        fchs
02022	        wait
02023	        fstpd   2(bx)
02024	        wait
02025	        ret
02026	
02027	.fif4:
02028	        mov     bx,sp
02029	        push    bx              ! make room for FP status word
02030	        wait
02031	        flds    4(bx)
02032	        wait
02033	        fmuls   8(bx)           ! multiply
02034	        wait
02035	        fld     st              ! copy result
02036	        wait
02037	        ftst                    ! test sign; handle negative separately
02038	        wait
02039	        fstsw   -2(bx)
02040	        wait
02041	        mov     ax,-2(bx)
02042	        sahf                    ! result of test in condition codes
02043	        jb      1f
02044	        frndint                 ! this one rounds (?)
02045	        wait
02046	        fcom    st(1)           ! compare with original; if <=, then OK
02047	        wait
02048	        fstsw   -2(bx)
02049	        wait
02050	        mov     ax,-2(bx)
02051	        sahf
02052	        jbe     2f
02053	        fisubs  one             ! else subtract 1
02054	        wait
02055	        jmp     2f
02056	1:                              ! here, negative case
02057	        frndint                 ! this one rounds (?)
02058	        wait
02059	        fcom    st(1)           ! compare with original; if >=, then OK
02060	        wait
02061	        fstsw   -2(bx)
02062	        wait
02063	        mov     ax,-2(bx)
02064	        sahf
02065	        jae     2f
02066	        fiadds  one             ! else add 1
02067	        wait
02068	2:
02069	        fsub    st(1),st        ! subtract integer part
02070	        wait
02071	        mov     bx,2(bx)
02072	        fstps   (bx)
02073	        wait
02074	        fstps   4(bx)
02075	        wait
02076	        pop     bx
02077	        ret
02078	
02079	.fif8:
02080	        mov     bx,sp
02081	        push    bx              ! make room for FP status word
02082	        wait
02083	        fldd    4(bx)
02084	        wait
02085	        fmuld   12(bx)          ! multiply
02086	        wait
02087	        fld     st              ! and copy result
02088	        wait
02089	        ftst                    ! test sign; handle negative separately
02090	        wait
02091	        fstsw   -2(bx)
02092	        wait
02093	        mov     ax,-2(bx)
02094	        sahf                    ! result of test in condition codes
02095	        jb      1f
02096	        frndint                 ! this one rounds (?)
02097	        wait
02098	        fcom    st(1)           ! compare with original; if <=, then OK
02099	        wait
02100	        fstsw   -2(bx)
02101	        wait
02102	        mov     ax,-2(bx)
02103	        sahf
02104	        jbe     2f
02105	        fisubs  one             ! else subtract 1
02106	        wait
02107	        jmp     2f
02108	1:                              ! here, negative case
02109	        frndint                 ! this one rounds (?)
02110	        wait
02111	        fcom    st(1)           ! compare with original; if >=, then OK
02112	        wait
02113	        fstsw   -2(bx)
02114	        wait
02115	        mov     ax,-2(bx)
02116	        sahf
02117	        jae     2f
02118	        fiadds  one             ! else add 1
02119	        wait
02120	2:
02121	        fsub    st(1),st        ! subtract integer part
02122	        mov     bx,2(bx)
02123	        fstpd   (bx)
02124	        wait
02125	        fstpd   8(bx)
02126	        wait
02127	        pop     bx
02128	        ret
02129	
02130	.fef4:
02131	                                ! this could be simpler, if only the
02132	                                ! fxtract instruction was emulated properly
02133	        mov     bx,sp
02134	        mov     ax,6(bx)
02135	        and     ax,#077600
02136	        je      1f              ! zero exponent
02137	        mov     cx,#7
02138	        shr     ax,cl
02139	        sub     ax,#126
02140	        mov     cx,ax           ! exponent in cx
02141	        mov     ax,6(bx)
02142	        and     ax,#0100177
02143	        or      ax,#0037400     ! load -1 exponent
02144	        mov     dx,4(bx)
02145	        mov     bx,2(bx)
02146	        mov     4(bx),ax
02147	        mov     2(bx),dx
02148	        mov     (bx),cx
02149	        ret
02150	1:                              ! we get here on zero exp
02151	        mov     ax,6(bx)
02152	        and     ax,#0177

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -