?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1.     ORG $1000
  2.     RELOCATE_START
  3.     ASSERT 2 * relocate_count == relocate_size
  4.     ASSERT 19 == relocate_count
  5.     dw      relocate_count
  6.     dw      relocate_size
  7.  
  8.     STRUCT st1
  9. b       BYTE    $12
  10. w       WORD    absolute1
  11. relInit WORD    reloc1          ; the default init value should be relocated
  12. noRel   WORD    reloc2-reloc1
  13. badRel  WORD    2*reloc1        ; warning about not simple "+offset"
  14.     ENDS
  15.  
  16.     STRUCT st2
  17. b       BYTE    $34
  18. w       WORD    absolute1
  19. relInit WORD    reloc2          ; the default init value should be relocated
  20. noRel   WORD    reloc2-reloc1
  21. badRel  WORD    2*reloc2        ; warning about not simple "+offset"
  22. st1A    st1
  23. st1B    st1     { high reloc1, absolute2, reloc2, reloc1-reloc2, 2*reloc2 }
  24.     ENDS
  25.  
  26. reloc1:
  27.  
  28.     ; instancing the struct in relocatable block
  29. .t1 st2     {}                  ; default init (no warnings, those were at definition, but relocation data in table)
  30. ; ^ expected relocation data: 07 10 10 10 19 10
  31. .t2 st2     {,,$ABCD,,,{,,$ABCD,,},{$EF,,$ABCD,,}}   ; remove any relocatable data
  32. .t3 st2     {,,$ABCD,,,{high reloc2,,$ABCD,,},{$EF,,2*reloc1,,reloc2}}   ; some relocatable and 2x warnings
  33. ; ^ expected relocation data: 53 10
  34.  
  35.     ld      ix,reloc1.t1        ; to be relocated (address of instance)
  36.     ld      iy,.t2              ; to be relocated (address of instance)
  37.  
  38.     ; using the struct offsets - no relocation data needed (offsets are relative values)
  39.     ld      a,(ix+st2.st1A.b)
  40.     ld      a,(ix+st2.st1A.w)
  41.     ld      a,(ix+st2.st1A.relInit)
  42.     ld      a,(ix+st2.st1A.noRel)
  43.     ld      a,st2               ; struct length is absolute
  44.     ld      a,st2.st1B          ; offset to nested sub-structure is absolute
  45.  
  46.     ; using struct addresses - to be relocated
  47.     ld      a,(reloc1.t1.st1A.b)
  48.     ld      hl,(reloc1.t1.st1A.w)
  49.     ld      de,(reloc1.t1.st1A.relInit)
  50.     ld      bc,(reloc1.t1.st1A.noRel)
  51.     ld      a,(.t2.st1B.b)
  52.     ld      hl,(.t2.st1B.w)
  53.     ld      de,(.t2.st1B.relInit)
  54.     ld      bc,(.t2.st1B.noRel)
  55.  
  56.     ; using absolute struct instance = to be ignored
  57.     ld      a,(absolute1.t1.st1A.b)
  58.     ld      hl,(absolute1.t1.st1A.w)
  59.     ld      de,(absolute1.t1.st1A.relInit)
  60.     ld      bc,(absolute1.t1.st1A.noRel)
  61.  
  62.     ; using alias instance placed at particular address
  63. akaT1   st2 = .t1               ; transitive relocation - to be relocated
  64.     ld      de,(akaT1.b)
  65.     ld      bc,(akaT1.w)
  66.     ld      a,(akaT1.st1B.b)
  67.     ld      hl,(akaT1.st1B.w)
  68.     ld      ix,akaT1.st1B
  69.  
  70.     ; same alias test, but with absolute instance = no relocation data
  71. akaA1   st2 = absolute1.t1
  72.     ld      a,(akaA1.st1A.b)
  73.     ld      hl,(akaA1.st1A.w)
  74.     ld      de,(akaA1.st1A.relInit)
  75.     ld      bc,(akaA1.st1A.noRel)
  76.     ld      ix,akaA1.st1A
  77.  
  78. reloc2:
  79.     RELOCATE_END
  80.  
  81.     ORG $2000
  82.     RELOCATE_TABLE
  83.  
  84. ; no relocation area (no warnings, no relocation data)
  85.     ORG $87DC
  86. absolute1:
  87.  
  88.     ; instancing the struct in absolute block - NOTHING to be relocated
  89. .t1 st2     {}
  90.     ; no warning about unstable values or value being different
  91. .t2 st2     {,,$ABCD,,,{high reloc2,,$ABCD,,},{$EF,,2*reloc1,,reloc2}}
  92.  
  93.     ld      ix,reloc1.t1        ; not to be relocated even when using relocatable instance
  94.     ld      iy,absolute1.t2
  95.  
  96.     ; using the struct offsets - no relocation data needed (offsets are relative values)
  97.     ld      a,(ix+st2.st1A.b)
  98.     ld      a,(ix+st2.st1A.w)
  99.     ld      a,(ix+st2.st1A.relInit)
  100.     ld      a,(ix+st2.st1A.noRel)
  101.     ld      a,st2               ; struct length is absolute
  102.     ld      a,st2.st1B          ; offset to nested sub-structure is absolute
  103.  
  104.     ; using struct addresses (relocatable ones and absolute ones - either should be NOT relocated)
  105.     ld      a,(reloc1.t1.st1A.b)
  106.     ld      hl,(reloc1.t1.st1A.w)
  107.     ld      de,(reloc1.t1.st1A.relInit)
  108.     ld      bc,(reloc1.t1.st1A.noRel)
  109.     ld      a,(absolute1.t2.st1B.b)
  110.     ld      hl,(absolute1.t2.st1B.w)
  111.     ld      de,(absolute1.t2.st1B.relInit)
  112.     ld      bc,(absolute1.t2.st1B.noRel)
  113.  
  114.     ; using relocatable alias (outside of block = no relocation)
  115.     ld      de,(akaT1.b)
  116.     ld      bc,(akaT1.w)
  117.     ld      a,(akaT1.st1B.b)
  118.     ld      hl,(akaT1.st1B.w)
  119.     ld      ix,akaT1.st1B
  120. absolute2:
  121.  
  122.     ASSERT 0 == __ERRORS__
  123.     ASSERT 6 == __WARNINGS__
  124.