OS_ReadLine bug in RO3.x / 4.x
Jon Abbott (1421) 2651 posts |
OS_ReadLine seems to corrupt R4 on RO3.x and RO4.×. I’m noting it here should someone Google it – unlikely, but you never know … I did! The PRM doesn’t actually say what happens to R4 on exit, but it was preserved on RO2 so the logical assumption would be that it’s also preserved on RO3+. EDIT: This turned out to an issue with the LineEditor module, which corrupts R4 on 26bit non-SA OS’s. |
Steve Revill (20) 1361 posts |
I believe the PRMs state that any registers not listed in the “On exit” section will be preserved, unless explicitly stated otherwise (PRM1-29). The documentation for OS_ReadLine (PRM1-910) looks like R4 should be preserved on exit, so I think you’re correct that this was a bug. |
Clive Semmens (2335) 3276 posts |
They do indeed state exactly that. |
Jeffrey Lee (213) 6048 posts |
Do you have any sample code which shows the bug? I find it somewhat surprising that a bug like that could go unnoticed for so long. I can’t see anything obviously wrong in the old kernel sources (R4 gets stacked on entry/exit), and some quick tests in BASIC in RISC OS 3.1 and 3.7 don’t show anything bad happening. OS_ReadLine is a vectored SWI (ReadLineV), so it’s possible it’s something else sitting on the vector which is corrupting R4. |
Jon Abbott (1421) 2651 posts |
I tested it from BASIC using:
On RO3.1 thru RO4.03 E% wasn’t &1234 on exit, off the top of my head it was &40 or something similar. I only picked up on it when I noticed a RO2 game doing odd things after text input. |
Rick Murray (539) 13850 posts |
It’s you. Here is a vanilla install of RISC OS 3.10: Here is a basic install of RISC OS 3.50 that loads PreDesk but drops out before entering the desktop (I was testing Harinezumi so I set the obey file to stop at that point): And here is a reasonably customised install of RISC OS 3.70 (and, yes, I prefer coding BASIC in Edit with a yellow-on-blue colour scheme, I find it more readable than the black/white default): In all cases, R4 is returned as These are all under emulation, by the way. |
Jeffrey Lee (213) 6048 posts |
That code works fine here, under emulated 3.1 & 3.7 and real 3.7. What kind of stuff do you have in your boot sequence? Aren’t there a couple of line editor utilities for RISC OS which add tab completion, history, etc. to the CLI? It wouldn’t surprise me if they worked by hooking into ReadLineV. |
Rick Murray (539) 13850 posts |
Just tested with Zap’s LineEditor v2.73 (20 Oct 1998) under RISC OS 3.70 – works fine. I should add – since libraries and assembler programs will be written on the assumption that R4 is not trashed, and since R4 is not one of the APCS trashable registers, I would have thought something this big might have been seen before. Do you have a utility like Can you boot to a base shell? On older machines – start up with Shift and numpad-* held down – should drop you directly into the command line. Try your little program then. What’s the result? |
Rick Murray (539) 13850 posts |
Poked around StrongEd on the Pi image. Hmmm, it doesn’t appear to have a line editing facility like Zap… Have I missed something? |
Fred Graute (114) 645 posts |
What in particular are you looking for? You can certainly use the LineEditor module with StrongED, been doing that for years. You can use it with Edit too, it’s not specific to Zap – people seem to think it is because it’s distributed with Zap. EDIT: One thing just occured to me. Do you have the TaskWindow mode installed? It has to be present (and used) or keystrokes won’t be passed on to the underlying task. |
Rick Murray (539) 13850 posts |
A line editor that is a part of StrongEd. I know that Zap’s LineEditor module is okay (already tested it) and that it works with other things (I use it a lot in ShellCLI). I was checking to see if you provided something similar.
No idea. I guess so as I started StrongEd, pressed ^F12 and a taskwindow (with buttons at the top and options/status at the bottom) appeared which worked and did stuff (including running the sample program above). |
Fred Graute (114) 645 posts |
There isn’t, the LineEditor module works fine with StrongED if you want one. There’s certainly nothing in StrongED sitting on ReadLineV.
You can tell by looking at the Infobar at the bottom. The name of the mode used will be displayed just right of centre. From your description I’d say TaskWindow mode is installed. |
Jon Abbott (1421) 2651 posts |
I could swear I SHIFT-booted at least the A440/1, in hindsight, RO3.11 has a nasty habit of retaining modules if you don’t do it from a power on. Anyhow…I’ve updated the OP. The culprit was the LineEditor module (2.76d is the version I tested) and only affects 26bit non-SA OS’s. I’ve left the patch in ADFFS anyhow, as it’s likely to be a commonly used module. |
Ronald May (387) 407 posts |
I’ve had a quick read of the source code, but I am still wondering how a program actually uses the LineEditor module? |