Difference between revisions of "OSWORD &06"
m (→See Also) |
(has same bug as OSBYTE &97) |
||
Line 68: | Line 68: | ||
write a modified Tube Host that intercepts OSWORD 5 and 6 to access extended | 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. | memory, but most programs rely on adding an extra OSWORD call. | ||
+ | |||
+ | ;Warning | ||
+ | |||
+ | Acorn MOS 1.20 writes the byte using a STA (zp),Y instruction. As it is an indexed-addressing instruction, the 6502 CPU always<!-- ref name="65xxprog">MOS Technology, Inc. (January 1976), [http://6502.org/documents/books/mcs6500_family_programming_manual.pdf MCS6500 Microcomputer Family Programming Manual], appendix B, p.B-26 (PDF p.228)</ref --><ref name="65xxhw">MOS Technology, Inc. (January 1976), [http://6502.org/documents/books/mcs6500_family_hardware_manual.pdf MCS6500 Microcomputer Family Hardware Manual], appendix A, section A.3.6, p.A-7 (PDF p.174)</ref><ref name="64doc">Jarkko Sonninen ''et al.'' (1994), [http://rk.nvg.ntnu.no/bbc/doc/6502.txt 64doc]</ref> performs a dummy read immediately before the write. This is harmless to RAM and ROM. If addressing memory-mapped I/O then be aware that some hardware, though not all, may operate inappropriately due to the dummy read: outputs could momentarily be set to the wrong level, or an interrupt condition could be cleared and lost. Review the datasheet for the hardware being accessed to see whether it will be adversely affected. | ||
==See Also== | ==See Also== |
Revision as of 16:55, 12 August 2021
OSWORD &06 (6) - Write I/O processor memory (Acorn MOS 1.00 and later)
On entry: XY!0=address to write to XY?4=byte to be written.
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. These routines can be used if you know your program has complete control of USERV and does not have to restore it, or restores it elsewhere.
DEFPROCio_call(io%,A$) !X%=&200:A%=6:REPEAT X%?4=io%:CALL&FFF1 io%=io%DIV256:?X%=?X%+1 UNTIL ?X%=2 OSCLI "LINE "+A$ ENDPROC : DEFFNio_call(io%,B%,C%) !X%=&200:A%=6:REPEAT X%?4=io%:CALL&FFF1 io%=io%DIV256:?X%=?X%+1 UNTIL ?X%=2 =FNbyte(136,B%,C%) DEFFNbyte(A%,X%,Y%)=((USR&FFF4)AND&FF00)DIV256
PROCio_call(address,"string")
will call address, entering
with A=0 and XY pointing to string. For example,
PROCio_call(&FFF7,"HELP")
calls OSCLI in the I/O processor.
result=FNio_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=FNio_call(&FFE7,0,0)
will call OSNEWL in
the I/O processor.
Implementations
All 8-bit Acorn systems write to whichever ROM/RAM is paged in. All except the BBC B+ write to main memory. The B+ recognises &FFFExxxx to write to the shadow screen memory, otherwise it writes to 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.
- Warning
Acorn MOS 1.20 writes the byte using a STA (zp),Y instruction. As it is an indexed-addressing instruction, the 6502 CPU always[1][2] performs a dummy read immediately before the write. This is harmless to RAM and ROM. If addressing memory-mapped I/O then be aware that some hardware, though not all, may operate inappropriately due to the dummy read: outputs could momentarily be set to the wrong level, or an interrupt condition could be cleared and lost. Review the datasheet for the hardware being accessed to see whether it will be adversely affected.
See Also
- OSWORD &05
- OSWORD &FA
- OSWORD &FF
- http://mdfs.net/Docs/Comp/BBC/Oswords
- MemIO library at http://mdfs.net/blib
Jgharston 23:54, 30 October 2011 (UTC) Jgharston (talk) 04:28, 29 March 2015 (UTC)
Jgharston (talk) 14:02, 31 January 2016 (UTC)- ↑ MOS Technology, Inc. (January 1976), MCS6500 Microcomputer Family Hardware Manual, appendix A, section A.3.6, p.A-7 (PDF p.174)
- ↑ Jarkko Sonninen et al. (1994), 64doc