Category:83Plus:Ports:By Address:Protected
From WikiTI
Revision as of 11:35, 28 January 2006 by 130.215.239.90 (Talk)
Protected Ports
Some of the I/O ports on the 83+ have been "protected" to prevent them from being written accidentally (in addition to preventing user programs from writing to them.)
The following restrictions are believed to apply to all protected ports:
- These ports can only be written to from privileged ROM pages. The privileged ROM pages are two utility code pages and one or two boot code pages. On the normal 83+ the pages are 1Ch, 1Dh, and 1Fh. On the normal 84+ the pages are 3Ch, 3Dh, and 3Fh. On the 83+ SE the pages are 7Ch, 7Dh, and 7Fh. On the 84+ SE the pages are 6Fh, 7Ch, 7Dh, and 7Fh. (Pages 3C-3E/6C-6E on the 84+, and page 1E/3E/7E, may also qualify, but no code is currently placed on those pages.)
- A specific sequence of instructions must be executed (all of them from a privileged page, with no interruptions) before the port will finally "listen." The sequence is:
nop nop im 1 di out (...),a
- A 'di' often precedes this sequence so that it cannot be broken by an interrupt, and a 'di' often follows it, after which the output value is re-checked, to prevent user programs from sneakily inserting their own output values.
- Because the hardware only checks what bytes are read, and whether they are read from a privileged page, but not whether they are actually executed, certain variants on this sequence are also permissible; for example:
ld hl,0 im 1 di out (...),a
ld hl,(word_0000) ; where word_0000 is the address of two zero ; bytes stored on a privileged page im 1 di out (...),a
ld ix,byte_ed ; where byte_ed is the address of an ED byte ld hl,byte_f3 ; and byte_f3 is the address of an F3 byte ; both stored on a privileged page rlc b,(ix+0) ld d,(hl) out (...),a
- The last works because the opcode for RLC B,(IX+0) is DD CB 00 00, the byte read from (ix) is ED, then the opcode for LD D,(HL) is 56, and the byte read from (hl) is F3. This could be useful since it allows protected ports to be written without destroying the interrupt mode.
The canonical protected port is, of course, the Flash write-enable port, port 14. Some of the other protected ports also appear to function only when Flash is write-enabled.
Pages in category "83Plus:Ports:By Address:Protected"
The following 8 pages are in this category, out of 8 total.