To DSP3MV de YT3MV 03.12.90 13:57 LOC 57345 Bytes novi manual73 *** YT3MV - DSP OPERATING SYSTEM MANUAL - V7.3 *** ================================================== 1. INTRODUCTION --------------- The YT3MV DSP operating system is intended to be used with the corresponding DSP computer including a MC68010 16 bit microprocessor, usually 1Mbyte of static nonvolatile CMOS RAM and peripheral devices including parallel and serial I/O ports, analog I/O ports (A/D and D/A converters), a floppy disk controller/driver and a real time clock. Since almost all of the available RAM is nonvolatile, the operation of the computer is no longer based on mechanical storage devices, like floppy or hard disks or tape drives. The operating system uses the nonvolatile RAM at the same time as a long term volume storage device (hard disk) and as the CPU working memory. Floppy disks are only used as a memory backup in the case of a system crash and/or to ease the transfer of programs and data. The nonvolatile RAM is organized as a directory of files. All the RAM files are stored in contiguous memory locations: program files can be executed in the same memory locations where are stored. This is a much simplier and better solution than the popular "RAM disks", which retain the same data organization as floppy disks with files split in a number of equal size blocks, requiring an additional RAM area and precious CPU time to assemble program files into executable programs. Most operating system commands only work with RAM files. A limited number of commands is provided to support the operation with floppy disks, since the latter are not used frequently. Operations with files on floppy disks are not just more slow and complex, they are also very time consuming for the CPU. In a computer devoted to Digital Signal Processing, the CPU is loaded with the very time demanding DSP routines almost to the theoretical speed limit of its processing power. Operation with disks or other mechanical storage devices at the same time would severely degrade the DSP computer performance. Routines to use the serial RS-232 port and the real time clock chip are also provided. Files can be received and/or transmitted through the RS-232 port using different speeds and data formats. The operating system includes a screen text editor program and a high-level language compiler. The screen text editor can be used to edit ASCII text files and in particular to prepare source programs for the high-level language compiler. The compiler program generates a machine code program for the MC68010 microprocessor from the source ASCII file. The high-level language allows single and indexed variables, floating-point arithmetics including transcendent functions, input/output routines and a simple and efficient way to insert and communicate with machine code routines. The latter is particularly important for DSP since the basic DSP routines have to be written directly in machine code since they must be very fast. On the other hand, the various support routines require complex mathematical operations that are easier to perform in high-level language. 2. OPERATING SYSTEM COMMANDS ---------------------------- All the operating system commands include a single letter command that may be followed by one or more filenames or parameters. Typing errors can be corrected using the key (code 7FH form keyboard) and the command is executed after depressing the key (code 0DH from the keyboard). A filename is made of up to 12 characters followed by an up to three characters long extension. When more than one filename is required by a certain command, the required filenames are separated using space characters. Complete filenames have to be typed: wildcards (*) are not allowed. Some commands are however able to find the right extension on their own. Some commands do not always require that one or more filenames are supplied, filenames typed with the previous commands are used in the case no filename is specified. Of course, dangerous commands like kill (K) or format (F) always require the exact number of filenames or parameters to follow. The operating system includes two directories of files: a RAM file directory (command M) and a floppy disk file directory (command D). The RAM fileddirectory may include more than one file with the same name and all the commands act on the first file with the specified name encountered in the directory. To access the other files rename (command J) or kill (command K) the first file carrying the same name. Two or more files with the same name are not allowed on a floppy disk. Files can not be killed or renamed on a floppy disk, the only way is to erase the complete disk by formatting it. The operating system provides three different error messages: ? means an operator error, usually an inexistent or duplicated file name. * means a floppy disk error. In the case of a disk read operation, the file loaded from the disk into the RAM should be discarded (killed) since it contains errors. In the case of a disk write operation, the disk should be formatted. A program crash, either due to a programming error or a hardware breakdown usually causes a bus error or an address error (or another unused exception vector). A call to the monitor program is generated and an error message is printed in the form: PC: F: S: A: The last two items are included only in the case of a long stack format (bus error and address error). The execution of a program or operating system command can be interrupted or aborted by pressing (code 03H from the keyboard, which calls the operating system immediately. The computer can now be commanded using the operating system commands: use command A to reset the computer, command Q to resume the execution or other commands to diagnose the problem. Implemented V7.3 commands include: A Abort - Software RESET Command Resets the computer in the same way as the reset pushbutton or at power-up. The actual action depends on the position of the partial/total reset switch. B Enter Autostart Command After the ":" symbol, the autostart command can be typed in as any other operating system command. The autostart command is executed immediately after each computer reset, its syntax being identical to the operating system commands originated from the keyboard. Any valid operating system command can be executed after a partial computer reset as the autostart command. After a total computer reset, the autostart command is first set to its default (the H (help) command) and then executed. C Copy RAM Files Copies the specified source files into a destination file. Up to 7 (source) files can be pasted together and the resulting file receives the last specified filename (destination). D Floppy Disk File Directory Prints the floppy disk file directory in the following format: up to 12 characters up to 3 characters between 0 and 79, two decimal digits 0 or 1, one digit between 1 and 5, one decimal digit up to 5 hexadecimal digits E Screen Text Editor - 63 Column Version Calls the screen text editor program, which has a number of its own commands described later. If no file with the specified name can be found in the memory file directory, a new, empty file is created. If there already exists a file in the memory file directory with the specified name, a copy is generated and the original file is renamed: its extension is modified to .BAK. If the specified filename carries the extension .EXE, the editor automatically looks for a file with the same name but with the extension .SRC. All the editor commands are control characters. The exit command is or (code 0CH from the keyboard). The E command automatically sets the screen display routine in the 64 column mode, thus text with line lengths up to 63 characters can be edited. See also the Y command for editing text with lines up to 84 characters long. F Format / Verify Floppy Disk Formats the floppy disk from the specified start-track up to and including the specified end-track. One track includes 5 sectors on each side of the floppy disk. Each sector is 1024 bytes long. A fully formatted 80 track floppy disk thus includes 800 sectors or 800 kbytes. The usual formatting command is: F 0 79 The formatting routine prints out the number of the track actually being formatted. Defective tracks, if any, are marked with the symbol "*". Floppy disks containing defective tracks should be discarded immediately, since the operating system does not allow bad sectors. In the latter case it is recommended to try the formatting once again, reinserting the floppy in the drive. Most errors with 3.5" floppy disks were found to be caused by an incorrect mechanical insertion rather than a defective floppy disk. If the floppy disk is write protected, the command will only perform a verification of the formatting. G Compile .SRC >>--->> .EXE / .OLD Compiles a source file in high-level language (extension .SRC) into an executable machine code program file (extension .EXE). Both the .SRC and .EXE files share the same name (first 12 characters) and the command looks automatically for the correct extensions. If a file with the specified name and extension .EXE already exists, a copy is made first and the original is renamed to .OLD. The source file is then compiled in the same memory locations that carried the copy of the original .EXE file. In this way the numerical values of the variables in the old .EXE file are transferred to the new .EXE file if the latter uses the same variables. An error in the source program is indicated with a "?" followed by the offset (in hexadecimal) in the .SRC file where the error was found. WARNING! Do not try to run the resulting .EXE file, if an error was found by the compiler! H HELP Prints out a short help file including a list of all the operating system commands. The display routine is reset to obtain bright characters on a dark background. I Input File From RS-232 Port To RAM Data received by the serial RS-232 port according to the format specified with the command P is assembled into a RAM file. The length of the recorded file is displayed in hexadecimal format. The recording can be stopped by pressing any key on the keyboard. The RS-232 signals are used in the following way: TXD not used (remains negated). RTS remains negated. DTR becomes asserted when the command is started and is negated when the command is stopped. RXD accepts the serial data. DSR is used as a carrier detect: must be asserted to accept data. CTS is ignored. K Kill RAM File Kills a RAM file. All the files located above the deleted file are shifted down in the memory, to create a contiguous empty space at the top of the RAM. WARNING! The computer should not be reset during the execution of the kill command, otherwise the files located above the deleted file may be damaged! L Load From Floppy Disk To RAM Loads the specified file from the floppy disk to the RAM. The operating system will answer with a "?" if no such file can be found on the floppy disk or if a file with the same name already exsists in the RAM. WARNING! If the operating system answers with a "*" (indicating a floppy disk error) or the computer is reset during the execution of the command, a corrupted file may still appear in the RAM file directory with no additional warning messages! M RAM File Directory Prints the RAM file directory in the following format: up to 12 characters up to 3 characters usually 6 hexadecimal digits up to 6 hexadecimal digits At the end of the file directory, the number of the remaining free RAM space bytes is displayed (hexadecimal). N New Memory Space Tells the computer where and how much RAM is available. After a total reset, the start address is set to 39600H and the length to 6A00H corresponding to a small amount of free RAM on the CPU board, which is always present in the system, regardless of its configuration. The start address and length have to be set according to the available memory at system start-up. A N command without (or followed by an incorrect number of) parameters will only display the current parameters. O Output File From RAM To RS-232 Port Transmit a RAM file through the serial RS-232 port according to the format specified with the P command. The length of the remaining part of the file to be transmitted is displayed in hexadecimal format. The RS-232 signals are used in the following way: TXD supplies the serial data. RTS becomes asserted at the beginning of the transmission and is negated after the execution of the command. DTR remains negated. RXD is not used (is ignored). DSR is ignored. CTS is used to temporarily stop the transmission when negated, the transmission resumes when CTS again becomes asserted. P Parameters RS-232 Port Sets and displays the parameters of the RS-232 port to be used with commands I and O. is in bits per second (bauds) and the value entered is rounded to the nearest available bit rate. All standard data rates between 50 and 19200 bps can be selected. is the number of data bits, between 5 and 8. 0 or 2 mean no parity bit, 1 means odd parity and 3 means even parity. If less than three parameters are supplied, only the first parameter(s) will be modified. A P without any parameters will just display the current port parameters. After a total reset, the parameters of the RS-232 port are set to the default values: 9600 bps, 8 bits, no parity. Q Quit Quits the operating system if called from another program or using . If the operating system was not called from another programor using , then the command Q resets the computer exactly like the command A. R Run .EXE Runs the specified program file. The extension is set to .EXE automatically. To return to the operating system, the program file should include a RTS instruction at the end. The latter condition is fulfilled automatically if the .EXE file is generated by the high-level language compiler (command G). Program files usually include some memory space to store the values of the variables. Since the latter are modified during the execution of the program, the whole program file will be modified as well! Therefore, two previously identical .EXE files will no longer compare if they were executed with different data. S Save From RAM To Floppy Disk Saves the specified file from the RAM to the floppy disk. The operating system will answer with a "?" if no such file can be found in the RAM or if a file with the same name already exsists on the floppy disk. WARNING! If the operating system answers with a "*" (indicating a floppy disk error) or the computer is reset during the execution of the command, a corrupted file may still appear in the floppy disk file directory with no additional warning messages! T Type ASCII File Types the specified file on the screen as ASCII characters. Some control characters are interpreted by the display routine and in particular sequences may modify the display parameters. Use the command H (help) to reset the display routine. U Set / Read Real Time Clock Sets the real time clock chip to the specified date and time. The string should contain exactly 12 figures with no spaces or other characters between the numbers. If no date and time is specified, the command U will just print out the actual date and time supplied from the real time clock chip. V Verify - Compare Two RAM Files Compares two RAM files. First, the difference in length in bytes (hexadecimal) is printed out. After that all the differing bytes are printed out in the following way: :^ up to the end of the shorter file, the excess bytes at the end of the longer file are ignored. W
Write / Read Memory Location Writes the given 16 bit data word to the specified memory location. If no data is supplied it just performs a read from the specified address. This command provides a direct access to the hardware and is used essentially to debug the hardware and/or for system initialisation (start-up). WARNING! The W command may corrupt files or crash the operating system if used incorrectly! X Execute .CMD File Executes the specified operating system command file. The extension is set automatically to .CMD. An operating system command file is an ASCII file that includes one or more operating system commands identical to the commands typed directly to the operating system. Each command is executed after a encountered in the command file. An operating system command file can be assembled using the screen text editor (commands E or Y) like any other ASCII file. WARNING! It is not recommended to use commands B, K, N and Q in command files! Y Screen Text Editor - 84 Column Version Calls the screen text editor program in the same way as command E. A more detailed description of the editor commands follows later. The Y commands sets the screen display routine to 85 columns allowing the editing of ASCII files with up to 84 characters per line, including the 80 character per line computer standard. Otherwise, the Y editor works exactly as the E editor. 3. SYSTEM START-UP ------------------ When powering-up the computer for the first time, a total computer reset has to be performed and some operating system parameters have to be adjusted. The same procedure is also recommended after a program crash that might have damaged the content of some memory locations before the computer stopped. The hardware can be reset in four different ways: - Applying the supply voltage. - Pressing the RESET pushbutton. - Using the operating system command A (Abort). - A software jump or call to the location 000100H. The action taken by the computer after a reset is applied is identical in all four cases, it only depends on the position of the TOTAL/PARTIAL RESET switch. If the latter is open, a total computer reset will be performed. If it is closed, only a partial computer reset will be performed. During a total computer reset, the complete operating system software is copied from the EPROM to the nonvolatile system RAM, all the operating system parameters are set to their default values, all the peripheral devices are reset, the modified character generator table is generated. All the memory which is not used by the operating system is however left unchanged! After a total computer reset the HELP message should appear on the video screen, since the default autostart command is command H. The TOTAL/PARTIAL RESET switch has to be closed (enabling a partial reset) and the available RAM space has to be specified using the command N. If there is one megabyte of RAM available starting at address 200000H, the command is: N 200000 100000 To clear the content of the RAM, if any RAM files are displayed by the command M, it is sufficient to clear the first RAM location using the command W, in the above case: W 200000 0 Further initialisation commands may include commands B, P and U to set respectively the autostart command, the serial port parameters and the real time clock but they are not essential like the N command. When the nonvolatile RAM contains useful data, like the operating system software with updated parameters and application program and data files, it is reasonable to perform a partial computer reset at power-up. During a partial computer reset, only the exception vector table is copied from the EPROM to the nonvolatile RAM, all the peripheral devices are reset, the video screen is cleared and the autostart command is executed. After a partial reset, the computer is immediately ready for use, including the application program and data files in the nonvolatile RAM which operates almost like a "hard-disk"! 4. HARDWARE CONFIGURATION ------------------------- The hardware required to run the DSP operating system includes: (A) CPU board with the MC68010 microprocessor, operating system EPROM, 64 kbytes of nonvolatile CMOS RAM, keyboard interface and real time clock. (B) Video board with 128 kbytes of dual port video RAM. (C) One or more 256 kbytes CMOS memory boards. (D) Analog I/O and RS-232 board. (E) Serial I/O and floppy interface board, including a 3.5" floppy drive. (F) Bus board and power supply. The operating system can run with just the memory on the CPU board (A), the latter is however far too small to load most application programs and additional memory boards (C) have to be added. The analog I/O and RS-232 board (D) is only used by the operating system with instructions I, O and P, however all the DSP application programs need the analog I/O. Similarly, the serial I/O and floppy interface board is only required with instructions D, F, L and S. The CPU board (A) includes a timeout logic that generates a bus error if no memory or peripheral device terminates a bus cycle within 192 CPU clock cycles. Missing or defective peripheral devices can thus be detected, as well as inexsistent memory locations. The MC68010 CPU allows a 16 Mbyte address range. The first megabyte is reserved for the operating system memory, video memory and peripheral devices and the remaining 15 megabytes can be used for general purpose memory. The first (system) megabyte is allocated as follows: 000000H to EPROM containing the operating system software 007FFFH 010001H 71055 port A - parallel keyboard input 010003H 71055 port B - spare parallel output 010005H 71055 port C - keyboard strobe & RTC chip control 010007H 71055 command register 020001H Analog I/O 71051 data register 020003H Analog I/O 71051 control register 024001H 71054 CTR0 A/D sampling rate 024003H 71054 CTR1 RS-232 baud rate 024005H 71054 CTR2 D/A sampling rate 024007H 71054 control register 028001H RS-232 71051 data register 028003H RS-232 71051 control register 030000H to 64 kbytes nonvolatile system RAM 03FFFFH 040000H to 128 kbytes dual port video RAM 05FFFFH 080001H 8530 B command 080003H 8530 B data 080005H 8530 A command 080007H 8530 A data 084001H LS273 latch 088001H 2797 control register 088003H 2797 track register 088005H 2797 sector register 088007H 2797 data register Care should be taken if other peripheral devices are to be added, since the above addresses are not fully decoded. In addition, the locations immediately below 030000H should be left unused to allow a safe end in the case of a program crash making the stack to grow indefinitely: the resulting double bus error will stop the CPU and prevent it from destroying all the memory content. Function code 7 is decoded and hardwired to VPA\ to generate interrupt autovectors, the remaining function codes are not further decoded. The interrupts are assigned as follows: INT1 RTC 4990 TP INT2 RS-232 71051 TX ready INT3 RS-232 71051 RX ready (FDC 2797 INT) INT4 FDC 2797 DRQ INT5 D/A 71051 TX ready (8530 INT) INT6 A/D 71051 RX ready INT7 KBD 71055 INTA The computer hardware includes a nonvolatile memory supply and protection circuit that preserves the content of the nonvolatile RAM regardless of the power-up and/or power-down sequences. The protection circuit applies the reset signal to the microprocessor and inhibits the access to the nonvolatile RAM chips and real time clock chip immediately after the supply voltage at the input of the 5V switching voltage regulator falls below the minimum value of 6.5V. The reset and inhibit signals are only removed about one second after the regulator input voltage has rised above 7V. 5. OS V7.3 ROM ROUTINES ----------------------- The DSP operating system V7.3 consists of 16 kbytes of MC68010 machine code stored in a 27128 or a 27C256 EPROM. After a total computer reset the operating system software is copied from the EPROM into the nonvolatile system RAM. The operating system is always executed in the RAM since the access time of the RAM is much shorter than that of the EPROM. The organisation of the software contained in the EPROM is follows: 000000H to Initial exception vector table 0000FFH 000100H to Start-up routine 0001FFH 000200H to Programs and data to be copied into the system RAM 003FFFH between locaations 035800H and 0395FFH The nonvolatile system RAM is organized as follows: 030000H to System stack (16 kbytes) 033FFFH 034000H to Modified character generator table 0357FFH 035800H to ASCII character generator table 035AFFH 035B00H to Keyboard and video routines (TRAP0, TRAP1, TRAP2, 035DFFH TRAP5, TRAP10 and INT7) 035E00H to Exception vector table (64 vectors) 035EFFH 035F00H to Operating system program 0395FFH 039600H to Spare RAM area (6A00H bytes free) 03FFFFH The following general purpose routines can be accessed through TRAP instructions: TRAP0 Prints the content of D0.B as an ASCII character on the screen. The screen format is 32 lines of either 64 or 85 characters each. In the 64 column mode, the character font is 7x7 pixels while in the 85 column mode it is 5x7 pixels. The routine performs automatic line feeds if the number of characters exceeds 64 or 85 and automatically scrolls the screen up as well. The following control characters are implemented: (08H) Moves the cursor one character position back. (09H) Moves the cursor one character position forward and performs a line feed and/or scroll if necessary. (0AH) Moves the cursor one line down performs a scroll if necessary. (0BH) Moves the cursor one line up. (0CH) Clears the screen. (0DH) Moves the cursor at the beginning of the line. (1BH) + two characters Sets the display parameters with the following two characters. The first determines the brightness of the background (modulo 32) and the second the brightness of the characters (also modulo 32). Further, bit 5 of the first character selects either 64 column mode (0) or 85 column mode (1). The switching between display modes can be performed at any time: it is not necessary to start a new line or clear the screen. Any other control characters and codes above 126 (7EH) print the cursor symbol. TRAP1 Supplies in A0 the start address of the screen display routine parameter table: cursor position (2 words) & display mode (3 words). TRAP2 Keyboard entry routine. Displays a blinking cursor. Any character typed on the keyboard causes an exit and is available in D0 but it is NOT printed on the screen. TRAP3 Not used. TRAP4 Calls the operating system program. TRAP5 Keyboard interrogation routine. Supplies in D0 the last typed caracter and the number of times any key was depressed from the last call of TRAP5. TRAP6 Prints the content of D0.L in hexadecimal format on the screen. TRAP7 Sets A0 to the beginning of a parameter table including the RAM start address, the RAM length and the autostart command string. TRAP8 Executes an operating system command string supplied as -(A6). TRAP9 Searches a file in the RAM with the name supplied as (A0)+. The start address of the file is made available in A1 and the file length in D0. If the file is not found, D0 is set to FFFFFFFFH and A1 points to the first free RAM location. If no free RAM is available A1 is set to 0. TRAP10 Supplies in A5 the reference address of the floating- -point arithmetics routines. TRAP11, 12, 13 and 14 Not used. The operating system commands work with files. Any file includes a header of 20 (14H) bytes followed by an even number of data bytes. The file start address and file length are always referred to the data bytes WITHOUT the header. The 20 header bytes are assigned as follows: 1 byte File start flag AAH 12 bytes File name 3 bytes File name extension 4 bytes File length In the nonvolatile RAM the header of the first file in the RAM directory starts on the first available RAM location. The header of the next file starts immediately after the last data byte of the first file. After the last file there is an empty space usually filled with zero bytes. There are no empty spaces between RAM files. After a K (Kill) command, the files above the killed file are shifted down and the resulting empty space at the top of the RAM is filled with zeros. Files are arranged in a similar way on the floppy disk. The first file starts on sector 1, side 0 and track 0. When wirting a long file on the floppy disk, the sector number is incremented first. When the track is full, the floppy drive heads are switched to the other side. When both sides are full the heads are moved to the next track. There are no empty sectors between files, however, each file uses an integer number of sectors. The last sector may include filler bytes so that the next file starts exactly on the beginning of the next available sector. 6. THE SCREEN EDITOR -------------------- The screen editor can be entered with the E or Y command to edit a text file made of ASCII characters. The original file, if any, will be renamed .BAK. The two versions of the screen editor differ only in the maximum number of printable characters allowed in a line, but are otherwise identical. The E comand will set the screen to 64 columns and will allow lines up to 63 characters long (to prevent the automatic line-feed and allow to display the cursor at the end of the line). The Y command will set the screen to 85 columns and correspondingly allow 84 characters in a line. If the file does not correspond to a text file: if it does not contain a + combination at least every 63 (E) or 84 (Y) printable characters (the maximum allowed number of characters in a line), then the file will be truncated just in front of the detected error. Stand-alone characters are not allowed and cause a truncation of the file. The file may however contain other control characters which are printed as inverse characters (dark characters on a bright background). All the screen editor commands are ASCII control characters. Valid commands are: ^@ (00H) delete line. ^A (01H) scroll the display window one line up. ^B (02H) scroll the display window one line down. ^C (03H) call the monitor program immediately, exit after return with Q. ^D (04H) scroll the display window 8 lines (1/4 page) up. ^E (05H) scroll the display window 8 lines (1/4 page) down. ^F (06H) scroll the display window 1 page (32 lines) up. ^G (07H) scroll the display window 1 page (32 lines) down. ^H or (08H) cursor one character left (backward). ^I or (09H) cursor one character right (forward). ^J or (0AH) cursor one line down. ^K or (0BH) cursor one line up. ^L or (0CH) exit from the screen editor. ^M or (0DH) insert a new line. ^N (0EH) change an upper-case character into lower-case or a lower-case character into upper-case. ^O (0FH) allows the insertion of control characters: the next printable character typed will be transformed into a control character. (7FH) delete the character left of the cursor. All the other ASCII control characters (10H to 1FH) cause an exit. All printable characters (20H to 7EH) will be simply inserted in the text. Characters that disappear at the right margin are lost when the cursor is moved to another line or the screen window is moved along the text. The screen text editor updates the file in the nonvolatile RAM each time the cursor is moved to another line or the screen window is moved along the text. Therefore, in the case of an unexpected power failure or another source of a reset of the computer, only the last line typed may be lost, all the remaining text is saved in the nonvolatile RAM! When typing a long text it is therefore not necessary to periodically exit from the text editor to save the file like on computers that use dynamic memories and hard discs to avoid losing several hours of typing due to a power surge! When the editor is called for the first time, both the cursor and the display window will be positioned at the beginning of the text. However, when the editor is recalled, it will try to remember the position of the cursor and display window as they were set last time. The two editors E and Y have separate buffers for these variables. 7. THE HIGH-LEVEL LANGUAGE COMPILER ----------------------------------- The high-level language compiler accepts an ASCII source file (extension .SRC) and produces a relocateable machine code program for the MC68010 microprocessor (same file name, but with an extension .EXE). If an .EXE file with the same name already exsists, it will be renamed to .OLD and the numerical values of the variables will be copied into the new .EXE file. When an error is found in the source file, the resulting .EXE file should not be used! The compiler only supports floating-point or REAL type variables and constants. A variable name is made of up to six characters, the first must be a letter and the following may also be numbers. Upper and lower case letters are considered different symbols in variable names. A single variable requires six 16 bit words of memory and includes a 6 character variable name, a 16 bit binary exponent, a 31 bit mantissa and a sign bit. A 31 bit mantissa allows a computation accuracy of about 10 decimal digits for the basic operations (addition, multiplication, division) and about 8 to 9 decimal digits for transcendent functions. A 16 bit exponent allows numbers to range between about 10^-9863 and 10^+9863. This range is probably enough for any kind of computations. In the remote case of an overflow, the functions are programmed to set the result to zero with no warning meessages! Correspondingly, a division by zero produces a zero output. The floating-point format can support ACCURATE operations with integers, provided that these are small enough. For addition and subtraction, both operands and result have to be absolutely smaller than 2^32-1 or 4294976295. For multiplication and division, at least one of the operands or result have to be smaller than 2^16-1 or 65535. Real number results are always truncated to the nearest absolutely smaller value that can be represented with the given real number format. Note that most decimal numbers with nonzero figures behind the decimal point do not have an exact representation in the binary format: for example, 2.3 would be printed as 2.299999 if the result is not additionally rounded before printout. Arrays may have up to 20 dimensions and must be declared. Each index may range between 0 and 65535. Each array element requires three 16 bit words of memory and some additional memory is required to store the array name and information about its dimensions. Arithmetic expressions are executed in the same order as they are written: all the arithmetic operations including functions have the same priority. Parentheses are not accepted. For example, the expression: MMY/45+12*ERT=FGH meaans, that the actual value of the variable MMY is first divided by 45, then 12 is added to the result of the division, later the sum is multiplied by the value of the variable ERT and finally the result of the operation is assigned to the variable FGH. Variable names are case sensitive: fgh, fgH, fGh, fGH, Fgh, FgH, FGh and FGH are considered 8 different and completely independent variables. Similarly, the expression: -TYP(J)*TYP(J)+1$Q=IOP(N) means that the negative value of the J-th element of the single dimension array TYP() is multiplied by itself, 1 is added to the result and the square root (function $Q) of the sum is assigned to the N-th element of the array IOP(). The compiler allows the exsistance of a single variable with the same name as an array: for example TYP(J) and TYP are completely independent, the first being an array and the second a single variable. More than one arithmetic expression can be written in a single program line, separators are simply space characters or any ASCII control characters, including and . Functions include both mathematical and other functions. They may or may not require an operand and may or may not produce a result. Mathematical functions require one operand and produce one result. In the case of a math function with a limited domain, like arcsin, no warning or error messages are generated if the operand lies outside its domain. Instead, the result is set to the nearest sensible value. All the trigonometric functions and their inverses work with angles expressed in radians. The exponent and logarithm functions work with the base of the natural logarithm e=2.718.... All the functions are denoted by the symbol "$" followed by one letter; both upper and lower case letters are considered the same here. Valid functions are: $: Declare an array. For example, $:TGU(12,3,7) means that TGU() is a three dimensional array, the first index ranges between 0 and 12, the second between 0 and 3 and the third between 0 and 7. The dimensions of the array are therefore 13*4*8 since 0 is a valid index! WARNING! The complier will provide no warning or error messages if two arrays or more are declared with the same name. $< Print the following ASCII characters on the screen. The string must be terminated with a ">" character, which is not printed. $A ARCTAN mathematic function. Domain unlimited. Range between -PI/2 and PI/2. $B Absolute value function. Domain unlimited. Range all positive numbers. $C Cosine function. Domain unlimited. Range between -1 and +1. $D ARCCOS mathematic function. Domain unlimited. Range between 0 and PI. For arguments less than -1 the function returns the value PI and for arguments greater than 1 the output is 0. $E Exponent function with the base e. Domain unlimited. Too large arguments produce a zero result. Range all positive numbers. $F Fractional part function. Domain unlimited. Range between -1 and +1. The function computes the fractional part of the absolute value of the argument and retains the sign. $H ARCSIN mathematical function. Domain unlimited. Range between -PI/2 and +PI/2. For arguments less than -1 the function returns the value of -PI/2 and for arguments greater than +1 the output is PI/2. $I Integer part function. Domain unlimited. Range all integer numbers. The function computes the integer part of the absolute value and retains the sign. For example, the result of -1.5$I is -1! $J Unconditional jump to a label. The label number must follow immediately! $J+ Jump only when the result of the previous instruction was positive. A label number must follow immediately! $J- Jump only when the result of the previous instruction was negative. A label number must follow immediately! $K Call the keyboard input routine which produces an input string to be used with the functions $M and $N. This function displays a blinking cursor on the screen and any characters entered through the keyboard are shown on the screen. The latter can be edited using the (7FH) key. or other control characters cause a return to the main program that called $K. $L Natural logarithm function with the base e. Domain unlimited. Range limited to real numbers that can represent natural logarithms of real numbers. Negative arguments return a zero result. $M Transforms an ASCII character from the keyboard input string into a REAL (6 byte format) number. The string pointer is incremented by one character unless at the end of the string (returned value 13 or character ). $N Transforms a number represented by an input ASCII character string into a REAL (6 byte format) number. The string pointer is incremented to point to the next character after the number. Only integer and floating point decimal numbers are accepted. Entries in mantissa plus exponent format require to use the function $N twice and a short conversion routine. $O Prints a number on the screen in the format specified by the following two constants. For instance: FGH$O7,3 means that the value of the variable FGH will be printed with 7 decimal places in front of the decimal point and 3 decimal places after the decimal point. An overflow will be indicated with a pattern 9999999.999 and an underflow with a pattern 0.000. In any case, 12 characters will be printed: sign, up to 7 figures for the integer part, the decimal point and three figures for the fractional part. If the second constant is 0, the decimal point will not be printed. $P Sign function. Its output is 1 for any positive number, -1 for any negative number and 0 for 0 input. $Q Square root function. Domain unlimited. Negative inputs produce a zero result. Range all positive integers that can be square roots. $R Return from subroutine (called by "$Z" plus label). $S Sine function. Domain unlimited. Range between -1 and +1. $T Tangent function. Domaain unlimited. Range unlimited. $U Clock function. It produces an input string in the form "yy mm dd hh mm ss" to be read by the $M and $N functions, just like if the date and time were input from the keyboard using $K. $W Prints the ASCII character corresponding to the given number. $Z Call to subroutine. A label must follow immediately! $Z+ Call only when the result of the previous instruction was positive. A label must follow immediately! $Z- Call only when the result of the previous instruction was negative. A label must follow immediately! Jumps, conditional jumps and calls to subroutines are performed to labels. Labels are denoted by the symbol "#" followed by a label number. For example: #345 is a valid label. The expression: NJ-W$j+345 will cause a conditional jump on the above label only when the difference of NJ minus W is positive. If the result of the operation is zero, the operation is undefined: the jump may or may not occur! Comments should be written between the symbols "<" and ">" and are ignored by the compiler program. For instance, the expression: is simply skipped by the compiler program. Note that the function "$<" uses a similar syntax, however the latter does have an effect on the execution of the program! Machine code routines can be inserted in hexadecimal format using the expression "&<" to begin and ">" to end a hexadecimal listing. The high-level language compiler produces a machine code program that includes the following parts: - Program header - Table of array variables - Table of single variables - Table of labels - Compiled program The compiled program uses all of the 16 general purpose registers of the CPU. The content of some of the registers should not be modified in an uncontrolled way to avoid crashing of the following compiled code: These are: A7 - stack pointer A6 - base address of input string buffer A5 - base address of arithmetic routines (TRAP10) A4 - base address of variables and labels A3 - input string buffer pointer Some registers can be used immediately to communicate with the high-level language when inserting machine code routines. These are: A2 - Offset of the variable address D1 - 16 bit exponent of the current math expression D0 - 32 bit signed mantissa of the current math expression Registers A1, A0, D7, D6, D5, D4, D3 and D2 are only used by artihmetic expressions and functions to hold intermediate computation results and their content can be modified without affecting the execution of the compiled high-level language program. Further directions for using the high-level language compiler, either high-level language only or used together with machine code and operating system routines, can be found in the many application programs supplied for the DSP computer, and in particular their source code listings. The compiler only includes functions that were found necessary in writing applications software for the DSP computer. Although the latter may seem very restricted when compared to a commercial compiler running on a commercial computer, the tradeoff is computation speed. The code produced by the high-level language compiler running on a 10MHz MC68010 can do about 20000 basic arithmetic operations (addition, multiplication or division) per second or compute about 1200 trigonometric functions (sine or cosine) per second. 8. PROGRAMMING HINTS -------------------- Regardles of the software support available, efficient real-time programming of any computer requires using its peripherals directly and thus writing small portions of the software directly in machine code. This is especially true if new peripherals are added to the computer, since no software support is available. Considering the above fact, the software support in the high-level language compiler is intentionally kept to a minimum: it only includes the basic routines for keyboard input and screen output. On the other hand, the compiler is designed to allow very simple insertion of machine-code programs of any size and rather simple communication between machine code and high-level language software. In order to write machine code programs it is necessary to study the hardware first, and in particular the microprocessor used. A complete description of the MC68010 microprocessor can be found in the following two books: 1) Motorola: 16-bit Microprocessors Data Manual, 1983. 2) Motorola: M68000 16/32-bit Microprocessor Programmer's Reference Manual, 1984. Transferring parameters between machine-code routines and the high-level language main program can be accomplished in may different ways. To transfer single variables (not arrays) registers D0 and D1 can be used. For example, the expression: AAA&< ...HEX machine-code program... > supplies the mantissa of the variable AAA in D0.L (32 bits) and the exponent of the variable AAA in D1.W (16 bits). Both can then be used by the machine code program. Similarly, the expression: &< ...HEX machine-code program... >=AAA assigns D0.L to the manitissa of the variable AAA and D1.W to the exponent of the variable AAA. Since machine-code programs require signed or unsigned integer data, the high-level language program has to care about the necessary conversions from and back to the floating-point format. A very simple way to perform these conversions is to use a special constant, defined by the floating point format used: 65536*32768=npr ...or... &<7000 323C 801F>=npr Conversion from floating point to unsigned integer is then a simple addition operation. For example, the program: AAA+npr&<13C0 0001 0003> converts the value of the variable AAA to unsigned integer (of course npr has to be defined before!). The unsigned integer is available in D0.L. The following machine-code program takes the low-order 8 bits of D0.L and writes them to the immediate address 00010003H (spare parallel output port on the CPU board). The above program is thus equivalent to the BASIC "POKE" instruction. This simple conversion rule also works in the opposite direction. For example, the expression: npr&<1039 0001 0001>-npr=AAA first sets D0.L and D1.W to npr, then reads a byte from the immediate address 00010001H (keyboard) into the low-order 8bits of register D0, then converts the result from unsigned integer to floating point and finally assigns the result to the variable AAA. The operation of the above expression is thus similar to the BASIC "PEEK" instruction. Using different constants, converstions to and from signed integer format of any length up to 32 bits can be performed in a similar way. On the other hand, high-level language variables can be used to store or transfer binary data between machine code routines. In this case no conversions are necessary, since these variables are not being used by the high-level language functions. For example, suppose that a machine-code DSP routine needs 1kbyte of memory space for a lookup table. This memory space can be assigned by declaring a high-level language array variable of suitable dimensions: The expression: $:buffer(170) buffer(0)&<200A D08C>=addres first declares an array of 171 elements. Since every element requires 3 words or 6 bytes, this totals up to 171*6=1026bytes. The expression "buffer(0)" computes the relative address of the first element and stores it in A2. The following machine code adds A4 to A2 thus computing the absolute address of the first element of the array in D0.L and finally stores the result in the variable "addres". The start address of the 1kbyte memory area is thus computed dynamically during program execution and conveniently stored in a variable that can be accessed at any time. DSP programming usually includes both programming in machine code for the DSP algorithm itself and programming in a high-level language to support and use the DSP routines. To recall the DSP routines periodically interrupts have to be used. The following discussion describes how this can be done efficiently on the DSP computer described. When a MC68010 microprocessor receives an interrupt request with a priority level higher than the current processor priority (described with the corresponding bits in the status register) a call to the interrupt handling routine is made. Start addresses of interrupt handling routines are stored together with other exception vectors in the exception vector table in the computer memory. The exception vector table is located in the system RAM during normal program execution (except at power-up). Its start address is stored in the Vector Base Register (VBR). Hardwired logic on the processor board makes the MC68010 to operate in the autovector mode: each interrupt level is assigned a single vector in the exception vector table. After reset, all interrupt vectors are pointing to an error handling routine (except interrupt 7 - the operator keyboard) and the processor priority is set to 7. To use an interrupt, the following has to be made exactly in the order given: 1) Replace the current interrupt vector with a vector pointing to the interrupt handling routine. 2) Initialize the peripheral that will request the interrupt. 3) Adjust the processor priority level if required. After the interrupt is no longer being used, the following has to be made to restore the original conditions: 1) Disable the peripheral requesting the interrupt. 2) Return the default interrupt vector (pointing to the error handling routine). 3) Return the processor priority level if modified. The address of the memory location containing the interrupt vector is computed by adding the corresponding offset to the start address stored in the VBR. The offset is 64H for INT1 level autovector, 68H for INT2 ... up to 7CH for INT7. From the user point of view it is very convenient to build interrupt routines into high-level language programs that can be handled or compiled as any other program. The compiler produces relocatable .EXE program files: the operating system considers that an .EXE file can be executed on any memory address. However, the exception vector table contains absolute addresses. The program should therefore include a routine to compute the interrupt routine address dynamically each time the program is executed on a new memory location. In the case of the MC68010 it is convenient to use the Load Effective Address instruction, in particular LEA d(PC),An to find the actual program counter. The address-finding routine is usually located just in front of the interrupt routine so that the unknown start address can be computed easily. Interrupt routines are usually DSP routines written almost entirely in machine code. However, high-level language expressions are necessary to interface to the rest of the program. Whenever a call to an interrupt routine is made, it is necessary to save the content of the microprocessor internal registers on the stack and restore it before exiting from the routine. Considering the many MC68010 internal register this operation may be very time consuming. Since most DSP machine code routines only need a few registers, only the latter are saved and restored before exit to save CPU time. High-level language expressions however use all MC68010 registers! Programs designed for use in an interrupt driven multitasking environment require some additional features. Since different interrupt routines may belong to different main programs and the interrupt nesting is arbitrary, the content of all microprocessor registers is completely unknown when entering an interrupt routine. If high-level language expressions are used in interrupt routines, the values of registers containing base addresses, usually A4 and A5, have to restored for correct operation. 9. FUTURE UPGRADES ------------------ The DSP operating system V7.3 is the result of a long evolution. Therefore no major upgrades are planned for the operating system itself: any further upgrades are therefore planned just as applications software. *************************************************************** 2