[OpenBIOS] PATCH: Fix b(do) ... b(leaves) ... b(loop)/b(+loop)

Mark Cave-Ayland mark.cave-ayland at siriusit.co.uk
Thu May 21 21:28:42 CEST 2009


Hi everyone,

This patch fixes the b(do)...b(leaves)...b(loop)/b(+loop) structures by 
marking them as immediate rather then compile-only. Without this in 
place, the loop addresses would be calculated incorrectly which would 
cause the Fcode evaluator to jump to the wrong location for each loop 
iteration. I've confirmed that this change does not break 
do...leaves...loop in immediate mode either.

For reference, here are the test cases I used:


\ Test Fcode do...loop
\ Forth: 3 0 do i . cr loop
here
cc c,			\ offset16
a8 c,			\ 3
a5 c,			\ 0
17 c, 00 c, 08 c,	\ b(do)
19 c,			\ i
9d c,			\ .
92 c,			\ cr
15 c, ff c, fc c,	\ b(loop)
00 c,			\ end

\ Test Fcode do...+loop
\ Forth: 10 0 do i . cr 2 +loop
here
cc c,					\ offset16
10 c, 00 c, 00 c, 00 c, 10 c, 		\ b(lit) 0x10
a5 c,					\ 0
17 c, 00 c, 09 c, 			\ b(do)
19 c, 					\ i
9d c,					\ .
92 c,					\ cr
a7 c,					\ 2
16 c, ff c, fb c,			\ b(+loop)
00 c,					\ end

\ Test Fcode do...leave...loop
\ Forth: a 0 do i dup . 3 = if leave then loop
here
cc c,					\ offset16
10 c, 00 c, 00 c, 00 c, 0a c,		\ b(lit) 0xA
a5 c,					\ 0
17 c, 00 c, 0f c,			\ b(do)
19 c,					\ i
47 c,					\ dup
9d c,					\ .
a8 c,					\ 3
3c c,					\ =
14 c, 00 c, 04 c,			\ b?branch
1b c, 					\ b(leave)
b2 c,					\ b(>resolve)
15 c, ff c, f5 c,			\ b(loop)
00 c,					\ end


With these last 2 patches and diag-switch? set to true, the Fcode 
evaluator will now finish executing my SPARC64 disk image without 
crashing giving the following output:


OpenBIOS for Sparc64
Configuration device id QEMU version 1 machine id 0
CPUs: 1 x SUNW,UltraSPARC-II
UUID: 00000000-0000-0000-0000-000000000000
Welcome to OpenBIOS v1.0 built on May 21 2009 19:09
   Type 'help' for detailed information

[sparc64] Booting file 'disk' with parameters ''
Not a bootable ELF image
Not a Linux kernel image
Not a bootable a.out image
Loading FCode image...
Loaded 5936 bytes
entry point is 0x4000
Evaluating FCode...
reserved fcode word.
Loading package 1.4 04 Aug 1995 13:02:54.
reserved fcode word.
reserved fcode word.
reserved fcode word.
FCode UFS Reader 1.12 00/07/17 15:48:16.
Loading: /platform//ufsboot
Loading: /platform/sun4u/ufsboot
Boot load failed.

byte-load: stack overflow, diff -2

0 >


It looks as if the next stage is to implement the missing 
push-package/pop-package forth words to ensure that the ufs-file-system 
package is located at the correct point in the tree - I'll see if I can 
come up with something over the next few days.


ATB,

Mark.

-- 
Mark Cave-Ayland - Senior Technical Architect
PostgreSQL - PostGIS
Sirius Corporation plc - control through freedom
http://www.siriusit.co.uk
t: +44 870 608 0063
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openbios-doloop.patch
Type: text/x-diff
Size: 594 bytes
Desc: not available
URL: <http://lists.openbios.org/pipermail/openbios/attachments/20090521/a84c6abf/attachment.bin>


More information about the OpenBIOS mailing list