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

📄 lib86.txt

📁 操作系统设计与实现源码
💻 TXT
📖 第 1 页 / 共 5 页
字号:
04618	        pop     bx
04619	        pop     ax
04620	        stosb
04621	        mov     di,dx
04622	        jmp     (bx)
04623	1:
04624	        pop     bx
04625	        mov     ax,si
04626	        mov     si,sp
04627	        rep
04628	        mov
04629	        mov     sp,si
04630	        mov     si,ax
04631	        mov     di,dx
04632	        jmp     (bx)

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

04700	.define .sbi
04701	.text
04702	
04703	        ! #bytes in cx , top of stack in ax
04704	.sbi:
04705	        pop     bx              ! return subress
04706	        cmp     cx,#2
04707	        jne     1f
04708	        pop     cx
04709	        sub     ax,cx
04710	        neg     ax
04711	        jmp     (bx)
04712	1:
04713	        cmp     cx,#4
04714	        jne     9f
04715	        pop     dx
04716	        pop     cx
04717	        sub     cx,ax
04718	        mov     ax,cx
04719	        pop     cx
04720	        sbb     cx,dx
04721	        push    cx
04722	        jmp     (bx)
04723	9:
04724	.extern .trpilin
04725	        push    bx
04726	        jmp     .trpilin

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

04800	.define .set
04801	.text
04802	
04803	        ! #bytes in cx
04804	        ! bit # in ax
04805	.set:
04806	        pop     bx              ! return address
04807	        xor     dx,dx
04808	!ifdef create set
04809	        sub     sp,cx
04810	        push    bx
04811	        push    di
04812	        mov     bx,sp
04813	        xor     di,di
04814	        sar     cx,#1
04815	1:
04816	        mov     4(bx)(di),dx
04817	        inc     di
04818	        inc     di
04819	        loop    1b
04820	!endif
04821	        mov     bx,#8
04822	        div     bx
04823	        cmp     ax,di
04824	        jae     2f
04825	        mov     di,dx
04826	        movb    dl,bits(di)
04827	        mov     di,sp
04828	        add     di,ax
04829	        orb     4(di),dl
04830	        pop     di
04831	        ret
04832	2:
04833	ESET = 2
04834	.extern .error
04835	        pop     di
04836	        mov     ax,#ESET
04837	        call    .error
04838	        ret
04839	
04840	        .data
04841	bits:
04842	        .data1   1,2,4,8,16,32,64,128

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			src/lib/i86/em/stb.c	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

04900	/*
04901	 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
04902	 * See the copyright notice in the ACK home directory, in the file "Copyright".
04903	 */
04904	/* $Header: stb.c,v 1.1 89/02/07 11:01:46 ceriel Exp $ */
04905	/* library routine for copying structs */
04906	
04907	#include <ansi.h>
04908	
04909	_PROTOTYPE(int __stb, (int n, char *f, char *t ));
04910	__stb(n, f, t)
04911	register int n;
04912	register char *f, *t;
04913	{
04914	        if (n > 0)
04915	                do
04916	                        *t++ = *f++;
04917	                while (--n);
04918	}

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

05000	.define .sti
05001	.define .sts
05002	.text
05003	
05004	        ! #bytes in cx
05005	        ! address in bx
05006	        ! save di/si. they might be register variables
05007	.sts:
05008	        mov     dx,di           ! save di
05009	        mov     di,bx
05010	        pop     bx              ! return address
05011	        sar     cx,#1
05012	        jnb     1f
05013	        pop     ax
05014	        stosb
05015	        mov     di,dx
05016	        jmp     (bx)
05017	.sti:
05018	        ! only called with count > 4
05019	        mov     dx,di
05020	        mov     di,bx
05021	        pop     bx
05022	        sar     cx,#1
05023	1:
05024	        mov     ax,si
05025	        mov     si,sp
05026	        rep
05027	        mov
05028	        mov     sp,si
05029	        mov     di,dx
05030	        mov     si,ax
05031	        jmp     (bx)

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

05100	.define .stop
05101	.text
05102	.stop:
05103	        call    __exit

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

