pro mod_list_addr, list, ist, table_start

ist2 = long(list(ist+0) and 'ffff'x) + long(list(ist+1) and '7fff'x) * '10000'x		;make into long word address
ist2 = ist2 + table_start								;add offset
list(ist+0) = ist2 mod '10000'x								;break into two short words
list(ist+1) = ist2  /  '10000'x

;;print, ist, ist2

end
;---------------------------------------------------------
pro set_list_addr, table_start, list, infil=infil
;+
;NAME:
;	set_list_addr
;PURPOSE:
;	Given a bin list and a start address, modify all address
;	references within the list to allow the table to reside at
;	that address
;HISTORY:
;	Written 24-Jul-95 by M.Morrison
;	25-Jul-95 (MDM) - Added header information
;	 2-Aug-95 (MDM) - Fixed bug with IRBIN processing
;	19-Mar-96 (MDM) - Added capability to stop list processing when
;			  reach the number of entries (for VWBIN) because
;			  of problem with 6003 list.
;	23-May-96 (MDM) - Corrected error for IRBIN when going from addressed
;			  offset back to an offset of 0
;	19-Jul-96 (MDM) - Removed address adjustment for crop list (the
;			  addresses it was moving were ccd pixel address.
;	15-Nov-96 (MDM) - Removed "printf,lun"
;	 6-Jan-97 (MDM) - Adjusted 23-May-96 mod to allow forward offsets
;RESTRICTIONS:
;	* The start table address must be 0000 for the input list
;-
;
if (n_elements(infil) ne 0) then list = rfits(infil, h=h)
list = unsign(list, 16)
;
case list(0) of
    376: begin		;crop instruction
;;		for i=0,list(2)-1 do begin
;;		    ist = 16+i*3
;;		    mod_list_addr, list, ist, table_start
;;		end
	 end
    414: begin		;vwbin instruction
	    qdone = 0
	    ist = 16L
	    while (not qdone) do begin
		list0 = list(ist:ist+9)

		mod_list_addr, list, ist+0, table_start		;x-vector weight addresses
		mod_list_addr, list, ist+3, table_start		;y-vector weight addresses
		mod_list_addr, list, ist+6, table_start		;data list addresses

		bits, list(ist+1), barr
		qdone = barr(15)
		nn = (ist-16)/10
		if (nn ge list(2)) then qdone = 1	;MDM added 19-Mar-96
		ist = ist + 10
	    end
	 end
    416: begin		;rwbin instruction
		for i=0,list(2)-1 do begin
		    ist = 16+i*7
		    mod_list_addr, list, ist, table_start
		end
	 end
    418: begin		;awbin instruction
	    qdone = 0
	    ist = 16L
	    while (not qdone) do begin
		mod_list_addr, list, ist+0, table_start		;weight
		mod_list_addr, list, ist+4, table_start		;data list addresses

		bits, list(ist+1), barr
		qdone = barr(15)
		ist = ist + 8
		nn = (ist-16)/8
		if (nn ge list(3)) then qdone = 1		;should really be list(2)
	    end
	    sea_mark_list, lun, ist, marks, list
	 end
    420: begin		;irbin instruction
		qdone = 0
		ist = 16L
		while (not qdone) do begin

		    ist2 = long(list(ist+0) and 'ffff'x) + long(list(ist+1) and '7fff'x) * '10000'x
		    if (table_start lt 0) then ist2 = ist2 + table_start	;MDM 6-Jan-97

		    mod_list_addr, list, ist, table_start	;data list addresses

		    for ii1=0,list(ist+2)-1 do begin
		        ist3 = ist2+ii1*6+2
		        mod_list_addr, list, ist3, table_start	;skip/take list
		    end

		    bits, list(ist+1), barr
		    qdone = barr(15)
		    ist = ist + 5
		    nn = (ist-16)/5
		    if (nn ge list(2)) then qdone = 1
		end
	 end
    else: begin
		print, '; OP CODE NOT RECOGNIZED - modify MAKE_ASCII_LIST'
	  end
endcase
;
end
