Xref: utzoo comp.lang.lisp:835 comp.sys.mac.programmer:546 comp.unix.aux:106 Path: utzoo!mnetor!uunet!husc6!think!ames!elroy!cit-vax!newton From: newton@cit-vax.Caltech.Edu (Mike Newton) Newsgroups: comp.lang.lisp,comp.sys.mac.programmer,comp.unix.aux Subject: (Austin) Kyoto Common Lisp on MacII under A/UX Message-ID: <6206@cit-vax.Caltech.Edu> Date: 20 Apr 88 10:57:47 GMT Reply-To: newton@cit-vax.UUCP (Mike Newton) Organization: California Institute of Technology Lines: 393 Warning readers: this article has the long and gory details of KCL on A/UX. Hit 'n' now unless this interests you.... Here's the original request: >> From: gleicher@duke.cs.duke.edu (Michael Gleicher) >> Newsgroups: comp.sys.mac.programmer,comp.lang.lisp >> Subject: Anyone ported a good lisp to the Mac II >> Message-ID: <11609@duke.cs.duke.edu> >> Date: 19 Apr 88 00:30:12 GMT >> >> Has anyone ported a good public domain Lisp or Scheme to the Mac II? >> >> I would be most interested in Kyoto Common Lisp, CMU common lisp ( >> spice?), Utah common lisp, or CScheme, or even T. >> >> If any of these would be easy to port and haven't been, let me know >> and I might try. I would much rather get one thats been done >> already though. >> >> Michael Lee Gleicher gleicher@cs.duke.edu) Here's my experience with KCL and A/UX (Mac II unix): I spent about 30 hours trying to get Kyoto Common Lisp up under A/UX, but never did manage to get it to work completely. I did get the system up to where it would read defun's, execute them, do arithmetic (including, i believe bignums). However, I could never get it to compile a file. I used William Schelter's extensions to KCL -- AKCL, but because of make bugs, actually only was dealing w/ the KCL core. Here are the necessary steps, as i remember them (not 100% accurate!): [1] Get the version of 'make' from the Unix archives (Vol. 7). The A/UX make has many bugs (i've sent bug reports to Apple) and will not handle (A)KCL's makefiles -- except for the directory 'unixport' which one must use the AUX make, as the unix archives one does not work. Note: this is sad, as (A)KCL compiles on several ATT & BSD machines w/ its makefiles. I dont know what Apple did wrong here [2] Smakefile 'include' a defs file. Include it manually, as neither make will do it. [3] Neither make will do the 'make sources' correctly --this is the part that put's Bill's extensions in to KCL. I never got this to work, rather, i ignored it. [4] at the end of this letter are the sources for the 3 assembly files. Note that I have not had time to merge them into the originals, but instead have used them as seperate files, compiled them and stuck the '.o' files into the 'o' directory under the right name. THESE FILES ARE NOT GUARANTEED TO BE CORRECT. They SEEM to work, at least as far as I could tell. I'm pretty sure of character_table, less so of double precision math, and the least for the last one. NOTE -- compile the C files w/o '-O', and w/ '-S' and then edit the extraneous linkage code. I've include the .s code below as well. The optimizer chokes on the opcodes that the c compiler doesnt produce. [5] Edit object.h (????) and make a definition for MAC2 that is identical to SUN3 except replace ATT for BSD. [6] you will probably want to set the MAXPAGES=8192 as A/UX as distributed does not have enough swap for 16384. [7] Start the makes [8] The makes will die in many places. [A] Most of these will be 'compiler error.... L012' which means the compiler botched a cast to (short) or (char) from enum. Change the cast to (int) and start over. Sorry, I did not record where all these occur. [B] Two of the 'unix...c' files reference defines which seem to be valid for ATT and/or BSD, but which arent in apple AUX. Most of these are easily inferred from looking at the right '/usr/include/sys/*.h' files. I am sending a copy of this to wfs@rascal.ics.utexas.edu All bugs that I found i reported to Apple. I was pretty upset at how hard it was to get as far as i did. If anyone ever finished the work needed for the port I would _greatly_ appreciate hearing from you. I suggest that you also send a copy to wfs. - mike Oh, by the way -- if you have everything perfect and type a top level make, it takes ~ 3.5 hours to compile everything! It will take even longer if make sources worked! ++++++++++ mac2_chtab.s ++++++++++ (this i am pretty sure of) data even space 1024 global character_table character_table: space 2048 ++++++++++ bitopM2.c +++++++++++ /* (c) Copyright Taiichi Yuasa and Masami Hagiya, 1984. All rights reserved. Copying of this file is authorized to users who have executed the true and proper "License Agreement for Kyoto Common LISP" with SIGLISP. */ /* bitop.c Sets and/or tests bits in the mark table. The first 8 words of the Lisp data area have their mark bits in the byte location pointed to by MARK_TABLE, and the next 8 words in the next byte location, and so on. GET_MARK_BIT(X) Returns 1 if the mark bit for the word address X is on. Otherwise, returns 0. SET_MARK_BIT(X) Sets on the mark bit for the word address X. GET_SET_MARK_BIT(X) Sets on the mark bit for the word address X, and returns 1 if the mark bit was previously on. Returns 0 otherwise. */ /* This part of the code written by Mike Newton (newton@csvax.caltech.edu) for the Mac II. It should be compiled instead of bitop.c and the bitopM2.o be moved to o/bitop.o */ /* #include "include.h" This wasnt needed! */ extern int *mark_table; /* * extern int *mark_table; * * get_mark_bit(x) * int x; * { * int y; * * y = (*(mark_table+(x/4/32)) >> (x/4%32)) & 1; * return(y); * } */ get_mark_bit(x) int *x; { asm(" mov.l (8,%fp),%d0"); asm(" lsr.l &2,%d0"); asm(" mov.l %d0,%d1"); asm(" lsr.l &3,%d1"); asm(" mov.l mark_table,%a0"); asm(" btst %d0,(0,%a0,%d1.l)"); asm(" sne %d0"); /* Optimizer dies on this */ asm(" and.l &1,%d0"); } /* set_mark_bit(x) * int x; * { * int y; * * y = 1 << (x/4%32); * y = (*(mark_table+(x/4/32))) | y; * *(mark_table+ (x/4/32))=y; * } */ set_mark_bit(x) int *x; { asm(" mov.l (8,%fp),%d0"); asm(" lsr.l &2,%d0"); asm(" mov.l %d0,%d1"); asm(" lsr.l &3,%d1"); asm(" mov.l mark_table,%a0"); asm(" bset %d0,(0,%a0,%d1.l)"); } /* * get_set_mark_bit(x) * int x; * { * int y; * * y = get_mark_bit(x); * set_mark_bit(x); * return(y); * } */ get_set_mark_bit(x) int *x; { asm(" mov.l (8,%fp),%d0"); asm(" lsr.l &2,%d0"); asm(" mov.l %d0,%d1"); asm(" lsr.l &3,%d1"); asm(" mov.l mark_table,%a0"); asm(" bset %d0,(0,%a0,%d1.l)"); asm(" sne %d0"); /* and this */ asm(" and.l &1,%d0"); } ++++++++++ bitopM2.s +++++++++++ file "bitopM2.c" global get_mark_bit global set_mark_bit set S%1,0 set T%1,0 set F%1,-4 set FPO%1,4 set FPM%1,0x0000 set M%1,0x0000 get_mark_bit: link.l %fp,&-4 mov.l (8,%fp),%d0 lsr.l &2,%d0 mov.l %d0,%d1 lsr.l &3,%d1 mov.l mark_table,%a0 btst %d0,(0,%a0,%d1.l) sne %d0 and.l &1,%d0 unlk %fp rts global get_set_mark_bit set S%2,0 set T%2,0 set F%2,-4 set FPO%2,4 set FPM%2,0x0000 set M%2,0x0000 set_mark_bit: link.l %fp,&-4 mov.l (8,%fp),%d0 lsr.l &2,%d0 mov.l %d0,%d1 lsr.l &3,%d1 mov.l mark_table,%a0 bset %d0,(0,%a0,%d1.l) unlk %fp rts set S%3,0 set T%3,0 set F%3,-4 set FPO%3,4 set FPM%3,0x0000 set M%3,0x0000 get_set_mark_bit: link.l %fp,&-4 mov.l (8,%fp),%d0 lsr.l &2,%d0 mov.l %d0,%d1 lsr.l &3,%d1 mov.l mark_table,%a0 bset %d0,(0,%a0,%d1.l) sne %d0 and.l &1,%d0 unlk %fp rts ++++++++++ earithM2.c +++++++++++ /* (c) Copyright Taiichi Yuasa and Masami Hagiya, 1984. All rights reserved. Copying of this file is authorized to users who have executed the true and proper "License Agreement for Kyoto Common LISP" with SIGLISP. */ /* earith.c EXTENDED_MUL and EXTENDED_DIV perform 32 bit multiplication and division, respectively. EXTENDED_MUL(D,Q,R,HP,LP) calculates D*Q+R and saves the result into the locations HP and LP. D, Q, and R are 32 bit non-negative integers and HP and LP are word addresses. The word at LP will contain the lower 31 (not 32) bits of the result and its most significant bit is set 0. The word at HP will contain the rest of the result and its MSB is also set 0. EXTENDED_DIV(D,H,L,QP,RP) divides [H:L] by D and saves the quotient and the remainder into the locations QP and RP, respectively. D, H, L are 32 bit non-negative integers and QP and RP are word addresses. Here, [H:L] means the 64 bit integer (imaginary) represented by H and L as follows. 63 62 31 30 0 |0|0||| Although [H:L] is 64 bits, you can assume that the quotient is always represented as 32 bit non-negative integer. */ /* This part of the code written by Mike Newton (newton@csvax.caltech.edu) for the Mac II. It should be compiled instead of bitop.c and the bitopM2.o be moved to o/bitop.o */ /* #include "include.h" */ extended_mul(d, q, r, hp, lp) int d, q, r; int *hp, *lp; { asm(" mov.l %d2,-(%sp)"); asm(" clr.l %d2"); asm(" mov.l (8,%fp),%d0"); asm(" mulu.l (12,%fp),%d1:%d0"); asm(" add.l (16,%fp),%d0"); asm(" addx.l %d2,%d1"); asm(" lsl.l &1,%d0"); asm(" roxl.l &1,%d1"); asm(" lsr.l &1,%d0"); asm(" mov.l (20,%fp),%a0"); asm(" mov.l %d1,(%a0)"); asm(" mov.l (24,%a6),%a0"); asm(" mov.l %d0,(%a0)"); } extended_div(d, h, l, qp, rp) int d, h, l; int *qp, *rp; { asm("movm.l (12,%fp),&0x303"); asm("lsl.l &1,%d1"); asm("lsr.l &1,%d0"); asm("roxr.l &1,%d1"); asm("divu.l (8,%fp),%d0:%d1"); asm("mov.l %d0,(%a1)"); asm("mov.l %d1,(%a0)"); } ++++++++++ earithM2.s +++++++++++ file "earithM2.c" global extended_mul global extended_div set S%1,0 set T%1,0 set F%1,-4 set FPO%1,4 set FPM%1,0x0000 set M%1,0x0000 extended_mul: link.l %fp,&-4 mov.l %d2,-(%sp) clr.l %d2 mov.l (8,%fp),%d0 mulu.l (12,%fp),%d1:%d0 add.l (16,%fp),%d0 addx.l %d2,%d1 lsl.l &1,%d0 roxl.l &1,%d1 lsr.l &1,%d0 mov.l (20,%fp),%a0 mov.l %d1,(%a0) mov.l (24,%a6),%a0 mov.l %d0,(%a0) unlk %fp rts set S%2,0 set T%2,0 set F%2,-4 set FPO%2,4 set FPM%2,0x0000 set M%2,0x0000 extended_div: link.l %fp,&-4 movm.l (12,%fp),&0x303 lsl.l &1,%d1 lsr.l &1,%d0 roxr.l &1,%d1 divu.l (8,%fp),%d0:%d1 mov.l %d0,(%a1) mov.l %d1,(%a0) unlk %fp rts -- newton@csvax.caltech.edu amdahl!cit-vax!newton Caltech 256-80 818-356-6771 (afternoons,nights) Pasadena CA 91125 Beach Bums Anonymous, Pasadena President "Reality is a lie that hasn't been found out yet..."