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

Stefan Reinauer stepan at coresystems.de
Thu May 21 21:45:32 CEST 2009


On 21.05.2009 21:28 Uhr, Mark Cave-Ayland wrote:
> 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.

Can you run this with "true to ?fcode-verbose"? I wonder what those
reserved fcode words are.

Stefan

-- 
coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br.
      Tel.: +49 761 7668825 • Fax: +49 761 7664613
Email: info at coresystems.dehttp://www.coresystems.de/
Registergericht: Amtsgericht Freiburg • HRB 7656
Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866




More information about the OpenBIOS mailing list