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

📄 lib386.txt

📁 操作系统设计与实现源码
💻 TXT
📖 第 1 页 / 共 5 页
字号:
06305	.sri:
06306	        pop     edx              ! return address
06307	        cmp     eax,4
06308	        jne     1f
06309	        pop     eax
06310	        pop     ecx
06311	        sar     eax,cl
06312	        push    eax
06313	        jmp     edx
06314	1:
06315	.extern EODDZ
06316	.extern .trp
06317	        mov     eax,EODDZ
06318	        push    edx
06319	        jmp     .trp

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			src/lib/i386/em/em_sti.s	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

06400	.sect .text; .sect .rom; .sect .data; .sect .bss
06401	.sect .text
06402	.define .sti
06403	.define .sts
06404	
06405	        ! #bytes in ecx
06406	        ! address in ebx
06407	        ! save edi/esi. they might be register variables
06408	.sts:
06409	        pop     edx
06410	        sar     ecx,1
06411	        jnb     1f
06412	        pop     eax
06413	        movb    (ebx),al
06414	        jmp     edx
06415	1:
06416	        sar     ecx,1
06417	        jnb     1f
06418	        pop     eax
06419	        o16 mov (ebx),ax
06420	        jmp     edx
06421	1:
06422	        push    edx
06423	        mov     edx,edi
06424	        mov     edi,ebx
06425	        pop     ebx
06426	        jmp     1f
06427	.sti:
06428	        ! only called with count >> 4
06429	        mov     edx,edi
06430	        mov     edi,ebx
06431	        pop     ebx
06432	        sar     ecx,2
06433	1:
06434	        mov     eax,esi
06435	        mov     esi,esp
06436	        rep movs
06437	        mov     esp,esi
06438	        mov     edi,edx
06439	        mov     esi,eax
06440	        jmp     ebx

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			src/lib/i386/em/em_stop.s	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

06500	.sect .text; .sect .rom; .sect .data; .sect .bss
06501	.sect .text
06502	.define .stop
06503	.stop:
06504	        jmp     ___exit

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			src/lib/i386/em/em_strhp.s	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

06600	.sect .text; .sect .rom; .sect .data; .sect .bss
06601	.sect .text
06602	.define .strhp
06603	.extern .reghp, .limhp, EHEAP, .trp
06604	
06605	.strhp:
06606	        pop     ebx
06607	        pop     eax
06608	        mov     (.reghp),eax
06609	        cmp     eax,(.limhp)
06610	        jb      1f
06611	        add     eax,02000
06612	        and     eax,~0777
06613	        push    ebx
06614	        push    eax
06615	        call    __brk
06616	        pop     ecx
06617	        pop     ebx
06618	        cmp     eax,-1
06619	        je      2f
06620	1:
06621	        mov     (.limhp),ecx
06622	        jmp     ebx
06623	2:
06624	        mov     eax,EHEAP
06625	        push    ebx
06626	        jmp     .trp

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			src/lib/i386/em/em_trp.s	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

06700	.sect .text; .sect .rom; .sect .data; .sect .bss
06701	.sect .text
06702	.define .trp
06703	.extern .trppc, .stop
06704	
06705	                ! eax is trap number
06706	.trp:
06707	        xor     ebx,ebx
06708	        xchg    ebx,(.trppc)
06709	        test    ebx,ebx
06710	        jz      2f
06711	        push    eax
06712	        call    ebx
06713	        pop     eax
06714	        ret
06715	2:
06716	        push    eax
06717	        call    .stop

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			src/lib/i386/em/em_unknown.s	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

06800	.sect .text; .sect .rom; .sect .data; .sect .bss
06801	.sect .text
06802	.define .unknown
06803	.extern EILLINS, .fat
06804	
06805	.unknown:
06806	        mov  eax,EILLINS
06807	        push eax
06808	        jmp  .fat

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			src/lib/i386/em/em_xor.s	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

06900	.sect .text; .sect .rom; .sect .data; .sect .bss
06901	.sect .text
06902	.define .xor
06903	
06904	        ! #bytes in ecx
06905	.xor:
06906	        pop     ebx             ! return address
06907	        mov     edx,edi
06908	        mov     edi,esp
06909	        add     edi,ecx
06910	        sar     ecx,2
06911	1:
06912	        pop     eax
06913	        xor     eax,(edi)
06914	        stos
06915	        loop    1b
06916	        mov     edi,edx
06917	        jmp     ebx

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			src/lib/i386/head/em_abs.h	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