05200	.define .strhp
05201	.text
05202	.extern .reghp, .limhp, .fat
05203	EHEAP = 17
05204	
05205	.strhp:
05206	        pop     bx
05207	        pop     ax
05208	        mov     .reghp,ax
05209	        cmp     ax,.limhp
05210	        jb      1f
05211	        add     ax,#01000
05212	        and     ax,#0177000
05213	        mov     .limhp,ax
05214	        cmp     ax,sp
05215	        jae     2f
05216	1:
05217	        jmp     (bx)
05218	2:
05219	        mov     ax,#EHEAP
05220	        jmp     .fat

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

05300	.define .trpdivz
05301	.define .trpilin
05302	.define .trpcase
05303	.define .trprang
05304	.define .trpset
05305	.define .trpnofp
05306	.define .trpheap
05307	.define .trp
05308	
05309	.bss
05310	.M: .zerow 24/2
05311	
05312	.text
05313	.extern .trpdivz
05314	.extern .trpilin
05315	.extern .trpcase
05316	.extern .trprang
05317	.extern .trpset
05318	.extern .trpnofp
05319	.extern .trpheap
05320	.extern .trp
05321	
05322	.trpdivz:
05323	mov ax,#6
05324	mov dx,#.Mdivz
05325	jmp .Trp
05326	.trpilin:
05327	mov ax,#18
05328	mov dx,#.Milin
05329	jmp .Trp
05330	.trpcase:
05331	mov ax,#20
05332	mov dx,#.Mcase
05333	jmp .Trp
05334	.trprang:
05335	mov ax,#1
05336	mov dx,#.Mrang
05337	jmp .Trp
05338	.trpset:
05339	mov ax,#2
05340	mov dx,#.Mset
05341	jmp .Trp
05342	.trpnofp:
05343	mov ax,#18
05344	mov dx,#.Mnofp
05345	jmp .Trp
05346	.trpheap:
05347	mov ax,#17
05348	mov dx,#.Mheap
05349	jmp .Trp
05350	
05351	.Trp:
05352	xor     bx,bx
05353	.extern .trppc
05354	xchg    bx,.trppc
05355	test    bx,bx
05356	jz      2f
05357	push    ax
05358	call    (bx)
05359	pop     ax
05360	ret
05361	2:
05362	mov bx,#22
05363	push bx
05364	push dx
05365	mov ax,#2
05366	push ax
05367	call .Write
05368	call __exit
05369	
05370	.trp:
05371	mov dx,ax
05372	cmp dx,#21
05373	jae 1f
05374	sal dx,#1
05375	mov bx,#.Mtable
05376	add bx,dx
05377	mov bx,(bx)
05378	test bx,bx
05379	jz 1f
05380	mov dx,bx
05381	jmp 2f
05382	1:
05383	mov bx,#.Mtrp+14
05384	mov cx,#6
05385	mov dx,ax
05386	1:
05387	and dx,#7
05388	add dx,'0'
05389	movb (bx),dl
05390	dec bx
05391	sar dx,#1
05392	sar dx,#1
05393	sar dx,#1
05394	loop 1b
05395	mov dx,#.Mtrp
05396	2:
05397	jmp .Trp
05398	
05399	.Write:
05400	push bp
05401	mov bp,sp
05402	mov .M+2,#4
05403	mov bx,4(bp)
05404	mov .M+4,bx
05405	mov bx,8(bp)
05406	mov .M+6,bx
05407	mov bx,6(bp)
05408	mov .M+10,bx
05409	mov ax,#.M
05410	push ax
05411	mov ax,#1
05412	push ax
05413	
05414	mov ax,#1
05415	mov bx,#.M
05416	mov cx,#3
05417	int 32
05418	mov sp,bp
05419	pop bp
05420	ret
05421	
05422	
05423	.data
05424	.Mtable:
05425	        .data2 0,       .Mrang, .Mset,  0,      0,      0,      .Mdivz, 0
05426	        .data2 0,       0,      0,      0,      0,      0,      0,      0
05427	        .data2 0,       .Mheap, .Milin, .Milin, .Mcase
05428	
05429	.Mdivz: .asciz "Error: Division by 0 \n"
05430	.Milin: .asciz "Illegal EM instruct'n\n"
05431	.Mcase: .asciz "Err in EM case instr \n"
05432	.Mrang: .asciz "Variable out of range\n"
05433	.Mset:  .asciz "Err in EM set instr  \n"
05434	.Mnofp: .asciz "Floating pt not impl.\n"
05435	.Mheap: .asciz "Heap overflow        \n"
05436	
05437	.Mtrp:  .asciz "EM trap 0000000 octal\n"

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

