Chapter VI Program-related Data Representations

VI.1  General


The program related  data is  the data to  be read  and processed  by    a 
microprocessor of the 68000 MPU family.  It is  stored in 2048 byte   Data 
blocks and should not  be mixed in the  same sector with  audio or   video 
data.  These Data blocks are stored in Mode  2, Form 1 sectors, with   the 
submode byte data bit set to one.

Different types of  data present  on a CD-I  disc are  distinguished    as 
executable object code and data to be processed by the application.

CD-RTOS does not restrict the format or contents of data to be   processed 
by an application program.  This data can be:

                    - Text
                    - Phonetic coding
                    - Binary data



VI.2  Executable Object Code


2.1  Object Code Files


Object code is always  stored in separate 'object  code' files. Such    an 
object code file is stored in Mode 2, Form 1 sectors and does not  contain 
audio or video sectors.   The submode byte of  each sector of  an   object 
code file must  have the  data bit set  to one.   In addition,  the   last 
sector of  the file  must have  the EOF  bit  set to  one.  The     coding 
information byte for object code files is undefined  and must be set    to 
zero.

The unit of a loadable program is one  named file, which may contain   one 
or several software modules.  These files may be located anywhere   within 
the CD-I  file system.   By convention,  they are  usually  placed in    a 
directory named 'CMDS'.

Software modules are usually created by the CD-RTOS  linker.  A   complete 
definition of the module format is given in Appendix VII.1 (chapter 1).

Object code files are not real-time files.  If  a data error occurs   that 
cannot be corrected by the CD-I controller hardware or device driver,  the 
affected module(s) may not be loaded or executed.




2.2  Instruction Set Summary


The 68000  MPU  family  includes  several  similar, but  not    identical, 
microprocessors.  To be compatible with all players, the object code on  a 
CD-I disc must be written for the microprocessor with features which   are 
common to  all (e.g.,  to the  68000 itself).  This  instruction set    is 
defined in the  'M68000 16/32-Bit  Microprocessor Programmer's   Reference 
Manual', published by Motorola (document number M68000UM).

One  incompatibility  exists  in  the  68000  family.   The   68000    MPU 
instruction set allows a  'move from sr' instruction  to be executed    by 
user state  programs.   Other  processors  regard  this as  a    privilege 
violation  and  provide  the   'move  from  ccr'  instruction     instead. 
Unfortunately, 'move from ccr' is not a legal 68000 instruction.

To overcome this difference, application programs may not  use the   'move 
from sr' instruction.  Instead, the 'move from ccr'  instruction must   be 
used.  This instruction  is emulated  by the CD-RTOS  kernel on    players 
which use  the 68000  (or other)  MPU. Since  emulation  is slow,  it   is 
recommended that the 'scc' instruction be used to  save the state of   the 
condition code register.

CD-RTOS provides a service  request (F$SetSys) to examine  system   global 
variables.  One  of these  variables (D_MPUTyp)  is initialized  by    the 
system to contain the MPU actually present on  a particular CD-I   player. 
Programs wishing  to  exploit extended  MPU  features may  inspect    this 
variable and use processor  specific routines to take  advantage of    the 
native instruction  set.  However, it  is  always mandatory  to    provide 
functionally equivalent  routines which  use only  the instructions    and 
addressing modes available on  a 68000 MPU.  The  application must    take 
care of  the compatibility  problems resulting  from the  difference    in 
performance when executed on the Base Case System.

The 68000 MPU user  state instruction set is  summarized in Figure   VI.1. 
The conditions  that  may be  tested  in the  'bcc',  'dbcc',  and   "scc" 
instructions in Figure VI.1 are:

     cc     carry clear               lt     less than
     cs     carry set                 hi     higher
     eq     equal                     hs     higher or same
     ge     greater or equal          ne     not equal
     gt     greater than              mi     minus
     lo     lower                     pl     plus
     le     less than or equal        vc     overflow clear
     ls     lower or same             vs     overflow set


Figure VI.1

________________________________________________________________
_      Instructions            _        Description            _
________________________________________________________________
_abcd                          _ add decimal                   _
_add, adda, addi, addq, addx   _ add binary                    _
_and, andi, andi to ccr        _ logical and                   _
_asl                           _ arithmetic shift left         _
_asr                           _ arithmetic shift right        _
_bcc                           _ conditional branch            _
_bchg                          _ bit test and change           _
_bclr                          _ bit test and clear            _
_bra                           _ unconditional branch          _
_bset                          _ bit test and set              _
_chk                           _ check register against bounds _
_clr                           _ clear to zero                 _
_cmp, cmpa, cmpi, cmpm         _ compare                       _
_dbcc, dbra                    _ test, decrement, and branch   _
_divs, divu                    _ signed and unsigned divide    _
_eor, eori, eori to ccr        _ logical exclusive or          _
_exg                           _ exchange registers            _
_ext                           _ sign extend                   _
_jmp                           _ jump                          _
_jsr                           _ jump to subroutine            _
_lea                           _ load effective address        _
_link                          _ link and allocate stack       _
_lsl                           _ logical shift left            _
_lsr                           _ logical shift right           _
_move, movea, movem, movep,    _                               _
_   moveq, move to or from ccr _ move data                     _
_muls, mulu                    _ signed or unsigned multiply   _
_nbcd                          _ negate decimal                _
_neg, negx                     _ negate binary                 _
_nop                           _ no operation                  _
_not                           _ logical complement            _
_or, ori, ori to ccr           _ logical inclusive or          _
_pea                           _ push effective address        _
_rol, roxl                     _ rotate left                   _
_ror, roxr                     _ rotate right                  _
_rts, rtr                      _ return from subroutine        _
_sbcd                          _ subtract decimal              _
_scc                           _ set according to condition    _

  ________________________________________________________________Figure 
