Difference between revisions of "OSWORD &05"

From BeebWiki
Jump to: navigation, search
(Added implementation details and single-byte code.)
m (Formatted title.)
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:OSWORD]]
+
[[Category:OSWORD]][[Category:Second Processors]]__NOTOC__
OSWORD &05 (5) - Read I/O processor memory
+
{{PageTitle|OSWORD &05 (5): Read I/O processor memory}}
Acorn MOS 1.00 and later
+
  On entry:
 +
    XY!0=address to read from
 +
  On exit:
 +
    XY?4=the byte read
  
On entry:
+
Some systems recognise screen memory at &FFFExxxx and sideways ROMs at
  XY!0=address to read from
+
&FFrr8000-&FFrrBFFF.
On exit:
 
  XY?4=the byte read
 
 
 
Some systems recognise screen memory at &FFFExxxx and sideways ROMs at &FFrr8000-&FFrrBFFF.
 
  
 
==Coding==
 
==Coding==
Line 15: Line 14:
 
<code>X%</code>=>5-byte control block, <code>Y%=X%DIV256</code>.
 
<code>X%</code>=>5-byte control block, <code>Y%=X%DIV256</code>.
  
    DEFPROCmem_rd(io%,mem%,num%)
+
  DEFPROCmem_rd(io%,mem%,num%)
    A%=5:REPEAT
+
  A%=5:REPEAT
      !X%=io%:CALL&FFF1:?mem%=X%?4
+
    !X%=io%:CALL&FFF1:?mem%=X%?4
      io%=io%+1:mem%=mem%+1:num%=num%-1
+
    io%=io%+1:mem%=mem%+1:num%=num%-1
    UNTILnum%<1:ENDPROC
+
  UNTILnum%<1:ENDPROC
    :
+
  :
    DEFPROCmem_wr(io%,mem%,num%)
+
  DEFPROCmem_wr(io%,mem%,num%)
    A%=6:REPEAT
+
  A%=6:REPEAT
      !X%=io%:X%?4=?mem%:CALL&FFF1
+
    !X%=io%:X%?4=?mem%:CALL&FFF1
      io%=io%+1:mem%=mem%+1:num%=num%-1
+
    io%=io%+1:mem%=mem%+1:num%=num%-1
    UNTILnum%<1:ENDPROC
+
  UNTILnum%<1:ENDPROC
 +
 
 +
  REM To read a single byte:
 +
  !X%=addr:A%=5:CALL&FFF1:byte=X%?4
 +
  :
 +
  REM To write a single byte
 +
  X%?4=byte:!X%=addr:A%=6:CALL&FFF1
 +
 
 +
By copying code to the I/O processor and the I/O processor's USERV you can
 +
call an arbitary address in the I/O processor.
 +
 
 +
  DEFPROCmem_call(io%,A$):LOCAL old%
 +
  !X%=&200:REPEAT
 +
    A%=5:CALL&FFF1:old%=256*X%?4+old%DIV256
 +
    A%=6:X%?4=io%:CALL&FFF1:io%=io%DIV256
 +
    ?X%=?X%+1
 +
  UNTIL ?X%=2
 +
  OSCLI "LINE "+A$
 +
  !X%=&200:REPEAT
 +
    X%?4=old%:CALL&FFF1:old%=old%DIV256
 +
    ?X%=?X%+1
 +
  UNTIL ?X%=2
 +
  =B%
 +
  :
 +
  DEFFNmem_call(io%,B%,C%):LOCAL old%
 +
  !X%=&200:REPEAT
 +
    A%=5:CALL&FFF1:old%=256*X%?4+old%DIV256
 +
    A%=6:X%?4=io%:CALL&FFF1:io%=io%DIV256
 +
    ?X%=?X%+1
 +
  UNTIL ?X%=2
 +
  B%=FNbyte(136,B%,C%)
 +
  !X%=&200:REPEAT
 +
    X%?4=old%:CALL&FFF1:old%=old%DIV256
 +
    ?X%=?X%+1
 +
  UNTIL ?X%=2
 +
  =B%
 +
  DEFFNbyte(A%,X%,Y%)=((USR&FFF4)AND&FF00)DIV256
 +
 
 +
<code>PROCmem_call(address,"string")</code> will call ''address'', entering
 +
with A=0 and XY pointing to ''string''. For example,
 +
<code>PROCmem_call(&FFF7,"HELP")</code> calls OSCLI in the I/O processor.
  
    REM To read a single byte:
+
<code>result=FNmem_call(address,param1,param2)</code> will call ''address'',
    !X%=addr:A%=5:CALL&FFF1:byte=X%?4
+
entering with A=1, X=param1 and Y=param2, and will return the result in XY.
    :
+
For example, <code>result=FNmem_call(&FFE7,0,0)</code> will call OSNEWL in
    REM To write a single byte
+
the I/O processor.
    X%?4=byte:!X%=addr:A%=6:CALL&FFF1
+
 
 +
You should be careful if the called code generate an error as then USERV
 +
will not be restored to its previous value.
  
 
==Implementations==
 
==Implementations==
 +
Implemented in Acorn MOS 1.00 and later.
 +
 
All 8-bit Acorn systems read from whichever ROM is paged in. All except the
 
