The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* [TUHS] Query on PDP-11 assembly
@ 2008-04-30 11:56 Warren Toomey
  2008-04-30 13:55 ` Brantley Coile
  2008-04-30 15:08 ` Carl Lowenstein
  0 siblings, 2 replies; 10+ messages in thread
From: Warren Toomey @ 2008-04-30 11:56 UTC (permalink / raw)


All, I'm trying to write a PDP-11 disassembler for a.out files. I'm having
trouble dealing with jsrs. Take, for example, the code here:
http://minnie.tuhs.org/UnixTree/1972_stuff/s1/frag19.html

I can happily deal with the   jsr pc,do   type of jsr, but the ones
involving r5 have me stumped, e.g.:

	jsr	r5,questf; < nonexistent\n\0>; .even

It appears that data is being inserted into the executable directly
after the jsr instruction. How does the rts which returns from the jsr
know how much data to skip, and what is the involvement of r5 here?

Thanks,
	Warren



^ permalink raw reply	[flat|nested] 10+ messages in thread
* [TUHS] Query on PDP-11 assembly
@ 2008-04-30 16:20 James A. Markevitch
  0 siblings, 0 replies; 10+ messages in thread
From: James A. Markevitch @ 2008-04-30 16:20 UTC (permalink / raw)


> I can happily deal with the   jsr pc,do   type of jsr, but the ones
> involving r5 have me stumped, e.g.:
> 
>         jsr     r5,questf; < nonexistent\n\0>; .even

I have encountered this type of construct a lot when doing disassemblers
over the years.  My usual strategy for dealing with this is:

1. If it's quick and dirty and I am not running huge amounts of code,
then the disassembler allows the user to provide a list of "hints" to
it.  The hints for this would describe the arguments to each subroutine.
For illustrative purposes, you might have a side file that contains
the following:

	subr 002004 questf string

meaning that location 002004 is a subroutine names questf that expects
a null-terminated string as the argument.  As an additional benefit,
you get a nice name for the subroutine that the disassembler can put
into the output.

And if a subroutine takes two 16-bit arguments, you might have:

	subr 003436 mysub arg16 arg16

If the disassembler identifies each of the targets of the jsr
instructions, then you can usually do a quick look at the code to
see what it expects, then add to the side file, then re-run the
disassembler.

2. If you want to be less quick and dirty, you can have the disassembler
do a partial flow analysis of the code to figure out what is expected
for arguments.  This is usually much more involved and you still often
need to add hints for cases where the '60s or '70s programmer did some
kind of "neat trick" when coding.

My philosophy on these is to use tools to get to the 95%+ level of
automation and provide hints to pick up the rest.  Using strategy
number 1 above will probably get you a lot of success with a small
amount of coding in your disassembler.

James Markevitch



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-05-01 23:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-30 11:56 [TUHS] Query on PDP-11 assembly Warren Toomey
2008-04-30 13:55 ` Brantley Coile
2008-04-30 14:41   ` Naoki Hamada
2008-05-01 23:47     ` Warren Toomey
2008-04-30 16:53   ` Milo Velimirovic
2008-04-30 17:00     ` Larry McVoy
2008-04-30 17:47       ` John Cowan
2008-04-30 17:59         ` Larry McVoy
2008-04-30 15:08 ` Carl Lowenstein
2008-04-30 16:20 James A. Markevitch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).