/**************************************************************************** Filename: UARTRW.ASM Created on: Sunday 25-June-2000, 17:46, TVJM, broken out from file UART.C. Revision History: -Thursday 6-July-2000, 01:43, TVJM: Removed function truncate to file ARCHIVE.CCC -Wednesday 5-July-2000, 23:11, TVJM: Added function truncate. -Friday 30-June-2000, 24:31, TVJM: Reformatted for printout. -Friday 30-June-2000, 23:26, TVJM: Added function float_to_fix. -Friday 30-June-2000, 15:05, TVJM: Added function get_exponent. -Wednesday 28-June-2000, 17:29, TVJM: Added code to mask off only 8-bit data for UART reads. -Wednesday 28-June-2000, 16:26, TVJM: Attempted removing double-reads for holds. -Wednesday 28-June-2000, 13:31, TVJM: Corrected incomplete comment bug. -Wednesday 28-June-2000, 13:19, TVJM: Reverted back to original double hold time. -Wednesday 28-June-2000, 13:16, TVJM: Added idle instruction to synchronize background UART operations with foreground CODEC ultra-sampling interrupts. -Tuesday 27-June-2000, 23:17, TVJM: Added double reads to assist hold times. Created by: Tom V.J.Maglione, 29 Rice Rd, Wayland, MA 01778 (508) 655-9120 Purpose: This file documents some assembler-language source code to read from and write to the EZ-KIT UART. ****************************************************************************/ #include "\ez-kit\21k\include\DEF21060.h" /* for Sharc symbols */ #include "\ez-kit\21k\include\ASM_SPRT.h" /* for Sharc C-language macros */ #include "symbols.h" /* project-wide symbolic constant definitions */ /**************************************************************************** The next section allocates the 48-bit Program Memory Code segment: ****************************************************************************/ .segment/pm seg_pmco; { EZKIT user 48-bit Program Memory Code segment } .file "UARTRW.ASM"; /* from HELLO.C example */ /**************************************************************************** Begin of function "get_exponent": This function takes 1 input floating-point number and returns its base-2 unbiased exponent value in register R0: Note: numbers in square brackets represent cycle counts, e.g.-[4]. ****************************************************************************/ .global _get_exponent; _get_exponent: ! FUNCTION PROLOGUE: int get_exponent(float input); ! rtrts protocol, params in registers, DM stack, doubles are floats /*************************************************************************** The next section assumes the C-compiler sets the following register values as shown and saves other registers used or reserved by the compiler: M5=M13=0; M6=M14=1; M7=M15=-1; Note that the input float on entry is in register f4 as a 32-bit IEEE floating-point number ***************************************************************************/ leaf_entry; /*[0] C-language called entry macro for no internal calls */ r0=logb f4; /*[1] get base-2 unbiased exponent from input float number */ leaf_exit; /*[4] C-language called return macro for no internal calls */ !! Total time = 5 cycles /**************************************************************************** End of function "get_exponent"... ****************************************************************************/ /**************************************************************************** Begin of function "float_to_fix": This function takes 1 input floating-point number and returns the rounded integer value in register R0: Note: numbers in square brackets represent cycle counts, e.g.-[4]. ****************************************************************************/ .global _float_to_fix; _float_to_fix: ! FUNCTION PROLOGUE: int float_to_fix(float input); ! rtrts protocol, params in registers, DM stack, doubles are floats /*************************************************************************** The next section assumes the C-compiler sets the following register values as shown and saves other registers used or reserved by the compiler: M5=M13=0; M6=M14=1; M7=M15=-1; Note that the input float on entry is in register f4 as a 32-bit IEEE floating-point number ***************************************************************************/ leaf_entry; /*[0] C-language called entry macro for no internal calls */ r0=fix f4; /*[1] round towards nearest integer */ leaf_exit; /*[4] C-language called return macro for no internal calls */ !! Total time = 5 cycles /**************************************************************************** End of function "float_to_fix"... ****************************************************************************/ /**************************************************************************** Begin of function "read_from_uart": This function takes 1 input argument address and returns the value read from the UART address in register R0: Note: numbers in square brackets represent cycle counts, e.g.-[4]. ****************************************************************************/ .global _read_from_uart; _read_from_uart: ! FUNCTION PROLOGUE: int read_from_uart(int * address); ! rtrts protocol, params in registers, DM stack, doubles are floats /*************************************************************************** The next section assumes the C-compiler sets the following register values as shown and saves other registers used or reserved by the compiler: M5=M13=0; M6=M14=1; M7=M15=-1; Note that the input int address on entry is in register r4 as a twos-complement signed 32-bit integer value right-justified in r4: ***************************************************************************/ leaf_entry; /*[0] C-language called entry macro for no internal calls */ i4=r4; /*[1] get address of UART register to be read */ r1=0x000000FF; /*[1] mask for LS 8-bits from UART */ idle; /*[1+?] enter low power state, wait for interrupt */ r0=dm(m5,i4); /*[1] actual read return value */ r0=r0 and r1; /*[1] mask-off LS 8-bits from UART data */ leaf_exit; /*[4] C-language called return macro for no internal calls */ !! Total time = 9 + ? cycles (due to unknown wait until next interrupt) /**************************************************************************** End of function "read_from_uart"... ****************************************************************************/ /**************************************************************************** Begin of function "write_to_uart": This function takes 2 input arguments for address and value and writes the value to the UART address. Note: numbers in square brackets represent cycle counts, e.g.-[4]. ****************************************************************************/ .global _write_to_uart; _write_to_uart: ! FUNCTION PROLOGUE: void write_to_uart(int * address, int value); ! rtrts protocol, params in registers, DM stack, doubles are floats /*************************************************************************** The next section assumes the C-compiler sets the following register values as shown and saves other registers used or reserved by the compiler: M5=M13=0; M6=M14=1; M7=M15=-1; Note that the input int address on entry is in register r4 and the input int value on entry is in register r8. ***************************************************************************/ leaf_entry; /*[0] C-language called entry macro for no internal calls */ i4=r4; /*[1] get address of UART register to be written */ idle; /*[1+?] enter low power state, wait for interrupt */ dm(m5,i4)=r8; /*[1] actual write of value to address */ leaf_exit; /*[4] C-language called return macro for no internal calls */ !! Total time = 7 + ? cycles (due to unknown wait until next interrupt) /**************************************************************************** End of function "write_to_uart"... ****************************************************************************/ .endseg; /* End of segment seg_pmco */ /**************************************************************************** End of file "UARTRW.ASM"... ****************************************************************************/