;+
; NAME:
;	LOAD2IHEX
; PURPOSE:
;	Creates Intel-hex load module from BCS parameter area that can 
;	be converted to required form by BCS_CONV
; CATEGORY:
; CALLING SEQUENCE:
;	.run load2ihex
; INPUTS:
;	Plan area should have been read (and modified) in first!
; OPTIONAL INPUT PARAMETERS:
; KEYWORD PARAMETERS:
; OUTPUTS:
;	produces file "seqn.hex" on current directory
; OPTIONAL OUTPUT PARAMETERS:
; COMMON BLOCKS:
; SIDE EFFECTS:
; RESTRICTIONS:
; PROCEDURE:
;	Asks for area of parameter area required, creates laod for each
;	untile offset and length of zero entered
; MODIFICATION HISTORY:
;	RDB   5-May-94
;-

yesnox,'* Create file',afil
lunw=0
if afil then openw,lunw,'seqn.hex',/get_lun

again:
print,' '
read,'* Enter offset and length: ',ioff,ilen
if ilen eq 0 then goto, endit

hdump = plan_area(ioff:ioff+ilen)
hprint,hdump

ibase = '3800'x

jseg = fix(ilen/16)
jrem = fix(ilen - jseg*16)
print,jseg,jrem
fmt='(a,Z2.2,Z4.4,17Z2.2)'

for jj = 0,jseg-1 do begin
  iadd = ibase + ioff + 16*jj
  ll = string(':',16,iadd,0,hdump(jj*16:jj*16+15),format=fmt)
  print,ll
  if lunw gt 0 then printf,lunw,ll
endfor

iadd = ibase + ioff + 16*jj
ll = string(':',jrem,iadd,0,hdump(jj*16:jj*16+jrem-1),format=fmt)
print,ll
if lunw gt 0 then printf,lunw,ll
goto, again

endit:
ll = ':00000001FF'
print,ll
if lunw gt 0 then printf,lunw,ll

if lunw gt 0 then free_lun,lunw

end
