My apologies... rereading loader miller.s, I see that it reuses SP/R2 for
BSS cleanup, which is why it has a different value.
I've modified loader chuck.s to include the static base initialization:
---chuck.s---
TEXT start(SB), $-4
/* set static base */
MOVW $setSB(SB), R3
/* set stack pointer */
MOVW $0x80020000, R2
/* set frame pointer */
ADD R0, R2, R8
/* call main */
JAL R1, main(SB)
Now it works correctly with this loader.
Thanks to everyone!
P.S. What a blast from the past—I wrote an assignment on the Wumpus Hunt
game for an AI course over 20 years ago. ;-)
El sáb, 30 ago 2025 a las 0:26, Charles Forsyth (<[email protected]>)
escribió:
> and before you know it, you can run hunt the wumpus!
>
> On Fri, 29 Aug 2025 at 23:22, Charles Forsyth <[email protected]>
> wrote:
>
>> it's perhaps subtle just to track it down. with enough registers, and
>> depending on the architecture's addressing, plan 9 c uses a Static Base
>> register ("SB") to access data.
>> on Risc-V it looks like R3 is SB, so you need something early in chuck.s
>> that sets SB. in fact, make it the first instruction.
>> It might be
>> MOV $setSB(SB), R3
>>
>>
>> On Fri, 29 Aug 2025 at 21:51, José J. Cabezas Castillo <
>> [email protected]> wrote:
>>
>>> Thank you very much — that’s exactly it. I modified the chuck.s loader,
>>> and now the execution continues, but nothing is being printed.
>>>
>>> I've found that in another part of the code, the PC resets to 0 again
>>> (when it tries to access the string data). I want to run more tests before
>>> asking for help.
>>>
>>> José J.
>>>
>>> El vie, 29 ago 2025 a las 21:40, <[email protected]> escribió:
>>>
>>>> I think you need to start chuck.s with
>>>> TEXT start(SB), $-4
>>>> This treats the routine as a leaf function and doesn't insert code to
>>>> make space for parameters on the stack, which I believe is what's happening
>>>> with R2.
>>>>
>>>> David
>>>>
>>>
>>>
>>> --
>>> José J. Cabezas
>>>
>> *9fans <https://9fans.topicbox.com/latest>* / 9fans / see discussions
> <https://9fans.topicbox.com/groups/9fans> + participants
> <https://9fans.topicbox.com/groups/9fans/members> + delivery options
> <https://9fans.topicbox.com/groups/9fans/subscription> Permalink
> <https://9fans.topicbox.com/groups/9fans/T3f252d4d7c5389ee-Md8718ca7512d7da2abe3c6ff>
>
--
José J. Cabezas
------------------------------------------
9fans: 9fans
Permalink:
https://9fans.topicbox.com/groups/9fans/T3f252d4d7c5389ee-M7f2a0bf8220d9a2582e72183
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription