Difference between revisions of "OSGBPB"
m (1 revision) |
(→6502Em) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 25: | Line 25: | ||
|} | |} | ||
− | + | {| cellpadding="0" cellspacing="0" border="0" | |
+ | | '''Function summary''' | ||
+ | |- valign="top" | ||
+ | | &01 || Write bytes to open file using new pointer | ||
+ | |- valign="top" | ||
+ | | &02 || Write bytes to open file ignoring new pointer | ||
+ | |- valign="top" | ||
+ | | &03 || Read bytes from open file using new pointer | ||
+ | |- valign="top" | ||
+ | | &04 || Read bytes from open file ignoring new pointer | ||
+ | |- valign="top" | ||
+ | | &05 || Read media title and boot option of CSD disk | ||
+ | |- valign="top" | ||
+ | | &06 || Read name of current directory | ||
+ | |- valign="top" | ||
+ | | &07 || Read name of current library | ||
+ | |- valign="top" | ||
+ | | &08 || Read object names from current directory | ||
+ | |- valign="top" | ||
+ | | &09 || Read object names from directory, work/login filename, command line tail | ||
+ | |- valign="top" | ||
+ | | &0A || Read object names and information from directory | ||
+ | |- valign="top" | ||
+ | | &0B || Read object names and extended information from directory | ||
+ | |- valign="top" | ||
+ | | &0C || Read object names and filetype information from directory | ||
+ | |} | ||
+ | |||
+ | |||
+ | ===Functions=== | ||
{| cellpadding="0" cellspacing="0" | {| cellpadding="0" cellspacing="0" | ||
− | | | + | | valign="top" | &01 || Write bytes to open file using new pointer. |
|- | |- | ||
− | | valign="top" | & | + | | valign="top" | &02 || Write bytes to open file ignoring new pointer. |
|- | |- | ||
− | | valign="top" | & | + | | valign="top" | &03 || Read bytes from open file using new pointer. |
|- | |- | ||
− | + | | valign="top" | &04 || Read bytes from open file ignoring new pointer. | |
− | |||
− | | valign="top" | &04 || Read bytes from | ||
|- | |- | ||
| valign="top" colspan="2" | | | valign="top" colspan="2" | | ||
:With functions &01 and &03 the PTR is first set to the supplied value before transferring data. | :With functions &01 and &03 the PTR is first set to the supplied value before transferring data. | ||
− | :On exit the number of bytes actually transferred is subtracted from the 'number of bytes' field and added to the 'data address' field and the PTR. | + | :On exit the number of bytes actually transferred is subtracted from the 'number of bytes' field and added to the 'data address' field and the PTR. The new PTR is returned in the 'PTR' field. The carry flag is returned set if the 'number of bytes' field is not zero on exit -- meaning a read was attempted past EOF. If the read or write extended past end-of-file the EOF error-flag is set and a further read without changing PTR will cause an EOF error. |
:If a write extends past EOF the file is extended, however the contents of the new part of the file are undefined unless overwritten. An error occurs if the object is not a file or does not have the correct access. | :If a write extends past EOF the file is extended, however the contents of the new part of the file are undefined unless overwritten. An error occurs if the object is not a file or does not have the correct access. | ||
:If the handle is 0, action is undefined. Some systems allow multiple bytes to be written to OSWRCH or read from OSRDCH if the handle is 0. | :If the handle is 0, action is undefined. Some systems allow multiple bytes to be written to OSWRCH or read from OSRDCH if the handle is 0. | ||
|- | |- | ||
− | | valign="top" | &05 || | + | | valign="top" | &05 || Read title and boot option of CSD disk into data block: |
:&00 length of title (n) | :&00 length of title (n) | ||
:&01 title in ASCII characters | :&01 title in ASCII characters | ||
Line 50: | Line 77: | ||
:&03+n | :&03+n | ||
|- | |- | ||
− | | valign="top" | &06 || | + | | valign="top" | &06 || Read currently selected directory name into data block: |
:&00 length of drive identity (n) | :&00 length of drive identity (n) | ||
:&01 ASCII drive identity (drive number) | :&01 ASCII drive identity (drive number) | ||
Line 58: | Line 85: | ||
:&03+n+m | :&03+n+m | ||
|- | |- | ||
− | | valign="top" | &07 || | + | | valign="top" | &07 || Read current library name into data block: |
:&00 length of drive identity (n) | :&00 length of drive identity (n) | ||
:&01 ASCII drive identity (drive number) | :&01 ASCII drive identity (drive number) | ||
Line 66: | Line 93: | ||
:&03+n+m | :&03+n+m | ||
|- | |- | ||
− | | valign="top" | &08 || Read | + | | valign="top" | &08 || Read object names from current directory into data block: |
:&00 length of filename 1 (n) | :&00 length of filename 1 (n) | ||
:&01 filename 1 in ASCII characters | :&01 filename 1 in ASCII characters | ||
Line 72: | Line 99: | ||
:&02+n filename 2 in ASCII characters | :&02+n filename 2 in ASCII characters | ||
:&02+n+m etc... | :&02+n+m etc... | ||
− | :The first call to function &08 should be made with the transfer pointer set to zero. This will read the first filename, and the pointer will be updated so that the next call will read the next filename. | + | :The first call to function &08 should be made with the transfer pointer set to zero. This will read the first filename, and the pointer will be updated so that the next call will read the next filename. The cycle number of the current directory is also returned in XY+0. When no filenames are left, the call returns with the 'number of filenames' greater than zero and the carry flag set. |
|- | |- | ||
− | | valign="top" | &09 || Reads work/login filename, command line tail | + | | valign="top" | &09 || Reads object names from directory, work/login filename, command line tail: |
+ | Reading object names: | ||
+ | :&00 object name, null terminated | ||
+ | :xxx next record | ||
+ | |||
+ | Reading work/login filename or command line tail: | ||
:&00 length of drive identity or command line tail (n) | :&00 length of drive identity or command line tail (n) | ||
:&01 ASCII drive identity (drive number) or comand line tail | :&01 ASCII drive identity (drive number) or comand line tail | ||
Line 81: | Line 113: | ||
:&02+n+m | :&02+n+m | ||
− | :If the handle is a channel number of an open directory, reads a null-terminated list of directory entries. | + | :If the handle is a channel number of an open directory, reads a null-terminated list of directory entries. The function is called as for OSGBPB 8, but the updated number of objects is the number of filenames read. See also implementation notes |
|- | |- | ||
− | | valign="top" | &0A || Read | + | | valign="top" | &0A || Read object names and information from the opened directory whose channel number is passed in the handle. If the channel is zero the current directory is scanned. This function is called as for OSGBPB 9. Each record is a whole multiple of four bytes long: |
:&00 Load address | :&00 Load address | ||
:&04 Execution address | :&04 Execution address | ||
Line 89: | Line 121: | ||
:&0C Attributes | :&0C Attributes | ||
:&10 Object type (1=file, 2=directory, 3=image file, 4=unresolved symbolic link) | :&10 Object type (1=file, 2=directory, 3=image file, 4=unresolved symbolic link) | ||
− | :&14 Object name, null terminated | + | :&14 Object name, null terminated, padded to four bytes |
:xxx next record | :xxx next record | ||
|- | |- | ||
− | | valign="top" | &0B || Read | + | | valign="top" | &0B || Read object names and extended information from the opened directory whose channel number is passed in the handle. If the channel is zero the current directory is scanned. This function is called as for OSGBPB 9. Each record is a whole multiple of four bytes long: |
:&00 Load address | :&00 Load address | ||
:&04 Execution address | :&04 Execution address | ||
Line 100: | Line 132: | ||
:&14 Sector start address | :&14 Sector start address | ||
:&18 Five zeros or centisecond time since 1900 | :&18 Five zeros or centisecond time since 1900 | ||
− | :&1D Object name, null terminated | + | :&1D Object name, null terminated, padded to four bytes |
:xxx next record | :xxx next record | ||
|- | |- | ||
− | | valign="top" | &0C || Read | + | | valign="top" | &0C || Read object names and filetype information from the opened directory whose channel number is passed in the handle. If the channel is zero the current directory is scanned. This function is called as for OSGBPB 9. Each record is a whole multiple of four bytes long: |
:&00 Load address | :&00 Load address | ||
:&04 Execution address | :&04 Execution address | ||
Line 110: | Line 142: | ||
:&10 Object type (1=file, 2=directory, 3=image file, 4=unresolved symbolic link) | :&10 Object type (1=file, 2=directory, 3=image file, 4=unresolved symbolic link) | ||
:&14 Object file type (b8-b19 of load address) | :&14 Object file type (b8-b19 of load address) | ||
− | :&18 Object name, null terminated | + | :&18 Object name, null terminated, padded to four bytes |
:xxx next record | :xxx next record | ||
|} | |} | ||
Line 154: | Line 186: | ||
===Z80Tube=== | ===Z80Tube=== | ||
The Z80Tube Z80 emulator implements OSGBPB 9,0 to read the command line tail. | The Z80Tube Z80 emulator implements OSGBPB 9,0 to read the command line tail. | ||
+ | |||
+ | ===65Tube=== | ||
+ | The emulator traps implemented in 65Tube allows calls to OSGBPB with A>9 to pass additional parameters: | ||
+ | {| cellpadding="0" cellspacing="0" | ||
+ | |- valign="top" | ||
+ | | On entry: || || On exit: || | ||
+ | |- valign="top" | ||
+ | | XY?0 || = ignored || XY?0 || = directory cycle | ||
+ | |- valign="top" | ||
+ | | XY!1 || = address || XY!1 || = updated address | ||
+ | |- valign="top" | ||
+ | | XY!5 || = count || XY!5 || = returned count | ||
+ | |- valign="top" | ||
+ | | XY!9 || = offset || XY!9 || = updated offset | ||
+ | |- valign="top" | ||
+ | | XY!13 || =>directory name || XY!13 || = preserved | ||
+ | |- valign="top" | ||
+ | | XY!17 || =>wildcard to match || XY!17 || = preserved | ||
+ | |} | ||
+ | |||
+ | ===6502Em=== | ||
+ | The emulator traps implemented in Warm Silence's 6502Em implement OSGBPB 9 to read object names from the current directory, but use the control block contents differently from the standard: | ||
+ | {| cellpadding="0" cellspacing="0" | ||
+ | |- valign="top" | ||
+ | | On entry: || || On exit: || | ||
+ | |- valign="top" | ||
+ | | XY?0 || = count || XY?0 || = returned count | ||
+ | |- valign="top" | ||
+ | | XY!1 || = address || XY!1 || = preserved | ||
+ | |- valign="top" | ||
+ | | XY!5 || = buffer length || XY!5 || = preserved | ||
+ | |- valign="top" | ||
+ | | XY!9 || = offset || XY!9 || = updated offset | ||
+ | |} | ||
+ | |||
[[User:Jgharston|Jgharston]] 17:01, 6 November 2009 (UTC) | [[User:Jgharston|Jgharston]] 17:01, 6 November 2009 (UTC) | ||
+ | [[User:Jgharston|Jgharston]] ([[User talk:Jgharston|talk]]) 15:56, 30 September 2016 (UTC) | ||
+ | [[User:Jgharston|Jgharston]] ([[User talk:Jgharston|talk]]) 00:03, 3 October 2016 (UTC) |
Revision as of 01:03, 3 October 2016
Read or write multiple bytes of data
Contents
Specification
6502 | Z80 | 6809 | PDP11 | 80x86 | 32016 | ARM | On entry: | On exit: |
A | A | A | R0 | AL | R1 | R0 | = function code | = &00 if supported, preserved if not supported, but see notes. |
XY | HL | X | R1 | BX | =>control block | undefined | ||
Control block | ||||||||
&00 | R2 | R1 | Handle | Cycle number | ||||
&01 | R3 | R2 | Data address | Updated Data address | ||||
&05 | R4 | R3 | Number of bytes or objects to transfer | Updated Number of bytes or objects | ||||
&09 | R5 | R4 | Pointer to use for transfer | Updated Pointer | ||||
&0D | ||||||||
Cy=EOF status (but see notes) |
Function summary | |
&01 | Write bytes to open file using new pointer |
&02 | Write bytes to open file ignoring new pointer |
&03 | Read bytes from open file using new pointer |
&04 | Read bytes from open file ignoring new pointer |
&05 | Read media title and boot option of CSD disk |
&06 | Read name of current directory |
&07 | Read name of current library |
&08 | Read object names from current directory |
&09 | Read object names from directory, work/login filename, command line tail |
&0A | Read object names and information from directory |
&0B | Read object names and extended information from directory |
&0C | Read object names and filetype information from directory |
Functions
&01 | Write bytes to open file using new pointer. |
&02 | Write bytes to open file ignoring new pointer. |
&03 | Read bytes from open file using new pointer. |
&04 | Read bytes from open file ignoring new pointer. |
| |
&05 | Read title and boot option of CSD disk into data block:
|
&06 | Read currently selected directory name into data block:
|
&07 | Read current library name into data block:
|
&08 | Read object names from current directory into data block:
|
&09 | Reads object names from directory, work/login filename, command line tail:
Reading object names:
Reading work/login filename or command line tail:
|
&0A | Read object names and information from the opened directory whose channel number is passed in the handle. If the channel is zero the current directory is scanned. This function is called as for OSGBPB 9. Each record is a whole multiple of four bytes long:
|
&0B | Read object names and extended information from the opened directory whose channel number is passed in the handle. If the channel is zero the current directory is scanned. This function is called as for OSGBPB 9. Each record is a whole multiple of four bytes long:
|
&0C | Read object names and filetype information from the opened directory whose channel number is passed in the handle. If the channel is zero the current directory is scanned. This function is called as for OSGBPB 9. Each record is a whole multiple of four bytes long:
|
Notes
Some filing systems preserve A even if they support the function.
Many filing systems do not return Carry consistently. The only consistent way of telling if the end of file has been reached is to test whether the updated number of bytes/objects is unequal to zero.
Calling from BBC BASIC
BBC BASIC makes no calls to OSGBPB.
Entry points
- BBC BASIC Entry Address: &FFD1
- 6502 Entry Address: &FFD1, vectors via &021A
- Z80 Entry Address: &FFD1, vectors via &FFD2
- 6809 Entry Address: &FFD1, vectors via &FFD2
- 80x86 Entry Address: INT &41, vectors via 0000:0104
- 32000 Entry Address: SVC &0F
- PDP-11 Entry Address: EMT 11, vector &0B
- ARM Entry Address: SWI &0C "OS_GBPB", vector &0C
Implementations
CFS
Not implemented, simply returns with an RTS instruction.
The Master 128 implements &02 and &04.
ROMFS
Not implemented, simply returns with an RTS instruction.
The Master 128 implements &04.
DFS
Acorn DFS and contemporary filing systems implement functions &01 to &08 inclusive. Watford DFS implements &09 to read the work name.
ADFS
ADFS implements &01 to &08
HADFS
HADFS implements &01 to &0B.
Z80Tube
The Z80Tube Z80 emulator implements OSGBPB 9,0 to read the command line tail.
65Tube
The emulator traps implemented in 65Tube allows calls to OSGBPB with A>9 to pass additional parameters:
On entry: | On exit: | ||
XY?0 | = ignored | XY?0 | = directory cycle |
XY!1 | = address | XY!1 | = updated address |
XY!5 | = count | XY!5 | = returned count |
XY!9 | = offset | XY!9 | = updated offset |
XY!13 | =>directory name | XY!13 | = preserved |
XY!17 | =>wildcard to match | XY!17 | = preserved |
6502Em
The emulator traps implemented in Warm Silence's 6502Em implement OSGBPB 9 to read object names from the current directory, but use the control block contents differently from the standard:
On entry: | On exit: | ||
XY?0 | = count | XY?0 | = returned count |
XY!1 | = address | XY!1 | = preserved |
XY!5 | = buffer length | XY!5 | = preserved |
XY!9 | = offset | XY!9 | = updated offset |
Jgharston 17:01, 6 November 2009 (UTC)
Jgharston (talk) 15:56, 30 September 2016 (UTC)
Jgharston (talk) 00:03, 3 October 2016 (UTC)