[LMH]Exploiter Progress

Robert Swindells rjs@fdy2.demon.co.uk
Mon Jul 1 16:02:00 2002


John Leuner wrote:
>> > Would FIND-POSITION-IN-LIST look something like this? Is the use of ==
>> > the same as EQ? Can destination be C_NIL?
>> 
>> Something like that, yes. You forgot to increment index, and you need to
>> add DTP_FIX to index when setting destination. Other than that, looks
>> good. Thank you.

>Is this better?

[Source to FIND-POSITION-IN-LIST snipped]

>With this I get an error in funcall.c (funcall_array):  

>printf("funcall(): array is unfamiliar type. %lx\n", ary_header);

>I tried calling dump_raw_array on ary_header, but it just carries on
>for a long time.

This is down to the array access code that I added. The array isn't
marked as simple, but it isn't too complicated to access.

This patch lets it get up to a call to %ALLOCATE-AND-INITIALIZE-ARRAY

--- funcall.c	Sun Jun 30 22:36:53 2002
+++ ../exploiter.rjs/funcall.c	Tue Jul  2 00:39:38 2002
@@ -161,11 +161,10 @@
     if (ARY_DISPLACED(ary_header)) {
 	data = memread(function + 1);
 	printf("funcall(): array is displaced to %lx.\n", ADDRESS(data));
-    } else if (ARY_SIMPLE(ary_header)) {
-	data = function + 1;
+    } else if (ARY_LL(ary_header)) {
+	data = function + 2;
     } else {
-	printf("funcall(): array is unfamiliar type. %lx\n", ary_header);
-	exit(-1);
+	data = function + 1;
     }
 
     if ((ARY_TYPE(ary_header) != ART_Q) &&
--- exploiter.h	Sun Jun 30 18:55:42 2002
+++ ../exploiter.rjs/exploiter.h	Tue Jul  2 00:40:28 2002
@@ -208,14 +208,15 @@
 #define ARY_BITS_NS          0x00000400
 #define ARY_BITS_INDEX       0x000003ff
 
-#define ARY_TYPE(q)       ((q) & ARY_BITS_TYPE     )
-#define ARY_PHYSICAL(q)   ((q) & ARY_BITS_PHYSICAL )
-#define ARY_LEADER(q)     ((q) & ARY_BITS_LEADER   )
-#define ARY_DISPLACED(q)  ((q) & ARY_BITS_DISPLACED)
-#define ARY_SIMPLE(q)     ((q) & ARY_BITS_SIMPLE   )
-#define ARY_DIMS(q)      (((q) & ARY_BITS_DIMS     ) >> 12)
-#define ARY_NS(q)         ((q) & ARY_BITS_NS       )
-#define ARY_INDEX(q)      ((q) & ARY_BITS_INDEX    )
+#define ARY_TYPE(q)       ((q) & ARY_BITS_TYPE       )
+#define ARY_PHYSICAL(q)   ((q) & ARY_BITS_PHYSICAL   )
+#define ARY_LEADER(q)     ((q) & ARY_BITS_LEADER     )
+#define ARY_DISPLACED(q)  ((q) & ARY_BITS_DISPLACED  )
+#define ARY_SIMPLE(q)     ((q) & ARY_BITS_SIMPLE     )
+#define ARY_DIMS(q)      (((q) & ARY_BITS_DIMS       ) >> 12)
+#define ARY_LL(q)         ((q) & ARY_BITS_LONG_LENGTH)
+#define ARY_NS(q)         ((q) & ARY_BITS_NS         )
+#define ARY_INDEX(q)      ((q) & ARY_BITS_INDEX      )
 
 #define ART_ERROR_CODE			0
 #define ART_1B_CODE			1
--- miscop.c	Mon Jul  1 00:03:54 2002
+++ ../exploiter.rjs/miscop.c	Tue Jul  2 00:56:02 2002
@@ -276,6 +276,34 @@
     return 1;
 }
 
+MISCOP(534) { /* MAX */
+    lisp_q num1;
+    lisp_q num2;
+
+    num1 = pop();
+    num2 = pop();
+
+    /* FIXME: Not even checking datatypes (!) */
+
+    destination = DTP_FIX | ((ADDRESS(num1) > ADDRESS(num2)) ?
+			     ADDRESS(num1) : ADDRESS(num2));
+    return 1;
+}
+
+MISCOP(535) { /* MIN */
+    lisp_q num1;
+    lisp_q num2;
+
+    num1 = pop();
+    num2 = pop();
+
+    /* FIXME: Not even checking datatypes (!) */
+
+    destination = DTP_FIX | ((ADDRESS(num1) < ADDRESS(num2)) ?
+			     ADDRESS(num1) : ADDRESS(num2));
+    return 1;
+}
+
 MISCOP(536) { /* EXPT */
     lisp_q base;
     lisp_q exponent;
@@ -460,6 +488,31 @@
     return 1;
 }
 
+MISCOP(616) { /* FIND-POSITION-IN-LIST */
+    lisp_q foo;
+    lisp_q list;
+    int index = 0;
+
+    list = pop();
+    foo = NOT_CDRCODE(pop());
+	
+    while((NOT_CDRCODE(list) != (C_NIL))) {
+	if(NOT_CDRCODE(car(list)) == foo) {
+	    destination = DTP_FIX | index;
+	    return 1;
+	}
+	index++;
+	list = cdr(list);
+    }
+
+    destination = C_NIL;
+
+    return 1;
+}
+
+
+
+
 MISCOP(632) { /* VALUE-CELL-LOCATION */
     lisp_q symbol;
 
@@ -641,7 +694,7 @@
     miscop_520, NULL,       NULL,       NULL,
     miscop_524, miscop_525, NULL,       NULL,
     NULL,       NULL,       NULL,       NULL,
-    NULL,       NULL,       miscop_536, NULL,
+    miscop_534, miscop_535, miscop_536, NULL,
 
     /* 540 - 557 */
     NULL,       NULL,       NULL,       NULL,
@@ -660,7 +713,7 @@
     NULL,       NULL,       NULL,       NULL,
     NULL,       NULL,       NULL,       NULL,
     miscop_610, NULL,       NULL,       miscop_613,
-    NULL,       NULL,       NULL,       NULL,
+    NULL,       NULL,       miscop_616, NULL,
 
     /* 620 - 637 */
     NULL,       NULL,       NULL,       NULL,