[OpenBIOS] PATCH: Fix various bugs in bbranch and b?branch implementations

Mark Cave-Ayland mark.cave-ayland at siriusit.co.uk
Mon Apr 27 21:57:09 CEST 2009


Hi folks,

The attached patch fixes all of the various combinations of forwards and 
backwards branches for both bbranch and b?branch. With this patch 
applied to the latest openbios-svn, I can now run OpenBIOS to the point 
where it crashes out Qemu checked out a few weeks back. Nice :)

A couple of the fixes in this patch are for bugs introduced in my last 
commit. Whilst continuing to dig deeper into various bugs, I didn't 
appreciate at the time that it is not necessarily the description of the 
branch words that matters, more how they are tokenized by the Fcode 
evaluator.

For reference, here are the branch test cases I used to verify this 
behaviour:


\ Testing forward b?branch/bbranch (if/else/then equivalent)
\ Forth: 1 if .s else abort then
here
cc c,			\ offset16
a6 c,			\ 1 (change to a5 for 0 to pick the else clause)
14 c, 0 c, 7 c,		\ b?branch (if)
13 c, 0 c, 4 c,		\ bbranch  (else)
b2 c,			\ b(>resolve)
02 c, 16 c,		\ abort
b2 c,			\ b(>resolve)
9f c,			\ show stack
00 c,			\ end

\ Test backwards b?branch (begin/until equivalent)
\ Forth: 0 begin 1 + dup . dup 3 = until drop

here
cc c,			\ offset16
a5 c,			\ 0
b1 c,			\ b(<mark) (begin)
a6 c, 1e c,		\ +1
47 c,			\ dup
9d c, 92 c,		\ display the number
47 c,			\ dup
a8 c,			\ count to 3
3c c,			\ =
14 c, ff c, f7 c,	\ b?branch (until)
46 c,			\ drop (clear up stack)
0  c,			\ End

\ Test backwards bbranch (begin/while/repeat equivalent)
\ Forth: 3 begin dup . dup while 1 - repeat drop

here
cc c,			\ offset16
a8 c,			\ 3
b1 c,			\ b(<mark) (begin)
47 c,			\ dup
9d c, 92 c,		\ display the number
47 c,			\ dup
14 c, 00 c, 06 c,	\ b?branch (while)
a6 c, 1f c,		\ -1
13 c, ff c, f6 c,	\ bbranch (repeat)
b2 c,			\ b(>resolve)
46 c,			\ drop
00 c,			\ end


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-branch.patch
Type: text/x-diff
Size: 960 bytes
Desc: not available
URL: <http://lists.openbios.org/pipermail/openbios/attachments/20090427/9e24ccbe/attachment.bin>


More information about the OpenBIOS mailing list