home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Guide / c-cplusplus-interactive-guide.iso / c_ref / csource4 / 284_01 / stand.doc < prev    next >
Encoding:
Text File  |  1989-03-13  |  8.1 KB  |  205 lines

  1. Documentation for stand-alone program
  2.  
  3.  
  4. 1. Stand-Alone Program
  5.  
  6.     A stand-alone program is a program you can execute without
  7.     CP/M in I8080. The program performs a disk file access and
  8.     console I/O by calling the BIOS module of I8080 directly.
  9.  
  10. 2. Execution Environment
  11.  
  12.     A stand-alone program is stored in Intel hexa format under the host
  13.     operating system. This file can be created using assembler under CP/M.
  14.     However, the coding suitable for the operating system is necessary 
  15.     when the program runs under the different operating system from CP/M.
  16.  
  17.     The program starts from the address 0 instead of 100H. At the beginning
  18.     of the execution of the program, the program counter is the only
  19.     register whose content is initialized. The other registers need to be
  20.     initialized. Note that the value of the stack pointer isn't 
  21.     initialized, either.
  22.  
  23.     To terminate the execution of the program, an I8080 instruction,
  24.     HLT, should be executed. After the termination of the program,
  25.     it exits to the host operating system. The program can't be
  26.     terminated by executing RET instruction or jumping to the address 0.
  27.  
  28. 3. BIOS 
  29.  
  30.     A stand-alone program can perform input and output functions 
  31.     using the service corresponding to BIOS under CP/M. This, however,
  32.     doesn't mean that the program calls CP/M BIOS. When a stand-alone 
  33.     program is executing, CP/M BIOS doesn't exist.  The program uses
  34.     only service functionally corresponding to CP/M BIOS.
  35.  
  36.     To utilize BIOS functions, an I8080 instruction, ESC is used.
  37.     ESC instruction is two bytes and consists of two EDH. It also
  38.     has a one byte operand that represents the function number.
  39.     In total, 12 functions are defined below.
  40.  
  41.     0    System initialization
  42.     1    Program reload
  43.     2    Keyboard checking
  44.     3    Character input from keyboard
  45.     4    Character output to display
  46.     5    Character output to printer
  47.     6    Character output to aux
  48.     7    Character input from aux
  49.      12    Setup of disk I/O buffer
  50.     13    Sector input from disk
  51.     14    Sector ouput to disk
  52.     15    Printer checking
  53.  
  54.  
  55. 4. Disk Input/Output
  56.  
  57.     A stand-alone program can access to a file in the host operating 
  58.     system because of the virtual disk. In that case, please keep in
  59.     mind things discussed below.
  60.  
  61.     Files accessed from the program must exist before it starts 
  62.     executing. It is impossible to detect the end of file when either
  63.     reading or writing files. You can make a file bigger by writing 
  64.     to the file, although you cannot make it smaller.
  65.  
  66. 5. Input/Output Instructions
  67.  
  68.     A stand-alone program can perform input and output using not only BIOS
  69.     calls but input/ouput instructions of I8080. When using the I8080
  70.     instructions, the input and output operations are not performed by 
  71.     the host hardware but the simulation of the instructions.
  72.  
  73.     To use the input/output instructions, you need to create the 
  74.     appropriate simulation program for devices around LSI and record
  75.     the validity of ports used for I/O operations. After you create
  76.     the program, you need to recompile I8080 itself.
  77.  
  78.     In default, this feature is selected with an option if no available 
  79.     port exists. 
  80.  
  81.  
  82. 6. Parameter passing and returned value in BIOS call
  83.  
  84.     Some functions need parameters. The values of parameters will be stored 
  85.     in C register or BC register pair. When a function returns a value, 
  86.     the returned value will be stored in A register. However, as for the 
  87.     function 13 and 14, DE register pair will be used for parameters.
  88.  
  89.     The functions 13 and 14 uses the indirect method to get the disk 
  90.     address information. The parameter those functions receive is the 
  91.     address of a three byte long area in memory. Each byte, there, 
  92.     specifies a drive number, track number and sector number respectively. 
  93.     In DE register pair, the first address of the area will be stored 
  94.     as a parameter.
  95.  
  96.     The number from 0 to 7 is acceptable for the disk drive number. 
  97.     The disk drive number 0 corresponds to CP/M disk drive A and
  98.     so on up to the drive H. The valid track number is from 0 to 76.
  99.     However, the tracks 0 and 1 are valid only if a physical drive
  100.     is available. In the virtual disk, the number from 2 to 76 is
  101.     valid. The sector number is valid from 0 to 25.
  102.  
  103.  
  104. 7. Description of BIOS functions
  105.  
  106.     0 System initialization
  107.  
  108.     This function is called only once immediately after CP/M BIOS is loaded.
  109.     Although this function is defined for the historical reasons,
  110.     it actually does nothing. It can be ignored in the stand-alone 
  111.         program.
  112.  
  113.     1 Program reload
  114.     
  115.     This function reloads a currently executing program into memory.
  116.     It is defined for CP/M warm start. If the reload is successful,
  117.     it returns 0 in register A. If it fails, a value but 0 is returned.
  118.     When this function is used in a stand-alone program, note that the 
  119.     contents of the boot file is loaded and overwrites in memory.
  120.  
  121.     2 Keboard checking
  122.  
  123.     This function checks if the keyboard is ready to receive input
  124.     (File handle 0 in MSDOS). If it is ready, 0FFH is returned in register
  125.     A. If not, 0 is returned.
  126.  
  127.     3 One character input from keyboard
  128.     
  129.     This function inputs a character from keyboard (File handle 0 in 
  130.     MSDOS). The character is stored in register A. If there is no 
  131.     character from the keyboard, it waits until a character is available. 
  132.     No echo of the character is performed.
  133.  
  134.     4 One character ouput to display
  135.  
  136.     This function outputs a character to dispaly (File handle 1 in MSDOS).
  137.     The output character is stored in register C. If the display is not
  138.     ready, this function waits until the display is ready.
  139.  
  140.     5 One character output to printer
  141.  
  142.     This function outputs a chracter to printer (File handle 3 in MSDOS).
  143.     The output character is stored in register C. If the printer is not
  144.     ready, this function waits until the printer is ready.
  145.  
  146.     6 One character ouput to aux
  147.  
  148.     This function ouputs a character to auxiliary device (File handle 4 in
  149.     MSDOS).
  150.     The output character is stored in register C. If the device is not
  151.     ready, this function waits until the device is ready.
  152.  
  153.     7 One character input from aux
  154.  
  155.     This function inputs a character from the auxiliary device (File handle
  156.     is 4 in MSDOS). The input character is stored in register C. If a 
  157.     character is not ready, this function waits until one is available.
  158.  
  159.     12 Setup of disk I/O buffer
  160.  
  161.     This function sets up a disk I/O buffer. The buffer address is 
  162.     stored in a register pair BC.  The size of the buffer is at most 
  163.     128 byte long.
  164.     Once this function is used to allocate a buffer, all disk access is
  165.     performed through this buffer until the buffer is set up again.
  166.     A buffer isn't set up after a stand-alone program starts executing.
  167.     The result will not be guaranteed when the disk is accessed without
  168.     setting up an I/O buffer. The same is true when the buffer size exceeds
  169.     the limit.
  170.  
  171.     13 Sector input from disk
  172.  
  173.     This function inputs a sector from the virtual disk. It is called
  174.     after the address where the sector address is stored is entered
  175.     in register pair DE. The contents of the sector that is specified
  176.     with the sector address is transferred into the buffer already
  177.     set up by BIOS 12. If the transfer is successful, it returns 0 in
  178.     register A. If it fails, any value but 0 is returned.
  179.     If the specified sector address doesn't exist in the virtual disk,
  180.     the contents of the buffer will be unknown, although it will terminate
  181.     normally.
  182.  
  183.     14 Sector output to disk
  184.  
  185.     This function outputs a sector to the virtual disk. It is called
  186.     after the address where the sector address is stored is entered in
  187.     register pair DE. The contents of the buffer by already set up
  188.     with BIOS 12 is transferred into the specified sector. If the transfer
  189.     is successful, it returns 0 in register A. If an error occures,
  190.     the function returns any value but 0.
  191.     If the specified sector address doesn't exist in the virtual disk,
  192.     the contents of the buffer will be unknown although it will terminate
  193.     normally.
  194.     
  195.     15 Printer checking
  196.  
  197.     This function checks if the printer (File handle 3 in MSDOS) is ready 
  198.     to output. If the printer is ready, the function returns 0FFH in 
  199.     register A. Otherwise, it returns 0.
  200.  
  201.  
  202.  
  203.     
  204.  
  205.