# File: fmt_bin_v05.src
#
program "%Z% MODULE: %M% RELEASE: %R%.%L% CREATED: %G% %U%"
source "/mdisw/cfl/prep/src/fmt_bin_v05.src"
descr "Loads IP queue instructions"
#=======================================================
#
#
#; FILE:    fmt_4x4bin.ips
#; PURPOSE: To perform a 4x4 binning of an image
#; METHOD:
#;       Inputs
#;               $IPRL_BIN_PARAM      - Holds:   source page(l,h) 
#;	Pages:
#;		19	== the intermediate 4x4 binning product
#; RESTRICTION:
#;	The 1024x1024 extract needs to have already been performed
#; HISTORY: Written 5-Sep-95 by M.Morrison
#;	16-Oct-95 (MDM) - Changed to use page 14 for 4x4 bin list
#;	19-Oct-95 (MDM) - Modified to not use R168 or R170 
#;	19-Oct-95 (MDM0 - Major reconstruction to be more general
#;			  TODO - look at the scaling factors of the ROWBIN instructio
#;	20-Oct-95 (MDM) - Corrected the logic - it wasn't counting loop
#;	24-Oct-95 (MDM) - Removed fixed register reference to R6000
#;       16-Nov-95 (MDM) - Changed the subroutine call for the deb
#;                         from QSR_DUMP_IPREG to QSR_DEBUG_IPREG
#;	 7-Dec-95 (MDM) - Modified to not do SETREGS for the ROWBIN, LR
#;			  Do a copy from another regiser list instead
#;	 1-Aug-96 (MDM) - Added logic to increase the K value depending
#;
#QSR_FMT_2X2BIN::
#    ;SETREGS $IPRL_BIN_ROWBIN+2 9   19:0x0000 1024 2 1024 512 16 
#    ;SETREGS $IPRL_BIN_LRBIN+3 5    0 4 14:0xffe60 $IPRL_BIN_LR_O
#    ;SETREG  $IPRL_BIN_DPC 0x1001
#    COPYRD2D $IPRL_BIN_ROWBIN2X2 $IPRL_BIN_ROWBIN+2 6
tcblock mbipmacl 0x1132    0x0144 0x11EE 0x1202 0x0006 
#    COPYREG  $IPRL_BIN_LRBIN2X2  $IPRL_BIN_LRBIN+5		;get low word
tcblock mbipmacl 0x1136    0x0142 0x120B 0x1213 
#    COPYREG  $IPRL_BIN_DPC2X2    $IPRL_BIN_DPC
tcblock mbipmacl 0x1139    0x0142 0x1218 0x121B 
#    SETREGS $IPRL_BIN_LR_NWORDS 2  0x4000L			;number of input pix
tcblock mbipmacl 0x113C    0x01B2 0x1216 0x0002 0x4000 \
                                0x0000 
#    SETREGS $IPRL_BIN_NWORDS 2 0x40000L
tcblock mbipmacl 0x1141    0x01B2 0x121C 0x0002 0x0000 \
                                0x0004 
#    SETREG  $IPRL_BIN_DONE_ADDR 0x0008				;address of source page
tcblock mbipmacl 0x1146    0x0140 0x121E 0x0008 
#    SETREG  $IPRL_BIN_K_SHIFT 1					;amount to increase K by
tcblock mbipmacl 0x1149    0x0140 0x1507 0x0001 
#    GOTO &COMMON_CODE
tcblock mbipmacl 0x114C    0x0156 0x1184 
#
#QSR_FMT_4X4BIN::
#    ;SETREGS $IPRL_BIN_ROWBIN+2 9   19:0x0000 1024 4 1024 256 16 
#    ;SETREGS $IPRL_BIN_LRBIN+3 5    0 4 14:0xffe00 $IPRL_BIN_LR_O
#    ;SETREG  $IPRL_BIN_DPC 0x1002
#    COPYRD2D $IPRL_BIN_ROWBIN4X4 $IPRL_BIN_ROWBIN+2 6
tcblock mbipmacl 0x114E    0x0144 0x11F4 0x1202 0x0006 
#    COPYREG  $IPRL_BIN_LRBIN4X4  $IPRL_BIN_LRBIN+5		;get low word
tcblock mbipmacl 0x1152    0x0142 0x120C 0x1213 
#    COPYREG  $IPRL_BIN_DPC4X4    $IPRL_BIN_DPC
tcblock mbipmacl 0x1155    0x0142 0x1219 0x121B 
#    SETREGS $IPRL_BIN_LR_NWORDS 2  0x8000L			;number of input pix
tcblock mbipmacl 0x1158    0x01B2 0x1216 0x0002 0x8000 \
                                0x0000 
