📄 lib86.t
字号:
04623 1:04624 pop bx04625 mov ax,si04626 mov si,sp04627 rep04628 mov04629 mov sp,si04630 mov si,ax04631 mov di,dx04632 jmp (bx)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib/i86/em/sbi.s ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++04700 .define .sbi04701 .text04702 04703 ! #bytes in cx , top of stack in ax04704 .sbi:04705 pop bx ! return subress04706 cmp cx,#204707 jne 1f04708 pop cx04709 sub ax,cx04710 neg ax04711 jmp (bx)04712 1:04713 cmp cx,#404714 jne 9f04715 pop dx04716 pop cx04717 sub cx,ax04718 mov ax,cx04719 pop cx04720 sbb cx,dx04721 push cx04722 jmp (bx)04723 9:04724 .extern .trpilin04725 push bx04726 jmp .trpilin.Ep 36 src/lib/i86/em/set.s++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib/i86/em/set.s ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++04800 .define .set04801 .text04802 04803 ! #bytes in cx04804 ! bit # in ax04805 .set:04806 pop bx ! return address04807 xor dx,dx04808 !ifdef create set04809 sub sp,cx04810 push bx04811 push di04812 mov bx,sp04813 xor di,di04814 sar cx,#104815 1:04816 mov 4(bx)(di),dx04817 inc di04818 inc di04819 loop 1b04820 !endif04821 mov bx,#804822 div bx04823 cmp ax,di04824 jae 2f04825 mov di,dx04826 movb dl,bits(di)04827 mov di,sp04828 add di,ax04829 orb 4(di),dl04830 pop di04831 ret04832 2:04833 ESET = 204834 .extern .error04835 pop di04836 mov ax,#ESET04837 call .error04838 ret04839 04840 .data04841 bits:04842 .data1 1,2,4,8,16,32,64,128.Op 37 src/lib/i86/em/stb.c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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 do04916 *t++ = *f++;04917 while (--n);04918 }++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib/i86/em/sti.s ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++05000 .define .sti05001 .define .sts05002 .text05003 05004 ! #bytes in cx05005 ! address in bx05006 ! save di/si. they might be register variables05007 .sts:05008 mov dx,di ! save di05009 mov di,bx05010 pop bx ! return address05011 sar cx,#105012 jnb 1f05013 pop ax05014 stosb05015 mov di,dx05016 jmp (bx)05017 .sti:05018 ! only called with count > 405019 mov dx,di05020 mov di,bx05021 pop bx05022 sar cx,#105023 1:05024 mov ax,si05025 mov si,sp05026 rep05027 mov05028 mov sp,si05029 mov di,dx.Ep 38 src/lib/i86/em/sti.s05030 mov si,ax05031 jmp (bx)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib/i86/em/stop.s ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++05100 .define .stop05101 .text05102 .stop:05103 call __exit++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib/i86/em/strhp.s ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++05200 .define .strhp05201 .text05202 .extern .reghp, .limhp, .fat05203 EHEAP = 1705204 05205 .strhp:05206 pop bx05207 pop ax05208 mov .reghp,ax05209 cmp ax,.limhp05210 jb 1f05211 add ax,#0100005212 and ax,#017700005213 mov .limhp,ax05214 cmp ax,sp05215 jae 2f05216 1:05217 jmp (bx)05218 2:05219 mov ax,#EHEAP05220 jmp .fat++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib/i86/em/trp.s ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++05300 .define .trpdivz05301 .define .trpilin05302 .define .trpcase05303 .define .trprang05304 .define .trpset05305 .define .trpnofp05306 .define .trpheap05307 .define .trp05308 05309 .bss.Op 39 src/lib/i86/em/trp.s05310 .M: .zerow 24/205311 05312 .text05313 .extern .trpdivz05314 .extern .trpilin05315 .extern .trpcase05316 .extern .trprang05317 .extern .trpset05318 .extern .trpnofp05319 .extern .trpheap05320 .extern .trp05321 05322 .trpdivz:05323 mov ax,#605324 mov dx,#.Mdivz05325 jmp .Trp05326 .trpilin:05327 mov ax,#1805328 mov dx,#.Milin05329 jmp .Trp05330 .trpcase:05331 mov ax,#2005332 mov dx,#.Mcase05333 jmp .Trp05334 .trprang:05335 mov ax,#105336 mov dx,#.Mrang05337 jmp .Trp05338 .trpset:05339 mov ax,#205340 mov dx,#.Mset05341 jmp .Trp05342 .trpnofp:05343 mov ax,#1805344 mov dx,#.Mnofp05345 jmp .Trp05346 .trpheap:05347 mov ax,#1705348 mov dx,#.Mheap05349 jmp .Trp05350 05351 .Trp:05352 xor bx,bx05353 .extern .trppc05354 xchg bx,.trppc05355 test bx,bx05356 jz 2f05357 push ax05358 call (bx)05359 pop ax05360 ret05361 2:05362 mov bx,#2205363 push bx05364 push dx05365 mov ax,#205366 push ax05367 call .Write05368 call __exit05369 .Ep 40 src/lib/i86/em/trp.s05370 .trp:05371 mov dx,ax05372 cmp dx,#2105373 jae 1f05374 sal dx,#105375 mov bx,#.Mtable05376 add bx,dx05377 mov bx,(bx)05378 test bx,bx05379 jz 1f05380 mov dx,bx05381 jmp 2f05382 1:05383 mov bx,#.Mtrp+1405384 mov cx,#605385 mov dx,ax05386 1:05387 and dx,#705388 add dx,'0'05389 movb (bx),dl05390 dec bx05391 sar dx,#105392 sar dx,#105393 sar dx,#105394 loop 1b05395 mov dx,#.Mtrp05396 2:05397 jmp .Trp05398 05399 .Write:05400 push bp05401 mov bp,sp05402 mov .M+2,#405403 mov bx,4(bp)05404 mov .M+4,bx05405 mov bx,8(bp)05406 mov .M+6,bx05407 mov bx,6(bp)05408 mov .M+10,bx05409 mov ax,#.M05410 push ax05411 mov ax,#105412 push ax05413 05414 mov ax,#105415 mov bx,#.M05416 mov cx,#305417 int 3205418 mov sp,bp05419 pop bp05420 ret05421 05422 05423 .data05424 .Mtable:05425 .data2 0, .Mrang, .Mset, 0, 0, 0, .Mdivz, 005426 .data2 0, 0, 0, 0, 0, 0, 0, 005427 .data2 0, .Mheap, .Milin, .Milin, .Mcase05428 05429 .Mdivz: .asciz "Error: Division by 0 \n".Op 41 src/lib/i86/em/trp.s05430 .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 .unknown05501 .text05502 .extern .fat05503 EILLINS = 1805504 05505 .unknown:05506 mov ax,#EILLINS05507 push ax05508 jmp .fat++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib/i86/em/vars.s ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++05600 .define .reghp, .limhp, .ignmask, .trppc05601 .extern .reghp, .limhp, .ignmask, .trppc05602 05603 .data05604 .reghp:05605 .data2 endbss05606 .limhp:05607 .data2 endbss05608 .ignmask:05609 .data2 133605610 .trppc:05611 .data2 0++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib/i86/em/xor.s ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++05700 .define .xor05701 .text05702 05703 ! #bytes in cx05704 .xor:05705 pop bx ! return address05706 mov dx,di05707 mov di,sp05708 add di,cx05709 sar cx,#1.Ep 42 src/lib/i86/em/xor.s05710 1:05711 pop ax05712 xor ax,(di)05713 stos05714 loop 1b05715 mov di,dx05716 jmp (bx)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib/i86/misc/alloca.s ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++05800 #05801 ! alloca() - allocate space on the stack Author: Kees J. Bot05802 ! 26 Jan 199405803 05804 #if __ACK__ /* BCC can't do alloca(), register saving is wrong. */05805 05806 .text05807 .define _alloca05808 _alloca:05809 pop cx ! Return address05810 pop ax ! Bytes to allocate05811 add ax, #2*2+1 ! Add space for two saved register variables05812 andb al, #0xFE ! Align05813 mov bx, sp ! Keep current sp05814 sub sp, ax ! Lower stack05815 mov ax, sp ! Return value05816 push 2(bx) ! Push what is probably the saved si05817 push (bx) ! Saved di05818 ! Now ACK can still do:05819 ! pop di; pop si; mov sp, bp; pop bp; ret05820 push ax ! Dummy argument05821 jmp (cx)05822 #endif++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib/i86/misc/getprocessor.s ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++05900 ! getprocessor() - determine processor type Author: Kees J. Bot05901 ! 26 Jan 199405902 05903 .text05904 05905 o32 = 0x66 ! 32 bit operand size prefix05906 05907 ! int getprocessor(void);05908 ! Return 86, 186, 286, 386, 486, 586, ...05909 05910 .define _getprocessor05911 05912 _getprocessor:05913 push bp05914 mov bp, sp.Op 43 src/lib/i86/misc/getprocessor.s05915 push sp ! see if pushed sp == sp05916 pop ax05917 cmp ax, sp05918 jz new_processor05919 mov cx, #0x0120 ! see if shifts are mod 3205920 shlb ch, cl ! zero tells if 8605921 mov ax, #8605922 jz got_processor05923 mov ax, #18605924 jmp got_processor05925 05926 new_processor: ! see if high bits are set in saved GDT05927 sub sp, #6 ! space for GDT ptr05928 .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 38605931 mov ax, #28605932 jnz got_processor05933 05934 ! 386, 486, 58605935 and sp, #0xFFFC ! Align stack to avoid AC fault (needed?)05936 mov cx, #0x0004 ! Try to flip the AC bit introduced on the 48605937 call flip05938 mov ax, #386 ! 386 if it didn't react to "flipping"05939 jz got_processor05940 mov cx, #0x0020 ! Try to flip the ID bit introduced on the 58605941 call flip05942 mov ax, #486 ! 486 if it didn't react05943 jz got_processor05944 .data1 o3205945 pushf05946 .data1 o3205947 pusha ! Save the world05948 .data1 o3205949 xor ax, ax0595
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -