[OpenBIOS] b?branch

Programmingkid programmingkidx at gmail.com
Wed Dec 20 18:45:53 CET 2017


> On Dec 20, 2017, at 8:53 AM, Jd Lyons <lyons_dj at yahoo.com> wrote:
> 
> I’ve run into trouble with b?branch not working as expected by the nVidia Option Rom Fcode.
> 
> What Openbios does now for b?branch is:
> 
> From fcode.fs:
> ===
> \ b?branch ( continue? -- )
> \   Conditional branch FCode. Followed by FCode-offset.
> 
> : b?branch
>  fcode-offset 0< if \ if we jump backwards, we can forsee where it goes
>    ['] do?branch ,
>    resolve-dest
>    execute-tmp-comp
>  else
>    setup-tmp-comp ['] do?branch ,
>    here 0
>    0 ,
>  then-
>  ; immediate
> ===
> 
> I fond some code from SLOF that may work a little better:
> 
> : b?branch ( flag -- )
>    ?compile-mode IF
>       read-fcode-offset ?negative IF
>          dest-on-top postpone until
>       ELSE
>          postpone if
>       THEN
>    ELSE
>       ( flag ) IF
>          fcode-offset jump-n-ip       \ Skip over offset value
>       ELSE
>          read-fcode-offset
>          ?jump-direction jump-n-ip
>       THEN
>    THEN
> ; immediate
> 
> Unfortunately it’s not just a simple copy and paste, I get errors when trying to compile Openbios with this code.
> 
> When you have time, could you help me step though it and figure out where it is failing, and how to fix it, I’m just not very good at C and could really use some help from someone that understands what the code is trying to do, and what I need to port over from SLOF to get it to compile.
> 
> Thanks,
> James

I tried copying and pasting into OpenBIOS and saw these errors:
?compile-mode: undefined word.
read-fcode-offset: undefined word.
dest-on-top: undefined word.
?jump-direction: undefined word.

I could not find these words in my openfirmware specification pdf document. My guess is they only exist on SLOF. In general the definition of words tend not to be so portable. 

OpenBIOS does come with a built-in debugger that would allow you to see exactly what is executing. 

https://docs.oracle.com/cd/E19620-01/805-4436/6j4719ca7/index.html
- Webpage on how to use the forth debugger

Here is a quick tutorial:

Lets say you want to debug this simple word:

: myword 
1
2
3
4
;

To indicate that a word is to be debugged type this: debug myword

Then run the word myword by just typing myword and pushing return at the prompt.

You will see something like this next:
: myword  ( Empty )

To step thru each instruction in myword, push the return key.

You will see this each time the return key is pushed:
<adddress>: 1 ( 1 )
<adddress>: 2 ( 1 2 )
<adddress>: 3 ( 1 2 3 )
<adddress>: (lit) (1 2 3 4)
<adddress>: (semis) 
[ Finished myword ] ok

The values in the parentheses indicate what is going into the stack. 

I suggest familiarizing yourself with the debugger first before starting on the b?branch word.

One question to answer is are we experiencing problems at compile time or at run-time.







More information about the OpenBIOS mailing list