#    SETREGS $IPRL_BIN_NWORDS 2 0x10000L
tcblock mbipmacl 0x115D    0x01B2 0x121C 0x0002 0x0000 \
                                0x0001 
#    SETREG  $IPRL_BIN_DONE_ADDR 0x0004				;address of source page
tcblock mbipmacl 0x1162    0x0140 0x121E 0x0004 
#    SETREG  $IPRL_BIN_K_SHIFT 2					;amount to increase K by
tcblock mbipmacl 0x1165    0x0140 0x1507 0x0002 
#    GOTO &COMMON_CODE
tcblock mbipmacl 0x1168    0x0156 0x1184 
#
#QSR_FMT_8X8BIN::
#    ;SETREGS $IPRL_BIN_ROWBIN+2 9   19:0x0000 1024 8 1024 128 16 
#    ;SETREGS $IPRL_BIN_LRBIN+3 5    0 4 14:0xffe30 $IPRL_BIN_LR_O
#    ;SETREG  $IPRL_BIN_DPC 0x1003
#    COPYRD2D $IPRL_BIN_ROWBIN8X8 $IPRL_BIN_ROWBIN+2 6
tcblock mbipmacl 0x116A    0x0144 0x11FA 0x1202 0x0006 
#    COPYREG  $IPRL_BIN_LRBIN8X8  $IPRL_BIN_LRBIN+5		;get low word
tcblock mbipmacl 0x116E    0x0142 0x120D 0x1213 
#    COPYREG  $IPRL_BIN_DPC8X8    $IPRL_BIN_DPC
tcblock mbipmacl 0x1171    0x0142 0x121A 0x121B 
#    SETREGS $IPRL_BIN_LR_NWORDS 2  0x8000L			;number of input pix
tcblock mbipmacl 0x1174    0x01B2 0x1216 0x0002 0x8000 \
                                0x0000 
#    SETREGS $IPRL_BIN_NWORDS 2 0x4000L
tcblock mbipmacl 0x1179    0x01B2 0x121C 0x0002 0x4000 \
                                0x0000 
#    SETREG  $IPRL_BIN_DONE_ADDR 0x0002				;address of source page
tcblock mbipmacl 0x117E    0x0140 0x121E 0x0002 
#    SETREG  $IPRL_BIN_K_SHIFT 3					;amount to increase K by
tcblock mbipmacl 0x1181    0x0140 0x1507 0x0003 
#;    GOTO &COMMON_CODE
#
#COMMON_CODE:
#
#    GETQADR  $IPRL_DEBUG_ADDR
tcblock mbipmacl 0x1184    0x015C 0x1FFD 
#    CALLQUE  $QSR_DEBUG_IPREG                                    
tcblock mbipmacl 0x1186    0x01F8 0x10C9 
#
#
#    COPYREG  $IPRL_BIN_PARAM   $IPRL_BIN_ROWBIN			;copy the sourc
tcblock mbipmacl 0x1188    0x0142 0x11E9 0x1200 
#    COPYREG  $IPRL_BIN_PARAM+1 $IPRL_BIN_ROWBIN+1		;copy the sour
tcblock mbipmacl 0x118B    0x0142 0x11EA 0x1201 
#    ROWBIN   $IPRL_BIN_ROWBIN					;do the binning in one directio
tcblock mbipmacl 0x118E    0x01D4 0x1200 
#
#
#    COPYREG  $IPRL_BIN_PARAM+2 $IPRL_BIN_LRBIN+1		;copy the low w
tcblock mbipmacl 0x1190    0x0142 0x11EB 0x120F 
#    COPYREG  $IPRL_BIN_PARAM+3 $IPRL_BIN_LRBIN+2		;copy the high 
tcblock mbipmacl 0x1193    0x0142 0x11EC 0x1210 
#    GETQADR  $IPRL_DEBUG_ADDR
tcblock mbipmacl 0x1196    0x015C 0x1FFD 
#    CALLQUE  $QSR_DEBUG_IPREG                                    
tcblock mbipmacl 0x1198    0x01F8 0x10C9 
#
#    SETREGS  $IPRL_BIN_LR_OFFSET 2 0 0				;initialize the offset
tcblock mbipmacl 0x119A    0x01B2 0x1FF5 0x0002 0x0000 \
                                0x0000 
