Subversion Repositories pentevo

Rev

Blame | Last modification | View Log | Download | RSS feed | ?url?

  1.         cpu     68000
  2.         page    0
  3.  
  4.         padding on
  5.  
  6.         org     $1000
  7.  
  8.         ; Text string has an odd number of characters, so add a pad byte
  9.         ; right before the machine instruction:
  10.  
  11.         dc.b    "Hello world"
  12.         move.l  $100000,d0
  13.  
  14.         ; Byte strings themselves do not require word alignment, so no
  15.         ; pad bytes are inserted among the dc.b statements.  dc.w however
  16.         ; gets a pad byte in front.  TODO: 68020++ allow misaligned word
  17.         ; access.  Do not pad data statements on them?
  18.  
  19.         dc.b    "Hello world"
  20.         dc.b    "Hello world"
  21.         dc.b    "Hello world"
  22.         dc.w    1,2,3,4
  23.  
  24.         ; Similar handling for space reservation.  The only difference is
  25.         ; that a byte of space is reserved, and no zero byte is written:
  26.  
  27.         dc.b    [5]?
  28.         dc.w    [4]?
  29.  
  30.         ; ds.x is equivalent to dc.x ?
  31.  
  32.         ds.b    5
  33.         ds.w    4
  34.  
  35.         ; Now the nasty details about labels: The label's value should of
  36.         ; course ; point to the instruction and not the (invisible) pad byte!
  37.         ; This ; is the 'simple' case when the label and instruction are on
  38.         ; the ; same line:
  39.  
  40.         dc.b    1
  41. label1: nop
  42.         jmp     label1
  43.  
  44.         ; Some people like putting the label on a separate line.  Though it
  45.         ; is debatable, label fixup is also done in this case, and the result
  46.         ; is the same as in the previous case:
  47.  
  48.         dc.b    1
  49. label2:
  50.         nop
  51.         jmp     label2
  52.  
  53.         ; Putting more empty lines (i.e. lines with at most a comment)
  54.         ; between label and instruction does not change anything:
  55.  
  56.         dc.b    1
  57. label3:
  58.  
  59.         ; blahblahblah
  60.  
  61.         nop
  62.         jmp     label3
  63.  
  64.         ; The 'memory' about the 'most recent label' ends when a non-empty
  65.         ; line (i.e. a line with a statement and/or another label) is
  66.         ; encountered.  So, label4 points to the odd address of the padding
  67.         ; byte, not to the even address of the NOP instruction:
  68.  
  69.         dc.b    1
  70. label4:
  71. pos3    equ     label4
  72.         nop
  73.         expect  180
  74.         jmp     label4
  75.         endexpect
  76.  
  77.         ; Only the most recent label is memorized and possibly adapted.  So
  78.         ; in this case, label5 holds an odd address (of the pad byte...),
  79.         ; and label6 the padded address:
  80.  
  81.         dc.b    1
  82. label5:
  83. label6:
  84.         nop
  85.         expect  180
  86.         jmp     label5
  87.         endexpect
  88.         jmp     label6
  89.  
  90.         ; The same is (of course) true if the second label is in the same
  91.         ; line as the padded instruction:
  92.  
  93.         dc.b    1
  94. label7:
  95. label8: nop
  96.         expect  180
  97.         jmp     label7
  98.         endexpect
  99.         jmp     label8
  100.