From c9512955214665bf7417d3478316e4dcb1c73746 Mon Sep 17 00:00:00 2001 From: ceriel Date: Thu, 19 Jan 1989 16:43:32 +0000 Subject: [PATCH] Initial revision --- mach/i386/libem/.distr | 5 ++++ mach/i386/libem/LIST | 47 ++++++++++++++++++++++++++++++++++++++ mach/i386/libem/Makefile | 30 ++++++++++++++++++++++++ mach/i386/libem/adi.s | 18 +++++++++++++++ mach/i386/libem/and.s | 20 ++++++++++++++++ mach/i386/libem/blm.s | 15 ++++++++++++ mach/i386/libem/cii.s | 33 ++++++++++++++++++++++++++ mach/i386/libem/cms.s | 23 +++++++++++++++++++ mach/i386/libem/com.s | 14 ++++++++++++ mach/i386/libem/compmodule | 4 ++++ mach/i386/libem/csa4.s | 27 ++++++++++++++++++++++ mach/i386/libem/csb4.s | 29 +++++++++++++++++++++++ mach/i386/libem/cuu.s | 22 ++++++++++++++++++ mach/i386/libem/dup.s | 17 ++++++++++++++ mach/i386/libem/dvi.s | 21 +++++++++++++++++ mach/i386/libem/dvu.s | 21 +++++++++++++++++ mach/i386/libem/end.s | 17 ++++++++++++++ mach/i386/libem/error.s | 42 ++++++++++++++++++++++++++++++++++ mach/i386/libem/exg.s | 20 ++++++++++++++++ mach/i386/libem/fakfp.s | 38 ++++++++++++++++++++++++++++++ mach/i386/libem/fat.s | 10 ++++++++ mach/i386/libem/gto.s | 8 +++++++ mach/i386/libem/iaar.s | 19 +++++++++++++++ mach/i386/libem/ilar.s | 15 ++++++++++++ mach/i386/libem/inn.s | 32 ++++++++++++++++++++++++++ mach/i386/libem/ior.s | 18 +++++++++++++++ mach/i386/libem/isar.s | 15 ++++++++++++ mach/i386/libem/lar4.s | 40 ++++++++++++++++++++++++++++++++ mach/i386/libem/loi.s | 44 +++++++++++++++++++++++++++++++++++ mach/i386/libem/mli.s | 20 ++++++++++++++++ mach/i386/libem/mon.s | 7 ++++++ mach/i386/libem/ngi.s | 19 +++++++++++++++ mach/i386/libem/nop.s | 24 +++++++++++++++++++ mach/i386/libem/print.s | 47 ++++++++++++++++++++++++++++++++++++++ mach/i386/libem/rck.s | 20 ++++++++++++++++ mach/i386/libem/return.s | 17 ++++++++++++++ mach/i386/libem/rmi.s | 21 +++++++++++++++++ mach/i386/libem/rmu.s | 21 +++++++++++++++++ mach/i386/libem/rol.s | 20 ++++++++++++++++ mach/i386/libem/ror.s | 20 ++++++++++++++++ mach/i386/libem/sar4.s | 39 +++++++++++++++++++++++++++++++ mach/i386/libem/sbi.s | 19 +++++++++++++++ mach/i386/libem/set.s | 42 ++++++++++++++++++++++++++++++++++ mach/i386/libem/sli.s | 20 ++++++++++++++++ mach/i386/libem/sri.s | 20 ++++++++++++++++ mach/i386/libem/sti.s | 39 +++++++++++++++++++++++++++++++ mach/i386/libem/stop.s | 5 ++++ mach/i386/libem/strhp.s | 27 ++++++++++++++++++++++ mach/i386/libem/trp.s | 17 ++++++++++++++ mach/i386/libem/unknown.s | 9 ++++++++ mach/i386/libem/xor.s | 18 +++++++++++++++ 51 files changed, 1155 insertions(+) create mode 100644 mach/i386/libem/.distr create mode 100644 mach/i386/libem/LIST create mode 100644 mach/i386/libem/Makefile create mode 100644 mach/i386/libem/adi.s create mode 100644 mach/i386/libem/and.s create mode 100644 mach/i386/libem/blm.s create mode 100644 mach/i386/libem/cii.s create mode 100644 mach/i386/libem/cms.s create mode 100644 mach/i386/libem/com.s create mode 100755 mach/i386/libem/compmodule create mode 100644 mach/i386/libem/csa4.s create mode 100644 mach/i386/libem/csb4.s create mode 100644 mach/i386/libem/cuu.s create mode 100644 mach/i386/libem/dup.s create mode 100644 mach/i386/libem/dvi.s create mode 100644 mach/i386/libem/dvu.s create mode 100644 mach/i386/libem/end.s create mode 100644 mach/i386/libem/error.s create mode 100644 mach/i386/libem/exg.s create mode 100644 mach/i386/libem/fakfp.s create mode 100644 mach/i386/libem/fat.s create mode 100644 mach/i386/libem/gto.s create mode 100644 mach/i386/libem/iaar.s create mode 100644 mach/i386/libem/ilar.s create mode 100644 mach/i386/libem/inn.s create mode 100644 mach/i386/libem/ior.s create mode 100644 mach/i386/libem/isar.s create mode 100644 mach/i386/libem/lar4.s create mode 100644 mach/i386/libem/loi.s create mode 100644 mach/i386/libem/mli.s create mode 100644 mach/i386/libem/mon.s create mode 100644 mach/i386/libem/ngi.s create mode 100644 mach/i386/libem/nop.s create mode 100644 mach/i386/libem/print.s create mode 100644 mach/i386/libem/rck.s create mode 100644 mach/i386/libem/return.s create mode 100644 mach/i386/libem/rmi.s create mode 100644 mach/i386/libem/rmu.s create mode 100644 mach/i386/libem/rol.s create mode 100644 mach/i386/libem/ror.s create mode 100644 mach/i386/libem/sar4.s create mode 100644 mach/i386/libem/sbi.s create mode 100644 mach/i386/libem/set.s create mode 100644 mach/i386/libem/sli.s create mode 100644 mach/i386/libem/sri.s create mode 100644 mach/i386/libem/sti.s create mode 100644 mach/i386/libem/stop.s create mode 100644 mach/i386/libem/strhp.s create mode 100644 mach/i386/libem/trp.s create mode 100644 mach/i386/libem/unknown.s create mode 100644 mach/i386/libem/xor.s diff --git a/mach/i386/libem/.distr b/mach/i386/libem/.distr new file mode 100644 index 000000000..e862ca95b --- /dev/null +++ b/mach/i386/libem/.distr @@ -0,0 +1,5 @@ +LIST +Makefile +compmodule +end.s +libem_s.a diff --git a/mach/i386/libem/LIST b/mach/i386/libem/LIST new file mode 100644 index 000000000..955e075d6 --- /dev/null +++ b/mach/i386/libem/LIST @@ -0,0 +1,47 @@ +libem_s.a +adi.s +and.s +blm.s +cii.s +cms.s +com.s +csa4.s +csb4.s +cuu.s +dup.s +dvi.s +dvu.s +error.s +exg.s +fakfp.s +fat.s +gto.s +iaar.s +ilar.s +inn.s +ior.s +isar.s +lar4.s +loi.s +mli.s +mon.s +ngi.s +nop.s +print.s +rck.s +return.s +rmi.s +rmu.s +rol.s +ror.s +sar4.s +sbi.s +set.s +sli.s +sri.s +sti.s +stop.s +strhp.s +trp.s +unknown.s +xor.s diff --git a/mach/i386/libem/Makefile b/mach/i386/libem/Makefile new file mode 100644 index 000000000..b6a883d78 --- /dev/null +++ b/mach/i386/libem/Makefile @@ -0,0 +1,30 @@ +# $Header$ +MACH=i386 + +all: libem_o.a end.o + +install: all + ../../install libem_o.a tail_em + ../../install end.o end_em + +cmp: all + -../../compare libem_o.a tail_em + -../../compare end.o end_em + + +end.o: end.s + $(MACH) -I../../../h -O -c end.s + +libem_o.a: libem_s.a + ASAR=aal ; export ASAR ;\ + march . libem_o.a + +clean: + rm -f *.o libem_o.a + +opr : + make pr | opr + +pr: + @arch pv libem_s.a | pr -h `pwd`/libem_s.a + @pr `pwd`/end.s diff --git a/mach/i386/libem/adi.s b/mach/i386/libem/adi.s new file mode 100644 index 000000000..396c197fe --- /dev/null +++ b/mach/i386/libem/adi.s @@ -0,0 +1,18 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define .adi + + ! #bytes in ecx , top of stack in eax + .sect .text +.adi: + pop ebx ! return address + cmp ecx,4 + jne 9f + pop ecx + add eax,ecx + jmp ebx +9: +.extern EODDZ +.extern .trp + mov eax,EODDZ + push ebx + jmp .trp diff --git a/mach/i386/libem/and.s b/mach/i386/libem/and.s new file mode 100644 index 000000000..eddfa7976 --- /dev/null +++ b/mach/i386/libem/and.s @@ -0,0 +1,20 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define .and + + ! #bytes in ecx + ! save edi; it might be a register variable + + .sect .text +.and: + pop ebx ! return address + mov edx,edi + mov edi,esp + add edi,ecx + sar ecx,2 +1: + pop eax + and eax,(edi) + stos + loop 1b + mov edi,edx + jmp ebx diff --git a/mach/i386/libem/blm.s b/mach/i386/libem/blm.s new file mode 100644 index 000000000..4e1a8ce17 --- /dev/null +++ b/mach/i386/libem/blm.s @@ -0,0 +1,15 @@ +.sect .text +.define .blm + + ! ecx: count in words +.blm: + mov ebx,esp + mov eax,esi + mov edx,edi + mov edi,4(ebx) + mov esi,8(ebx) + rep movs + mov esi,eax + mov edi,edx + ret 8 + diff --git a/mach/i386/libem/cii.s b/mach/i386/libem/cii.s new file mode 100644 index 000000000..60a3c5bd4 --- /dev/null +++ b/mach/i386/libem/cii.s @@ -0,0 +1,33 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define .cii + +.sect .text +.cii: + pop ebx ! return address + ! pop ecx, dest. size + ! pop edx, src. size + ! eax is source + cmp edx,1 + jne 2f + o16 cbw ! needs operand size toggle to convert + ! from one to two bytes. + cwde + mov edx,4 + jmp 1f +2: + cmp edx,2 + jne 1f + cwde ! convert from 2 to 4 bytes + mov edx,4 +1: + cmp edx,ecx + jne 9f + cmp edx,4 + jne 9f + jmp ebx +9: +.extern EILLINS +.extern .fat + mov eax,EILLINS + push eax + jmp .fat diff --git a/mach/i386/libem/cms.s b/mach/i386/libem/cms.s new file mode 100644 index 000000000..d8d263918 --- /dev/null +++ b/mach/i386/libem/cms.s @@ -0,0 +1,23 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define .cms + + ! #bytes in ecx + .sect .text +.cms: + pop ebx ! return address + mov edx,esp + push esi + push edi + mov esi,edx + add edx,ecx + mov edi,edx + add edx,ecx + sar ecx,2 + repe cmps + je 1f + inc ecx +1: + pop edi + pop esi + mov esp,edx + jmp ebx diff --git a/mach/i386/libem/com.s b/mach/i386/libem/com.s new file mode 100644 index 000000000..dfc5f702b --- /dev/null +++ b/mach/i386/libem/com.s @@ -0,0 +1,14 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define .com + + ! #bytes in ecx + .sect .text +.com: + mov ebx,esp + add ebx,4 + sar ecx,2 +1: + not (ebx) + add ebx,4 + loop 1b + ret diff --git a/mach/i386/libem/compmodule b/mach/i386/libem/compmodule new file mode 100755 index 000000000..575cf59d9 --- /dev/null +++ b/mach/i386/libem/compmodule @@ -0,0 +1,4 @@ +if i386 -c $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/i386/libem/csa4.s b/mach/i386/libem/csa4.s new file mode 100644 index 000000000..f90245062 --- /dev/null +++ b/mach/i386/libem/csa4.s @@ -0,0 +1,27 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define .csa4 + +.sect .text +.csa4: + ! ebx, descriptor address + ! eax, index + mov edx,(ebx) ! default + sub eax,4(ebx) + cmp eax,8(ebx) + ja 1f + sal eax,2 + add ebx,eax + mov ebx,12(ebx) + test ebx,ebx + jnz 2f +1: + mov ebx,edx + test ebx,ebx + jnz 2f +.extern ECASE +.extern .fat + mov eax,ECASE + push eax + jmp .fat +2: + jmp ebx diff --git a/mach/i386/libem/csb4.s b/mach/i386/libem/csb4.s new file mode 100644 index 000000000..4a8214183 --- /dev/null +++ b/mach/i386/libem/csb4.s @@ -0,0 +1,29 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define .csb4 + +.sect .text +.csb4: + !ebx, descriptor address + !eax, index + mov edx,(ebx) + mov ecx,4(ebx) +1: + add ebx,8 + dec ecx + jl 4f + cmp eax,(ebx) + jne 1b + mov ebx,4(ebx) +2: + test ebx,ebx + jnz 3f +.extern ECASE +.extern .fat + mov eax,ECASE + push eax + jmp .fat +3: + jmp ebx +4: + mov ebx,edx + jmp 2b diff --git a/mach/i386/libem/cuu.s b/mach/i386/libem/cuu.s new file mode 100644 index 000000000..16177b6c3 --- /dev/null +++ b/mach/i386/libem/cuu.s @@ -0,0 +1,22 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define .ciu +.define .cui +.define .cuu + +.sect .text +.ciu: +.cui: +.cuu: + pop ebx ! return address + ! pop ecx, dest. size + ! pop edx, source size + ! eax is source + cmp edx,ecx + jne 8f + jmp ebx +8: +.extern EILLINS +.extern .fat + mov eax,EILLINS + push eax + jmp .fat diff --git a/mach/i386/libem/dup.s b/mach/i386/libem/dup.s new file mode 100644 index 000000000..071a46c32 --- /dev/null +++ b/mach/i386/libem/dup.s @@ -0,0 +1,17 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define .dup + + ! #bytes in ecx + .sect .text +.dup: + pop ebx ! return address + mov eax,esi + mov edx,edi + mov esi,esp + sub esp,ecx + mov edi,esp + sar ecx,2 + rep movs + mov esi,eax + mov edi,edx + jmp ebx diff --git a/mach/i386/libem/dvi.s b/mach/i386/libem/dvi.s new file mode 100644 index 000000000..f7a87300e --- /dev/null +++ b/mach/i386/libem/dvi.s @@ -0,0 +1,21 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define .dvi + + ! #bytes in eax + .sect .text +.dvi: + pop ebx ! return address + cmp eax,4 + jne 1f + pop eax + cwd + pop ecx + idiv ecx + push eax + jmp ebx +1: +.extern EODDZ +.extern .trp + mov eax,EODDZ + push ebx + jmp .trp diff --git a/mach/i386/libem/dvu.s b/mach/i386/libem/dvu.s new file mode 100644 index 000000000..5f5a71784 --- /dev/null +++ b/mach/i386/libem/dvu.s @@ -0,0 +1,21 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define .dvu + + ! #bytes in eax + .sect .text +.dvu: + pop ebx ! return address + cmp eax,4 + jne 1f + pop eax + xor edx,edx + pop ecx + div ecx + push eax + jmp ebx +1: +.extern EODDZ +.extern .trp + mov eax,EODDZ + push ebx + jmp .trp diff --git a/mach/i386/libem/end.s b/mach/i386/libem/end.s new file mode 100644 index 000000000..b986b7a64 --- /dev/null +++ b/mach/i386/libem/end.s @@ -0,0 +1,17 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define endtext,enddata,endbss +.define _end,_etext,_edata + + ! $Header$ + .sect .text +endtext: +_etext: + .align 4 + .sect .data +enddata: +_edata: + .align 4 +.sect .endsect +_end: +endbss: + .align 4 diff --git a/mach/i386/libem/error.s b/mach/i386/libem/error.s new file mode 100644 index 000000000..36684efa3 --- /dev/null +++ b/mach/i386/libem/error.s @@ -0,0 +1,42 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define .error +.define .Xtrp + + ! eax is trap number + ! all registers must be saved + ! because return is possible + ! May only be called with error no's <16 +.sect .text +.error: + push ebp + push esi + push edi + push edx + push ecx + push ebx + push eax + mov ecx,eax + mov ebx,1 + sal ebx,cl +.extern .ignmask +.extern .trp + test ebx,(.ignmask) + jne 2f + call .trp +2: + pop eax + pop ebx + pop ecx + pop edx + pop edi + pop esi + pop ebp + ret + +.Xtrp: + cmp eax,16 + jge 1f + call .error + ret +1: + jmp .trp diff --git a/mach/i386/libem/exg.s b/mach/i386/libem/exg.s new file mode 100644 index 000000000..d491dffdd --- /dev/null +++ b/mach/i386/libem/exg.s @@ -0,0 +1,20 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.define .exg + + ! #bytes in ecx +.sect .text +.exg: + push edi + mov esp,edi + add edi,8 + mov ebx,edi + add ebx,ecx + sar ecx,2 +1: + mov eax,(ebx) + xchg eax,(edi) + mov (ebx),eax + loop 1b +2: + pop edi + ret diff --git a/mach/i386/libem/fakfp.s b/mach/i386/libem/fakfp.s new file mode 100644 index 000000000..0baadb914 --- /dev/null +++ b/mach/i386/libem/fakfp.s @@ -0,0 +1,38 @@ +.define .adf4, .adf8, .sbf4, .sbf8, .mlf4, .mlf8, .dvf4, .dvf8 +.define .ngf4, .ngf8, .fif4, .fif8, .fef4, .fef8 +.define .cif4, .cif8, .cuf4, .cuf8, .cfi, .cfu, .cff4, .cff8 +.define .cmf4, .cmf8 +.sect .text +.sect .rom +.sect .data +.sect .bss + +! $Header$ + + .sect .text +.adf4: +.adf8: +.sbf4: +.sbf8: +.mlf4: +.mlf8: +.dvf4: +.dvf8: +.ngf4: +.ngf8: +.fif4: +.fif8: +.fef4: +.fef8: +.cif4: +.cif8: +.cuf4: +.cuf8: +.cfi: +.cfu: +.cff4: +.cff8: +.cmf4: +.cmf8: + mov eax,18 ! illegal instruction EILLINS + jmp .trp diff --git a/mach/i386/libem/fat.s b/mach/i386/libem/fat.s new file mode 100644 index 000000000..0302552dc --- /dev/null +++ b/mach/i386/libem/fat.s @@ -0,0 +1,10 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .fat + +.fat: +.extern .trp +.extern .stop + call .trp + call .stop + ! no return diff --git a/mach/i386/libem/gto.s b/mach/i386/libem/gto.s new file mode 100644 index 000000000..0149f27ca --- /dev/null +++ b/mach/i386/libem/gto.s @@ -0,0 +1,8 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .gto + +.gto: + mov ebp,8(ebx) + mov esp,4(ebx) + jmp (ebx) diff --git a/mach/i386/libem/iaar.s b/mach/i386/libem/iaar.s new file mode 100644 index 000000000..af9fd286b --- /dev/null +++ b/mach/i386/libem/iaar.s @@ -0,0 +1,19 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .iaar + +.iaar: + pop ecx + pop edx + cmp edx,4 +.extern .unknown + jne .unknown + pop ebx ! descriptor address + pop eax ! index + pop edx ! array base + sub eax,(ebx) + mul 8(ebx) + mov ebx,edx + add ebx,eax + push ecx + ret diff --git a/mach/i386/libem/ilar.s b/mach/i386/libem/ilar.s new file mode 100644 index 000000000..15514863e --- /dev/null +++ b/mach/i386/libem/ilar.s @@ -0,0 +1,15 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .ilar + +.ilar: + pop ecx + pop edx +.extern .unknown + cmp edx,4 + jne .unknown + pop ebx ! descriptor address + pop eax ! index + push ecx +.extern .lar4 + jmp .lar4 diff --git a/mach/i386/libem/inn.s b/mach/i386/libem/inn.s new file mode 100644 index 000000000..95d8ac01b --- /dev/null +++ b/mach/i386/libem/inn.s @@ -0,0 +1,32 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .inn + + ! #bytes in ecx + ! bit # in eax +.inn: + xor edx,edx + mov ebx,8 + div ebx + mov ebx,esp + add ebx,4 + add ebx,eax + cmp eax,ecx + jae 1f + movb al,(ebx) + mov ebx,edx + testb al,bits(ebx) + jz 1f + mov eax,1 + jmp 2f +1: + xor eax,eax +2: + pop ebx + add esp,ecx + ! eax is result + jmp ebx + + .sect .rom +bits: + .data1 1,2,4,8,16,32,64,128 diff --git a/mach/i386/libem/ior.s b/mach/i386/libem/ior.s new file mode 100644 index 000000000..ac40fb403 --- /dev/null +++ b/mach/i386/libem/ior.s @@ -0,0 +1,18 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .ior + + ! #bytes in ecx +.ior: + pop ebx ! return address + mov edx,edi + mov edi,esp + add edi,ecx + sar ecx,1 +1: + pop eax + or eax,(edi) + stos + loop 1b + mov edi,edx + jmp ebx diff --git a/mach/i386/libem/isar.s b/mach/i386/libem/isar.s new file mode 100644 index 000000000..75b46b7b5 --- /dev/null +++ b/mach/i386/libem/isar.s @@ -0,0 +1,15 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .isar + +.isar: + pop ecx + pop eax + cmp eax,4 +.extern .unknown + jne .unknown + pop ebx ! descriptor address + pop eax ! index + push ecx +.extern .sar4 + jmp .sar4 diff --git a/mach/i386/libem/lar4.s b/mach/i386/libem/lar4.s new file mode 100644 index 000000000..4eaa070a1 --- /dev/null +++ b/mach/i386/libem/lar4.s @@ -0,0 +1,40 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .lar4 + +.lar4: + ! ebx, descriptor address + ! eax, index + pop ecx + pop edx ! base address + push ecx + sub eax,(ebx) + mov ecx,8(ebx) + imul ecx + add edx,eax + sar ecx,1 + jnb 1f + xor eax,eax + movb al,(edx) + pop ebx + push eax + jmp ebx +1: + sar ecx,1 + jnb 1f + xor eax,eax + o16 mov ax,(edx) + pop ebx + push eax + jmp ebx +1: + mov edx,esi ! saved esi + mov eax,8(ebx) + pop ebx ! return address + sub esp,eax + mov eax,edi ! save edi + mov edi,esp + rep movs + mov edi,eax + mov esi,edx + jmp ebx diff --git a/mach/i386/libem/loi.s b/mach/i386/libem/loi.s new file mode 100644 index 000000000..b1919eedf --- /dev/null +++ b/mach/i386/libem/loi.s @@ -0,0 +1,44 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .loi +.define .los + + ! #bytes in ecx + ! address in ebx + ! save esi/edi. they might be register variables +.los: + pop edx + mov eax,ecx + sar ecx,1 + jnb 1f + xor eax,eax + movb al,(edx) + push eax + jmp edx +1: + sar ecx,1 + jnb 1f + xor eax,eax + o16 mov ax,(edx) + push eax + jmp edx +1: + mov ebx,edx + mov edx,esi + sub esp,eax + jmp 1f + +.loi: + ! only called with size >= 4 + mov edx,esi + mov esi,ebx + pop ebx + sub esp,ecx + sar ecx,2 +1: + mov eax,edi + mov edi,esp + rep movs + mov esi,edx + mov edi,eax + jmp ebx diff --git a/mach/i386/libem/mli.s b/mach/i386/libem/mli.s new file mode 100644 index 000000000..84185fb62 --- /dev/null +++ b/mach/i386/libem/mli.s @@ -0,0 +1,20 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .mli + + ! #bytes in eax +.mli: + pop ebx ! return address + cmp eax,4 + jne 1f + pop eax + pop ecx + mul ecx + push eax + jmp ebx +1: +.extern EODDZ +.extern .trp + mov eax,EODDZ + push ebx + jmp .trp diff --git a/mach/i386/libem/mon.s b/mach/i386/libem/mon.s new file mode 100644 index 000000000..42cac7ca8 --- /dev/null +++ b/mach/i386/libem/mon.s @@ -0,0 +1,7 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .mon + +.mon: +.extern .stop + call .stop diff --git a/mach/i386/libem/ngi.s b/mach/i386/libem/ngi.s new file mode 100644 index 000000000..b15a1fab8 --- /dev/null +++ b/mach/i386/libem/ngi.s @@ -0,0 +1,19 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .ngi + + ! #bytes in eax +.ngi: + pop ebx ! return address + cmp eax,4 + jne 1f + pop ecx + neg ecx + push ecx + jmp ebx +1: +.extern EODDZ +.extern .trp + mov eax,EODDZ + push ebx + jmp .trp diff --git a/mach/i386/libem/nop.s b/mach/i386/libem/nop.s new file mode 100644 index 000000000..c0f59f222 --- /dev/null +++ b/mach/i386/libem/nop.s @@ -0,0 +1,24 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .nop +.extern printd, printc, hol0 + +SIO_S = 0xDA +SIO_D = 0xD8 +RXRDY = 0x02 + +.nop: + mov eax,(hol0) + call printd +! movb al,' ' +! call printc +! mov eax,esp +! call printd +!1: +! inb SIO_S +! andb al,RXRDY +! jz 1b +! inb SIO_D +! call printc + movb al,'\n' + jmp printc diff --git a/mach/i386/libem/print.s b/mach/i386/libem/print.s new file mode 100644 index 000000000..a18cd920a --- /dev/null +++ b/mach/i386/libem/print.s @@ -0,0 +1,47 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define printc,printd,prints + + ! argument in eax + ! uses ebx +prints: + xchg eax,ebx +1: + movb al,(ebx) + inc ebx + testb al,al + jz 2f + call printc + jmp 1b +2: + ret + + ! argument in eax + ! uses ecx and edx +printd: + xor edx,edx + mov ecx,10 + div ecx + test eax,eax + jz 1f + push edx + call printd + pop edx +1: + xchg eax,edx + addb al,'0' + + ! argument in eax +printc: + push eax + mov ebx,esp + mov eax,1 + push eax + push ebx + push eax + call _write + pop ebx + pop ebx + pop ebx + pop ebx + ret diff --git a/mach/i386/libem/rck.s b/mach/i386/libem/rck.s new file mode 100644 index 000000000..e1a6669e4 --- /dev/null +++ b/mach/i386/libem/rck.s @@ -0,0 +1,20 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .rck + + ! descriptor address in ebx + ! value in eax, must be left there +.rck: + cmp eax,(ebx) + jl 2f + cmp eax,4(ebx) + jg 2f + ret +2: + push eax +.extern ERANGE +.extern .error + mov eax,ERANGE + call .error + pop eax + ret diff --git a/mach/i386/libem/return.s b/mach/i386/libem/return.s new file mode 100644 index 000000000..f12a88139 --- /dev/null +++ b/mach/i386/libem/return.s @@ -0,0 +1,17 @@ +.define .sdret, .dsret, .sret, .dret, .cret +.sect .text + +.dsret: + pop edi +.sret: + pop esi +.cret: + mov esp,ebp + pop ebp + ret + +.sdret: + pop esi +.dret: + pop edi + jmp .cret diff --git a/mach/i386/libem/rmi.s b/mach/i386/libem/rmi.s new file mode 100644 index 000000000..775abbdd7 --- /dev/null +++ b/mach/i386/libem/rmi.s @@ -0,0 +1,21 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .rmi + + ! #bytes in eax +.rmi: + pop ebx ! return address + cmp eax,4 + jne 1f + pop eax + cwd + pop ecx + idiv ecx + push edx + jmp ebx +1: +.extern EODDZ +.extern .trp + mov eax,EODDZ + push ebx + jmp .trp diff --git a/mach/i386/libem/rmu.s b/mach/i386/libem/rmu.s new file mode 100644 index 000000000..d51029d58 --- /dev/null +++ b/mach/i386/libem/rmu.s @@ -0,0 +1,21 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .rmu + + ! #bytes in eax +.rmu: + pop ebx ! return address + cmp eax,4 + jne 1f + pop eax + xor edx,edx + pop ecx + idiv ecx + push edx + jmp ebx +1: +.extern EODDZ +.extern .trp + mov eax,EODDZ + push ebx + jmp .trp diff --git a/mach/i386/libem/rol.s b/mach/i386/libem/rol.s new file mode 100644 index 000000000..68365d7fc --- /dev/null +++ b/mach/i386/libem/rol.s @@ -0,0 +1,20 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .rol + + ! #bytes in eax +.rol: + pop edx ! return address + cmp eax,4 + jne 1f + pop eax + pop ecx + rol eax,cl + push eax + jmp edx +1: +.extern EODDZ +.extern .trp + mov eax,EODDZ + push edx + jmp .trp diff --git a/mach/i386/libem/ror.s b/mach/i386/libem/ror.s new file mode 100644 index 000000000..ef34a9658 --- /dev/null +++ b/mach/i386/libem/ror.s @@ -0,0 +1,20 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .ror + + ! #bytes in eax +.ror: + pop edx ! return address + cmp eax,4 + jne 1f + pop eax + pop ecx + ror eax,cl + push eax + jmp edx +1: +.extern EODDZ +.extern .trp + mov eax,EODDZ + push edx + jmp .trp diff --git a/mach/i386/libem/sar4.s b/mach/i386/libem/sar4.s new file mode 100644 index 000000000..2cbeef6f2 --- /dev/null +++ b/mach/i386/libem/sar4.s @@ -0,0 +1,39 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .sar4 + +.sar4: + ! ebx, descriptor address + ! eax, index + pop ecx + pop edx ! base address + push ecx + sub eax,(ebx) + mov ecx,8(ebx) + push edx + imul ecx + pop edx + add edx,eax + sar ecx,1 + jnb 1f + pop ebx + pop eax + movb (edx),al + jmp ebx +1: + sar ecx,1 + jnb 1f + pop ebx + pop eax + o16 mov (edx),ax + jmp ebx +1: + pop ebx + xchg edi,edx ! edi = base address, edx is saved edi + mov eax,esi + mov esi,esp + rep movs + mov esp,esi + mov esi,eax + mov edi,edx + jmp ebx diff --git a/mach/i386/libem/sbi.s b/mach/i386/libem/sbi.s new file mode 100644 index 000000000..2897d3181 --- /dev/null +++ b/mach/i386/libem/sbi.s @@ -0,0 +1,19 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .sbi + + ! #bytes in ecx , top of stack in eax +.sbi: + pop ebx ! return subress + cmp ecx,4 + jne 1f + pop ecx + sub eax,ecx + neg eax + jmp ebx +1: +.extern EODDZ +.extern .trp + mov eax,EODDZ + push ebx + jmp .trp diff --git a/mach/i386/libem/set.s b/mach/i386/libem/set.s new file mode 100644 index 000000000..0f334bc37 --- /dev/null +++ b/mach/i386/libem/set.s @@ -0,0 +1,42 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .set + + ! #bytes in ecx + ! bit # in eax +.set: + pop ebx ! return address + xor edx,edx +!ifdef create set + sub esp,ecx + push ebx + push edi + mov ebx,esp + xor edi,edi + sar ecx,1 +1: + mov 4(ebx)(edi),edx + add edi,4 + loop 1b +!endif + mov ebx,8 + div ebx + cmp eax,edi + jae 2f + mov edi,edx + movb dl,bits(edi) + mov edi,esp + add edi,eax + orb 8(edi),dl + pop edi + ret +2: +.extern ESET +.extern .trp + pop edi + mov eax,ESET + jmp .trp + + .sect .rom +bits: + .data1 1,2,4,8,16,32,64,128 diff --git a/mach/i386/libem/sli.s b/mach/i386/libem/sli.s new file mode 100644 index 000000000..dd5b61667 --- /dev/null +++ b/mach/i386/libem/sli.s @@ -0,0 +1,20 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .sli + + ! #bytes in eax +.sli: + pop edx ! return address + cmp eax,4 + jne 1f + pop eax + pop ecx + sal eax,cl + push eax + jmp edx +1: +.extern EODDZ +.extern .trp + mov eax,EODDZ + push edx + jmp .trp diff --git a/mach/i386/libem/sri.s b/mach/i386/libem/sri.s new file mode 100644 index 000000000..2fb78715f --- /dev/null +++ b/mach/i386/libem/sri.s @@ -0,0 +1,20 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .sri + + ! #bytes in eax +.sri: + pop edx ! return address + cmp eax,4 + jne 1f + pop eax + pop ecx + sar eax,cl + push eax + jmp edx +1: +.extern EODDZ +.extern .trp + mov eax,EODDZ + push edx + jmp .trp diff --git a/mach/i386/libem/sti.s b/mach/i386/libem/sti.s new file mode 100644 index 000000000..4bd0e1a99 --- /dev/null +++ b/mach/i386/libem/sti.s @@ -0,0 +1,39 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .sti +.define .sts + + ! #bytes in ecx + ! address in ebx + ! save edi/esi. they might be register variables +.sts: + pop edx + sar ecx,1 + jnb 1f + pop eax + movb (ebx),al + jmp edx +1: + sar ecx,1 + jnb 1f + pop eax + o16 mov (ebx),ax + jmp edx +1: + mov ebx,edx + mov edx,edi + jmp 1f +.sti: + ! only called with count >> 4 + mov edx,edi + mov edi,ebx + pop ebx + sar ecx,2 +1: + mov eax,esi + mov esi,esp + rep movs + mov esp,esi + mov edi,edx + mov esi,eax + jmp ebx diff --git a/mach/i386/libem/stop.s b/mach/i386/libem/stop.s new file mode 100644 index 000000000..fbf0e691e --- /dev/null +++ b/mach/i386/libem/stop.s @@ -0,0 +1,5 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .stop +.stop: + int 3 diff --git a/mach/i386/libem/strhp.s b/mach/i386/libem/strhp.s new file mode 100644 index 000000000..ff2c217ce --- /dev/null +++ b/mach/i386/libem/strhp.s @@ -0,0 +1,27 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .strhp +.extern .reghp, .limhp, EHEAP, .trp + +.strhp: + pop ebx + pop eax + mov (.reghp),eax + cmp eax,(.limhp) + jb 1f + add eax,02000 + and eax,~0777 + mov (.limhp),eax + push ebx + push eax + call _brk + pop ecx + pop ebx + cmp eax,-1 + je 2f +1: + jmp ebx +2: + mov eax,EHEAP + push ebx + jmp .trp diff --git a/mach/i386/libem/trp.s b/mach/i386/libem/trp.s new file mode 100644 index 000000000..4292fe30c --- /dev/null +++ b/mach/i386/libem/trp.s @@ -0,0 +1,17 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .trp +.extern .trppc, .stop + + ! eax is trap number +.trp: + xor ebx,ebx + xchg ebx,(.trppc) + test ebx,ebx + jz 2f + push eax + call ebx + pop eax + ret +2: + call .stop diff --git a/mach/i386/libem/unknown.s b/mach/i386/libem/unknown.s new file mode 100644 index 000000000..59425f25c --- /dev/null +++ b/mach/i386/libem/unknown.s @@ -0,0 +1,9 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .unknown +.extern EILLINS, .fat + +.unknown: + mov eax,EILLINS + push eax + jmp .fat diff --git a/mach/i386/libem/xor.s b/mach/i386/libem/xor.s new file mode 100644 index 000000000..2dfb30d96 --- /dev/null +++ b/mach/i386/libem/xor.s @@ -0,0 +1,18 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss +.sect .text +.define .xor + + ! #bytes in ecx +.xor: + pop ebx ! return address + mov edx,edi + mov edi,esp + add edi,ecx + sar ecx,2 +1: + pop eax + xor eax,(edi) + stos + loop 1b + mov edi,edx + jmp ebx