Motorola M68000 User's Guide Page 116

  • Download
  • Add to my manuals
  • Print
  • Page
    / 256
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 115
102 Assembly Language Programming for the 68000 Family
The BSR instruction operates identically to the JSR instruction except
that it has the same limited addressing range as the conditional branch
instructions discussed in Chapter 5. The target address of the BSR instruc
tion must be a label. The JSR instruction allows the use of a wider range
of addressing modes. For example, we can place the address of the sub
routine in an address register and then use register indirect addressing.
The instructions
LEA SUBR,AO
JSR (AO)
have the same effect as the single instruction
JSR SUBR
You should use the BSR instruction whenever possible, since it takes up
less space in memory for subroutine calls that are relatively close to the
address of the BSR itself.
Passing Param eters
An assembly language subroutine is normally free to access any vari
ables within a program. You might want a subroutine to use specific
variables of your program as data for its operation. Some variables might
only be examined and not modified by the subroutine. Others might be
modified. An important point is that if a subroutine specifically refer
ences variables other than ones it uses for its own internal purposes, the
programmer is stuck with always using these variables to pass data to
and from the subroutine. From your programming in a high-level lan
guage, you are most likely wondering if parameters or arguments can be
passed to subroutines in assembly language. The answer is yes. By allow
ing parameters, we can make a subroutine more general by not always
requiring the same specific variables to be used to pass data to or from
the subroutine.
Parameters or arguments can be passed to subroutines in a great
variety of ways. There are no standard methods as would be used by
high-level languages. The choice is up to the programmer. In fact, it is
common practice for several different methods to be used in the same
program. The simplest method is to place the parameters to be passed
to the subroutine in one or more of the registers. We did this with the
BIGEST subroutine. Under normal circumstances one or more values are
returned by the subroutine. These values can be placed in the same or
Page view 115
1 2 ... 111 112 113 114 115 116 117 118 119 120 121 ... 255 256

Comments to this Manuals

No comments