Who owns the PRM copyright now?
Pages: 1 2
nemo (145) 2556 posts |
And you continue to confuse one implementation with the API in general.
This is an implementation detail. It is not the API.
I haven’t asserted that. I said this:
It’s not like you to resort to straw men.
Again, I must direct you to OS_Byte 131 on the Beeb, which returns up to 23bits in A,Y,X (in that order). Here’s the code from the 2nd processor OS that returns OSHWM from OSBYTE &83: FAB5 : A9 01 : ©A : LDA #&01 ; &010000 FAB7 : A2 00 : ¢@ : LDX #&00 FAB9 : A0 00 : @ : LDY #&00 FABB : 60 : ` : RTS And here’s the code for OSBYTE &84: FAC6 : A9 04 : ©D : LDA #&04 ; &040000 FAC8 : A2 00 : ¢@ : LDX #&00 FACA : A0 00 : @ : LDY #&00 FACC : 60 : ` : RTS
This is absolutely wrong, as the above code demonstrates. Surely you’re not going to argue that this Acorn implementation ‘counts’, but that Acorn implementation doesn’t count? That won’t wash. You are simply wrong in your assertion that OSBYTE can only return 16bit addresses. It has been returning greater than 16bit addresses since the 1980s. This isn’t a matter of opinion. If you don’t believe me, the Advanced User Guide or actual Acorn code, please peruse any other documentation of OSBYTE, such as the BeebWiki at MDFS. |
Rick Murray (539) 13851 posts |
In not talking about what other OS Bytes may or may not do. I’m responding simply to:
It’s not a fiasco, it has only ever had a high byte and a low byte, hence a 16 bit value. Look at the MOS source. Look at any incarnation of RISC OS. There was another call to read the upper 16 bits of the co processor address. It’s not a fiasco, it’s just unfortunate that finally something has happened that means the call now returns gibberish. BTW, if the OS Byte can return 23 (24?) bit results, surely even that would have been inadequate to give any &FFxxxxxx address? Hence the separate call. |
nemo (145) 2556 posts |
Does this help you understand the difference between API and implementation?
On BBC MOS. No one has suggested that RISC OS returns large addresses like that. The RISC OS convention has already been given above, but is: SWI OS_Byte ORR Rn, R1, R2, LSL#8 Which is a 32bit result. Here’s how I described it before: SYS"OS_Byte",166,,255 TO ,X%,Y% MOSVAR%=X%OR(Y%<<8) I’ve also named an RO5 module that does that. Do you want me to list all the modules that do that? I would have though that one would be sufficient, but name your threshold. |
Rick Murray (539) 13851 posts |
Actual Beeb user guide:
Advanced User Guide:
The New Advanced User Guide says that for OSBYTE, A is preserved. BBC MOS 1.20: ************************************************************************* * * * OSBYTE 131 READ OSHWM (PAGE in BASIC) * * * ************************************************************************* F085 LDY &0244 ; read current OSHWM F088 LDX #&00 ; F08A RTS ; Clearly: 1, The use of A to return extra bits appears to have been retrofitted for some uses of the Tube coprocessor. Documentation of its use doesn’t seem to be mentioned in the official user guide (issue 1) nor the AUG (issue unknown, the one at http://stardot.org.uk/mirrors/www.bbcdocs.com/filebase/essentials/BBC%20Microcomputer%20Advanced%20User%20Guide.pdf). Therefore I would contend that whatever it is that passes larger values using the A register is the anomaly (whether out of necessity or not) as the BBC MOS and all of its documentation as well as the RISC OS implementation all seem to agree – it’s a low byte and a high byte and nothing more. That is the API that is documented, that is the API visible by looking at the code of the respective operating systems. That is the API. Whatever it is that actually mucks around with the A register is just plain wrong as the published documentation of the API states that A is preserved. However, I will grant you, the idea of the code and the documentation doing entirely different things, I believe we’ve been here before. A lot. I rest my case. |
Steve Fryatt (216) 2105 posts |
You are simply wrong in your assertion that OSBYTE can only return 16bit addresses. It has been returning greater than 16bit addresses since 1982. This isn’t a matter of opinion. OK, then…
(p155, Bray, Dickens and Holmes, August 1983). The following two pages, for OSBYTEs 132 and 133, are very similar – although there’s a clear typo on the OSBYTE 132 page. They refer to “low-byte” and “high-byte”, which is very definitely 16-bit. What subtle word-play have I missed here? |
nemo (145) 2556 posts |
Correct (finally!) – by Acorn. Extending the API at that point. The fact that documentation already distributed and manuals already printed did not spontaneously change is regrettable but to be expected.
So every change Acorn made to the original Beeb API is an “anomaly”? This is a degree of retropurity that even I cannot subscribe to. Which is why I wrote earlier: Surely you’re not going to argue that this Acorn implementation ‘counts’, but that Acorn implementation doesn’t count? That won’t wash.
Which we have done, hence revealing the 23bit form of that API, introduced in order to return values greater than 16bit on the Beeb. (And all of this banter about OSBYTE is missing the point that OS_Byte has always returned values that are not bytes – OS_Byte 143 is definitive.) I still feel you’re misunderstanding the relationship between API and implementation. If an API says “R0 shall be returned as a value between 0 and 7” but there are official implementations that return 42, then the API documentation is wrong – the code has revealed that. But if the API says “R0 shall return a value between 0 and 7” and every implementation you can find returns 4, that does not mean the documented API is wrong. Here’s a concrete example: The published API for RemV says: Exit R0 Next byte to be removed (examine option), or corrupted (remove option) R1 Preserved R2 Byte removed (remove option), or corrupted (examine operation) C flag set if buffer was empty on entry You’ll note the strange asymmetry regarding which register holds the byte – R0 under some circumstances, R2 under others. But the published API is clear. It’s also wrong. To see why you have to delve into the depths of the Kernel’s RdchVHandler which, after checking that it’s not expanding a function key, calls RemV with V clear in order to remove a byte from the keyboard buffer. As you can see above, this ought to be in R2. However, the very next thing it does is set R2 to zero, and thereafter assume that R0 contained the byte. It has done this in every single version of RISC OS from right now all the way back to Arthur 0.30. So regardless of the sincere belief of whoever wrote that documentation all those years ago, the OS depends on the byte removed being in R0. Always has. Therefore, every implementation of RemV – the kernel, BufferManager, DeepKeys etc, has always had to return the byte in R0, otherwise the OS doesn’t work. However, they also have to return it in R2, because of the documented API that third parties may have relied on. So for RemV, R0=R2. If at this point you’re beginning to feel it’s rather unfair that I keep pulling out examples like this… does that not prove my point about the importance of having a definitive document of the actual API, and what better place than here? Which is where we started. |
nemo (145) 2556 posts |
Steve asked
Must be an M128 Turbo thing, so that would be ~1985? I mentioned the AUG because of this definitive promise: This call returns the start address of the memory used by the operating system to store its internal variables. Not because of its superseded assertion about the 6502’s A register. |
Steve Pampling (1551) 8172 posts |
So, not only have we established that the documentation being proposed in the wiki needs to properly reflect the implemented behaviour1, but also if the information is to correctly reflect the implementation in older versions of the OS we can not use the old documentation except as guidance for what might be true. 1 Accurate documents might help programmers a little, might even help point out where OS developers need to correct long standing mistakes. |
Steve Fryatt (216) 2105 posts |
OK. So we have a RISC OS API that examination of the source tells us has been resolutely 16 bit since Arthur, and is documented as being 16 bit even on the Beeb MOS. But we’re not allowed to document it as 16 bit in the RISC OS PRM because Acorn broke the documented MOS API in one version of MOS by corrupting a preserved register on return. Only we can’t find this MOS API change documented anywhere official, nor agree exactly which version of MOS it was in. And the RISC OS developers dropped it anyway. I think I’m following this argument. :-) |
Colin Ferris (399) 1818 posts |
Mmm – sound a bit like Brexit :-| |
nemo (145) 2556 posts |
Yes and no. I see it as a ratchet: APIs do change over time, but they should only go one way – more capable, not less. The published API is a contract with the programmer. Sometimes an API must be obsoleted due to lack of foresight, such as OS_HeapSort – address bits used as flags is untenable now. However, breaking a RISC OS API because of some perceived restriction of the BBC Micro’s 6502 is indefensible, and the ReadLineV case of processor mode selecting incompatible APIs is deeply regrettable (and that API is still not unified). The API must consist of the superset of published documentation and official implementations. This will inevitably require some predication: “This flag is only available from version x.xx…”. |
nemo (145) 2556 posts |
It’s very simple. The API says This call returns the start address of the memory used by the operating system to store its internal variables. A promise kept through every version of the OS (and how that was implemented does not matter one jot in this case – it was supposed to return the address, it returned the address). That was then broken because of a philosophical belief – that OS_Byte couldn’t return arbitrary values – despite 1) that not being true, and 2) the existing code already working perfectly when a 32bit value is returned. It was a mistake. The 6502 is irrelevant.
They extended it. It’s happened a lot since then.
It’s not corrupted. If b7 is set it is preserved. If b7 is clear it’s the top 7 bits of a 23bit value. ‘Corrupted’ implies undefined, liable to be any value. It isn’t, it is unambiguously defined… but it’s only relevant to OSBYTE, not to OS_Byte.
OS_Byte is not 16bit for crying out loud! Do OS_Byte takes and emits word-sized parameters. The Kernel treats R0 as a byte by ANDing it with 255, but other ByteV claimants can and do implement OS_Bytes > 255 (such as VProtect, off the top of my head). Some OS_Bytes return word-sized results in a single register. Others are defined to return a result in two registers, and those registers must be combined using That someone in 2019 is trying to argue that what has been 32bit for 32 years should somehow be 16bit because of the 6502 when OSBYTE wasn’t even 16bit is beyond parody. |
Steve Pampling (1551) 8172 posts |
I think you meant to say1 “This flag is only available from version x.xx…”.(assumes unity of developmental threads) or for certain circumstances “This flag is only available in these versions x.xx to x.xx +n.” 1 Because I’m such a nice person I will assume you missed out the possibility that something was moved, changed or added in the ROL branch that doesn’t exist in other versions that were before or parallel. |
Rick Murray (539) 13851 posts |
Something which doesn’t appear to be mentioned anywhere other than the one source. You know why you’re checking bit 7? Because it is a bodge. A half assed quick hack to make do rather than putting it in OSWORD where “big values” belong. You’re checking bit 7 because the API is supposed to preserve A.
I still feel you’re misunderstanding that a bodge does not instantly revise the API. I’ve provided references both pre and post the Tube. Everything, read again EVERYTHING, including source, treats it as a low byte and a high byte.
Irrelevant. The promise that A is preserved came first and I don’t like the idea of arbitrarily retconning an API.
Christ almighty – you’re using Tory party logic now.
Yup. “TASK” and magic values in the Wimp. It’s shameful. I’m still wondering what will happen with a window defined as a pane on Select, the exact same bit appears to mean two different things. Did I mention it was shameful?
That somebody is desperately clinging to the notion that a specific API is different to all of the documentation and source that exists aside from this one implementation is beyond parody. RISC OS didn’t suffer a lack of memory. It would not have been hard to allocate a word (just two extra bytes) and a couple of instructions to mush the extra 24 bits into place. They did not, they treated it as a two byte, or 16 bit, value. Asides from – what was it, HighBasic or something? – asides from that OSHWM is a 16 bit value. End of. |
Rick Murray (539) 13851 posts |
It’s worth noting that there seems to be some confusion (obfuscation?) along the way regarding whether or not OS_Byte handles values larger than a byte. This is not what I’m arguing. Clearly X,Y were byte sized on the Beeb but can easily be word sized on RISC OS (such as the deprecated OS_Byte 143). In order to handle “big modes”, OS_Byte and anything that calls it will need to cope with words – it’s perfectly feasible to have more than 256 text columns on screen now… Anyway, what I am arguing is this hideously broken hack pushing crap into the A register on the Beeb in order to add some extra address bits. Why is this bad? Because there exists an OSBYTE that provides the high order address bits of the machine – namely OSBYTE &82. The problem we’re running into is it is essentially an API developed for an eight bit processor with sixteen bit addressing range (sorry nemo, history requires the 6502 to be anything but irrelevant, it is why this stuff is the way it is), that was later botched into returning larger values for some reason (interesting that it appears to be 6502 code returning addresses the 6502 cannot directly address!), which was subsequently ignored, and was then implemented on RISC OS in the same manner as the BBC MOS “because it worked” (due to page zero use) but was in effect rubbish liable to break the moment the address went over 64K (remember, nemo, it’s held in two bytes in the kernel workspace, it is implicitly 16 bit). |
David Feugey (2125) 2709 posts |
Of course everyone should try to avoid this, but – hey – API must change too. The documentation IS NOT the API, but the textual description of the API. Another chicken and egg problem. |
Clive Semmens (2335) 3276 posts |
From a Tech Author’s pov, this is precisely the point. |
nemo (145) 2556 posts |
You know that phenomenon where you wake up with the solution to a knotty problem?! Rick, I realise that we are talking slightly at cross-purposes. You have been adamant about the 8bit/16bit restriction, and yet I’ve demonstrated with various OSBYTEs and OS_Bytes that there is no such restriction. Well of course there is a restriction for some of them: The MOSVARs themselves. There’s little point returning the address of the THE MOSVARs without defining what that points at – the MOSVARs are bytes. So although the OS_Byte API would seem to support 32bit MOSVARs (the AND and EOR masks can be 32bit), the ability to read/write them direct requires them to be bytes. (And the ability to peek and poke them is a defined part of the API, as it is intended to allow access without having to enable interrupts for the duration of the lengthy OS_Byte call). However, and this is the crucial point: The address of the MOSVARs is not itself a MOSVAR. Let’s list the many ways it is not a MOSVAR: 1. You cannot write to it – that is defined. I realise that it is confusing that this call was implemented using the same code in the BBC MOS, but that’s an implementational wheeze to allow the OS to implement the call to return the address in only two bytes of ROM, by reusing the MOSVAR code (and at the cost of two bytes of RAM). Otherwise the MOS would have had to do: CMP #&A6 BNE next LDX #lo LDY #hi RTS A saving of seven bytes, when ROM bytes were scarce. I’ll respond to any other points you’ve made after my morning’s conference calls! |
Rick Murray (539) 13851 posts |
<facepalm> |
nemo (145) 2556 posts |
Sorry for the delay, I’ve had a busy week.
It’s not a variable. I even put it in bold.
ORR Rn,R1,R2,LSL#8 |
Pages: 1 2