[OpenBIOS] [PATCH] Add tbu@ and tbl@ words

Programmingkid programmingkidx at gmail.com
Sat Dec 30 04:30:17 CET 2017

> On Dec 29, 2017, at 8:01 PM, BALATON Zoltan <balaton at eik.bme.hu> wrote:
> I've tried to implement it the way I've suggested and came up with the 
> patch below, but it does not seem to work. I think this is because the 
> arithmetic in get-msec overflows and does not get the right values. Could 
> it be it works in SLOF because that runs on 64bit? Or is something needed 
> to tell Forth to use 64bit values on PPC32? Any ideas?

I continuously printed the tb@ word's value by using this program:

tb@ . .

The tbu value looks right. The tbl value is a problem. When it prints it sometimes prints as a negative value. We need a way to print the value as unsigned. I switch over to the monitor and type this command "info registers" to see the timebase registers value to verify their values. Only the tbu value looks right.

I also made this test program:

#include <stdio.h>
#include <inttypes.h>

int main(int argc, const char * argv[]) {

    uint64_t tbu, tbl;
    tbl = 4000000000;
    tbu = 1;
    printf("tbl = %" PRId64 "\n", tbl);
    printf("or'ed value: %" PRId64 "\n", (uint64_t)((tbu << 32) | tbl));  // should be 8,294,967,296
    return 0;

When I change the uint64_t type to uint32_t at the declaration of the variables, the printed value is wrong. So this is why I think switching over to uint64_t might help.

Hope this info helps.

More information about the OpenBIOS mailing list