Re: Backpatch?

boggs@osage.csc.ti.com (Lowell Boggs)
Fri, 30 Jun 1995 14:54:42 GMT

          From comp.compilers

Related articles
Backpatch? diaman@ee.upatras.gr (Nikos Diamantopoulos) (1995-06-25)
Re: Backpatch? boggs@osage.csc.ti.com (1995-06-30)
Re: Backpatch? gclind01@ulkyvx.louisville.edu (1995-07-01)
Re: Backpatch? IanC@gibside.demon.co.uk (Ian Cull) (1995-07-05)
Re: Backpatch? taweil@ucs.usc.edu (1995-07-13)
Re: Backpatch? jcea@ait.uvigo.es (1995-07-19)
Re: Backpatch? hebert@prism.uvsq.fr (1995-07-20)
Re: Backpatch? albaugh@agames.com (1995-07-20)
| List of all articles for this month |
Newsgroups: comp.compilers
From: boggs@osage.csc.ti.com (Lowell Boggs)
Keywords: code
Organization: Texas Instruments
References: 95-06-096
Date: Fri, 30 Jun 1995 14:54:42 GMT

>I need a backpatch mechanism such that i can use a variable before its
>definition. There are languages such as ALGOL, PL/1 that make use of
>such a mechanism.
>If anybody knows something about, he would greatly help me.
>
> Thanks


        I used to work with an assembler that used back patching for symbol
        names. The technique worked like this:


* the source code was parsed and an in memory version of the
object file was created


* when a previously undefined symbol was used on an assembly line:


mov r7,FRED


the symbol FRED was assumed to be a forward reference and the
opcode generated looked like this:


00000000: <move memory to register 7>
00000004: <0>


also a symbol table entry for FRED was created and it had a
pointer to the <0> in the opcode just generated ( 0000004 to
be precise).


* Subsequent references to FRED generated opcodes like this:


00000100: <do something to memory>
00000104: <address of previous reference to FRED: 0000004>


....


00000200: <do something else to memory>
00000204: <address of previous reference to FRED: 0000104>


* when FRED is finally declared, its real address (within the
generated object module) becomes known, and the symbol table
entry for FRED contains the address (within the object module)
where the most recent reference to FRED is found.


all the reference to FRED in the generated object module can
be patched up by searching the linked list which is held in
object module locations:


0000204
0000104
0000004


above.


Hope this helps,


        Lowell
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.