# File: QQP_12b.src
#
program "%Z% MODULE: %M% RELEASE: %R%.%L% CREATED: %G% %U%"
source "QQP_12b.dhs"
descr "QQP_12b - Loads TRACE i/p program into DHC queue"
#
# DSBQUE                ; Disable Queue
/icdhldin,wc=1,w1=0x0154 
#
#=======================================================
#
#
#;  File QQP_12b.src (From QQP_12b.dhs)
#;  This file contains the dhc code required to generate queue ver
#;  version 12a (or 129).
#;
#;  The patch contains to functional modifications:
#;
#;  1.  The code now returns the maximum and minum values from any
#;      IMIN request.
#;  2.  The code reverses the byte order of the timeword passed to
#;      firmware via the HSSENTER instruction in jitter mode.
#;
#;  Item 1 is the result of a new requirement.  Item 2 corrects a 
#;  not discovered until operations simulations in November 1997.
#;
#;  Several different areas are patched to realize these changes. 
#;  sections in which the IMAX and IMIN are output, one in the his
#;  routine and one in the imax routine.  Within each of these the
#;  subsections: one for IMAX and one for IMIN.  
#;  The timeword reversal is done in two sections.  The first make
#;  byte reversal subroutine at the end of the jitter mode program
#;  is the code for the routine.
#;
#;  In addition to the above, there is apatch that changes the ver
#;
#;  This (.src) code has been generated by writing a dhc source fi
#;  processing it by the DHC linker (dhclnk).
#;
#;
#
#
#; This section defines the register addressing region for the ima
#; patches.
#
#REGBLK 0x28E P1_RESULTS[12]
#REGEQU $P1_RESULTS+4 P1_RESULT_IMXV
#REGEQU $P1_RESULTS+7 P1_RESULT_IMNV
#REGBLK 0x52F P1_HIMINVAL[3]
#REGBLK 0x532 P1_HIMAXVAL[3]
#REGBLK 0x536 P1_FINDIMIN[3]
#REGBLK 0x539 P1_FINDIMAX[3]
#
#; This section fixes the imax and imin code in the histogram rout
#
#.ORG 0x41D
#COPYRD2D  $P1_HIMAXVAL $P1_RESULT_IMXV 3
/ICDHCMD,wc=5,w1=0x91,w2=0x041D,w3=0x0144,w4=0x0532,w5=0x0292,w6=0x0003
#.ORG 0x428
#COPYRD2D  $P1_HIMINVAL $P1_RESULT_IMNV 3
/ICDHCMD,wc=5,w1=0x91,w2=0x0428,w3=0x0144,w4=0x052F,w5=0x0295,w6=0x0003
#
#; This section fixes the imax and imin code in the Imax routine
#
#.ORG 0x50A
#COPYRD2D  $P1_FINDIMAX $P1_RESULT_IMXV 3
/ICDHCMD,wc=5,w1=0x91,w2=0x050A,w3=0x0144,w4=0x0539,w5=0x0292,w6=0x0003
#.ORG 0x519
#COPYRD2D  $P1_FINDIMIN $P1_RESULT_IMNV 3
/ICDHCMD,wc=5,w1=0x91,w2=0x0519,w3=0x0144,w4=0x0536,w5=0x0295,w6=0x0003
#
#; This section defines the register addressing region for the jit
#; patches.
#
#.RORG  HSS 0x1800
#REGBLK $HSS HSSSTUFF[16]
#REGEQU $HSSSTUFF+15 HSSAPID  
#REGEQU $HSSSTUFF+20 HSSTIME  
#
#; this section makes three calls to the byte reversal routine, on
#; time word.  Since it overwrites a couple of instruction at the 
#; jitter mode program, these are reloaded after the new code.
#
#.ORG 0x10AC
#SETREG  $BYTEREVSOURCE $HSSTIME
/ICDHCMD,wc=4,w1=0x91,w2=0x10AC,w3=0x0140,w4=0x1823,w5=0x1814
#CALLQUE $ByteRevSub
/ICDHCMD,wc=3,w1=0x91,w2=0x10AF,w3=0x01F8,w4=0x1D80
#SETREG  $BYTEREVSOURCE $HSSTIME+1
/ICDHCMD,wc=4,w1=0x91,w2=0x10B1,w3=0x0140,w4=0x1823,w5=0x1815
#CALLQUE &ByteRevSub
/ICDHCMD,wc=3,w1=0x91,w2=0x10B4,w3=0x01F8,w4=0x1D80
#SETREG  $BYTEREVSOURCE $HSSTIME+2
/ICDHCMD,wc=4,w1=0x91,w2=0x10B6,w3=0x0140,w4=0x1823,w5=0x1816
#CALLQUE $ByteRevSub
/ICDHCMD,wc=3,w1=0x91,w2=0x10B9,w3=0x01F8,w4=0x1D80
#SETREG  $HSSAPID 0x48
/ICDHCMD,wc=4,w1=0x91,w2=0x10BB,w3=0x0140,w4=0x180F,w5=0x0048
#CALLQUE &HssOutSub
/ICDHCMD,wc=3,w1=0x91,w2=0x10BE,w3=0x01F8,w4=0x1E3D
#ENDMAC
/ICDHCMD,wc=2,w1=0x91,w2=0x10C0,w3=0x01FC
#
#;  This is the byte reversal routine.  I have placed it at addres
#;  just before the existing utilities section at 1E00.  I chose t
#;  it here rather than at the end of utilites in order to perserv
#;  last address and to continue to have the version number very c
#;  the end of the code.
#
#.ORG 0x1D80
#.RORG BYTEREV 0x1820
#REGBLK $BYTEREV BYTEREVCONST[3]
#REGDEF $BYTEREV BYTEREVSOURCE
#REGDEF $BYTEREV BYTEREVTEMP
#REGDEF $BYTEREV BYTEREVRESULT
#
#ByteRevSub:
#SETREGS  $BYTEREVCONST 3 8 -8 0xFF
/ICDHCMD,wc=5,w1=0x91,w2=0x1D80,w3=0x01B2,w4=0x1820,w5=0x0003,w6=0x0008
/ICDHCMD,wc=3,w1=0x91,w2=0x1D84,w3=0xFFF8,w4=0x00FF
#COPYRI2D $BYTEREVSOURCE $BYTEREVTEMP 1
/ICDHCMD,wc=5,w1=0x91,w2=0x1D86,w3=0x01AC,w4=0x1823,w5=0x1824,w6=0x0001
#REGAND   $BYTEREVTEMP   $BYTEREVCONST+2 $BYTEREVRESULT
/ICDHCMD,wc=5,w1=0x91,w2=0x1D8A,w3=0x0150,w4=0x1824,w5=0x1822,w6=0x1825
#SHIFT    $BYTEREVRESULT $BYTEREVRESULT  $BYTEREVCONST
/ICDHCMD,wc=5,w1=0x91,w2=0x1D8E,w3=0x018A,w4=0x1825,w5=0x1825,w6=0x1820
#SHIFT    $BYTEREVTEMP   $BYTEREVTEMP    $BYTEREVCONST+1
/ICDHCMD,wc=5,w1=0x91,w2=0x1D92,w3=0x018A,w4=0x1824,w5=0x1824,w6=0x1821
#REGAND   $BYTEREVTEMP   $BYTEREVCONST+2 $BYTEREVTEMP
/ICDHCMD,wc=5,w1=0x91,w2=0x1D96,w3=0x0150,w4=0x1824,w5=0x1822,w6=0x1824
#REGOR    $BYTEREVTEMP   $BYTEREVRESULT  $BYTEREVRESULT
/ICDHCMD,wc=5,w1=0x91,w2=0x1D9A,w3=0x2150,w4=0x1824,w5=0x1825,w6=0x1825
#COPYRD2I $BYTEREVRESULT $BYTEREVSOURCE 1
/ICDHCMD,wc=5,w1=0x91,w2=0x1D9E,w3=0x01AA,w4=0x1825,w5=0x1823,w6=0x0001
#RTNQUE
/ICDHCMD,wc=2,w1=0x91,w2=0x1DA2,w3=0x01FA
#
#; This just gets me an address.
#
#.ORG 0x1E3D
#HssOutSub:
#
#;  This section changes the version to 12b
#
#.RORG  INT3_OUT 0x0070
#REGBLK $INT3_OUT INT3_OUTPUTBLOCK[16]
#REGEQU $INT3_OUTPUTBLOCK INT3_VRPN
#.ORG 0x1E43
#SETREG $INT3_VRPN 0x12B
/ICDHCMD,wc=4,w1=0x91,w2=0x1E43,w3=0x0140,w4=0x0070,w5=0x012B
#
#=======================================================
#
# ENBQUE                ; Enable Queue
/icdhldin,wc=1,w1=0x0136
#
#
return
#
#=======================================================