#RPT:
#	SETREG    $IPRL_BIN_LRBIN+3 0 				;set list pointer to zero
tcblock mbipmacl 0x119F    0x0140 0x1211 0x0000 
#
#        LRBIN     $IPRL_BIN_LRBIN				;do one set of binning
tcblock mbipmacl 0x11A2    0x01D0 0x120E 
#        ADDADR    $IPRL_BIN_LR_OFFSET $IPRL_BIN_LR_NWORDS $IPRL_B
tcblock mbipmacl 0x11A4    0x0148 0x1FF5 0x1216 0x1FF5 
#	REGSUB    $IPRL_BIN_DONE_ADDR $IPRL_BIN_LR_OFFSET+1 $IPRL_BIN_DO
tcblock mbipmacl 0x11A8    0x2146 0x121E 0x1FF6 0x121F 
#	BRANCHNE  $IPRL_BIN_DONE_ADDR+1 0 &RPT
tcblock mbipmacl 0x11AC    0x01B0 0x121F 0x0000 0x119F 
#
#    ;--- do the decoding of the destination page
#    GETQADR  $IPRL_DEBUG_ADDR
tcblock mbipmacl 0x11B0    0x015C 0x1FFD 
#    CALLQUE  $QSR_DEBUG_IPREG                                    
tcblock mbipmacl 0x11B2    0x01F8 0x10C9 
#
#    COPYREG  $IPRL_BIN_PARAM+1 $IPRL_HDECODE_PARAM          ;copy
tcblock mbipmacl 0x11B4    0x0142 0x11EA 0x114A 
#    COPYREG  $IPRL_BIN_PARAM+3 $IPRL_HDECODE_PARAM+1        ;copy
tcblock mbipmacl 0x11B7    0x0142 0x11EC 0x114B 
#    CALLQUE  $QSR_DO_HDECODE                                ;deco
tcblock mbipmacl 0x11BA    0x01F8 0x1010 
#
#    ;--- now copy the relevant info to the hrdinit slot
#    COPYRI2D $IPRP_HDECODE_ADDR+1  $IPRL_HEAD_WORK 10       ;copy
tcblock mbipmacl 0x11BC    0x01AC 0x1152 0x1155 0x000A 
#    COPYREG  $IPRL_BIN_PARAM+2     $IPRL_HEAD_WORK+6        ;copy
tcblock mbipmacl 0x11C0    0x0142 0x11EB 0x115B 
#    COPYREG  $IPRL_BIN_PARAM+3     $IPRL_HEAD_WORK+7        ;copy
tcblock mbipmacl 0x11C3    0x0142 0x11EC 0x115C 
#    COPYREG  $IPRL_BIN_DPC         $IPRL_HEAD_WORK+5        ;over
tcblock mbipmacl 0x11C6    0x0142 0x121B 0x115A 
#    COPYREG  $IPRL_BIN_NWORDS	   $IPRL_HEAD_WORK+8	    ;set the o
tcblock mbipmacl 0x11C9    0x0142 0x121C 0x115D 
#    COPYREG  $IPRL_BIN_NWORDS+1	   $IPRL_HEAD_WORK+9	    ;
tcblock mbipmacl 0x11CC    0x0142 0x121D 0x115E 
#    BRANCHEQ $IPRL_HEAD_WORK+3 0 &SKIP_K_SHIFT		    ;if sending i
tcblock mbipmacl 0x11CF    0x01AE 0x1158 0x0000 0x11D7 
#        REGADD   $IPRL_HEAD_WORK+3 $IPRL_BIN_K_SHIFT $IPRL_HEAD_W
tcblock mbipmacl 0x11D3    0x0146 0x1158 0x1507 0x1158 
#SKIP_K_SHIFT:
#    COPYRD2I $IPRL_HEAD_WORK $IPRP_HDECODE_ADDR+1 10        ;copy
tcblock mbipmacl 0x11D7    0x01AA 0x1155 0x1152 0x000A 
#
#    GETQADR  $IPRL_DEBUG_ADDR
tcblock mbipmacl 0x11DB    0x015C 0x1FFD 
#    CALLQUE  $QSR_DEBUG_IPREG                                    
tcblock mbipmacl 0x11DD    0x01F8 0x10C9 
#    CALLQUE  $QSR_DO_HEADER
tcblock mbipmacl 0x11DF    0x01F8 0x105F 
#
#    RTNQUE
tcblock mbipmacl 0x11E1    0x01FA 
#=======================================================
#
return
#
#=======================================================
