Professional Documents
Culture Documents
Xxx2bd Hex For
Xxx2bd Hex For
Xxx2bd Hex For
*
* Copyright 2022, Kevin G. Rhoads. All Rights Reserved.
* portions Copyright 2005, 1999, Kevin G. Rhoads. All Rights Reserved.
*
* Permission for use and distribution in accordance with
* GNU General Public License 2.0 or later is granted.
*
* Permission for use and distribution in accordance with
* Creative Commons CC-BY-SA License is granted.
*
* Source is F77 with MS/DVF extensions.
*
integer*1 abyte(16),ia
integer*2 aword(16),kk,nn,bytes,block,sector
character*1 a_char(16),a
equivalence (ia,a)
character*2 crlf
character*3 trichar(16)
character*127 arg,outfile
character drive*1,path*64,file*8,ext*3,sect*3
character base*8,orgbase*8,unitname*11,commonname*9
integer*4 nargs,argstat,offset,k,l
integer*2 curarg,i,j, i2and
logical*2 cmdline,endflag,dogoto
external nargs,getarg,fnovr
*---------
curarg = 1
cmdline = (nargs().gt.1)
nn = 255
* change crlf to match system definition, what follows is right
* for MS-DOS
crlf = char(13)//char(10)
if (cmdline) then
call getarg(curarg,arg,argstat)
* print *,' arg is ',arg
arg = arg(1:len_trim(arg))
* print *,' Trimmed arg is ',arg
curarg = curarg + 1
if ( curarg.gt.nargs() ) stop ' Bye - out of arguments'
else
stop ' Bye '
endif
*----
offset = 0
open (unit=10,file=arg,status='old',form='binary',err=9000)
call fnsep(arg,drive,path,base,ext)
drive = ' '
path = ' '
file = ' '
ext = 'FOR'
call fnovr(arg,outfile,drive,path,file,ext)
9013 continue
open (unit=11,file=outfile,status='unknown',form='formatted',
& err=9003)
dogoto = .false.
print *,'-------------------------------------------------------'
* print *,'Doing file ',arg(1:len_trim(arg))
print *,'Doing file ',arg
write (*,*) ' '
*
* Use following for DVF command line build initial alignment,
* that there are other problems with build via FL32 compatibility
* driver
* write (*,'(a1\)') ' '
ia = 0
a = base(1:1)
if (ia.ge.48.and.ia.le.57) then
base = 'a'//base
endif
orgbase = base
sector = 0
dogoto = .false.
if (sector.eq.0) print *,' starting '//unitname
bytes = bytes + j
* if read returned bytes, process them
if (j.gt.0) then
do 2 i = 1,j
* not attempting to print control chars (ascii < 32)
*
* alternate "if" for designating over 126 as unprintable also
* if (abyte(i).ge.32.and.abyte(i).lt.127) then
* if (abyte(i).ge.0) then
if (abyte(i).ge.32.and.abyte(i).lt.255) then
a_char(i) = char(abyte(i))
else
* using ~ for unprintables
a_char(i) = '~'
endif
* use z2.2 for DVF and z2 for MS Fortran 5.1 if you need HEX
* write (trichar(i),'(i4.3)') aword(i)
write (trichar(i),'(i3.3)') aword(i)
2 continue
if (lines.eq.1) then
if (block.eq.1) then
*
* start new block data, new common &c
write (11,7007) crlf
unitname = base(1:len_trim(base))//'_bd'
write (11,7003) unitname,crlf
write (11,7004) base,crlf
commonname = base(1:len_trim(base))//'c'
write (11,7005) commonname,base,crlf
*
* write block 1, line 1
write (11,7031) base,crlf
dogoto = .false.
elseif (block.eq.2) then
write (11,7032) base,crlf
elseif (block.eq.3) then
write (11,7033) base,crlf
elseif (block.eq.4) then
write (11,7034) base,crlf
elseif (block.eq.5) then
write (11,7035) base,crlf
elseif (block.eq.6) then
write (11,7036) base,crlf
elseif (block.eq.7) then
write (11,7037) base,crlf
elseif (block.eq.8) then
write (11,7038) base,crlf
dogoto = .true.
endif
write (11,7001) (trichar(i),i=1,16),(a_char(i),i=1,16),
& crlf
elseif (lines.eq.2) then
write (11,7011) (trichar(i),i=1,16),(a_char(i),i=1,16),
& crlf
elseif (lines.eq.3) then
write (11,7012) (trichar(i),i=1,16),(a_char(i),i=1,16),
& crlf
elseif (lines.eq.4) then
write (11,7021) (trichar(i),i=1,16),(a_char(i),i=1,16),
& crlf
if (dogoto) then
bytes = 0
sector = sector + 1
*
* 160k diskettes have 320 sectors
* 320k diskettes have 640 sectors
* this version of XXX2BD can handle up to 999 additional blocks
if (sector.gt.4095.or.endflag) then
goto 9003
endif
write (sect,'(z3)') sector
base = orgbase(1:(len_trim(orgbase)-3)) // sect
dogoto = .false.
offset = offset + j
k = offset/512
l = offset - k*512
if (l.eq.0) then
write (11,7002) crlf
write (11,7006) crlf
* goto 9003
endif
if (.not. endflag) goto 9023
endif
endif
else
* no bytes read
goto 9003
endif
offset = offset + j
k = offset/512
l = offset - k*512
if (l.eq.0) then
write (11,7002) crlf
write (11,7006) crlf
* goto 9003
endif
if (.not. endflag) goto 9002
*----
9003 continue
print *,' Ended with '//unitname
close (unit=11,status='keep',err=9004)
9004 continue
close (unit=10,status='keep',err=9005)
9005 continue
*with blank
7001 format (5x,'1/',15(a3,','),a3,', |',8a1,' ',8a1,a2\)
7011 format (5x,'2 ',15(a3,','),a3,', |',8a1,' ',8a1,a2\)
7012 format (5x,'3 ',15(a3,','),a3,', |',8a1,' ',8a1,a2\)
7021 format (5x,'4 ',15(a3,','),a3,'/ |',8a1,' ',8a1,a2\)
7002 format (1x,a2\)
7003 format (6x,'block data ',a11,a2\)
7004 format (6x,'integer*1 ',a8,'(512)',a2\)
7005 format (6x,'common /',a9,'/',a8,a2\)
7006 format (6x,'end',a2\)
7007 format ('*','-------------------------------------------------',
1 '---------------------',a2\)
7031 format (6x,'data (',a8,'(i),i=1,64)',a2\)
7032 format (6x,'data (',a8,'(i),i=65,128)',a2\)
7033 format (6x,'data (',a8,'(i),i=129,192)',a2\)
7034 format (6x,'data (',a8,'(i),i=193,256)',a2\)
7035 format (6x,'data (',a8,'(i),i=257,320)',a2\)
7036 format (6x,'data (',a8,'(i),i=321,384)',a2\)
7037 format (6x,'data (',a8,'(i),i=385,448)',a2\)
7038 format (6x,'data (',a8,'(i),i=449,512)',a2\)
end
*------------------------------------------------------
integer*2 function i2and(i,j)
integer*2 i,j
i2and = i .and. j
return
end