VI.1 (cont'd)

________________________________________________________________
_sub, suba, subi, subq, subx   _ subtract binary               _
_swap                          _ swap register halves          _
_tas                           _ test and set                  _
_trap, os9, tcall              _ call system or library routine_
_trapv                         _ trap on overflow              _
_tst                           _ compare with zero             _
_unlk                          _ de allocate stack and unlink  _

________________________________________________________________2.3   
System Modules


CD-RTOS (see VII and  Appendix VII.1) has two  distinct environments    in 
which object  code  may be  executed  - user  state,  and  system   state. 
Application programs  are executed  in user  state.  File  managers    and 
device drivers are always executed in system state.

A system state  routine has  access to the  entire capabilities  of    the 
hardware.  For  example, on  memory protected  systems, a  system    state 
routine may access  any memory  in the system.   It may  alter    internal 
system data  structures,  mask interrupts,  or  take direct  control    of 
hardware interrupt vectors if necessary.  There are also a small group  of 
CD-RTOS service requests accessible only from system state.

System state is synonymous  with the 68000 MPU  family supervisor   state. 
The 68000 MPU  system state  instruction set includes  a few    privileged 
instructions that may be used in system state routines.  This  instruction 
set is outlined in Figure VI.2.


Figure VI.2

________________________________________________________________
_       Instruction        _          Description              _
________________________________________________________________
_andi to sr                _ logical and to status register    _
_eori to sr                _ exclusive or to status register   _
_move to sr, move from sr  _ move word to/from status register _
_move usp                  _ move to/from user stack pointer   _
_ori to sr                 _ inclusive or to status register   _
_reset                    _ reset external devices            _
_rte                       _ restore status register and return_
_stop1                     _ halt processor                    _
________________________________________________________________



VI.3  Data to be Processed by an Application


All program related data  that is to be  processed by an  application   is 
stored in Mode  2, Form  1 sectors on  the disc.   The data  bit in    the 
submode byte of each sector must be set to one.

Such data  may  be included  in  real-time records,  typically   at    the 
beginning of a real-time  record.  If such data  is not at  or near    the 
beginning of a real-time  record it is recommended  that they be    placed 
before the real-time record as non real-time sectors.




3.1  Character Sets


Programs that display textual  data are required to  have a font    module 
associated with the  character set  that is used.   A font  module is    a 
standard CD-RTOS data module that contains the image of each character  in 
the character set.  The format of a font  module is described further   in 
VII.2.3.2.10).




3.1.1  CD-I Standard Character Set


The CD-I standard character set conforms to the ISO 8859-1 character  set. 
The font module for this character set must  be in ROM in the Base    Case 
System.  A copy of this character set is shown in Figure VI.3.

The following characters have  special meaning when used  with this   font 
module for display via UCM.

       $08 H     Cursor Left
       $0A H     Cursor Down
       $OB H     Cursor Up
       $0C H          Cursor Right
       $0D H          Carriage Return
       $1E H          Cursor Home





Figure VI.3






3.1.2  Other Character Sets


A coded character  set can  be any character  set identified  in the   ISO 
International Register of Coded  Character Sets to be  Used with    escape 
sequences or  shifted  JIS Kanji.   To  display characters  for  a   coded 
character set, the font  module must reside in  memory before   displaying 
the characters.  A  font module  can be stored  in ROM  or on  the   disc. 
Because a font module  (i.e. other than for  the standard character   set) 
may not be in  ROM on all systems,  any font module  other than for    ISO 
8859-1 must reside on each disc where the  font is used.  Functions    are 
supplied in UCM for loading and accessing font modules.

When textual information that is used by CD-RTOS is stored in files,   the 
text can be encoded in any coded character set.  If a character set  other 
than ISO 8859-1 is used, the corresponding font module must be   installed 
before any system function that uses the font  module is executed.    Font 
modules can also be used for representing images other than characters.


It should be noted that it is the  responsibility of the application    to 
ensure that  characters  are both  visible  and legible  on  the   display 
screen. As for the  number of characters (e.g.  40 or 80)  which can    be 
displayed accross the Safety Area of the screen, the application needs  to 
access and use the  information contained in the  System's   Configuration 
Status Descriptor (CSD, see A VII.2.4) in order to assure legibility.3.2   
Phonetic Coding


Text that represents phonetic coding to be used  for speech may be   coded 
on the disc using the ISO 8859-1 character set.  This text is read by   an 
application program which converts it into 8-bit PCM  data (i.e.,   filter 
gain values K0 and K1 equal to zero).  This data is then output via   CDFM 
functions described  in  VII.2.2.4.   The  format  of the  PCM  data    is 
described in Chapter IV.




3.3  Binary Data


Binary data is  data that  is to be  decoded by  an application   program. 
CD-RTOS places no restrictions on the format or content of binary data.





VI.4  Subheader Values


4.1.  General



In General, the subheader values for all data  sectors discussed in   this 
chapter are:

            File number:% xxxxxxxx
            Channel number:% 000xxxxx
       Submode:       % x00x100x
       

e.g.,       executable object code is non-real time, Mode 2, Form 1  with 
      the  data bit set and audio/video bits having the value zero.


4.2.  Coding Information Byte


The data or program  related data Coding Information  byte is defined   as 
follows:
  
       ____________________________________________
       _                 Reserved                 _
       ____________________________________________
bit       7                                      0

      

      
       
       

