home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / program / books / 68k_book / arp_src / prg_2br.s < prev    next >
Text File  |  1985-11-20  |  2KB  |  57 lines

  1.  ; Program Name: RYES_PNO.S
  2.  ;          aka: PRG_2BR.S
  3.  
  4.  ; Assembly Instructions:
  5.  
  6.  ;    The algorithms in this program can be assembled in Relocatable or
  7.  ; PC-relative mode.  But when they are assembled in PC-relative mode, the
  8.  ; code is not always what we want.
  9.  
  10.  ; Experiment 1.
  11.  
  12.  ;    Shows that a pointer, declared in the data section, to a variable
  13.  ; declared in the bss section will contain the correct address when
  14.  ; assembly is in Relocatable mode; but when assembled in PC-relative mode,
  15.  ; the pointer will contain the location at which the variable resided
  16.  ; during the assembly process.
  17.  
  18.  movea.l   _variable, a0       ; A pointer to a variable is loaded into
  19.                                ; an address register.
  20.  ; End of Experiment 1.
  21.  
  22.  ; Experiment 2.
  23.  
  24.  ;    Illustrates that the instructions
  25.  
  26.  ;         move.l #label, -(sp)
  27.  ;         move.l #label, An
  28.  
  29.  ; are not compatible with assembly in the PC-relative mode, and that
  30.  ; the following instructions must be used instead.
  31.  
  32.  ;         pea    label
  33.  ;         lea    label.
  34.  
  35.  move.l    #label_1, -(sp)
  36.  move.l    #label_1, a0
  37.  move.l    #label_2, -(sp)
  38.  move.l    #label_2, a1
  39.  
  40.  pea       label_1
  41.  lea       label_1, a0
  42.  pea       label_2
  43.  lea       label_2, a1
  44.  
  45.  ; End of Experiment 2.
  46.  
  47.  data
  48. label_1:   dc.l      1
  49. _variable: dc.l variable       ; _variable is a pointer to variable.
  50.  bss
  51. label_2:   ds.l      1
  52. variable:  ds.l      1         ; During loading, we want the address of
  53.                                ; this variable to be stored in the
  54.                                ; location addressed by the pointer.
  55.  end
  56.  
  57.