TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: TAUNO.VOIPIO@NOTUSED.FI.I
from: QUESTOR
date: 2021-01-08 21:40:00
subject: Re: AI and decompilation?

On Wed, 6 Jan 2021 14:17:30 +0200, Tauno Voipio
 wrote:
>This is a common construction in compiler-generated
>machine code, if the first function calls another
>just before return.
>
>bar:    .cfi_startproc
>         ... do something
>         call foo
>         ret
>
>foo:    .. do more ..
>         ret

It's a common construction in human-generated assembly as well, at least on the
PDP10.

Instead of

BAR: [do bar stuff]
 PUSHJ P, FOO
 POPJ, P

One writes

BAR: [do bar stuff]
 JRST FOO

and lets the POPJ at the end of FOO return from the call to BAR.  Saves an
instruction.  In PDP10 land, the mnemonic PJRST is defined to be the JRST
instruction in order to alert the reader of this intention, so one would write

BAR: [do bar stuff]
 PJRST FOO


Similarly, routines will often pop (restore) saved registers off the stack
before returning.  Rather than duplicate that code, one uses a PJRST to a label
in another routine that does the same thing.

BAR: PUSH P, T1
 PUSH P, T2
 [do bar stuff]
TPOPJ2: POP P, T2
TPOPJ1: POP P, T1
 POPJ P,

FOO: PUSH P, T1
 PUSH P, T2
 [do foo stuff]
 PJRST TPOPJ2

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.