begin ; !Analyse Imp object file (show external entries and references)
include "inc:util.imp"
recordformat headerf(byte mark,version,short checks,
short exportsize,importsize,
integer codesize,
short reset,entry,
integer ownsize,
integer stacksize,
integer spare1,spare2)
recordformat extf(short flags,parmtype,
integer objtype,
integer address,
string (255) name)
constbytearray code(0:3)='#','S','E','Y'
record (headerf)name header
record (extf)name e
integer start,limit,p,q,n
string (255)s
routine ph(integer value)
if value>>16 = 0 then phex4(value) else phex(value)
end
routine show(integer value)
ph(value)
printsymbol('('); write(value,0); printsymbol(')')
end
routine SHOW CHECKS(integer bits)
integer PROBE=16_8000, I=1
const string TEXT = c
"-ARR-LOOP-CAP-OVER-ASS-STRASS-SASS-BASS-LINE-DIAG-TRACE-STACK--VOL-"
printstring(" Checks: ")
if bits = 0 start
printstring("none")
else
cycle
cycle
printsymbol(charno(text,i)) if bits&probe # 0
i = i+1
repeat until charno(text,i) = '-'
probe = probe>>1
repeat until probe = 16_0002
finish
newline
end
s = cliparam
to upper(s)
s = s.".MOB" if substring(s,length(s)-3,length(s)) # ".MOB"
connectfile(s,0,start,limit); limit = limit+start
header == record(start)
if header_mark # 16_FE start
printstring("Not code file"); newline
stop
finish
if header_version # 16_02 start
printstring("Not V02 code file"); newline
finish
printstring(" Code size: "); show(header_codesize)
newline
printstring(" Static requirement: "); show(header_ownsize)
newline
printstring(" Stack requirement: "); show(header_stacksize)
newline
show checks(header_checks)
printstring(" External entries:"); newline
spaces(2); ph(header_entry<<1); printstring(" Main entry")
spaces(13); ph(header_reset<<1); printstring(" Reset entry"); newline
if header_exportsize # 0 start
e == record(start+32)
n = 0
while e_flags < 0 cycle
space; space if n = 0; n = n+1
ph(e_address)
space
printsymbol(code(e_flags>>12&3))
space; space
printstring(e_name)
if n=2 then newline and n = 0 else spaces(20-length(e_name))
e == record(addr(e)+(length(e_name)+14)&(¬1))
repeat
newline unless n=0
finish
if header_importsize # 0 start
printstring(" External references:"); newline
n = 0
e == record(start+32+header_exportsize)
while e_flags < 0 cycle
space; space if n = 0; n = n+1
ph(e_address)
space
printsymbol(code(e_flags>>12&3))
space; space
printstring(e_name)
if n=2 then newline and n = 0 else spaces(20-length(e_name))
e == record(addr(e)+(length(e_name)+14)&(¬1))
repeat
newline unless n=0
finish
endofprogram