Difference between revisions of "83Plus:Ports:21"

From WikiTI
Jump to: navigation, search
(details of RAM protection)
Line 1: Line 1:
[[Category:83Plus:Ports:By_Address:Protected|21 - Hardware Type]] [[Category:83Plus:Ports:By_Address|21 - Hardware Type]] [[Category:83Plus:Ports:By_Name|Hardware Type]]
+
[[Category:83Plus:Ports:By_Address:Protected|21 - Hardware Type / RAM Protection]] [[Category:83Plus:Ports:By_Address|21 - Hardware Type / RAM Protection]] [[Category:83Plus:Ports:By_Name|Hardware Type / RAM Protection]]
 
{{SE-Only Port|01}}
 
{{SE-Only Port|01}}
 
{{Protected Port}}
 
{{Protected Port}}
Line 6: Line 6:
 
'''Port Number:''' 21h
 
'''Port Number:''' 21h
  
'''Function:''' Hardware Type
+
'''Function:''' Hardware Type / RAM Protection
  
This port is simply a protected register which is set by the boot code according to the hardware version.
+
This port is used as a flag to identify the hardware type (TI-84+ basic versus SE), as well as controlling the RAM execution protection.
  
 
=== Read Values ===
 
=== Read Values ===
 
* Bit 0: 1 on either the 83+ SE or the 84+ SE, 0 on the 84+ basic.
 
* Bit 0: 1 on either the 83+ SE or the 84+ SE, 0 on the 84+ basic.
 
* Bit 1: ''Unknown -- always set to zero''
 
* Bit 1: ''Unknown -- always set to zero''
* Bits 2-7 do not seem to do anything.
+
* Bits 4-5: current RAM protection mode (see below)
  
 
=== Write Values ===
 
=== Write Values ===
* [00h - FFh]: New value for the register
+
* Bits 0, 1, 4, 5: set new values for these bits.
 +
* Bits 2, 3, 6, 7: ignored
  
 
== Comments ==
 
== Comments ==
 
This port does not exist on the standard 83+.  See [[83Plus:Ports:02|port 2]].
 
This port does not exist on the standard 83+.  See [[83Plus:Ports:02|port 2]].
  
There is no reason to write to this port, but by reading from it you can determine something about the HW version.
+
The value of this port is initialized by the boot code to either 01 (TI-83+ SE, TI-84+ SE) or 00 (TI-84+ basic.)  Bit 0 can thus be used to determine the hardware type (in fact, the OS checks both bits 0 and 1, by ANDing the value with 3; it may be a good idea for user programs to do the same.)
  
TIOS polls both bits 0 and 1, by taking the logical AND with 3.
+
=== RAM protection modes ===
 +
There are four possible RAM protection modes, which have differing effects in terms of which RAM pages are permitted to contain executable code.  Note that bits 4-6 of the page number are ignored for purposes of determining executability (e.g., page 92h is equivalent to page 82h.)
 +
 
 +
* '''Mode 0''' (the default): Execution is allowed on pages 81h, 83h, 85h, 87h, 89h, 8Bh, 8Dh, and 8Fh.
 +
* '''Mode 1''': Execution is allowed on pages 81h, 82h, 85h, 86h, 89h, 8Ah, 8Dh, and 8Eh.
 +
* '''Mode 2''': Execution is allowed on pages 81h, 82h, 89h, and 8Ah.
 +
* '''Mode 3''': Execution is allowed on pages 81h and 82h only.
 +
 
 +
(If you ever attempt to execute code from a "disallowed" page, the calculator resets.)
  
 
== Example ==
 
== Example ==

Revision as of 18:45, 30 September 2009

This port only exists as a distinct port on the TI-83 Plus Silver Edition, the TI-84 Plus, and the TI-84 Plus Silver Edition. On the standard TI-83 Plus, it acts as a shadow of port 01.
This port is protected, which means user programs cannot ordinarily write to it directly.

Synopsis

Port Number: 21h

Function: Hardware Type / RAM Protection

This port is used as a flag to identify the hardware type (TI-84+ basic versus SE), as well as controlling the RAM execution protection.

Read Values

  • Bit 0: 1 on either the 83+ SE or the 84+ SE, 0 on the 84+ basic.
  • Bit 1: Unknown -- always set to zero
  • Bits 4-5: current RAM protection mode (see below)

Write Values

  • Bits 0, 1, 4, 5: set new values for these bits.
  • Bits 2, 3, 6, 7: ignored

Comments

This port does not exist on the standard 83+. See port 2.

The value of this port is initialized by the boot code to either 01 (TI-83+ SE, TI-84+ SE) or 00 (TI-84+ basic.) Bit 0 can thus be used to determine the hardware type (in fact, the OS checks both bits 0 and 1, by ANDing the value with 3; it may be a good idea for user programs to do the same.)

RAM protection modes

There are four possible RAM protection modes, which have differing effects in terms of which RAM pages are permitted to contain executable code. Note that bits 4-6 of the page number are ignored for purposes of determining executability (e.g., page 92h is equivalent to page 82h.)

  • Mode 0 (the default): Execution is allowed on pages 81h, 83h, 85h, 87h, 89h, 8Bh, 8Dh, and 8Fh.
  • Mode 1: Execution is allowed on pages 81h, 82h, 85h, 86h, 89h, 8Ah, 8Dh, and 8Eh.
  • Mode 2: Execution is allowed on pages 81h, 82h, 89h, and 8Ah.
  • Mode 3: Execution is allowed on pages 81h and 82h only.

(If you ever attempt to execute code from a "disallowed" page, the calculator resets.)

Example

	in a,(2)
	ld b,a
	and 80h
	jr z,TI83p_BE
	in a,(21h)
	and 3
	jr z,TI84p_BE
	bit 5,b
	jr z,TI83p_SE
	; calculator is an 84+ SE

TI84p_BE:
	; calculator is an 84+ BE

TI83p_SE:
	; calculator is an 83+ SE

TI83p_BE:
	; calculator is an 83+ BE