ast@cs.vu.nl (Andy Tanenbaum) (10/06/88)
: This is a shar archive. Extract with sh, not csh. : This archive ends with exit, so do not worry about trailing junk. : --------------------------- cut here -------------------------- PATH=/bin:/usr/bin:/usr/ucb echo Extracting 'brksize.s' sed 's/^X//' > 'brksize.s' << '+ END-OF-FILE ''brksize.s' X.define _brksize X.data X.globl endbss, _brksize X_brksize: .word endbss + END-OF-FILE brksize.s chmod 'u=rw,g=r,o=r' 'brksize.s' set `wc -c 'brksize.s'` count=$1 case $count in 70) :;; *) echo 'Bad character count in ''brksize.s' >&2 echo 'Count should be 70' >&2 esac echo Extracting 'catchsig.s' sed 's/^X//' > 'catchsig.s' << '+ END-OF-FILE ''catchsig.s' X.define _begsig X.globl _begsig X.globl _vectab, _M Xmtype = 2 | M+mtype = &M.m_type X_begsig: X push ax | after interrupt, save all regs X push bx X push cx X push dx X push si X push di X push bp X push ds X push es X mov bx,sp X mov bx,18(bx) | bx = signal number X mov ax,bx | ax = signal number X dec bx | vectab[0] is for sig 1 X add bx,bx | pointers are two bytes on 8088 X mov bx,_vectab(bx) | bx = address of routine to call X push _M+mtype | push status of last system call X push ax | func called with signal number as arg X call (bx) Xback: X pop ax | get signal number off stack X pop _M+mtype | restore status of previous system call X pop es | signal handling finished X pop ds X pop bp X pop di X pop si X pop dx X pop cx X pop bx X pop ax X pop dummy | remove signal number from stack X iret X X.data Xdummy: .word 0 + END-OF-FILE catchsig.s chmod 'u=rw,g=r,o=r' 'catchsig.s' set `wc -c 'catchsig.s'` count=$1 case $count in 814) :;; *) echo 'Bad character count in ''catchsig.s' >&2 echo 'Count should be 814' >&2 esac echo Extracting 'getutil.s' sed 's/^X//' > 'getutil.s' << '+ END-OF-FILE ''getutil.s' X.define _get_base, _get_size, _get_tot_mem X.globl _get_base, _get_size, _get_tot_mem X.globl endbss X X|*========================================================================* X| utilities * X|*========================================================================* X_get_base: | return click at which prog starts X mov ax,ds X ret X X_get_size: | return prog size in bytes (text+data+bss) X mov ax,#endbss | end is compiler label at end of bss X ret X X| Find out how much memory the machine has, including vectors, kernel MM, etc. X_get_tot_mem: X cli X push es X push di X mov ax,#16384 | start search at 256K (16384 clicks) X sub di,di XL1: mov es,ax X seg es X mov (di),#0xA5A4 | write random bit pattern to memory X xor bx,bx X seg es X mov bx,(di) | read back pattern just written X cmp bx,#0xA5A4 | compare with expected value X jne L2 | if different, no memory present X add ax,#4096 | advance counter by 64K X cmp ax,#0xA000 | stop seaching at 640K X jne L1 XL2: pop di X pop es X sti X ret + END-OF-FILE getutil.s chmod 'u=rw,g=r,o=r' 'getutil.s' set `wc -c 'getutil.s'` count=$1 case $count in 1045) :;; *) echo 'Bad character count in ''getutil.s' >&2 echo 'Count should be 1045' >&2 esac echo Extracting 'sendrec.s' sed 's/^X//' > 'sendrec.s' << '+ END-OF-FILE ''sendrec.s' X.define _send,_receive,_sendrec X X| See ../h/com.h for C definitions XSEND = 1 XRECEIVE = 2 XBOTH = 3 XSYSVEC = 32 X X|*========================================================================* X| send and receive * X|*========================================================================* X| send(), receive(), sendrec() all save bp, but destroy ax, bx, and cx. X.globl _send, _receive, _sendrec X_send: mov cx,*SEND | send(dest, ptr) X jmp L0 X X_receive: X mov cx,*RECEIVE | receive(src, ptr) X jmp L0 X X_sendrec: X mov cx,*BOTH | sendrec(srcdest, ptr) X jmp L0 X X L0: push bp | save bp X mov bp,sp | can't index off sp X mov ax,4(bp) | ax = dest-src X mov bx,6(bp) | bx = message pointer X int SYSVEC | trap to the kernel X pop bp | restore bp X ret | return X + END-OF-FILE sendrec.s chmod 'u=rw,g=r,o=r' 'sendrec.s' set `wc -c 'sendrec.s'` count=$1 case $count in 809) :;; *) echo 'Bad character count in ''sendrec.s' >&2 echo 'Count should be 809' >&2 esac echo Extracting 'setjmp.s' sed 's/^X//' > 'setjmp.s' << '+ END-OF-FILE ''setjmp.s' X.define _setjmp,_longjmp X.globl _setjmp, _longjmp X.text X_setjmp: mov bx,sp X mov ax,(bx) X mov bx,*2(bx) X mov (bx),bp X mov *2(bx),sp X mov *4(bx),ax X xor ax,ax X ret X X_longjmp: xor ax,ax X push bp X mov bp,sp X mov bx,*4(bp) X mov ax,*6(bp) X or ax,ax X jne L1 X inc ax XL1: mov cx,(bx) XL2: cmp cx,*0(bp) X je L3 X mov bp,*0(bp) X or bp,bp X jne L2 X hlt XL3: X mov bp,*0(bp) X mov sp,*2(bx) X mov cx,*4(bx) X mov bx,sp X mov (bx),cx X ret X X + END-OF-FILE setjmp.s chmod 'u=rw,g=r,o=r' 'setjmp.s' set `wc -c 'setjmp.s'` count=$1 case $count in 445) :;; *) echo 'Bad character count in ''setjmp.s' >&2 echo 'Count should be 445' >&2 esac exit 0