07000	/* $Header: em_abs.h,v 1.3 87/03/10 08:58:45 ceriel Exp $ */
07001	/*
07002	 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
07003	 * See the copyright notice in the ACK home directory, in the file "Copyright".
07004	 */
07005	#define LINO_AD         0
07006	#define FILN_AD         4
07007	
07008	#define LINO            (*(int    *)(_hol0()+LINO_AD))
07009	#define FILN            (*(char  **)(_hol0()+FILN_AD))
07010	
07011	#define EARRAY          0
07012	#define ERANGE          1
07013	#define ESET            2
07014	#define EIOVFL          3
07015	#define EFOVFL          4
07016	#define EFUNFL          5
07017	#define EIDIVZ          6
07018	#define EFDIVZ          7
07019	#define EIUND           8
07020	#define EFUND           9
07021	#define ECONV           10
07022	
07023	#define ESTACK          16
07024	#define EHEAP           17
07025	#define EILLINS         18
07026	#define EODDZ           19
07027	#define ECASE           20
07028	#define EMEMFLT         21
07029	#define EBADPTR         22
07030	#define EBADPC          23
07031	#define EBADLAE         24
07032	#define EBADMON         25
07033	#define EBADLIN         26
07034	#define EBADGTO         27

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			src/lib/i386/head/em_head.s	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

07100	#
07101	.sect .text; .sect .rom; .sect .data; .sect .bss
07102	.define ERANGE,ESET,EHEAP,ECASE,EILLINS,EIDIVZ,EODDZ
07103	.define .trppc, .ignmask
07104	
07105	ERANGE          = 1
07106	ESET            = 2
07107	EIDIVZ          = 6
07108	EHEAP           = 17
07109	EILLINS         = 18
07110	EODDZ           = 19
07111	ECASE           = 20
07112	
07113	#include <em_abs.h>
07114	
07115	.sect .data
07116	.trppc:
07117	        .data4  0
07118	.ignmask:
07119	        .data4  EIOVFL | EIUND | ECONV | EFOVFL | EFUNFL

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

07200	#
07201	!       alloca() - allocate space on the stack          Author: Kees J. Bot
07202	!                                                               2 Dec 1993
07203	.sect .text; .sect .rom; .sect .data; .sect .bss
07204	
07205	.sect .text
07206	        .align  16
07207	.define _alloca
07208	_alloca:
07209	#if __ACK__
07210	        pop     ecx             ! Return address
07211	        pop     eax             ! Bytes to allocate
07212	        add     eax, 2*4+3      ! Add space for two saved register variables
07213	        andb    al, 0xFC        ! Align
07214	        mov     ebx, esp        ! Keep current esp
07215	        sub     esp, eax        ! Lower stack
07216	        mov     eax, esp        ! Return value
07217	        push    4(ebx)          ! Push what is probably the saved esi
07218	        push    (ebx)           ! Saved edi
07219	                                ! Now ACK can still do:
07220	                                !       pop edi; pop esi; leave; ret
07221	        push    eax             ! Dummy argument
07222	        jmp     ecx
07223	#else
07224	        pop     ecx             ! Return address
07225	        pop     eax             ! Bytes to allocate
07226	        add     eax, 3
07227	        andb    al, 0xFC        ! Align
07228	        sub     esp, eax        ! Lower stack
07229	        mov     eax, esp        ! Return value
07230	        push    eax             ! Dummy argument
07231	        jmp     ecx
07232	#endif

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

07300	!       getprocessor() - determine processor type       Author: Kees J. Bot
07301	!                                                               26 Jan 1994
07302	
07303	.sect .text; .sect .rom; .sect .data; .sect .bss
07304	.sect .text
07305	
07306	! int getprocessor(void);
07307	!       Return 386, 486, 586, ...
07308	
07309	.define _getprocessor
07310	
07311	_getprocessor:
07312	        push    ebp
07313	        mov     ebp, esp
07314	        and     esp, 0xFFFFFFFC ! Align stack to avoid AC fault
07315	        mov     ecx, 0x00040000 ! Try to flip the AC bit introduced on the 486
07316	        call    flip
07317	        mov     eax, 386        ! 386 if it didn't react to "flipping"
07318	        jz      gotprocessor
07319	        mov     ecx, 0x00200000 ! Try to flip the ID bit introduced on the 586
07320	        call    flip
07321	        mov     eax, 486        ! 486 if it didn't react
07322	        jz      gotprocessor
07323	        pushf
07324	        pusha                   ! Save the world
07325	        mov     eax, 1
07326	        .data1  0x0F, 0xA2      ! CPUID instruction tells the processor type
07327	        andb    ah, 0x0F        ! Extract the family (5, 6, ...)
07328	        movzxb  eax, ah
07329	        imul    eax, 100        ! 500, 600, ...
07330	        add     eax, 86         ! 586, 686, ...
07331	        mov     7*4(esp), eax   ! Pass eax through
07332	        popa
07333	        popf
07334	gotprocessor:
07335	        leave
07336	        ret
07337	
07338	flip:
07339	        pushf                   ! Push eflags
07340	        pop     eax             ! eax = eflags
07341	        mov     edx, eax        ! Save original eflags
07342	        xor     eax, ecx        ! Flip the bit to test
07343	        push    eax             ! Push modified eflags value
07344	        popf                    ! Load modified eflags register
07345	        pushf
07346	        pop     eax             ! Get it again
07347	        push    edx
07348	        popf                    ! Restore original eflags register
07349	        xor     eax, edx        ! See if the bit changed
07350	        test    eax, ecx
07351	        ret

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			src/lib/i386/misc/iolib.s	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

07400	! Some I/O related routines like:
07401	!       unsigned char inb(int port);
07402	!       unsigned short inw(int port);
07403	!       void outb(int port, int value);
07404	!       void outw(int port, int value);
07405	!       void rep_inb(int port, unsigned char *buf, size_t count);
07406	!       void rep_inw(int port, unsigned short *buf, size_t count);
07407	!       void rep_outb(int port, unsigned char *buf, size_t count);
07408	!       void rep_outw(int port, unsigned short *buf, size_t count);
07409	!       void intr_enable(void);
07410	!       void intr_disable(void);
07411	
07412	.sect .text; .sect .rom; .sect .data; .sect .bss
07413	
07414	.sect .text
07415	.define _inb
07416	_inb:
07417	        push    ebp
07418	        mov     ebp, esp
07419	        mov     edx, 8(ebp)             ! port
07420	        xor     eax, eax
07421	        inb     dx                      ! read 1 byte
07422	        pop     ebp
07423	        ret
07424	
07425	.define _inw
07426	_inw:
07427	        push    ebp
07428	        mov     ebp, esp
07429	        mov     edx, 8(ebp)             ! port
07430	        xor     eax, eax
07431	    o16 in      dx                      ! read 1 word
07432	        pop     ebp
07433	        ret
07434	
07435	.define _outb
07436	_outb:
07437	        push    ebp
07438	        mov     ebp, esp
07439	        mov     edx, 8(ebp)             ! port
07440	        mov     eax, 8+4(ebp)           ! value
07441	        outb    dx                      ! output 1 byte
07442	        pop     ebp
07443	        ret
07444	
07445	.define _outw
07446	_outw:
07447	        push    ebp
07448	        mov     ebp, esp
07449	        mov     edx, 8(ebp)             ! port
07450	        mov     eax, 8+4(ebp)           ! value
07451	    o16 out     dx                      ! output 1 word
07452	        pop     ebp
07453	        ret
07454	
07455	.define _rep_inb
07456	_rep_inb:
07457	        push    ebp
07458	        mov     ebp, esp
07459	        push    edi
07460	        mov     edx, 8(ebp)             ! port
07461	        mov     edi, 12(ebp)            ! buf
07462	        mov     ecx, 16(ebp)            ! byte count
07463	        rep
07464	        inb     dx                      ! input many bytes
07465	        pop     edi
07466	        pop     ebp
07467	        ret
07468	
07469	.define _rep_inw
07470	_rep_inw:
07471	        push    ebp
07472	        mov     ebp, esp
07473	        push    edi
07474	        mov     edx, 8(ebp)             ! port
07475	        mov     edi, 12(ebp)            ! buf
07476	        mov     ecx, 16(ebp)            ! byte count
07477	        shr     ecx, 1                  ! word count
07478	        rep
07479	    o16 in      dx      

⌨️ 快捷键说明

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