Difference between revisions of "Using high workspace"
m (1 revision) |
m (Re-arranged diagrams.) |
||
(One intermediate revision by the same user not shown) | |||
Line 22: | Line 22: | ||
This will give the following layout: | This will give the following layout: | ||
+ | DC00 +------------------+ | ||
+ | | ROM 1 workspace | | ||
+ | DB00 +------------------+ | ||
+ | | ROM 2 workspace | | ||
+ | DA00 +------------------+ | ||
+ | | ROM 3 workspace | | ||
+ | D900 +------------------+ | ||
+ | | ROM 4 workspace | | ||
+ | D800 +------------------+ | ||
+ | | | | ||
+ | C800 +------------------+ Top of shared workspace | ||
+ | | Shared workspace | | ||
C000 +------------------+ | C000 +------------------+ | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
The owner of the shared workspace at &C000 can expand its workspace up to | The owner of the shared workspace at &C000 can expand its workspace up to | ||
Line 48: | Line 48: | ||
with eight pages of shared workspace: | with eight pages of shared workspace: | ||
− | + | DC00 +------------------+ | |
− | | ROM | + | | ROM 4 workspace | |
− | + | D800 +------------------+ | |
− | | ROM | + | | ROM 5 workspace | |
− | + | D400 +------------------+ | |
− | | ROM | + | | ROM 6 workspace | |
− | + | D000 +------------------+ | |
+ | | ROM 7 workspace | | ||
+ | CC00 +------------------+ | ||
+ | | ROM 8 workspace | | ||
+ | C800 +------------------+ Top of shared workspace | ||
+ | | Shared workspace | | ||
+ | C000 +------------------+ | ||
: : | : : | ||
: : | : : | ||
− | + | 1A00 +------------------+ | |
− | + | | ROM 1 workspace | | |
− | + | 1600 +------------------+ | |
− | + | | ROM 2 workspace | | |
− | + | 1200 +------------------+ | |
− | + | | ROM 3 workspace | | |
− | + | 0E00 +------------------+ | |
− | | ROM | ||
− | |||
− | | ROM | ||
− | |||
− | | ROM | ||
− | |||
The following example code from HADFS claims one page of private workspace | The following example code from HADFS claims one page of private workspace | ||
Line 80: | Line 80: | ||
\ ----------------------------------------------------------- | \ ----------------------------------------------------------- | ||
− | \ SERVICE &24 - State how much Hazel | + | \ SERVICE &24 - State how much private Hazel workspace needed |
\ ----------------------------------------------------------- | \ ----------------------------------------------------------- | ||
.Serv24 | .Serv24 | ||
DEY:RTS :\ Need one page of private workspace | DEY:RTS :\ Need one page of private workspace | ||
: | : | ||
− | \ ------------------------------------------ | + | \ ---------------------------------------------------------- |
− | \ SERVICE &21 - | + | \ SERVICE &21 - State how much shared Hazel workspace needed |
− | \ ------------------------------------------ | + | \ ---------------------------------------------------------- |
.Serv21 | .Serv21 | ||
CPY #&C9:BCS P%+4:LDY #&C9:RTS :\ Need at least nine pages of shared workspace | CPY #&C9:BCS P%+4:LDY #&C9:RTS :\ Need at least nine pages of shared workspace | ||
Line 99: | Line 99: | ||
INY:LDA #&22:RTS :\ Claim one page of workspace and return | INY:LDA #&22:RTS :\ Claim one page of workspace and return | ||
: | : | ||
− | \ --------------------------------------- | + | \ ------------------------------------------------------ |
− | \ SERVICE 1 - State shared workspace | + | \ SERVICE 1 - State how much shared low workspace needed |
− | \ --------------------------------------- | + | \ ------------------------------------------------------ |
.Serv1 | .Serv1 | ||
− | LDA OSFILE:CMP #&6C:BCC Serv1done :\ Don't claim low workspace on Master | + | LDA OSFILE:CMP #&6C:BCC Serv1done :\ Don't claim shared low workspace on Master |
CPY #&17:BCS P%+4:LDY #&17 :\ BBC needs nine pages of shared low workspace | CPY #&17:BCS P%+4:LDY #&17 :\ BBC needs nine pages of shared low workspace | ||
.Serv1done | .Serv1done | ||
LDA #1:RTS :\ Restore and return | LDA #1:RTS :\ Restore and return | ||
: | : | ||
− | \ ----------------------------------- | + | \ --------------------------------------- |
− | \ SERVICE 2 - Claim private workspace | + | \ SERVICE 2 - Claim private low workspace |
− | \ ----------------------------------- | + | \ --------------------------------------- |
.Serv2 | .Serv2 | ||
LDA OSFILE:CMP #&6C:BCS Serv2bbc :\ Always claim low workspace on BBC | LDA OSFILE:CMP #&6C:BCS Serv2bbc :\ Always claim low workspace on BBC | ||
LDA &DF0,X :\ Get workspace pointer | LDA &DF0,X :\ Get workspace pointer | ||
− | CMP #&DC:BCC Serv2done :\ If haven't run out of Hazel, use it | + | CMP #&DC:BCC Serv2done :\ If we haven't run out of Hazel, use it |
.Serv2bbc | .Serv2bbc | ||
TYA:STA &DF0,X :\ Note location of private workspace | TYA:STA &DF0,X :\ Note location of private workspace | ||
Line 120: | Line 120: | ||
.Serv2done | .Serv2done | ||
\ ROMs often do Break initialisation here | \ ROMs often do Break initialisation here | ||
− | + | LDA #2:RTS :\ Restore and exit | |
: | : | ||
\ ------------------------------------------------------ | \ ------------------------------------------------------ |
Latest revision as of 20:42, 20 November 2016
On the BBC Master there is extra workspace memory at &C000-&DFFF called Hazel. This is available for sideways ROM workspace instead of using memory at &E00 and pushing up BASIC's PAGE. A sideways ROM can use the Hazel workspace by responding to the Hazel workspace service calls &21 to &24. There is space for shared workspace from &C000 upwards and private workspace from &DC00 downwards.
Private workspace in low memory is claimed from &E00 upwards, but private workspace in Hazel is claimed from &DC00 downwards. This gives two results. It means that if not all of the high workspace is claimed the current owner of the shared workspace can use the rest of the workspace up to the bottom of the private workspace reported by Service Call &23. It also means that if more workspace is claimed than is available then a sideways ROM can respond to service call 2 and claim workspace in low memory instead.
As an example, imagine a system with four ROMs each claiming one page of private workspace, and the largest amount of shared memory is eight pages. This will give the following layout:
DC00 +------------------+ | ROM 1 workspace | DB00 +------------------+ | ROM 2 workspace | DA00 +------------------+ | ROM 3 workspace | D900 +------------------+ | ROM 4 workspace | D800 +------------------+ | | C800 +------------------+ Top of shared workspace | Shared workspace | C000 +------------------+
The owner of the shared workspace at &C000 can expand its workspace up to &D800.
On the other hand, imagine eight ROMs each claiming four pages of private workspace. This is &2000 bytes, but there is only &1C00 bytes of workspace available without accounting for any shared workspace. In this instance, ROMs have to note that there is not enough high workspace and claim it from low memory instead. This is done by pointing to the overflowed workspace on the high workspace service call, and checking for this on the low workspace service call. This example would give the following memory layout, again with eight pages of shared workspace:
DC00 +------------------+ | ROM 4 workspace | D800 +------------------+ | ROM 5 workspace | D400 +------------------+ | ROM 6 workspace | D000 +------------------+ | ROM 7 workspace | CC00 +------------------+ | ROM 8 workspace | C800 +------------------+ Top of shared workspace | Shared workspace | C000 +------------------+ : : : : 1A00 +------------------+ | ROM 1 workspace | 1600 +------------------+ | ROM 2 workspace | 1200 +------------------+ | ROM 3 workspace | 0E00 +------------------+
The following example code from HADFS claims one page of private workspace and nine pages of shared workspace. The code checks if it is operating on a BBC or a Master. On a BBC it claims low shared and private workspace, on the Master it claims high shared workspace, and claims either high or low private workspace.
The service calls are listed in the order they are called:
\ ----------------------------------------------------------- \ SERVICE &24 - State how much private Hazel workspace needed \ ----------------------------------------------------------- .Serv24 DEY:RTS :\ Need one page of private workspace : \ ---------------------------------------------------------- \ SERVICE &21 - State how much shared Hazel workspace needed \ ---------------------------------------------------------- .Serv21 CPY #&C9:BCS P%+4:LDY #&C9:RTS :\ Need at least nine pages of shared workspace : \ ------------------------------------------- \ SERVICE &22 - Claim Hazel private workspace \ ------------------------------------------- .Serv22 CPY #&DC:BCC P%+4:LDY #&DC :\ If run out of Hazel, point to top of Hazel TYA:STA &DF0,X :\ Note location of private workspace INY:LDA #&22:RTS :\ Claim one page of workspace and return : \ ------------------------------------------------------ \ SERVICE 1 - State how much shared low workspace needed \ ------------------------------------------------------ .Serv1 LDA OSFILE:CMP #&6C:BCC Serv1done :\ Don't claim shared low workspace on Master CPY #&17:BCS P%+4:LDY #&17 :\ BBC needs nine pages of shared low workspace .Serv1done LDA #1:RTS :\ Restore and return : \ --------------------------------------- \ SERVICE 2 - Claim private low workspace \ --------------------------------------- .Serv2 LDA OSFILE:CMP #&6C:BCS Serv2bbc :\ Always claim low workspace on BBC LDA &DF0,X :\ Get workspace pointer CMP #&DC:BCC Serv2done :\ If we haven't run out of Hazel, use it .Serv2bbc TYA:STA &DF0,X :\ Note location of private workspace INY :\ Use one page of low workspace .Serv2done \ ROMs often do Break initialisation here LDA #2:RTS :\ Restore and exit : \ ------------------------------------------------------ \ SERVICE &23 - Report bottom of Hazel private workspace \ ------------------------------------------------------ .Serv23 \ On entry, Y=start of private workspace in Hazel \ The ROM can store this value and extend its shared workspace \ up to this value when it owns the shared workspace LDA #&23:RTS
A consequence of the workspace pointer being able to point to memory at from &0000 upwards or &C000 upwards, the usual method of using bit 7 as an enabled/disabled flag cannot be used. Instead, both bit 7 and bit 6 are used, with %00xxxxxx and %11xxxxxx indiating the ROM is enable with workspace at &0000 or &C000, and %01xxxxxx and %10xxxxxx indicating the ROM is disabled. This can be checked for with the following code in the service handler:
.Service PHA:LDA &DF0,X :\ Get workspace flags BMI P%+4:EOR #&40 :\ Toggle bit 6 if bit 7 is zero ASL A:BPL ServDisabled:PLA :\ Exit if the resultant bit 6 is clear \ \ Do the service call dispatch \ .ServDisabled PLA:RTS :\ Restore service call and return
Low shared workspace can be claimed by any sideways ROM by issuing Service Call &0A. High shared workspace is claimed by Filing System Control call &06, so is normally only claimable by filing systems.