05500	.define .unknown
05501	.text
05502	.extern .fat
05503	EILLINS = 18
05504	
05505	.unknown:
05506	        mov  ax,#EILLINS
05507	        push ax
05508	        jmp  .fat

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

05600	.define .reghp, .limhp, .ignmask, .trppc
05601	.extern .reghp, .limhp, .ignmask, .trppc
05602	
05603	.data
05604	.reghp:
05605	        .data2   endbss
05606	.limhp:
05607	        .data2   endbss
05608	.ignmask:
05609	        .data2   1336
05610	.trppc:
05611	        .data2   0

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

05700	.define .xor
05701	.text
05702	
05703	        ! #bytes in cx
05704	.xor:
05705	        pop     bx              ! return address
05706	        mov     dx,di
05707	        mov     di,sp
05708	        add     di,cx
05709	        sar     cx,#1
05710	1:
05711	        pop     ax
05712	        xor     ax,(di)
05713	        stos
05714	        loop    1b
05715	        mov     di,dx
05716	        jmp     (bx)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			src/lib/i86/misc/alloca.s	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

05800	#
05801	!       alloca() - allocate space on the stack          Author: Kees J. Bot
05802	!                                                               26 Jan 1994
05803	
05804	#if __ACK__     /* BCC can't do alloca(), register saving is wrong. */
05805	
05806	.text
05807	.define _alloca
05808	_alloca:
05809	        pop     cx              ! Return address
05810	        pop     ax              ! Bytes to allocate
05811	        add     ax, #2*2+1      ! Add space for two saved register variables
05812	        andb    al, #0xFE       ! Align
05813	        mov     bx, sp          ! Keep current sp
05814	        sub     sp, ax          ! Lower stack
05815	        mov     ax, sp          ! Return value
05816	        push    2(bx)           ! Push what is probably the saved si
05817	        push    (bx)            ! Saved di
05818	                                ! Now ACK can still do:
05819	                                !       pop di; pop si; mov sp, bp; pop bp; ret
05820	        push    ax              ! Dummy argument
05821	        jmp     (cx)
05822	#endif

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			src/lib/i86/misc/getprocessor.s	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

05900	!       getprocessor() - determine processor type       Author: Kees J. Bot
05901	!                                                               26 Jan 1994
05902	
05903	.text
05904	
05905	        o32 = 0x66              ! 32 bit operand size prefix
05906	
05907	! int getprocessor(void);
05908	!       Return 86, 186, 286, 386, 486, 586, ...
05909	
05910	.define _getprocessor
05911	
05912	_getprocessor:
05913	        push    bp
05914	        mov     bp, sp
05915	        push    sp              ! see if pushed sp == sp
05916	        pop     ax
05917	        cmp     ax, sp
05918	        jz      new_processor
05919	        mov     cx, #0x0120     ! see if shifts are mod 32
05920	        shlb    ch, cl          ! zero tells if 86
05921	        mov     ax, #86
05922	        jz      got_processor
05923	        mov     ax, #186
05924	        jmp     got_processor
05925	
05926	new_processor:                  ! see if high bits are set in saved GDT
05927	        sub     sp, #6          ! space for GDT ptr
05928	        .data1  0x0F            ! Prefix for 286 instruction: sgdt -6(bp)
05929	        add     -6(bp), ax      ! save 3 word GDT ptr (This is NOT an add!)
05930	        cmpb    -1(bp), #0      ! top byte of GDT ptr is zero only for 386
05931	        mov     ax, #286
05932	        jnz     got_processor
05933	
05934	! 386, 486, 586
05935	        and     sp, #0xFFFC     ! Align stack to avoid AC fault (needed?)
05936	        mov     cx, #0x0004     ! Try to flip the AC bit introduced on the 486
05937	        call    flip
05938	        mov     ax, #386        ! 386 if it didn't react to "flipping"
05939	        jz 

⌨️ 快捷键说明

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