On Apr 17, 2016, at 11:05 AM, Mark Cave-Ayland wrote:
On 17/04/16 15:50, Programmingkid wrote:
Good news, I found out why replacing '\r' with '\n' works to boot Mac OS 9. It is because there are several words that require that character to be at the end of the line.
http://www.complang.tuwien.ac.at/forth/1275.ps This is the specifications to Open Firmware. Just do a search for EOL (End of Line a.k.a '\n'). You will see that several words need it in order to work.
They will look like this:
dev ( "device-specifier<eol>" -- )
The <eol> text is what specifies that '\n' should be at the end of the line.
Really? Interesting. Can you provide a self-contained test case that demonstrates that it is in fact the line ending that causes this independent of the r-stack manipulation? Bear in mind that OpenBIOS may deviate from the specification in its behaviour here.
I implemented another stack that two new words use in place of >r and r> when running code in the bootscript. I see this message with and without the '\r' to '\n' patch:
Dictionary space overflow: dicthead=000c3fe4 dictlimit=00080000
this image is not for this platform
This means the implementing another stack did not fix the problem. It appears to make it worse.
Here is the patch:
Index: include/libc/string.h =================================================================== --- include/libc/string.h (revision 1391) +++ include/libc/string.h (working copy) @@ -47,7 +47,7 @@ extern char *strdup( const char *str ); extern int strcasecmp( const char *cs, const char *ct ); extern int strncasecmp( const char *cs, const char *ct, size_t count ); - +extern char *strstr(char *buffer, const char *search_string); extern char *strncpy_nopad( char *dest, const char *src, size_t n );
#define _U 0x01 /* upper */ Index: kernel/bootstrap.c =================================================================== --- kernel/bootstrap.c (revision 1391) +++ kernel/bootstrap.c (working copy) @@ -89,7 +89,7 @@ "here", "here!", "dobranch", "do?branch", "unaligned-w@", "unaligned-w!", "unaligned-l@", "unaligned-l!", "ioc@", "iow@", "iol@", "ioc!", "iow!", "iol!", "i", "j", "call", "sys-debug", - "$include", "$encode-file", "(debug", "(debug-off)" + "$include", "$encode-file", "(debug", "(debug-off)", "sub_>r", "sub_r>" };
/* Index: kernel/forth.c =================================================================== --- kernel/forth.c (revision 1391) +++ kernel/forth.c (working copy) @@ -1848,6 +1848,37 @@ PUSH(rstack[rstackcnt - 2]); }
+/* The substitute return stack */ +#define MAX_SUB_RSTACK_SIZE 100 +static int sub_return_stack[MAX_SUB_RSTACK_SIZE]; +static int top = 0; + +/* + * sub_>r ( i -- ) (Substitute R: -- i ) + */ + +static void sub_gt_r(void) +{ + if (top >= MAX_SUB_RSTACK_SIZE) { + printf_console("Stack overflow\n"); + return; + } + sub_return_stack[top++] = POP(); +} + +/* + * sub_r> ( -- i ) (Substitute R: i -- ) + */ + +static void sub_r_gt(void) +{ + if (top < 0 ) { + printf_console("Stack underflow\n"); + return; + } + PUSH(sub_return_stack[top--]); +} + /* words[] is a function array of all native code functions used by * the dictionary, i.e. CFAs and primitives. * Any change here needs a matching change in the primitive word's @@ -1963,4 +1994,6 @@ do_encode_file, /* $encode-file */ do_debug_xt, /* (debug */ do_debug_off, /* (debug-off) */ + sub_gt_r, /* sub_>r */ + sub_r_gt /* sub_r> */ }; Index: libc/string.c =================================================================== --- libc/string.c (revision 1391) +++ libc/string.c (working copy) @@ -385,3 +385,30 @@ return __res; }
+// Search for a string within another string +char *strstr(char *buffer, const char *search_string) +{ + if (!*search_string || (strlen(search_string) == 0)) { + return buffer; + } + + int match_found, index, index2; + for (index = 0; index < strlen(buffer); index++) { + if (buffer[index] == search_string[0]) { + match_found = 1; + // see if we have a match + for (index2 = 0; index2 < strlen(search_string); index2++) { + if (buffer[index + index2] != search_string[index2]) { + match_found = 0; // match not found + break; + } + } + if(match_found == 1) { + return &buffer[index]; + } + } + } + + // Could not find search_string in buffer + return NULL; +} Index: libopenbios/bootinfo_load.c =================================================================== --- libopenbios/bootinfo_load.c (revision 1391) +++ libopenbios/bootinfo_load.c (working copy) @@ -19,6 +19,7 @@ #include "libopenbios/bootinfo_load.h" #include "libopenbios/ofmem.h" #include "libc/vsprintf.h" +#include "libc/string.h"
//#define DEBUG_BOOTINFO
@@ -116,6 +117,60 @@ return LOADER_NOT_SUPPORT; }
+static void erase_memory(char *memory, int size) +{ + int i; + for(i = 0; i < size; i++) { + memory[i] = ' '; + } +} + +// Replace all occurrences of orig_str in buffer with replace_str +static void replace_string(char *buffer, const char *orig_str, const char *replace_str) +{ + char *ptr; + int index, new_buf_index = 0; + const int max_size = 5000; + char *new_buffer = malloc(max_size * sizeof(char)); + erase_memory(new_buffer, max_size); + + for (index = 0; index < strlen(buffer); index++) { + if (buffer[index] == orig_str[0]) { + ptr = strstr(buffer + index, orig_str); + + // if we encountered an orig_str in the buffer + if (index == (ptr - buffer)) { + sprintf(new_buffer + new_buf_index, "%s ", replace_str); + new_buf_index += strlen(replace_str) + 1; + index += strlen(orig_str); + continue; + } + } + new_buffer[new_buf_index++] = buffer[index]; + } + + // Clear the origial buffer + erase_memory(buffer, max_size); + + // copy new_buffer into buffer + for (index = 0; index < strlen(new_buffer); index++) { + buffer[index] = new_buffer[index]; + } + buffer[index+1] = '\0'; +} + +/* Replace >r and r> with sub_>r and sub_r> */ +static void replace_return_stack_words(char *bootscript) +{ + const char *find_str1 = ">r"; + const char *replace_str1 = "sub_>r"; + const char *find_str2 = "r>"; + const char *replace_str2 = "sub_r>"; + + replace_string(bootscript, find_str1, replace_str1); + replace_string(bootscript, find_str2, replace_str2); +} + /* Parse SGML structure like: <chrp-boot> @@ -190,8 +245,11 @@ while (current < size) {
c = base[current++]; + + if(c == '\r') + c = '\n';
- if (c == '<') { + if (c == '<') { script = 0; tag = 1; taglen = 0; @@ -262,6 +320,7 @@ /* If the payload is bootinfo then we execute it immediately */ if (scriptvalid) { DPRINTF("bootscript: %s\n", bootscript); + replace_return_stack_words(bootscript); feval(bootscript); } else
On Sun, Apr 17, 2016 at 08:45:31PM -0400, Programmingkid wrote:
I implemented another stack that two new words use in place of >r and r> when running code in the bootscript. I see this message with and without the '\r' to '\n' patch:
Dictionary space overflow: dicthead=000c3fe4 dictlimit=00080000
this image is not for this platform
This means the implementing another stack did not fix the problem. It appears to make it worse.
Here is the patch:
Oh my.
hex 20 cells CREATE stash VARIABLE #stash #stash off : stash-push stash #stash cells + ! 1 stash +! ; : stash-pop -1 stash +! stash #stash cells + @ ; : >r state @ IF postpone >r EXIT THEN stash-push ; : r> state @ IF postpone r> EXIT THEN stash-pop ; : r@ state @ IF postpone r@ EXIT THEN stash-pop dup stash-push ;
Anyway, I had a quick look at the openbios code and it seems it doesn't even support IF and similar structure words in interpretation state at all. That is a little more work (requires a temporary definition, use a buffer for that (don't put it at HERE) because you can allocate from that temp definition; when you reach THEN that temp definition ends (not just at ; ); but things can nest, IF ... IF ... THEN ... THEN.)
It's not too hard but it interacts a little bit with the rest of the Forth system, so it needs testing etc. Maybe next weekend.
Segher
On Sun, Apr 17, 2016 at 08:36:28PM -0500, Segher Boessenkool wrote:
hex 20 cells CREATE stash VARIABLE #stash #stash off : stash-push stash #stash cells + ! 1 stash +! ; : stash-pop -1 stash +! stash #stash cells + @ ; : >r state @ IF postpone >r EXIT THEN stash-push ; : r> state @ IF postpone r> EXIT THEN stash-pop ; : r@ state @ IF postpone r@ EXIT THEN stash-pop dup stash-push ;
With IMMEDIATE after these last three words, of course. Bah.
Segher
On Apr 17, 2016, at 10:36 PM, Segher Boessenkool wrote:
On Sun, Apr 17, 2016 at 08:36:28PM -0500, Segher Boessenkool wrote:
hex 20 cells CREATE stash VARIABLE #stash #stash off : stash-push stash #stash cells + ! 1 stash +! ; : stash-pop -1 stash +! stash #stash cells + @ ; : >r state @ IF postpone >r EXIT THEN stash-push ; : r> state @ IF postpone r> EXIT THEN stash-pop ; : r@ state @ IF postpone r@ EXIT THEN stash-pop dup stash-push ;
With IMMEDIATE after these last three words, of course. Bah.
Thank you for the code. This is what I used:
hex 20 cells CREATE stash VARIABLE #stash #stash off : stash-push stash #stash cells + ! 1 stash +! ; : stash-pop -1 stash +! stash #stash cells + @ ; : >r state @ IF postpone >r EXIT THEN stash-push ; IMMEDIATE : r> state @ IF postpone r> EXIT THEN stash-pop ; IMMEDIATE : r@ state @ IF postpone r@ EXIT THEN stash-pop dup stash-push ; IMMEDIATE
When I tried booting Mac OS 9.2 at OpenBIOS revision 1395, with only your code added, I saw this:
Dictionary space overflow: dicthead=000c3fe4 dictlimit=00080000 Dictionary space overflow: dicthead=000c3fe4 dictlimit=00080000 Dictionary space overflow: dicthead=000c3fe4 dictlimit=00080000 Dictionary space overflow: dicthead=000c3fe4 dictlimit=00080000 Dictionary space overflow: dicthead=000c3fe4 dictlimit=00080000 Dictionary space overflow: dicthead=000c3fe4 dictlimit=00080000 Dictionary space overflow: dicthead=000c3fe4 dictlimit=00080000 Dictionary space overflow: dicthead=000c3fe5 dictlimit=00080000 Dictionary space overflow: dicthead=000c3fe6 dictlimit=00080000 Dictionary space overflow: dicthead=000c3fe7 dictlimit=00080000 Dictionary space overflow: dicthead=000c3fe8 dictlimit=00080000 Dictionary space overflow: dicthead=000c3fe9 dictlimit=00080000 Dictionary space overflow: dicthead=000c3fea dictlimit=00080000 Dictionary space overflow: dicthead=000c3feb dictlimit=00080000 Dictionary space overflow: dicthead=000c3fec dictlimit=00080000 Dictionary space overflow: dicthead=000c3fed dictlimit=00080000 Dictionary space overflow: dicthead=000c3ff0 dictlimit=00080000 Dictionary space overflow: dicthead=000c3ff4 dictlimit=00080000 Dictionary space overflow: dicthead=000c3ff8 dictlimit=00080000 Dictionary space overflow: dicthead=000c3ffc dictlimit=00080000
n?????X???dH$ < ?|! A?| ?x!@| d|h?<???8???|??N? K??H ?K???H (K???K??K??K??|qC?|{?`c |{?|qB?LdK??K??K??K??K??K??K??K???K??K??K??K??K??K??K??K??|1C?| &|2C?< ?|! A?| ?x!@| d|0B?8!???|B??A?a?? ??(??0??8?@?!H?AP?aX??`????????????!??A??a????????????????!??A??a??????????h|B??p| ??x|???8!??<`??8c??|i?N?!8!?h??p|? ?x| ???|???A?a? ?(??0??8?@?!H?AP?aX?`???????????!??A??a??????????????!??A??a???????Ld|1C?| &|2C?< ?|! A?| ?x!@| d|0B?8!???|B??A?a?? ??(??0??8?@?!H?AP?aX??`????????????!??A??a????????????????!??A??a??????????h|B??p| ??x|???8!??<`??8c?`|i?N?!8!?h??p|? ?x| ???|???A?a? ?(??0??8?@?!H?AP?aX?`???????????!??A??a??????????????!??A??a???????Ld|1C?| &|2C?< ?|! A?| ?x!@| d|0B?8!???|B????a ????????? ?!$?A(?a,??0??4|B??8| ??<|??@8!??<`??8c??|i?N?!H?|1C?| &|2C?< ?|! A?| ?x!@| d|0B?8!???|B????a ????????? ?!$?A(?a,??0??4|B??8| ??<|??@8!??<`??8c?`|i?N?!H8!?4??8|? ?<| ??@|????a ????????? ?!$?A(?a,??0?!Ld8<`?|cA?
With my patch I saw mostly the same thing except there was also a message that said "this image is not for this platform". I think this proves that the '\r' to '\n' patch is needed.
On Mon, Apr 18, 2016 at 10:29:25AM -0400, Programmingkid wrote:
With my patch I saw mostly the same thing except there was also a message that said "this image is not for this platform". I think this proves that the '\r' to '\n' patch is needed.
[ long lines ]
You need at least four things: - You need to EVALUATE the boot script per line, not as one string; - CARRET should indeed be treated as end-of-line, for that; - Return stack in interpret mode; - Structure words in interpret mode. That is at least
AHEAD IF THEN BEGIN AGAIN UNTIL CASE ENDCASE DO ?DO LOOP +LOOP
Segher
On Apr 18, 2016, at 11:00 PM, Segher Boessenkool wrote:
On Mon, Apr 18, 2016 at 10:29:25AM -0400, Programmingkid wrote:
With my patch I saw mostly the same thing except there was also a message that said "this image is not for this platform". I think this proves that the '\r' to '\n' patch is needed.
[ long lines ]
You need at least four things:
- You need to EVALUATE the boot script per line, not as one string;
How do you decide when to end a line?
- CARRET should indeed be treated as end-of-line, for that;
Do you mean ^ ? I don't remember any carret characters in the script.
- Return stack in interpret mode;
- Structure words in interpret mode. That is at least
AHEAD IF THEN BEGIN AGAIN UNTIL CASE ENDCASE DO ?DO LOOP +LOOP
I think it would be easier if I was sent a patch. The forth code for Mac OS 9.2 is located in a file called "Mac OS ROM". Just let me know if you need help obtaining this file.
On Mon, Apr 18, 2016 at 11:21:51PM -0400, Programmingkid wrote:
With my patch I saw mostly the same thing except there was also a message that said "this image is not for this platform". I think this proves that the '\r' to '\n' patch is needed.
[ long lines ]
You need at least four things:
- You need to EVALUATE the boot script per line, not as one string;
How do you decide when to end a line?
When there is an end-of-line character, or you reach the end of the script.
- CARRET should indeed be treated as end-of-line, for that;
Do you mean ^ ? I don't remember any carret characters in the script.
That is a caret. CARRET is an OF word, it is the ASCII 13 character. "Carriage return".
- Return stack in interpret mode;
- Structure words in interpret mode. That is at least
AHEAD IF THEN BEGIN AGAIN UNTIL CASE ENDCASE DO ?DO LOOP +LOOP
I think it would be easier if I was sent a patch. The forth code for Mac OS 9.2 is located in a file called "Mac OS ROM". Just let me know if you need help obtaining this file.
[ long lines ]
Thanks, but no, of course I have it.
Segher
On Apr 18, 2016, at 11:27 PM, Segher Boessenkool wrote:
On Mon, Apr 18, 2016 at 11:21:51PM -0400, Programmingkid wrote:
With my patch I saw mostly the same thing except there was also a message that said "this image is not for this platform". I think this proves that the '\r' to '\n' patch is needed.
[ long lines ]
You need at least four things:
- You need to EVALUATE the boot script per line, not as one string;
How do you decide when to end a line?
When there is an end-of-line character, or you reach the end of the script.
- CARRET should indeed be treated as end-of-line, for that;
Do you mean ^ ? I don't remember any carret characters in the script.
That is a caret. CARRET is an OF word, it is the ASCII 13 character. "Carriage return".
Ok. I see now.
- Return stack in interpret mode;
- Structure words in interpret mode. That is at least
AHEAD IF THEN BEGIN AGAIN UNTIL CASE ENDCASE DO ?DO LOOP +LOOP
I think it would be easier if I was sent a patch. The forth code for Mac OS 9.2 is located in a file called "Mac OS ROM". Just let me know if you need help obtaining this file.
[ long lines ]
Thanks, but no, of course I have it.
I don't know why executing one line at a time would make any difference, I will entertain your idea.
On Apr 18, 2016, at 11:27 PM, Segher Boessenkool wrote:
On Mon, Apr 18, 2016 at 11:21:51PM -0400, Programmingkid wrote:
With my patch I saw mostly the same thing except there was also a message that said "this image is not for this platform". I think this proves that the '\r' to '\n' patch is needed.
[ long lines ]
You need at least four things:
- You need to EVALUATE the boot script per line, not as one string;
How do you decide when to end a line?
When there is an end-of-line character, or you reach the end of the script.
- CARRET should indeed be treated as end-of-line, for that;
Do you mean ^ ? I don't remember any carret characters in the script.
That is a caret. CARRET is an OF word, it is the ASCII 13 character. "Carriage return".
- Return stack in interpret mode;
- Structure words in interpret mode. That is at least
AHEAD IF THEN BEGIN AGAIN UNTIL CASE ENDCASE DO ?DO LOOP +LOOP
I think it would be easier if I was sent a patch. The forth code for Mac OS 9.2 is located in a file called "Mac OS ROM". Just let me know if you need help obtaining this file.
[ long lines ]
Thanks, but no, of course I have it.
The executing one line at a time idea turned out to be a pretty good idea. That is enough to make Mac OS 9.2 boot. It is also entertaining to watch each executed line be printed to the terminal. Here is the patch:
Index: libopenbios/bootinfo_load.c =================================================================== --- libopenbios/bootinfo_load.c (revision 1395) +++ libopenbios/bootinfo_load.c (working copy) @@ -20,7 +20,7 @@ #include "libopenbios/ofmem.h" #include "libc/vsprintf.h"
-//#define DEBUG_BOOTINFO +#define DEBUG_BOOTINFO
#ifdef DEBUG_BOOTINFO #define DPRINTF(fmt, args...) \ @@ -116,6 +116,25 @@ return LOADER_NOT_SUPPORT; }
+// Execute the bootscript one line at a time +static void run_script(char *bootscript) +{ + char *ptr; + char *buffer = malloc(1000 * sizeof(char)); + int index = -1, prev_index = 0; + ptr = strchr(bootscript, '\r'); + while (ptr != NULL) { + prev_index = index; + index = ptr - bootscript; + strncpy(buffer, bootscript + prev_index + 1, index - prev_index); + buffer[index-prev_index] = '\0'; + ptr = strchr(bootscript + index + 1, '\r'); + DPRINTF("%s\n", buffer); + feval(buffer); + } + free(buffer); +} + /* Parse SGML structure like: <chrp-boot> @@ -262,7 +281,7 @@ /* If the payload is bootinfo then we execute it immediately */ if (scriptvalid) { DPRINTF("bootscript: %s\n", bootscript); - feval(bootscript); + run_script(bootscript); } else DPRINTF("Unable to parse bootinfo bootscript\n");
On Tue, Apr 19, 2016 at 01:17:30AM -0400, Programmingkid wrote:
The executing one line at a time idea turned out to be a pretty good idea. That is enough to make Mac OS 9.2 boot. It is also entertaining to watch each executed line be printed to the terminal. Here is the patch:
[ LONG LINES ]
If you look at forth/bootstrap/interpreter.fs, you see EVAL already handles multiple lines, but only with unix line endings:
: evaluate ( str len -- ?? ) 2dup + -rot over + over do i c@ 0a = if i over - (evaluate) i 1+ then loop swap over - (evaluate) ;
So, change that instead? Or rewrite it, it's yucky. Bonus points if you also handle 0d 0a and 0a 0d line endings.
Segher
On 19/04/16 07:39, Segher Boessenkool wrote:
On Tue, Apr 19, 2016 at 01:17:30AM -0400, Programmingkid wrote:
The executing one line at a time idea turned out to be a pretty good idea. That is enough to make Mac OS 9.2 boot. It is also entertaining to watch each executed line be printed to the terminal. Here is the patch:
[ LONG LINES ]
If you look at forth/bootstrap/interpreter.fs, you see EVAL already handles multiple lines, but only with unix line endings:
: evaluate ( str len -- ?? ) 2dup + -rot over + over do i c@ 0a = if i over - (evaluate) i 1+ then loop swap over - (evaluate) ;
So, change that instead? Or rewrite it, it's yucky. Bonus points if you also handle 0d 0a and 0a 0d line endings.
... which is what the original patch was trying to do last year: http://www.openfirmware.info/pipermail/openbios/2015-August/008781.html. This works for OS X but causes yaboot to throw errors on the console.
I still feel we're lacking a good explanation as to why processing this on a line-by-line basis makes a difference, and how the r-stack problem is being mitigated in this case.
ATB,
Mark.
On Tue, Apr 19, 2016 at 08:32:59AM +0100, Mark Cave-Ayland wrote:
The executing one line at a time idea turned out to be a pretty good idea. That is enough to make Mac OS 9.2 boot. It is also entertaining to watch each executed line be printed to the terminal. Here is the patch:
[ LONG LINES ]
If you look at forth/bootstrap/interpreter.fs, you see EVAL already handles multiple lines, but only with unix line endings:
: evaluate ( str len -- ?? ) 2dup + -rot over + over do i c@ 0a = if i over - (evaluate) i 1+ then loop swap over - (evaluate) ;
So, change that instead? Or rewrite it, it's yucky. Bonus points if you also handle 0d 0a and 0a 0d line endings.
... which is what the original patch was trying to do last year: http://www.openfirmware.info/pipermail/openbios/2015-August/008781.html.
This patch looks good.
This works for OS X but causes yaboot to throw errors on the console.
And that is weird. Any idea what causes it?
One way to avoid this problem is to only handle 0d this way if booting some mac thing, if we have detected that by then anyway :-/
I still feel we're lacking a good explanation as to why processing this on a line-by-line basis makes a difference, and how the r-stack problem is being mitigated in this case.
The Forth standard requires EVALUATE to treat its whole input as one string, carriage returns and newlines included. OF defers this to the Forth standard. So it would be best *not* to do this in EVALUATE, to comply with this.
The closest I've found to how to parse a script is the Forth requirements for how to handle INCLUDE-FILE, and that is line-by-line.
The R problems aren't mitigated at all IMO, just worked around.
I'll have a look at whether ofw's EVAL handles multiple lines.
Segher
On 18/04/16 02:36, Segher Boessenkool wrote:
On Sun, Apr 17, 2016 at 08:45:31PM -0400, Programmingkid wrote:
I implemented another stack that two new words use in place of >r and r> when running code in the bootscript. I see this message with and without the '\r' to '\n' patch:
Dictionary space overflow: dicthead=000c3fe4 dictlimit=00080000
this image is not for this platform
This means the implementing another stack did not fix the problem. It appears to make it worse.
Here is the patch:
Oh my.
hex 20 cells CREATE stash VARIABLE #stash #stash off : stash-push stash #stash cells + ! 1 stash +! ; : stash-pop -1 stash +! stash #stash cells + @ ; : >r state @ IF postpone >r EXIT THEN stash-push ; : r> state @ IF postpone r> EXIT THEN stash-pop ; : r@ state @ IF postpone r@ EXIT THEN stash-pop dup stash-push ;
Anyway, I had a quick look at the openbios code and it seems it doesn't even support IF and similar structure words in interpretation state at all. That is a little more work (requires a temporary definition, use a buffer for that (don't put it at HERE) because you can allocate from that temp definition; when you reach THEN that temp definition ends (not just at ; ); but things can nest, IF ... IF ... THEN ... THEN.)
It's not too hard but it interacts a little bit with the rest of the Forth system, so it needs testing etc. Maybe next weekend.
This weekend I had a chunk of time to dig into this, and I think I now have something that works. Looking at the OpenBOOT source, they reference what they call a pseudo r-stack to enable r-stack words to execute in interpret mode so I've followed a simlar pattern for OpenBIOS based upon your work above.
Another interesting part of the patchset was that the original patch to split on 0d as well as 0a is actually correct, but the regression in yaboot is caused by a separate bug in evaluate not correctly preserving the stack across statements split by newlines.
I'll post the patchset shortly, so tests and reviews are welcome. I know Ben H was really keen to get OS 9 booting under QEMU 2.7 out of the box if at all possible.
ATB,
Mark.
On Sun, Jul 17, 2016 at 03:18:22PM +0100, Mark Cave-Ayland wrote:
hex 20 cells CREATE stash VARIABLE #stash #stash off : stash-push stash #stash cells + ! 1 stash +! ; : stash-pop -1 stash +! stash #stash cells + @ ; : >r state @ IF postpone >r EXIT THEN stash-push ; : r> state @ IF postpone r> EXIT THEN stash-pop ; : r@ state @ IF postpone r@ EXIT THEN stash-pop dup stash-push ;
This weekend I had a chunk of time to dig into this, and I think I now have something that works. Looking at the OpenBOOT source, they reference what they call a pseudo r-stack to enable r-stack words to execute in interpret mode so I've followed a simlar pattern for OpenBIOS based upon your work above.
I did type it without any testing, hope it works ;-)
Another interesting part of the patchset was that the original patch to split on 0d as well as 0a is actually correct, but the regression in yaboot is caused by a separate bug in evaluate not correctly preserving the stack across statements split by newlines.
That explains some things :-)
I'll post the patchset shortly, so tests and reviews are welcome. I know Ben H was really keen to get OS 9 booting under QEMU 2.7 out of the box if at all possible.
Excellent! Thank you for all the hard work.
Segher