-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandLine_m.f90
More file actions
122 lines (109 loc) · 4.43 KB
/
CommandLine_m.f90
File metadata and controls
122 lines (109 loc) · 4.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
module CommandLine_m
! Command line processor for 1401 dissamblers and undumpers.
implicit NONE
private
public :: CommandLine
contains
subroutine CommandLine ( ShowAddr, ShowMem, Format, Title, Offset, WS )
logical,intent(out) :: ShowAddr ! Show addresses in output lines
logical,intent(out) :: ShowMem ! Dump memory after reading the SIMH dump
character, intent(out), optional :: Format ! A = Autocoder,
! D = simh Dump, 1 = one per card,
! 7 = seven per card, S = SPS,
! 4 = 1440 format
character(*), intent(out), optional :: Title ! to put on JOB card
integer, intent(out), optional :: Offset ! for tape dump
character, intent(out), optional :: WS ! Word separator encoding
integer :: I, L, Stat
character(100) :: Line, NextField
character :: MyWS
if ( present(format) ) format = ''
if ( present(title) ) title=''
! Analyze command line
l = 1
showAddr = .false.
showMem = .false.
myWS = '~' ! Default is Pierce encoding
do
call getarg ( l, line )
if ( line(1:3) == "" ) exit
if ( line(1:1) == '-' ) then
do i = 2, len(line)
if ( line(i:i) == "" ) then
exit
else if ( line(i:i) == "a" ) then
showAddr = .true.
else if ( line(i:i) == "m" ) then
showMem = .true.
else if ( present(format) .and. line(i:i) == 'A' ) then
format = 'A' ! Autocoder
else if ( present(format) .and. line(i:i) == 'D' ) then
format = 'D' ! simh Dump
else if ( present(format) .and. line(i:i) == '1' ) then
format = '1' ! One-field-per-card
else if ( present(format) .and. line(i:i) == '4' ) then
format = '4' ! 1440 format
else if ( present(format) .and. line(i:i) == '7' ) then
format = '7' ! Seven-fields-per-card
else if ( line(i:i) == 'p' ) then
myWS = '~' ! Pierce encoding
else if ( present(format) .and. line(i:i) == 'S' ) then
format = 'S' ! SPS
else if ( line(i:i) == 's' ) then
myWS = '=' ! traditional SimH encoding
else if ( present(format) .and. present(offset) &
& .and. line(i:i) == 'T' ) then
format = 'T' ! Tape, next field is offset else zero
offset = 0
call getarg ( l+1, nextField )
if ( nextField /= '' ) then
read ( nextField, *, iostat=stat ) offset
if ( stat /= 0 ) then
print *, 'Cannot get offset, zero used'
offset = 0
else
l = l + 1 ! skip next field
end if
end if
else
call usage
end if
end do
else if ( present(title) ) then
title = line
else
call usage
end if
l = l + 1
end do
if ( present(ws) ) ws = myWS
contains
subroutine Usage
call getarg ( 0, line )
if ( present(title) ) then
print '(4a)', 'Usage: ', trim(line), ' [options] [title] <input >output'
else
print '(4a)', 'Usage: ', trim(line), ' [options] <input >output'
end if
print '(a)', ' options: -a => Put addresses in 1:5 of output'
print '(a)', ' -m => Dump simulated memory after input'
if ( present(format) ) then
print '(a)', ' -A => Autocoder format input'
print '(a)', ' -D => simh Dump'
print '(a)', ' -1 => One-field-per-card format input'
print '(a)', ' -4 => 1440 format input'
print '(a)', ' -7 => seven-field-per-card format input'
print '(a)', ' -S => SPS format input'
print '(a)', ' -T => Tape dump, next field is offset'
end if
print '(a)', ' -p => use ~ for WS (Pierce encoding)'
print '(a)', ' -s => use = for WS (traditional SimH encoding)'
print '(a)', ' default encoding is ' // myWS
print '(a)', ' else => This output'
print '(a)', ' Options can be combined, e.g. -am'
print '(a)', 'Copyright (c) Van Snyder 2016. 2016-01-16 version.'
stop
end subroutine Usage
end subroutine CommandLine
end module CommandLine_m
!>> 2013-04-24 Make sure "offset" has a value even if there is no field after -T