[Simh] macro11

Johnny Billquist bqt at softjar.se
Sat Mar 7 09:55:25 EST 2020


Had some further exchanges in private with Don, but here is the bottom 
line as far as I am understanding things...

The relocation of a value have nothing to do with the instruction, or 
the addressing mode of the instruction. If that is being used, it is 
"wrong". The addressing mode, if the expression is relocatable, will 
decide what kind of relocatable record will be created, but it does not 
decide if there even should be a relocatable record or not.

This should all be about the value of the evaluated expression. If the 
evaluated expression is relative, then it needs to be relocated by the 
linker. If it is absolute, then MACRO-11 can create the end results 
directly.

A few examples:

.MAIN.  MACRO V05.05  Saturday 7-MAR-20 15:42  Page 1


       1 000000                                  .PSECT  FOO,I,RW
       2
       3 000000  000042                          .WORD   42
       4 000002  000000                  Y:      .WORD   0
       5
       6 000004  005067  177772                  CLR     Y
       7 000010  005037  000002'                 CLR     @#Y
       8 000014  005067  001234'                 CLR     X
       9 000020  005037  001234                  CLR     @#X
      10
      11 000000                                  .ASECT
      12         001000                          .=1000
      13         001234                  X=1234
      14
      15 001000  005067  000230                  CLR     X
      16 001004  005037  001234                  CLR     @#X
      17 001010  005067  000002'                 CLR     Y
      18 001014  005037  000002'                 CLR     @#Y
      19
      20         000001                          .END




.MAIN.  MACRO V05.05  Saturday 7-MAR-20 15:42  Page 1-1
Symbol table

X     = 001234          Y       000002R     002

. ABS.  001020    000   (RW,I,GBL,ABS,OVR)
         000000    001   (RW,I,LCL,REL,CON)
FOO     000024    002   (RW,I,LCL,REL,CON)
Errors detected:  0

*** Assembler statistics


Work  file  reads: 0
Work  file writes: 0
Size of work file: 40 Words  ( 1 Pages)
Size of core pool: 9524 Words  ( 36 Pages)
Operating  system: RSX-11M/M-PLUS

Elapsed time: 00:00:00.01
,TT=TT


Line 6 becomes an absolute expression since it's a subtraction of the 
relative address of Y from the current position, both in the same psect. 
Such an operation renders an absolute value.

Line 7 becomes relocatable, since the absolute address of Y is unknown 
because it's in a psect that can be moved around at link time.

Line 8 becomes relocatable because even though X is at a known address, 
the address of the instruction is unknown and subject to the location of 
the psect, which is only decided at link time.

Line 9 becomes absolute since it is an expression only dependent on an 
absolute value.

Line 15 becomes absolute since it's an expression subtracting two 
absolute values which obviously have an absolute result.

Line 16 becomes absolute since it is an expression only dependent on an 
absolute value.

Line 17 becomes relocatable because the address of Y is in another 
psect, and the subtraction of a relative address from an absolute 
renders a relative value.

Line 18 becomes relocatable because the absolute address of Y is 
unknown. MACRO-11 only have a relative value of Y.

Note that all references to Y contains 000002. This is because that is 
the offset of Y within the psect. This is added to the base of the psect 
(the part that comes from this object file), which is all the linker 
will know about.

   Johnny

On 2020-03-07 14:47, Rhialto wrote:
> On Sat 07 Mar 2020 at 01:59:03 +0100, Johnny Billquist wrote:
>> In the end, that is a different thing. Absolute addressing is not what Bob
>> was thinking about here...
>>
>> Here is what MACRO-11 does:
>>
>>        1 000000                                  .ASECT
>>        2         001000                          .=1000
>>        3         001234                  X=1234
>>        4
>>        5 001000  005067  000230                  CLR     X
>>        6
>>
>> Note that the addressing is still relative. But the actual offset required
>> can be computed by MACRO-11 at compile time.
> 
> This is the output of dumpobj for that code. It looks like indeed there
> is an unneeded relocation record in there:
> 
> GSD:
>          GLOBAL X     =1234 DEF ABS flags=110
>          MODNAME TEST  =0 flags=0
>          PSECT       =0  CON RW REL LCL I flags=40
>          PSECT . ABS.=1004  OVR RW ABS GBL I flags=104
>          XFER . ABS.=1 flags=10
> ENDGSD
> RLD
>          Location counter definition . ABS.+1000
> TEXT ADDR=1000 LEN=4
>          001000: 005067 001234               7...
> RLD
>          Internal displaced 1002=1234
> ENDMOD
> 
> It looks like the 2nd RLD record is generated by the code
> text_displaced_word() in object.c. That in turn must be called from this
> code in assemble_aux.c, since there are no other callers to
> store_displaced_word():
> 
> void mode_extension(
> ...
>      if (value->type == EX_LIT) {
>          if (mode->rel)                 /* PC-relative? */
>              store_displaced_word(str, tr, 2, value->data.lit);
>          else
>              store_word(str, tr, 2, value->data.lit);    /* Just a
>                                                             known
>                                                             value. */
> 
> My guess is that this could become something like
> 
>      if (value->type == EX_LIT) {
>          if (mode->rel) {              /* PC-relative? */
> 	    if (current_pc->section->flags & PSECT_REL) {
> 		store_displaced_word(str, tr, 2, value->data.lit);
> 	    } else {
> 		/* I can compute this myself. */
> 		store_word(str, tr, 2, value->data.lit - DOT - 2);
> 	    }
> 	} else {
>              store_word(str, tr, 2, value->data.lit);    /* Just a
>                                                             known
>                                                             value. */
> 	}
> 
> It seems like this case didn't come up in any previous tests; the
> regression tests show no change at all. (I have tested somewhat strictly
> by hand that various RSX-Kermit-11 source files generated the same
> object files as on RSX and that the listings, including macro expansion,
> didn't have any unexplained differences).
> 
> Any interesting test cases I can use with this, so see if it is correct
> this way?
> 
>         1                                        .TITLE  TEST RELOCATABLE REFERENCES
>         2 000000                                 .ASECT
>         3        001000                          .=1000
>         4        001234                  X == 1234
>         5 001000 005067  000230                  CLR     X
> 
> .     =******           X     =001234 G
> . ABS.  001004    000   (RW,I,GBL,ABS,OVR,NOSAV)
> 
> 
>>    Johnny
> -Olaf.
> 

-- 
Johnny Billquist                  || "I'm on a bus
                                   ||  on a psychedelic trip
email: bqt at softjar.se             ||  Reading murder books
pdp is alive!                     ||  tryin' to stay hip" - B. Idol


More information about the Simh mailing list