All 8-bit Acorn systems read from whichever ROM is paged in. All except the
 
BBC B+ read from main memory. The B+ recognises &FFFExxxx to read from the
 
BBC B+ read from main memory. The B+ recognises &FFFExxxx to read from the
shadow screen memory, otherwise it reads from main memory.
+
shadow screen memory, otherwise it reads from main memory. It is possible to
 +
write a modified Tube Host that intercepts OSWORD 5 and 6 to access extended
 +
memory, but most programs rely on adding an extra OSWORD call.
  
==See Also==
+
==See also==
 
* [[OSWORD &06]]
 
* [[OSWORD &06]]
 +
* [[OSWORD &FA]]
 +
* [[OSWORD &FF]]
 
* http://mdfs.net/Docs/Comp/BBC/Oswords
 
* http://mdfs.net/Docs/Comp/BBC/Oswords
 
* MemIO library at http://mdfs.net/blib
 
* MemIO library at http://mdfs.net/blib
  
 +
----
 
[[User:Jgharston|Jgharston]] 23:56, 30 October 2011 (UTC)
 
[[User:Jgharston|Jgharston]] 23:56, 30 October 2011 (UTC)
 
[[User:Jgharston|Jgharston]] ([[User talk:Jgharston|talk]]) 04:27, 29 March 2015 (UTC)
 
[[User:Jgharston|Jgharston]] ([[User talk:Jgharston|talk]]) 04:27, 29 March 2015 (UTC)
 +
[[User:Jgharston|Jgharston]] ([[User talk:Jgharston|talk]]) 14:01, 31 January 2016 (UTC)

Revision as of 16:39, 21 November 2021

OSWORD &05 (5): Read I/O processor memory
 On entry:
   XY!0=address to read from
 On exit:
   XY?4=the byte read

Some systems recognise screen memory at &FFFExxxx and sideways ROMs at &FFrr8000-&FFrrBFFF.

Coding

The following routines can be used to copy data to and from I/O memory regardless of the location of the calling program. It requires X%=>5-byte control block, Y%=X%DIV256.

 DEFPROCmem_rd(io%,mem%,num%)
 A%=5:REPEAT
   !X%=io%:CALL&FFF1:?mem%=X%?4
   io%=io%+1:mem%=mem%+1:num%=num%-1
 UNTILnum%<1:ENDPROC
 :
 DEFPROCmem_wr(io%,mem%,num%)
 A%=6:REPEAT
   !X%=io%:X%?4=?mem%:CALL&FFF1
   io%=io%+1:mem%=mem%+1:num%=num%-1
 UNTILnum%<1:ENDPROC
 
 REM To read a single byte:
 !X%=addr:A%=5:CALL&FFF1:byte=X%?4
 :
 REM To write a single byte
 X%?4=byte:!X%=addr:A%=6:CALL&FFF1

By copying code to the I/O processor and the I/O processor's USERV you can call an arbitary address in the I/O processor.

 DEFPROCmem_call(io%,A$):LOCAL old%
 !X%=&200:REPEAT
   A%=5:CALL&FFF1:old%=256*X%?4+old%DIV256
   A%=6:X%?4=io%:CALL&FFF1:io%=io%DIV256
   ?X%=?X%+1
 UNTIL ?X%=2
 OSCLI "LINE "+A$
 !X%=&200:REPEAT
   X%?4=old%:CALL&FFF1:old%=old%DIV256
   ?X%=?X%+1
 UNTIL ?X%=2
 =B%
 :
 DEFFNmem_call(io%,B%,C%):LOCAL old%
 !X%=&200:REPEAT
   A%=5:CALL&FFF1:old%=256*X%?4+old%DIV256
   A%=6:X%?4=io%:CALL&FFF1:io%=io%DIV256
   ?X%=?X%+1
 UNTIL ?X%=2
 B%=FNbyte(136,B%,C%)
 !X%=&200:REPEAT
   X%?4=old%:CALL&FFF1:old%=old%DIV256
   ?X%=?X%+1
 UNTIL ?X%=2
 =B%
 DEFFNbyte(A%,X%,Y%)=((USR&FFF4)AND&FF00)DIV256

PROCmem_call(address,"string") will call address, entering with A=0 and XY pointing to string. For example, PROCmem_call(&FFF7,"HELP") calls OSCLI in the I/O processor.

result=FNmem_call(address,param1,param2) will call address, entering with A=1, X=param1 and Y=param2, and will return the result in XY. For example, result=FNmem_call(&FFE7,0,0) will call OSNEWL in the I/O processor.

You should be careful if the called code generate an error as then USERV will not be restored to its previous value.

Implementations

Implemented in Acorn MOS 1.00 and later.

All 8-bit Acorn systems read from whichever ROM is paged in. All except the BBC B+ read from main memory. The B+ recognises &FFFExxxx to read from the shadow screen memory, otherwise it reads from main memory. It is possible to write a modified Tube Host that intercepts OSWORD 5 and 6 to access extended memory, but most programs rely on adding an extra OSWORD call.

See also


Jgharston 23:56, 30 October 2011 (UTC) Jgharston (talk) 04:27, 29 March 2015 (UTC) Jgharston (talk) 14:01, 31 January 2016 (UTC)