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EaEEaEEffE,EfEE@E"TEccE"E}(E XElE&ElE&E߅ETE6EE|aEE`EؑEE#EEEEEE4ER3EEREEETEdE!EEEEEcEEE7EPDE׻EPWE=zEʴE|E*EOEE֮EEgEEE#E.EzEEzEfE{BE4E{EE{EhEkEQEEvEEEEy3EE*EmE*E2E^
EE^E΋EzE?3E}E=EEAEEzEgE6?E"E6E"E6E"EE{eEElEzEEEMEeEaEEE8EAEEvEEE:E$EEEEEEEE'E4EE(jE{EEەEEgEEEҨEN9ExEdERFEERoE}gE^E}EDEE9EETEEE0EFEDKEEEEDqEEELmES\EES|EE{EEEE:EYEEcEE9EPE3E]E3EEaE+vE(E\EEvEEEŌEEE3E1EE#4EDE-REqE-FEQER|EE~qE\E~dE]ZE~kE]vE~E4UE8E'1EOE'EζEEREEAEEWE5ESthe first and last registers separated with a hyphen (R1-R3). You
can also combine individual registers with a range of registers
identified by label.
  Dn  add.w d1 ,d0
 debugging procedure 7-8  command-line options 78-81
 entering commands 16-24adding as tool types 78
 function and special keys 22-23-buffer 78-79
 introduction 3 4-cli 11, 79

  (A7) + n4return address
  (A7)+4+n4argument lefty
 PCprogram counter
 description 294-295  unalias command 92, 188
 examples 295-296 unassemble command 189 190
 -l option 295unassemble option, opt command  86, 167

cycles gadget  267  arrdim option 86-87
the global optimizer:


 The first assignment to index can be removed. Since the global



optalias
 -w
defines the symbol shortint to be 1. This option works as if you



 XREF @cfunc
 HOVE.LD6,-(A7)
If you do not specify a value, the assembler assigns a value of 1.

effective. Briefly, it works as follows:
 329 The Global Optimizer
is the reserved symbol to which the assembler assigns the index of
the last argument passed to the macro in the parameter list.
Compiler Options window 266 See also cross-development mode
compilingexamples 99
 compiling and linking programs 7-nok option 98

  breakpoints and task handling 108
M catch command 112
  CodeProbe features 4-5
watch command 70-72, 192  Workbench process, invoking  80
 dump command 145ENDM assembler directive 305, 307
 NOFORMAT
 cmpi.b #'+',7(a7)  ; should I add?

  You can invoke this macro with the following statement:

  extending across lines using backslashcontrolling program execution
 (\) 18 See program execution, controlling
  function and special keys 22-23 copy propagation 332
  instructions, the peephole optimizer deletes the TST.L instruction:

-d symbol(=value) option, asm command 89-94

  d command 252syntax 165
  executing up to a breakpoint 32 caret (^)
[] (brackets)
 See equals sign (=)
4. after control returns from the called function, adjust the stack
 pointer to account for pushed arguments (if any).

As stated earlier, the peephole optimizer analyzes the assembler
  instructions and replaces inefficient sequences of instructions with
  shorter, more efficient sequences. For example, for the following set of

 MOVE.LD1,D2
 invoking the debugger 26Dialog window

 definition 39View menu  21
 examples 45 46, 186
 integer parameter 45
 stepping into a called function 29 W
 syntax and description 45, 186
IFLE assembler directive 306-L option, diff utility 219
IFLT assembler directive 306label field, assembly language source line
IFNC assembler directive 306300
  commands, specifying  252-253strlen option  86, 167

CSECT__MERGED,1,,2,2
XREFxdata
  prototype for the assembler module in your C source file before calling
  the function. The prototype for the previous example is the following:
log file 6  mixed mode 83-84
loops opt source mixed command 46, 77
relocation information on the 68000:
 specifying addresses 311-314when to use 76-77
vary, depending on whether or not you compile your C function using
the parameters=register option.
moves expressions with a single use adjacent to the operation that
uses them. This optimization helps reduce temporary lifetimes and
supports optimizations that move code around. For example, in the
Part 5
Appendix

 bne.b noadd; no, check subtract
-m2
turns off the warnings generated by the -mO option. Use this option
if 68020 instructions are allowed.326 Chapter 11

  return code in the ret variable.

  .
Catch New Devices option 88
d command catch option 89
  datalDC.W10
 watch and watch break commands  32-34editing function keys 17-18
comma (,) editing modes 17
  are passed on the stack.
function can be recursive if it is designed carefully with this return
technique in mind.
 string parameter 58  editcommand option, scmsg Project menu
 structures and arrays 30-32, 59-61 257
 syntax 57, 143editing modes 17
 value and type of variables 32 ELSE assembler directive 305
 variable types 75  END assembler directive 305
dollar parameter ($)ENDC assembler directive 305
 line command 161env command 150-151
 set command 177environment 6
dollar sign ($)See also debugging environment, setting
 grep search pattern 227, 229, 231up
value from 24 to 100. The default is 60 lines.
 ibytes option 84-85  setting source mode 27-28
debugger may not know about variables that the optimizer moves or
 command 58escape characters in strings 18-19
  SigWait field 109
specifies that the sections designated by x are to be loaded into
 See brackets ([])
 very busy expression hoisting 333
gadgets in scopts utility 267 268
global data, referencing 322-323
  inlines single-call static (local) functions.

MOVE.Wdatal(A4),DO

N -n option 253
  -o option 253
-n option options, specifying 253
-speed command-line option  97symload command 112-113, 184
special keys 23-symfile option 98

 y = temp + 4;
label SET expression
 parameters 40  help command 26 27, 158
 starting execution of sample program 26Help key 23
 cautions for setting breakpoints 106,  sample program 1 37-39
 110sample program 2 53-56
  resident libraries 105, 106See devices option, opt command
opt task command 110 111
 definition 107P
 examples 111
modes:
 displaying watches and watch breaks 69,
 70X
.
.
 302-304G
  F global optimizer 329 333
executing codedisplay command 57
  See program execution, controlling  dump command 145

registers (continued)splat utility 291


EQUR assembler directive 305file comparison
errnum command, SC_SCMSG AREXXSee diff utility
port 263 file dependencies, tracking
 suppressing execution with -noprofiledefining aliases 90
 option 79-80 hiding macros 92
name specifies the name of the control section. You can use the name
  list of commands 116-118cover utility 216-218

 x = i / 3;
  module:
 optalias option 335  -p option 225
 -speed 97  See also cross-development mode
  examples 221-222format parameter 145

 replaces references to a variable with a constant when the variable
  constant propagation and folding
 format 310 generating H DEBUG hunks 8
 description 224 227hypergst utility 240-241


  However, you must specify the parameters=register option in
  335-336pound sign (#)
 machine and the compiler. The concept of a register variable is
 based on the idea that the variable is kept in a register for the
 entirety of its scope. Such restrictions no longer apply when a
 Step Into ResLib option 88 89  decimal option, dump command 65
 strlen option 86.DEFAULT fake target 281-282
 unalias command 92 default files, smake utility 287 288
 unassemble option 86#define capability, C preprocessor 93
 undefine command 94define command 141
actions, smake utility 273altfile command, SC _ SCMSG AREXX port
  optinline. For more information, refer to Chapter 8, "Compiling
  and Linking Your Program," of SAS/C Development System User's
 register assignment 329-330  syntax 224
 long as possible.

 Shell  -q option 290
starting across serial line11running smake 288-290
shortcut keys 23-24, 29, 34 -s option 290
shortcuts for command names 16  smake.def file 287-288
show [activate] command, SC_SCMSGspecial symbols 277

314 Chapter 11
generates an error for the next input line.
FORMAT
is included for compatibility only.
IDNT name
 Part 4
Using the SAS/C
Note: If the XREF statement for the external function precedes the
 using for cross debugging 97, 98-k option 290
 syntax and description 172 SC_SCMSG AREXX port 262-264
 46-47  dumping 61-62, 75
 debugging programs 45-46 verbose option, gst utility238
eliminates.
  If you use the debugger on optimized code, run the debugger in
 mixed mode by entering the following command on the debugger
asm >modn.lst -l modn327
 addressing modes supported 312debug=fullflush option 74
  for (; d < 10.0; ++d)
 -m optlon 295undefine command 94, 191
 See hypergst utility syntax and description 237_238
  macro procedure. End the macro definition with the ENDM directive on

  chapter, describes how to specify each type of constant.313 Using Assembly Language with C Language
  (An)  add.w (a1) ,d0

  XREF label[,label]. . .
You can define symbols to be in the data section by USillg XREF and
XDEF after the SECTION directive. The following exarnple uses 16-bit
addressing to reference both code and data:

SetFunction 114 options 289-290
greater than sign (>)host machine 6, 96
.SET fake target 282-283multiple targets 283
setenv command 11-n option 290

char lefty;
double middle,
int mrright;
264variables
 defining with equals sign (=)  277-278terminating tasks 108
 overriding definitions 278trap handling 113-114
 referring to macros 278  types of tasks 108
Map Options window 267  -m0 option, asm command 325
MASK2 assembler directive 306-m2 option, asm command 325
 parameters=register option 318-319  prev command, SC_SCMSG AREXX port
 d16  a 16-bit displacement
 examples 1 73  SC_CPR 101
 running go command before using 30See also AREXX macros
 See SECTION assembler directivedebugging applications 99348 Index


Constant propagation is often useful in programs that contain
 break command 48-53  surrounding character strings 19
errors and warnings, searching forSee smake utility
 See scmsg utility  file-matching algorithm 341-342
option results command (AREXX) 103beginning AREXX templates 261
optionsspecifying binary numbers in assembler
 See also command-line options
absolute addressing modes 313aliases for dump command in previous
absolute expressions 304  releases 146 147
accelerator keys 23-24, 29, 34alternate targets, smake utility 283 284
actions gadget 267262
activate command 107, 111, 127altline command, SC _ SCMSG AREXX
Address field, tasks command 109  port 262
changes to addition loops containing multiplications (usually those

You can address the arguments from A7 as follows:


  (A7)+8+n8argument middle
  (A7)+16+n4argument mrright

  Using the parameters=register Option
  Using the parameters=register option tells the compiler to pass
  some of the function arguments in registers instead of on the stack.
  Specifically, the first two pointer arguments are in A0 and A1, and the
  first two integral arguments are in D0 and D1. All other arguments
Break menu 21 22320-321
breakpointssaving register contents 317-318

defines a program unit name.
 quitting the debugger 10, 34altering contents 67-68
trace option, break command 51, 52  53,-w command line option 80
filename. If you specify a directory name as a prefix, include the (/).
  itself. After the MACRO directive, enter the lines that constitute the
 size 300support for escape characters 123
 dynamic by default 70XDEF assembler directive 308
The compiler identifies functions that expect arguments in registers
infinite loops 112See oml utility
 y = (i + j) * 2;

inserts a page break into the listing file.
assembles if the expression is greater than or equal to 0.
  by placing an @ in front of the function name. The @ replaces the
maximum bad characters  -m3 option, asm command 326
compiler options, settingstarting the kernel 98
 list option 86stepping over code 29-30
  -screen command-line option 80
  Sscratch registers 318

 See peephole Optimizer peephole optimizer 329
  for (i = 0; i < n; ++i)

  NotationMeaning
is included for compatibility only.
__MERGED for near data. You can use a specific name only

 commands for running sampledelete block, diff utility 220
bne.b noadd  ; no, check subtract

 can be changed to

The effect of global optimization's register allocation is quite
in the following function call, the compiler generates code to push the
arguments mrright, middle, and then lefty onto the stack.
search option, opt command87-88, 166 addsym option 8, 9


Qdetermining variable values 77
altering register contents 67-68
See also fregister command
break command 48-53, 135 136functions
 assembler statement size suffixes 302 See calling C functions from assembler
  See also bclear command  C mode 83
SET assembler direetive 307 local input files 284  286
set eommand 177 178 macros 277-281


; (semicolon)
EQU assembler directive 305 fake targets, smake utility 281-283
Using Macros," describes how to define and use macros.
 MASK2
instruction bytes-line command-line option 11, 79
 See ibytes option, opt command line parameter, location parameter 41

  Mode  Example

 See semicolon (;)
 Istat utility 244 248task option, opt command 107, 110  111,
Step Into ResLib option167
 See reslib option, opt commandtasks

dead code elimination
eliminates code that never can be executed.

common subexpression merging
the parameters=register option or use the __asm keyword, C
  copy propagation
-nok option 98  OpenLibrary function 114
* Heckel, P. (1978), "A Technique for Isolating Differences Between Files,"
Communications of the ACM (April), 264-8.342 Appendix
 separating multiple arguments in display entering on command line 16-19

  The algorithm will fail to match the blocks of xxx lines because it does


prevents the specified segments from being loaded into chip-
However, the algorithm frequently cross-matches single lines or two
blocks of lines. That is, lines L and L+k may be matched to lines L1
and L1-j. Consequently, after the process described previously is
completed, the matches must be untangled to generate a coherent
  setting 27-28, 83-84  displaying 30-31, 57, 59-60
start command 181-182 -t= option, lstat utility  244, 245-248
 See also restart command target files, smake utility 273
-dsymbol [ =valuel
defines symbol as if your source file contained this statement:
  symbol EQU value
 syntax 39  Help menu 16
reslib option, opt command  88-89, 167  automatically 8
restart command 172-173debug=symbolflush option 9, 25
 compared with start command 181  link option 9


You can specify the displacements, data, and numbers in decimal,
  hexadecimal, octal, or binary format. The information on entering
 cmpi.b #'-',7(a7)  ; should I subtract?
the sc command as follows:
sc parameters=register test
 CSECT directive 310 314  backslash character (\)
  Mode  Example

 options supported  324  326  special symbol in smake utility 277
 s option 326 specifying octal numbers in assembler
go command 39-44, 156-157 unload option 238

  CSECT statement, you can use a standard JSR instruction to a 4-byte
sc math=868881 test



 communicating with C language 314-323definitions 92 93, 141
 control sections, defining 309-314 referencing aliased commands 92
 expressions, specifying 302 304continuing lines in aliases 90
AREXX port 264syntax 273, 289
SigWait field, tasks command 109-t option 290
.SILENT fake target 283 terminology 273
report of the differences. Therefore, the diff utility cross-matches
The x can be one or more of the following:
  file. The title can be no longer than 40 characters.
  same asm, sc, and slink commands as shown in in the section
  in the section "Passing Parameters on the Stack." You also use the
  "Passing Parameters on the Stack."
135-w option
traceback information, displayingasm command 326
 See tb utility diff utility 220362 Index

 Low|work area |
[] Sweep downward into the first file. Each time you come to a line L
that is already matched to the line L1 in the second file, examine the
next line. This second line is referred to as L+1.
[] If L+1 is the same as the corresponding line L1+1 in the second
file, then match those lines as well.
  return code in the ret variable.
defines offsets. To define a table of offsets using the DS directive,
you use the OFFSET directive. To end an offset section, use a
had specified -dshortint= 1.

  invoking 250unassemble option 86, 167
  I command 252 opt env command 112356 Index

 go command 26, 39-44Diagnostic Message Options window  266
 online help 26-27echo mode 84
= (equals sign)
 induction variable transformations 331running the debugger on optimized code
  P[i] = f();
334 Chapter 12

 -m3
turns off the warnings generated by the -m0 option. Use this option
instructions and C source lines in the source window. Use the
assembly language code to determine if the variables you examine are
actually located where the debugger thinks they are.338339
  File 1  File 2
 defining communications parameters 97See structures, displaying
 examples 99  DC assembler directive 305
 See less than sign (<)
+ (plus sign)
 JSR  cfunc;call function
 ADDQ #8,A7;restore stack ptr
 MOVE.LD0,ret  ;save return value

PLEN n
 example 106sc.examples drawer 25
 libraries.cpr AREXX macro  106saving option settings in scopts utility
 limitations 106268-269
 setting breakpoints 105sc command
various control flow transformations
  -o option 219syntax 61, 145
  parameters 202  CNOP assembler directive 304
Global Optimization and the Debugger

is included for compatibility only.307  Using Assembly Language with C Language


  void main(void)
  {
char lefty;
double middle;
 defining assembly language macros  308exception hand0ing 113-114
 escaped macros not expanded 92-93opt task command 110 111

 optimizing 329-330 tb utility 295
 saving contents before retrievingsample CodeProbe session
 arguments from stack 317See CodeProbe sample session
  comment lines, cprinit file 82examples 81-82
  temp option 52-53, 135  passing parameters on the stack 315  
  asm command 326 devices option 88, 166
|  return address |
 break command 48-53syntax 93, 141
  error messages to that file.
  SECTION__MERGED,DATA
 syntax 46, 169 lstat utility 244
 See also define command  detach command 111-112
  Pri field 109 U
 finding specific tasks 112
  If you are not using registerized parameters, follow these steps:

address parameter 118-119ampersand operator (&)
  {
By default, the assembler loads the segments into memory not
  instructions. If you find additional patterns that the optimizer should
StackPtr field, tasks command 109smake utility 290
after optionargs command 130
INCLUDE directives. You can enter up to four -i options. The
screen. The listing displays the appropriate location counter and


  underscore (_) that the compiler normally places at the beginning of
 See also cprinit file  quotes, double (" ")
 assembler statement expressions 303syntax 98
 See scopts utility terminating 99-100

individual registers by separating each register with a slash

wclear command 34, 194  referencing global data 322-323
-wdialog command-line option  81using with CSECT directive  311-312
 caution when using variables for rangessmake utility 290
 71 stripping debug information 96
 For example, the following command assembles the file named
 modn.a, produces an object file named modn.o, and generates a
 listing file named modn. 1st that lists the source code and any error
 messages:

 smake utility 290special keys 23
 asm command 325  menu accelerator keys  23  24, 29, 34
-i option 17-18
ibytes option, opt command 84 85, 166
IDNT assembler directive 305
IF assembler directive 305L
IFC assembler directive 305
IFD assembler directive 306 l command, oml utility 252
 See caret (^)
 w OptiOII 326  333

 optrdepth
 -v option 291
  acopyd0,a5


  combine these object modules into an executable file, called a load

;this program.
 xdef _func

exits the macro expansion. This directive is a synonym for MEXIT.
FAIL

Passing Parameters on the Stack
 small cost in time for every loop that is not executed. There is also
 equal to 0. When optloop has been specified, there may be a
  labels from other modules and from routines written in the C
  language.
  references an external symbol defined with the XDEF directive.
 Defining and Using Macros

MOVE.L VAR1,D0

Running the Assembler
 multitasking features 4-5  -i 79
Using the __asm keyword on a function prototype or definition tells
 controlling 8  extending commands across lines
Next, the func module is called, and the return address is pushed
onto the stack. Figure 11.1 shows the stack after the func module has
been called.
if 68030 instructions are allowed.

 optimization creates a constant of the correct type. If the variable is
 optloop.
  the parameter placed.
rts
defines a constant block in memory. Using the DCB directive is
[label] DCB[.size] n,expression

quit command 170  registers
 See environmentfiles required 96
statistics utilities  task addresses 111
 Iprof utility 242-243task ID 110
stepping through codeSee also multitasking programs,
 See program execution, controlling debugging
strcat function 208 displaying current task 89
strcmp function  209turning task catching on or off 89361 Index


| | <-- A7+n
  Using the parameters=register option is similar to passing
parameters using the stack. For example, make sure you:
  See at sign (@)
{} (braces) ' (single quotes)
 setting on structures or arrays  71referencing global data 322-323
  LocationSizeContents
program counter-relative addressingsurrounding character strings 18

optimizing codeSee grep utility
 See global optimizerpausing 179
optloop option, global optimizer  335-336 definition 29, 39
optrdepth option, global optimizer 336examples 47, 168
336 Chapter 12
SECTION TEXT,CODE
  .
 parameters=register option 318-319extending commands across lines 18
 register-direct addressing modes  313AREXX macros 101-104
 when clause 42 44, 156 hidden option, scmsg Project menu  258
  returning values to calling function
  attaching actions to 50  53 stack, example 317
  return;
  }
 used only as a constant, global optimization eliminates the variable
 entirely. The following example demonstrates these optimizations:

assigns temporarily the value of the expression to the symbol
SPC n
label REG R1[-R2][/R3 [-R4]] . . .
assigns permanently the register list to label. You can specify
(R1/R2/R3), or you can specify a range of registers by specifying
(R1/R3-R5/R7). The assembler translates this list into the register
  ReturnLength
sends a listing of the source file to the standard output, usually the
badchar option 87
autoswap mode 88
Dcase option 85
  .
dir= option, cover utility 217
disassembling object modules (omd utility)  E
249


Technique for Isolating Differences Between Files by P. Heckel.*
The matching algorithm described by Heckel is simple, fast, and
 -c option 225  hunks command 159
 error messages 234 236 hyphen (-)
 examples 227 specifying range in grep search 226353 Index
 LLEN n
sets the number of characters per line in the listing file. n can be
 IFGT expression
 opttime

  type  specifies the type of section. A value of 0 indicates a code
  Calling Assembler Functions from C Functions 
moving invariants out of loops
  specifying in oml utility 252-253changing the default environment 11
INCLUDE assembler directive 306 libraries, managing
  comment field, assembly language source cprinit file
line 301 comment lines 82
 global optimizer (GO)
immediately above the 4-byte return address in the stack. For example,

command command line option 79expression parameter 120347 Index
 using 110 111grep utility 225
optalias option, global optimizer 335 smake utility 290
but it is modified to use the __asm keyword.


  Returning Values to the Calling Function
  Your assembler module should return values in one or more registers.
  The register(s) depend on the data type of the calling function.
 examples 118-119 identifying addresses 118
 using with location parameter 40 using with global optimizer 330
 overriding default format  57SC_SCMSG AREXX port 262-264
 indicating macros 277, 278representing state of the machine 14
 positional parameters in aliases 90, 128  run environment 6
 prefixing register names 119 user environment 6351 Index 

 asm command 326See cprinit file
 grep utility 225See profile scripts
 oml utility 253  scsetup utility 9, 271-272
 smake utility 290search command 176359 Index
search path 87 88generating H_SYMBOL hunk 8
searching for expressionsstripdebug option 77
 See grep utility smake utility 273 290
searching for patterns  -a option 289
 rulming the assembler 323-326bclear command 131
  nooptpeep
  {
  i = 10;
  cases where it previously would not have been. For example, the
optinline option, global optimizer 335functions 334


 generating H_SYMBOL hunk 8values returned from CodeProbe
 which statements are executed more heavily, it can use the loop
{
config= option, scmsg utility 255option 96
 clearing 34tb utility 295
moves a calculation in a loop, whose value is the same on each

 32-33dumping 62-63



-hx
  If you are using registerized parameters, follow these steps:
utility. The algorithm used by the diff utility is described in A
skips n blank lines in the listing file.308 Chapter 11
 grep utility 225 r command 252

 See whatis commandradix option 86, 167
rsize of 4, the assembler uses absolute addressing. If you
 removing all aliases 92using in cmd_list parameters 50
345 Index

the compiler to pass parameters in specific registers.

iteration, to the outside of the loop. For example, the loop
 task addresses 111 -p option
 task-lD argument 110 diff utility 2Z0
optcomplexity option, global optimizer 335 PAGE assembler directive 307
optdepth option, global optimizer 335parameters=register option  318  319
addressable by custom hardware, if it is available. This action325 Using ~ssembly Language with C Language
 determining address 112-d option 289
select command, SC_SCMSG AREXX port default (.def) files 287-288

Special Characters  @ (at sign)
 modify the variable's value in memory. The same condition applies
 to an external variable because it may appear in another function
 or the & operator may be used with it elsewhere.
 different from the use of the register storage class. In general, a
 variable declared using the register keyword is associated with a
return a pointer to this object in the D0 register. The calling function
 definition 304 using 76

  You can define a macro using the following sequence of directives and
  instructions:

  data2DC.L20
  If the assembler module returns a structure or union, it must define
 optinlille option 335patterns containing special characters,
 optinlocal option 335  specifying 232 234
 optloop option 335-336-q option 225
you want to assemble. The assembler assumes a source filename
extension of .a, and it produces an object file with the same filename
but with the .o extension. You can then use the linker, slink, to324 Chapter 11
  a line by itself. You can use the EXITM directive within the macro
  procedure to exit the macro before the ENDM directive.
RTS
 afunc  JSRcfunc(PC)
XDEFafunc

  Type  (Bits)  Syntax  Meaning
  For example, the following code calls the function cfunc with two
 host machine 96  DCB assembler directive 305
XREFcfunc
__asm keyword 319  320  autoedit option, scmsg utility 255
Currently, the peephole optimizer optimizes 22 patterns of assembler
 clearing watches and watch breaks 34


;  NOTE:  This code assumes that you have a math co-processor.
  examples 136calling assembler functions from C
displaying register contents 67
macros, smake utility 277-281 synchronous tasks 108
variables, temporary values, and constant values should be assigned

assembler directives 304-308autoswap mode 29, 88
[]  use the same asm command to assemble your assembler code.
[]  use the same slink command to link your C code.

Using the __asm Keyword
 passing parameters on the stack 315-318  interpretation in character strings 19,
 referencing global data 322-323  123
auto variable elimination and remapping
 optimizer avoids incorrect exceptions regard0ess of the setting of
  defines the maximum level of recursive function calls to be inlined.
  }
% (percent sign)


  the _\ts_inline keyword.
 machine register throughout the entire block in which it is declared

  Appendixdiff File-Matching Algorithm
  yyy zzz
;  NOTE:  This code assumes that you have a math co-processor.
;If you do not, your machine will crash when you run
;this program.

minimal.
In addition, this algorithm must first seed itself by identifying lines
that occur exactly once in each file. Therefore, this algorithm may fail
to match any lines even when there is an obvious match.
 location parameter forms 40 42 H_DEBUG hunks 7, 8
 fadd.l 16(a7),fpO  ; add 'mrright' to 'middle'
 go command 40 42, 156See pull-down menus
 image parameter 42, 120merge option, cover utility  217
OFFSET assembler directive  307rangelen option 87, 167
omd utility 249reslib option 88 89, 167
oml utility 250-254search option 87-88, 166
  chapter.

  disables typebased aliasing assumptions. If optalias is used, the
Run menu21  saving option settings 268-269

  ModeExample

 -r option 295underscore (_)
Appendix
diff File-Matching Algorithm
 optsize option 336-s option 225
 opttime option 336single character, specifying 228
single stepping through programs 29,-u option 290


NOLIST
tells the assembler to stop producing a listing file.
sets the number of lines per page in the listing file. n can be any
list mask format used by the MOVEM instruction.
[label] RORG n
sets the program counter to n bytes from the start of the current
relocatable section.
[label] SECTION name[,type]
  function names.
 single quotes (' ') around 19  floating-point instructions
 string parameter support 123 assembler statement size suffixes 301
  go command as last command of cmd list functions 314-321
 parameter 51 __asm keyword 319-320
 splat utility 291env option 112
Object Module Disassembler 249examples 167
Object Module Librarianibytes option 84-85, 166

Refer to the explanation for optloop later in this chapter for
more information about this type of optimization.

 bra.b exitpoint; ready to return
  defined. The rtype and rsize parameters define how to access the
  external address.
  double (IEEE) 64  D0.L,D1.Lhigh bits in D0
  list of functions 203 135
 expressions with a different type (for example, if an int variable is
  The test program will pass parameters on the stack. When you run
  test, you should see the following output:

  if (expression
number parameter 121opt command 82-89, 165 167
numeric keypad modes  17  arrdim option 86-87, 165
 fields in source line 300-301 Control-\ for terminating oml 251
 format of source lines 300escape character in grep searches 227,
 macros, defining and using 308231, 232-233
 options supported by assembler 324-326 escape character preceding semicolon 93
previously within the same function. For example, the following

 starting 25 34setting up in Workbench screen 11
 -s option 295  replaced by @ sign for compiler 318

tells the assembler to stop inserting page breaks and title headers in
go main command 26, 80  hidden option, scmsg utility 255
 commands 19flags, modifying
 See oml utility  ignorepath option 85, 166

  a[i]= temp;
optimized code, rumling debugger on  pass count 7, 40, 42
the variable is unused because of previous optimizations.
 used. The assignment can be eliminated as in this example:
  See also bdisable command-c option
 examples 68-69, 197  -z option, Istat utility  244

 bra.b exitpointfrom 'middle'
 syntax 294-unit command-line Option 97
size suffixes, assembler statements 301-302  source command 78, 180

coprocessor is present, four floating point registers for the use of
 illustrations 26global symbol information 8
 windowing interface 12-16  -startup 26, 80
  The range is 0 to 6, and the default is 1.
 line mode 11-command 79
optsize option, global optimizer 336  integer parameter 47
 memory configuration:
size field, assembly language source linesmake.def file 287-288
300smakefile 273
slash (/)source file

xdef _func

  -I option 219ranges, dumping 62-63
language, you can run the Assembler by entering the asm command as
After you have created your modules or programs in assembly

The size depends on whether you specify the shortint compiler OptiOII. A char


As previously stated, C functions pass parameters on the stack if you
do not specify the parameters=register option or use the __asm
power of 2. For example, an alignment of 1 means that the
section will begin on an even address, and a value of 2 means
 most are.
Some types of code may cause an exception, for example, division
 by 0. For this reason, the global optimizer restricts moved code to
sequences of instructions with shorter, more efflcient sequences.
environment variable (sc/cprpath) 11FAIL assembler directive 305
equals sign (=) file command, SC _ SCMSG AREXX port
 example 169lprof utility 242
public screen, specifying  80omd utility 249
public symbol 250oml utility 251
very busy expression hoisting
moves an expression that is computed along all paths from a point
in the code to a single, common location. For example, the code
 defining macros in smake utility 277-278 263
 (usually the entire function). In most functions, the variable is
328329


  void f(double d)
  for (; d < i; ++d)
opt source asm command 46Output window 15
opt source mixed command46, 77, 84,  overwrite editing mode  17
336
escape characters 18-19 File menu
  TTL title
 only used in a comparison with f loat variables), global
 setting 46, 83bottom command, SC_SCMSG AREXX
 examples 314 using in grep patterns 227
The following sections describe how to call assembler functions from C
functions and how to call C functions from assembler modules.

  The assembler expands the macro as follows:
 debug=line option 75 restart command 26
 -b option 219compatibility aliases 146-147
  char  8D0.Blow byte of D0
  call command 137-138
Using the ampersand (&) operator with a variable prevents the
 global optimizer from allocating that variable to a register because
 it cannot predict when the resultant pointer will be used to read or
 heavily used in some places and not used in other places. Yet, if a
 machine register is assigned to the variable, then the same register
  disables optimizations that might sacrifice time to save space. The
 creating 33using with CPRX 99
 function 69-70 defining symbols in data section  309
-wb command-line option 11, 80XREF assembler directive 308
diff file-matching algorithm  341-342 ASCII option 65-66
103config=option 255
 [] passing parameters by placing them on the stack. Unless you specify
 alias command 19 Line and Find Current Line items 20
 backslash (\) in character strings 19menu items and command-line
 backslash (\) in grep searches 227 equivalents 20-22
 character strings 18-19finish command 100, 154
 double quotes (" ") around 18-19 See rflag command
 dumping with ASCII option 66float option, dump command 64
exception hand0ing 113-114  floating-point numbers
memory not addressable by the Amiga system's custom hardware.

b bss or uninitialized data
c code segment
d data segment


 noadd:
  Guide, Volume I: Introduction, Compiler, Editor.
directives up to a depth of 3.
 LIST


addressable memory even if no other memory is available. This
int func (char lefty, double middle, int mrright);
optloop
  assumes that loops have multiple iterations when the number of
  iterations is variable. This assumption enables the movement of safe
  The lefty argument is placed into register d0, the middle argument

temp = i * m;
functions 15
for (j = 0; j < m; ++j)
nested breakpoints 52 x command 252
NARG assembler directive 306  -v option 253
networks  -x option 253

action could also prevent programs from running if external high-
  setting up new projectsoverriding macro definitions 278
See scsetup utility -p option 290

 second character in Dialog window's title specifying location 77-78

 moving invariants out of loops  331  336-337
Iprof utility 242 243 setting 83-84
Istat utility 244 248module 7
 -f option 244  module parameter, location parameter 42
restoring previously saved options in scoptsscmsg utility 255-265



Part 4

 See also specific directivesautoswap option, opt command 88, 165
assembly language 299 326
 memory addressable by the Amiga system's custom hardware. You
 should specify -c for screen image and audio data. The x can be
 scmsg utility Project menu optionsPri field, tasks command 109
 257 258printing expressions
IFEQ assembler directive 306-l option
 bar 17 source line fields, assembly language
sleep command 179 300 301
slinkcomment 301
[] After this downward sweep is completed, sweep upward in the first
 displaying variable values and types  32  detach command 111-112, 142
wait option, scmsg Project menu  258  where command 110, 198
that the section will begin at an address divisible by 4.
  Note: This parameter is not used on the Amiga. All sections
are long-word aligned.

m  lists additional data generated for source lines that camlot be
listed beside the original source line. This option allows
 odthe 32 bit outer displacement
 Xnan index register (a0.w--a7.1)
 xxx  any number in decimal, hexadecimal, octal, or binary format
  inlines small functions (as defined by optcomplexity) as well as
  (An)+ add.w (a1)+,d0
 See splat utility  actions performed by 274
watch breaks 32-34window command 199
 bne.b nosub; no, exit with error
340341
Watch window




 after clause 42, 156 verbose option238
file must correspond exactly with the lines in the object code file.


 The previous code can be changed to the following:
 executing until variable changes valuedevice command-line option 97
  each mode. The notation used in these tables is as follows:
rexxonly command, SC_SCMSG AREXX rexxonly option 256
Project menu, scmsg utility 257-259re-attaching tasks 112
  The SAS/C Macro Assembler does not assume any default control
  the default. Specifying both opttime and optsize may result in
When you use __asm, the calling C function places the parameters

 inline functions since one or more parameters to the inlined
opttime option, global optimizer  336 syntax  46, 168357 Index
 safe operations, including integral and pointer arithmetic other than

  defines the maximum depth of function calls to be inlined. The
IFGE assembler directive 306  diff utility 219

 forcing 31]quotes, single ('')

 Figure 11.1| Bottom of Stack |


analyzes the intermediate code produced by the compiler, performs
several types of optimizations, and produces output in the same
- (hyphen)
 See hyphen (-)
- (minus sign)
 See minus sign (-)
, (comma)
 See comma (,)
opening 335x command, oml utility 252
 specifying start-up window coordinates-x option
AddTask function 114AREXX port 262-264
 purpose 74 commands 103-104


 pointer to account for pushed arguments.

  code out of loops. The optloop option is the default. For more


section code
_func:
cmpi.b #'+',d0; should I add?
fadd.l d1,fp0; add 'mrright' to 'middle'
bra.b exitpoint  ; ready to return
various reductions in strength
performs associative reordering of additive operations involving
constants to reduce the operation count.
319 Using Assembly Language with C Language

  Chapter 12 Optimizing Your Code

  .
pull-down menus 20 22splat utility 291
 See also specific menustb utility 294
 list of pull-down menus and command-line  REG assembler directive 307
 very busy expression hoisting 333error messages 239
global symbol information  8  examples 238 239
global symbol tables  list optlon 237 238
 See gst utility  options supported 237 238
 completing execution before running other
 commands 30H
 examples 44, l56 157
 executing until breakpoint 30, 32 -h option
 last command of cmd list parameter 51asm command 324-325
eliminates recalculation of values that have been computed

  parameters that are currently in registers D7 and D6 and stores the
 MOVE.LD7,D0

  #include <stdio.h>
 MEXIT
assembler modules that are compatible with C programs compiled with
  You can force program counter-relative addressing of data in the
code section by specifying an rtype of 0 and an rsize of 2. The
assembler will search for the files in the order in which you specify
  name  specifies the name of the control section. You can use the name
will be promoted to an int.318 Chapter 11

  may be restored when your function terminates. Scratch registers are

exitpoint:
fmove.l fp0,d0  ; return 'int' in d0
end
 activating autoswap mode 29examples 141
starting the debugger 25-34 alternate targets 283 284

Optimizer Optiolls window  266  patterns, searching for
 functiolls 314 321 smake utility 289
 calling C functions from assemblerback-tick character (`)
  z option 244activate command 111
  asynchronous tasks 108

noadd:

cmpi.b #'-',d0; should I subtract?
 cannot be reused even in those sections where the variable is not
Listing/Cross Reference Options window
  K 266
follows:

 See also wdisable command  running CodeProbe 10-11
 The Peephole Optimizer
 running cross debugger 96-100DEBUG tool 11
  instructions, but the peephole optimizer can help catch the few places
  where this is not possible.
 starting the kernel (CPRK) 98  list of options 74
 forcing program counter-relativewhen to use 76-77
  .
  .
  p[temp + j] += 1;
IF expression


 81 omd utility 249
default value is 4.311 Using Assembly Language with C Language


}
nosub:

reordering of operations to reduce value lifetimes
 Memory |of size n |
it points to the 4-byte return address.
68020 are optional.
speed memory is not available on the machine. For example, the
equivalent to using the DC directive n times.
-m option, tb utility 295 commands for controlling tasks 107,

336-337specifying 135
assemb]es the following statemeIIts to the next ELSE or ENDIF if
in the registers required by the assembler module, so no stack
manipulation inside the assembler module is necessary.
  information, see "moving invariants out of loops," earlier in this
 adding to slink automatically 8, 9return codes 103
 break command 49, 135  array-slice parameter 119-120
program execution, controllingenclosing literals in assembler statement
 See also debugging programsexpressions 303
 continuing execution 30
 controlling debugging session 27-34-wsource 81
  trace option 51, 52-53, 135 retrieving parameters from the stack
  when option 49, 135317
  caution against placing in libraries 110calling C functions from assembler

  XDEF label[,label] . . .
  u option 295unload option, gst utility 238
  directives allow you to name each control section. The assembler uses

  The code generator contains all of the knowledge about the target
 hardware. For example, the following command causes all segments
 to be loaded into chip-addressable memory, regard0ess of the system
gotoline option, scmsg Project menu 258263
 displaying value and type of variables 32
 alias 89-92DS assembler directive 305
 customizing 89-94  dump command 61-66, 145 147
 wclear 34addresses, dumping 62
lists gadget 267
  -(An) add.w -(a1),d0
  d16(An)add.w 10(a1),d0
  d8(An,Xn) add.w 10(a1,a2.l),d0
  bd(An,Xn) add.w $10000(a1,a2.l),d0  (68020 only)
  ([bd,An],Xn,od)add.w ([10,a1],a2.l,20),d0(68020 only)



  these named control sections to control the location of data and code
  during linking.
Chapter 12, "How Does the Compiler Work?," in SAS/C
  sets the title string that is printed in the page headers in the listing
c code segment
d data segment

 By default, the assembler loads the segments into memory not
  XREF  xdata
. (period)
 definibon 69 80
assembles if the expression is less than or equal to 0.
  VAR2 DC.L $8000
 specifying immediate data 314debug=symbolflush option 74
should immediately move the data to the appropriate place.
 go command 40, 42, 156 arrays
 syntax errors 43-44Help window 14
The following table shows examples of program counter-relative
  addressing modes:

 creating 33See also specific windows
 clearing 34  windowing interface 12-16
 example 34 functions of CodeProbe windows 14-16
 function 70opening windows 15
 marked by exclamation mark (!) 33  screen layout 12-13
gotofile option, scmsg Project menu 257hide command, SC_SCMSG AREXX port
utility 269autoedit option 255
results variable, AREXX 103  Build menu 259
return codes available to AREXX macroscommand options 255-256
  22A4-relative address (BSS section)
tells the assembler to produce a listing file.
keyword.
  For example, the following assembler module, func, adds or
  -p Option 220 dzero command 148
  -q Option 220displaying ASCII text string 66
  syntax and description 219-221  examples 31, 148
  -w Option 220syntax 148
 See also wenable command  specifying with -screen command-line
 See also wlist commandoption 80
defines a program section. name is a character string, and type must
be CODE, DATA, or BSS. The section "Defining Control Sections,

In mixed mode, the debugger displays both assembly language
  The Stack after the| |  
  go command 40, 42-44, 156363 Index
 setting and showing within CodeProbe See grep utility


if (expression
 See also wclear commandinvoking CodeProbe 11

 nosub:
 fmove.b #-1,fpO; return -1 for error

  Mode  Example

  ([bd,An,Xn],od)add.w ([10,a1,a2.l],20),d0(68020 only)
 is defined as that constant. If the variable is used only in
{
compiler). The default value is 0 (code).
subtracts an integer argument and a double argument depending on
whether a plus ( + ) sign or a minus (--) sign is passed in the
the expression supplied as its argument is not 0. IF statements may
be nested.
IFC string, string
assembles if the strings are identical.306 Chapter 11
 reduction5 in strengtll 333  specifying patterns  225-227
 reordering of operations 333 -v option 225
 runnirlg 333_337 -V option 225
 returning values to calling function  special symbol in smake utility 277
  examples 254task option 107, 110-111, 167
optinlocal option, global optimizer 335running 334
-k option, smake utility 290LLEN assembler directive 306
 stepping into called functions 29  rangelen option, opt command 87, 167
 stepping over code 29-30ranges
 trace commands 45-46  caution when using variables for setting
compilerrunning 96
following code, the computation of the address ~ p 1 i ] can be
exclamation mark (!)  dumping 64-65
 setting on structures or arrays 71windows displayed in scopts utility
 oml utility options 253  inserting before undefine command 191
 scmsg utility options 255-256263

  not find any lines that occur exactly once in each file to seed the
  algorithm.343


 -m3 option 326oml utility 251, 253
alias command 89-92, 128-129  displaying 31, 59-61
entire function, even subtle dead stores are eliminated.
  rtype specifies whether the code or data in the section are addressed
44-47-x option 290
-noprofile command-line option 79-80  assembler statement expressions
nosource option, cover utility 217  303-304
NULL modem cable for cross debugging 96 OPSYN assembler directive 307
  autoswap option 88, 165
 IFND symbol
  StackPtr field 109  -u option
  State field 109asm command 326
 section code
When a loop is not executed at all, the moved code is executed in
  code


  registers D0, D1, A0, A1, FP0, and FP1.
  want to pass in a register, precede the parameter with the register
  keyword, two underscores (__), and the register into which you want
The prototype for the previous example is the following:
 In the changed code, i*m can be calculated when m is less than or
  is placed into register fp0, and the mrright argument is placed into
moved after the call:
  processor and its instructions and makes full use of the 680x0
  instruction set. The code generator tries not to generate extra
 when to use debug= options76-77  compared with alias command 92, 93
debugging programs 25 34, 35 72compared with C preprocessor #define
 BNE  LABEL
eliminates unused auto variables and reassigns storage offsets. Often
 x = i + j;
else
 See also quit command
The effect of the matching algorithm is to match blocks of text to each
other in the two files.
Index

 debug=symbolflush option 76  sample program 1 37-38
 specifying in assembler statements
 TST. LD2
unions are not re-entrant, although they are serially reusable. Such a

  You can access data declared in a C function from an assembler
The following list describes the steps your assembler module should
later in this chapter, discusses the SECTION macro.
 See underscore (_)

  and link test with the following commands:

> (greater than sign)
----------------------------------------------------------------------------
For example, you may have two files with the following contents:


  aaa bbb
 -o option 291


  Note: All fields of the operands on the addressing modes marked
  The following table shows examples of register-direct addressing

  An  addq.w #1 ,a1

  The following table shows examples of register-indirect addressing
objects, determining type or configuration  list option 86, 166
invoking the debugger See slink
return command 174Edit menu 260

  setting 32, 47-48catch option, opt command 89, 166

tasks command 109 110, 185transformation rules for macros, smake
  using for cross debugging 97@ command 253
-s option script files
  To use 32-bit addressing, remove references to the register A4 and to
Anesting aliases 92
 positional parameters 90
 addressable by custom hardware, if it is available. This action

.
 proceed commands 46-47functions 14

  temporary, set by go command 40, 43 change block, diff utility 221

character argument.
  For example, you can write the following program to call the f unc

SECTION assembler directive309-310  alternate targets 283 284
 valid types and sizes of relocationadding to sc command 9
 See also multitasking programs,  capability 93
  syntax of opt source command 83 setting watches or watch breaks 71
optimizer inspects all references to the variable throughout the

register __d1 int mrright);

  register d1.
equates an address or data register with label.
 location parameter 156smake utility 290
  assembler module in your C source file. For each parameter that you

int __asm func(register __d0 char lefty,
register __fp0 double middle,
The remainder of your C program is the same as that shown earlier
relocatable expressions 304 commands for running sample
 See also redirecting output (>)hunks
 setting ranges 71  266-267
 slow execution while using  33, 72wlist command 69, 71, 200
MACRO assembler directive  306  109 113
macrosdeactivate command 111
 IFLT expression
assembles if the expression is less than 0.
The following assembler code is the same f unc module that is
described previously in the section "Passing Parameters on the Stack,"
bne.b nosub  ; no, exit with error
320 Chapter 11

CSECT statement, you can use a standard reference to a four byte
external address.
XREF statement for the external function must appear after the CSECT312 Chapter 11
 fmove.d 8(a7),fp0  ; middle



 menu accelerator keys 23-24-device 97
 opening windows 15-16  -line 79
  func Module Is High| mrright | 
  Called Memory | | <-- A7+12+n

code
 marking watch breaks 33  hexadecimal notation in assembler
.
  defines an internal label as an external entry. By using the XREF
  directive, you can then refer to the symbols generated by these
  Function return values are passed back in one or more registers,321 Using Assembly Language with C Language


1. place the appropriate arguments in the correct registers.
  rtypersizeDescription

 See also debugging programsdetermining editing modes 17
any value from 60 to 132. The default value is 132 characters.
example, the following code moves data around:

 -m4
display command 57-61, 143-144  -e option, smake utility  289
  CSECT name[, type][, align][, rtype][, rsize]
 -v option 295user environment 6

 Before retrieving arguments from the stack into non-scratch
registers, you must first save the contents of those registers, so they
--------------------------------------------------------------------------------
NOPAGE
  label MACRO
.
ENDM
| middle  |
Return key for executing proceed format of messages 256-257
 320 321  badchar option, opt command  87, 165
 SECTION directive 309-310  definition 36, 48
 See slash (/)
 See period (.)
modes:

wbreak command 70-72, 193defining symbols in data section 309
wdisable command 195
;If you do not, your machine will crash when you run
 _func:
 fsub.l 16(a7),fp0  ; subtract 'mrright'
  turning off 32  character classes, grep utility 226
  for (i = O; i < j; i++)
  {
 executing until variable changes value R
 33 34
 executing up to breakpoints 32 r command, oml utility 252
 writing assembly language functionssyntax 131
 300 314  bdisable command 48, 132
assembly mode benable command 48, 133
depending on the data type declared for the calling function. The



CSECT name,type,align,rtype,rsize
  xxx xxx
 negation character in grep search 226,statement expressions 303
  xxx xxx
-a option, smake utility 289 referencing aliases commands with

[]  include a prototype of your assembler module in your C source
< (less than sign)
You must begin the definition with a MACRO directive on a line by
  For example, you could define a macro called acopy as follows:
 pull-down menus 20-22  -nok 98
for (i = 0; i < n; ++i)

  12 Optimizing Your Code
  If you save the assembler module func in a file named testa.a, you
  can assemble test.a with the following command:

* The smallest item that can be pushed onto the stack is the size of an integer.
|  lefty  |
 temp = i / 3;

 running the debugger on optimized code-$ option 225
336 337gst utility 237 239


  asm [>listfile] [options] filename

.
 one or more of the following:
 > prornpt for command line 16H_DEBUG hunks 7, 8
grep utility 224 236  H_SYMBOL hunks 8
 See ampersand operator (&)
& (ampersand symbol)
 See ampersand symbol (&)


 exitpoint:
 fmove.l fp0,d0 ; return 'int' in d0
 rts
  global optimizer uses worst-case aliasing. Using this option can
  significantly reduce the amount of optimization that can be
  performed. The nooptalias option is the default.

optcomplexity
relative to register A4 or to the PC. The default value is 0.
assembles if the expression is greater than 0.


O case option 85, 165
  module.
 smake utility 290register parameter 122-123
  definition 39call frame 6
with an underscore (_). Do not use this option if you entered all
 used. Therefore, global optimization changes a register's assigned

  program has been tested and most errors have been corrected.335 Optimizing Your Code
 -unit 97examples 99
 81symbol tables, global
  Instead of passing parameters into and out of a function, you can use
watches 26, 69  oml utility 253
 global optimizer compiler options  portname option, scmsg Project menu 258
 IFD symbol
fsub.l dl,fp0; subtract 'mrright' from 'mlddle'
264  tb utility 295
 display command 57command-line editing 17-18
 examples 143-144echo option, opt command 84, 166
264  default macros 279-280
retrieve the parameters from the stack. The arguments are placed on
IFNE assembler directive 306less than sign (<)

 addressing 311debug=line option 74
 end

  See CPRK  local input files, smake utility 284-286
kernel  load module 324
354 Index

command 29hidden option 255
REXX languageProject menu 257-259
 See AREXX interface quit option 255

optinlocal
for (j = 0; j < m; ++j)
In addition to specifying addresses relative to address registers and
}

 static by default 70 wmsg command 201
 See also wbreak command  Workbench screen
conventions are as follows:
  See also benable command  asm command 324
  See also blist commanddiff utility 219



  steps, n refers to the size of your work area in bytes.
The test instruction is not needed because the condition codes for the
 Address field 109  utility 280 281
Optimizer

program.
[]  retrieve any parameters that are passed on the stack before using
  void f(double d)
  {
  branch instruction are set by the move instruction.
  recognize, contact the Technical Support Division at SAS Institute Inc.
  Development User's Guide, Volume I, describes the sections produced
 See badchar option, opt command-m4 option, asm command 326
memcmp function 204
file attempting to match lines in the same way (except that you look
at L-1 and L1-1 when finding a matched line L).
 procedure 96 99  dead store elimination 330
  02PC-relative address (code section)

 index = 23;
 230FORMAT assembler directive 305
execute command 152 format parameter
EXITM assembler directive 305, 307  fregister command 155
expand command 153  function keys
expression parameter  actions performed 22-23
  operators not accepted 120function line parameter, location
expressionsparameter 41
  absolute 304  function parameter, location parameter 41,
port 264  syntax and description 255-257
rexxonly option, scmsg utility 256scopts utility 266-270
 activating autoswap mode 29using with cpr command 10
 adding or stripping debugging  label 300

location parameter 40 42, 123-124Memory window 15
x lists the expansion text for macros.

  to the program counter, you also can specify absolute addresses or
lefty = '+';
middle = 12345.;
mrright = 99;

 specifying with CSECT directive 311-314  command output 103-104
 specifying with SECTION directiveinvoking macros 102-103
 function actually may be constants.333 Optimizing Your Code
can be changed to
  short 16  D0.Wlow word of D0
 variable during the evaluation of the expression to ensure that the
 most heavily used variables are always in machine registers.
  enter immediate data. The following tables summarize the addressing
  modes supported by the SAS/C Assembler and provide examples of
  a[i]= p->q.r[10];
  definition 107  TTL assembler directive 308
  displaying tasks, example 109Type field, tasks command 109
image parameter, location parameter 42See resident libraries, debugging
initializing CodeProbe  libraries.cpr AREXX macro 106
 See cprinit fileline boundary 6
Input window 15 line command, SC_SCMSG AREXX port
Build menu, scmsg utility 259 262
built-in functions 202-203-cli command-line option 11, 79
 go command 26, 30, 32, 39-44-r option
  y = temp * 2;
  long  32  D0.Lall of D0
  pointer32  D0.Lall of D0
  float 32  D0.Lall of D0

turns off the warnings generated by the -mO option. Use this option
 syntax 291T
 -s option 291
stack, assembly language programs 317 -t option
 format 309 -c option 289
 setting and showing options  82-89 70-72
 creating watches 33specifying with -w command-line option
  Running the Optimizers
  To run the optimizers, specify the appropriate compiler option:
 See also define command  setting watches or watch breaks 71
 See also expand commandarrdim option, opt command 86 87, 165
 compared with define command 92,93 ASCII option, dump command 65-66
{
.
 starting the cross debugger (CPRX)debug= options 74-76
 y = i / 3 + 4;

  (xxx).Ladd.l (100).l,d0
  badchar option 87, 165
Options menu 20 2146 47
 See dollar parameter ($)
  (xxx).Wadd.w (100).w,d0


 debugging  defining symbols to nothing 93
can be changed to
 x = temp;
  }
The func assembler module returns an integer.316 Chapter 11
  auto variable elimination and
  those with the __inline keyword. The optinline option is the
  default when optimize is used. Refer to Chapter 11, "Using
  Amiga Specific Features of the SAS/C Language," in the SAS/C

  move.w  4(sp),d0
  move.l  6(sp),a5309 Using Assembly Language with C Language

Defining Control Sections
 33-34devices option, opt command 88, 166
 quitting the debugger 34 open by default 12, 26
The assembler supports the following options:

  The following table shows examples of absolute addressing modes:

  all option 110, 112 trap handling 113 114


the prefixes. If you specify a directory name as a prefix, include the
  nesting 52  case option, opt command 85, 165
  data1DC.W 10
 echo mode 84 setting breakpoints 32
}
bra.b exitpoint

 executing until variable changes valuecommand parameter, help command 27

defines section type and alignment requirements. The section
 -x option 295utilities
 __MERGED for near data. You can use a specific name only
them.
 go command 26  See also specific commands
 invoking the debugger 26address parameter 118 119
  -L option 219pointers, dumping 63-64
  options supported 219-220variables, dumping 61-62, 75
module using the XREF statement, as follows:

the stack from right to left; that is, the leftmost argument is

 division by 0, but not including iloating-point operations. The global
  operands in the section "Writing Assembler Statements," earlier in this
The following table shows how to specify immediate data:
comparing files options 98
  See diH utilityrequired on target machine 96
 See sc command starting before CPRX 97, 98
Compiler Options Index window 266 CPRX
 sample program (lines.c) 25starting 98-99
condition control register (CCR) flags 110stripping debug information with -x
constants-symfile option 98

  subrange parameter 123-124  -cli option 11
  syntax 16invoking the debugger 26
 See greater than sign (>)
  counter. For example, the following code calls the function cfunc
 scratch registers 318sample programs
 See also debug= options statement expressions 303
 illustrations 26 strlen option, opt command  86, 167
 309-310  libraries.cpr 106
addsym option macros provided by CodeProbe 101-102
  type parameter 124  syntax 9, 75

fmove.b #-1,fp0  ; return -1 for error

If your program contains the statement include abc . i, the

Referencing Global Data
global data.323 Using Assembly Language with C Language
 information 7  operand 300360 Index

This appendix describes the file-matching algorithm used by the diff
  float (68881) 32  FP0. S  single precision in FP0
  double (FFP)  32  D0.Lall of D0
 MOVE.LD6,D0

assembler searches for the file in the current directory. If that fails,
it searches for myinc/abc . i and then yourinc/abc . i.
functlons pass parameters on the stack.
 p[i * m + j] += 1;
 a significant time saving for loops that are executed many times, as

 displaying alias definitions 90asm command 323-326
 displaying current aliases 89-90 -c option 324
 escape characters 19 -d option 324
  by the compiler.


To use the __asm keyword, you must modify the prototype of the
RORG, OFFSET, SECTION, or END directive.
OPSYN oldname newname
 proceed commands 29, 46-47tb utility 295
  function key actions 22-23
-i command-line option 79 function keys for command-line editing
 See dollar sign ($)
 (asterisk)
 See asterisk (*)
| | <-- A7+8+n
 optsize
following command loads all three sections into high-speed r~AM
  int func(char lefty, double middle, int mrright);
int mrright;
 zooming to full size 30303
  }
  temp = i + j;
x = temp;

1. Enter the SUBI instruction if you need local storage:
 optimizing 332, 333terminating 99-100
 MOVE.LD7,-(A7);push argument
  Assembler modules may be called from C functions in three ways:

.
  register-direct addressing modes 313  using 75-76
 informatioll 311displaying full debugging information 25
 98 99determining which option to use  76-77
 target machine 96debug=full option 74

[] Identify those lines that occur only once in each file. Assume that
these lines match one another.
  You can access data declared in an assembler module from a C
function by placing the data declarations inside a data section and


 329 Introduction
 334 The Peephole Optimizer
 334 Running the Optimizers
 335 Global Optimization Compiler Options
 336 Global Optimization and the Debugger

  Mode  Example

 82-89  proceed command 46-47, 168
 induction variable transformations  331specifying 230-231
 reductions in strength 333 -x option 99

  disables optimizations that might sacrifice code size to save time.
  Only some loop optimizations do this. The nooptsize option is
[label] SECTION name[,type]

 examples 192 -wregister command-line option 81
 syntax and description 70, 192-wsource command-line option 81


  d16(PC)add.w 10(PC),d0

assembles if the symbol is defined.
 IFEQ expression
assembles if the expression is 0.
form as the compiler. Because the global optimizer works on
intermediate code, it has no knowledge of the target processor or its
instructions.

 peephole optimizer
abort command, SC_SCMSG AREXX portback-tick character (`) 92

 See plus sign ( +)

  using with detach command 111 112 specifying 228-230
Calling C Functions from Assembler Functions
  d8(PC,Xn) add.w 10(PC,a2.l), d0
printf("func(+) = %d\n", func(lefty, middle, mrright));
 quit command 10-noprofile 79-80
  double (68881)96  FP0.Xall of FP0
  optimizing subexpressions 331 42

To call an assembler module from your C program, include the
3. after control returns from the called function, adjust the stack
context option, opt command 85, 166 cross-debugging 6
a static work area (not on the stack) to hold the returned object and
 compared with register command 77  echo command 149
 expresslon parameter 57Edit menu, scmsg utility 260

can be changed to

  temp = p->q.r[10];
  for (i = 0; i < j; i++)

asm -m2 testa.a

  If you save the C source code in a file named test, you can compile

  code that is both slower and larger than most optimized code.
  0,1,2432-bit absolute address
 continuing execution 30delfile command, SC_SCMSG AREXX
 controlling program execution 27-34, port 263
 39-53  delnum command, SC_SCMSG AREXX
 definition 307 -b option 289
temp option, break command  52-53, 135  See specific utilities
terminating programs and tasks


 crashes caused by improper use 26parameters=register option 319
  reductions in strength 333functions
 calling assembler functions from C oml utility 253
ps command 169  diff utility 219
slink lib:c.o test.o testa.o lib lib:sc.lib
  Note: This approach implies that functions returning structures or
2. push any remaining arguments onto the stack.
3. add an ~ to the front of the function name, and call the function
 using the JSR instruction.
  #data add.1 #100,d0
  Option  Effect


  The filename is the name of the assembly language source file that
  else

source line fields, assembly language strcpy function 210
 setting breakpoints 32, 47-53radix option, opt command 86, 167
 single stepping 29, 44-47  range parameter 121 122
 using watch and watch break commandswatches 71
  }


  asm -hcdb prog . a

-iprefix
  relocatable 304 See built-in functions
 reordering 333
-f optionremapping 332
 grep utility 225 common subexpression merging 331
  Istat utility 244constant propagation and folding 332
rflag command 175  entering options on command line 269
right-Amiga key 23 exiting without saving changes 269
RORG assembler directive307gadgets 267-268
run environment 6  restoring previously saved options 269
build command, SC_SCMSG AREXX portclass command, SC _ SCMSG AREXX port
 Various arithmetic operations involving constants are reduced in
strength.
func(lefty,middle,mrright);

tasks performed by 269-270

Ikeys
  catch option 89, 166
-o option context option 85, 166
  diff utility 219displaying current task 89

 Introduction

 Your SAS/C Development System provides the following two
 optimizers:
analyzes the assembler instructions and replaces inefficient



func(+) = 12444317 Using Assembly Language with C Language
(continued)string parameter 123
  Debug field 109 ts command 45, 187
  examples 185type parameter 124
Optimizing your code may change this correspondence. Also, the
 command line:
 Conditional and logical expressions whose results are unused are
converted into corresponding if code. For instance, putchar
 JSR  @cfunc  ;call function
 MOVE.LD0,ret  ;save return value
Global Optimization Compiler Options
  smake utility 289control flow transformations 333

 The Global Optimizer
& (and operator)
addressesampersand symbol (&)
 absolute addressing modes 313special symbol in smake utility 277
 specifying start-up window coordinatessymbol= option, gst utility 238
sourceis option 77-78See gst utility
SPC assembler directive 307 See hypergst utility
splat utility 291-293debugging resident libraries 106
 -d option 291  definition 107
 description 291examples 184
  

  noopttime option is the default.
  acopy MACRO
 IFGE expression
  After setting up the return value, the assembler module exits by
 addsym 8, 9, 74PLEN assembler directive 307
 size sumxes, specifying 301 302examples 131
 Nl LL modem cable 96 deactivate command 107, 111, 140
 See and operator (&)
 uses of leftvar have this definition as the single reaching
  bd(PC,Xn) add.w $10000(PC,a2.l)(68020 only)
 format parameter 57  AREXX for invoking editors 261-262

 multiple arguments 58examples 264-265
windows for setting options 266-267
 specifying addresses 309-310comments in smakefiles 274
once in a given asm file.
section, 1 indicates a data section, and 2 indicates an
 See also resident libraries, debuggingdisplaying macro definitions 93
 breakpoints 47-53  delcomp command, SC_SCMSG AREXX
segment listscreating and using default files 288
 assigning pointers 113 creating smakefiles 274-276
semicolon (;)  defining transformation rules 280-281
 escaping with backslash (\) in echo-e option 289
 command 149-f option 289
2. Save registers D2 through D7, A2 through A6 if they will be
 changed during execution of the module.

if 68040 instructions are allowed.
 -oprefix
| | <-- A7+4+n
tool types, adding 78 -V option, grep utility 225
top command, SC _ SCMSG AREXX portvariable parameter 125

 using in cmd list parameters 50-h option 290
 CODE.


  ([bd,PC],Xn,od)add.w ([10,PC],a2.l,20),d0  (680Z0 only)
  ([bd,PC,Xn],od)add.w ([10,PC,a2.l],20),d0  (68020 only)
  See also specific functions cmd_list parameter, break command 50,
reversing the steps described earlier:
 move.w4(sp),\1
 move.l6(sp),\2
 ENDM

MOVE.L  d1,xdata(A4)310 Chapter 11

  afunc JSR cfunc(PC)

 33-34 commands
from stdio.h is implemented with a conditional expression. If the
result (the original character or an error indication) is not used, GO
converts it into if else code, eliminating a load into a register.
  1. restore registers that were saved.

specifies a prefix that you want placed in front of the output
Any drive or directory prefixes in the input filename are discarded

  data2DC.L 20
  .

 ps command 47blist command 36, 48, 134
-F option, diff utility 219copy propagation 332352 Index

 The global optimizer optimizes the flow of control and data through an
 entire function. The global optimizer performs several types of
 See exclamation mark (!)

 [] compiling your program with the parameters=register option.
This option tells the compiler to pass parameters in registers, but it


 optimizations:
-watch command line option 81 -wwatch command-line option 81
memcpy function 205
memmove function 206
Memory menu 22355 Index

type specifies the type of section. The type can be BSS, DATA, or
Specifying Addresses with the SECTION Directive
 lstat utility options 244Indicating comments m smakefiles 274
 smake utility 289-290See also ps command

Communicating between Assembly
  syntax and description 185smake utihty 290
allows the compiler to determine which registers to use.

blocks and then unmatches the smaller of the blocks. This process is
an attempt to satisfy the notion that the differences reported should be
 262, 262-264syntax 89, 128
 addressing modes supported by SAS/C and operator (&)
 forcing program counter-relativeAREXX interface 101
 addressing 311invoking editors 261-262
 trace command 45port 262
  2. advance the stack pointer in register A7 past the work area.
  3. return to the caller using an RTS instruction.
  location parameter 120 121dir= option 217
| |
|Top of Stack  |

 See braces ({})  See quotes, single ('')
\ (backslash character) " (quotes)
 See backslash character (\)  See quotes, double ("")
/ (slash)
& (ampersand operator)


induction variable transformations
 To use the parameters inside your assembler module, you must

 The arguments mrright, middle, and lefty use 4 bytes, 8
bytes, and 4 bytes, respectively.* Register A7 is the stack pointer, and
 Note: If you specify the shortintegers option, integers will be
 operation 300  display command 58
  The calling function removes the arguments from the stack.322 Chapter 11

 Workbench support 10-11-symfile 98
CodeProbe sample session 25-34  -unit 97
 register assignment
analyzes the function to determine which auto variables, formal


 assembler 312not used with register variables 58
 dumping 62 append block, diff utility 221
 examples 91, 128-129 -d symbol(=value) option  324
 expanding alias names  90, 91-h option  324-325344 Index
 expanding alias names 90fake targets 281-283
 preceding with escape character 93 file dependencies, example 275

 Anan address register (a0 a7)


source modes 83-84strings, dumping 65 66
 assembly mode 45, 46, 47, 83 strings gadget 267
 C mode 83stripdebug option 77

global optimizer (continued)  -f option 225
 dead code elimination 331-n option 225
serial ports-i option 290
 definition 27strlen function 211
to registers at each point in the function. The optimizer assigns up
to three address registers, four data registers, and, if a math
  mixed mode 46, 83-84, 336structures
 See back-tick character (')
# (pound sign)
 See pound sign (#)

 requirements 7 -pipe 97
 running 9-11
 display command 57 61port 263
next command, SC_SCMSG AREXX port.ONEERROR fake target 282
263  online help
nodebug option 74 See help command
.
  return;
performs various transformations to eliminate unreachable code or
useless control structures.
  For example, the following code calls the function cfunc with two
  parameters that are currently in registers D7 and D6 and stores the
 XREF cfunc
  If your C function is declared using the __asm keyword, you should
  pass the parameters in the appropriate registers.
  sections. You must use either the SECTION or CSECT directive before
  you define any code or data. A SECTION or CSECT directive defines
IFGT assembler directive 306  tb utility 295
! (exclamation mark)
$ (dollar sign)
^ (caret)
2 bytes instead of 4.
Prototype Generation Options window 267redirecting output (>)
  take to save register values and establish frame pointers. In these

 hiding in double quotes 92symload command 112-113
 default macros 279-280task handling by CodeProbe  108
 defining transformation rules  280-281tasks command 109-110

 oml utility 253  -s option 253
 smake utility 290syntax and description  250-251
 syntax 323 statement expressions 303
 u option 326auto variable elimination and remapping
IFND assembler directive 306left-Amiga m keyboard shortcut  29, 34
 dead store elimination 330-331number of times characters may appear,
asterisk ( )  braces ({})
data, examiningdebug=full option 76
stack variables 110 oml utility 253
register variables.
Generally speaking, the variables that are most used at a given
 moving invariants out of loops 331options supported 225
  optimizeturns on both the global and peephole optimizers.
wenable command 196
 bda  32-bit byte displacemer1t

.IGNORE fake target 282diff utility 220
control sections  See also CPRK
 See CSECT assembler directiveSee also CPRX
cross-development mode (continued)data structures, displaying
 preparing to use cross debugger 96dead code elimination 331
 reasolls for cross-debugging 95-96Debug field, tasks command  109
 terminating CPRX and CPRK 99-100using 76
CSECT assembler directive 310-314when to use 76 77
 parameters 310 using 75
 program counter-relative addressing  debug=symbol option 74
 modes, examples 314generating H DEBUG hunks 8
SUBI  n,A7
source option, opt command  83  84, 166subrange parameter 119, lZ3 124
Source window symbol 7
 functions 15See also debug=symbol option
 open by default 12, 26symbol command 183
 examples 291-293syntax and description 112-113, 184
-startup command-line option 26, 80 fake targets 281-283
State field, tasks command 109  multiple targets 283
Name field, tasks command 109 -t option 253
state of the machine  target machine 7, 96
  Name field 109
tb utility 294-296  tb utility 295
 assembly mode 47grep utility 224
 equivalents  20-22register command 66-68, 171
q optionexamples 171
 [] using the __asm keyword and specifying which registers
parameters are placed in.

3. Save floating-point registers FP2 through FP7 if a 68881 math
insert editing mode 17  263
defines the end of conditional assembly. This directive turns off
  optimizeturns on only the global optimizer.



  conditional 49 50 functions 322

asm command (continued)used in array-slice parameter  119
 -i option 325wild card indicator 34
 syntax and description 244 multiple targets, smake utility 283
 IFLE expression
 diffutility 220syntax 66 67, 171
 grep utility 225 register-direct addressing modes 313
quiet option, break command  52-53, 135Register window 15, 81
 SC_SCMSG AREXX port 263displaying contents 67
  To use all the capabilities of the debugger, the lines in the source code
 opt source mixed337 Optimizing Your Code
 -m0 option 325 asynchronous tasks 108
  .
XDEFafunc
MOVE.W  data1(A4),D0
MOVE.L  data2(A4),D1
 See percent sign (%)
 coprocessor is present and will be used by the module.

  The steps you take to call a C function from an assembler program


  menu accelerator keys 23-24example 217-218
  number parameter 121  merge option 217

1. push the arguments on the stack in the correct order.
multiple listing lines for each source line.
 running on optimized code 336 337  -screen 80
 terminology 5_7-speed 97
 breakpoints, setting 32-w 80
 clearing watches and watch breaks 34-wb. 11, 80
 compiling and linking 25-wd0alog 81
  Development System User's Guide, Volume I, for information about

  rsize specifies the size of the offset for the address. If you specify an
specify an rsize of 2, the assembler uses the value of rtype to
determine how to address code or data in the section. The
  The following table summarizes the valid types and sizes of
  12A4-relative address (data section)


  -cx
  pull-down menus 20-22 nosource option 217
2. call the function using the JSR instruction.

  the beginning of a relocatable control section. Pararneters on these

  relative to the PC:

 CodeProbe tasks 108V
 CPRK and CPRX 99
 oml utility 251  -v option
 scmsg utility 255  grep utility 225
text command, SC SCMSG AREXX portoml utility 253
trace command 45 46, 186, 187assembler statement expressions302
 radix option 86  steps for debugging 8
 rangelen option 87trace commands 45-46
 search path 87 88watch and wbreak commands32-34,
 source file location 77 78watches and watch breaks 69-72
 optcomplexity option 335 patterns at beginning or end of line,
 syntax and description 170 effect of opt task command 110
  defines the complexity of functions considered small by
associated with array indexing).332 Chapter 12

  In many cases, optimized code is more difflcult to debug than non-
 diff utility options 219 220 grep search pattern 226, 231
 grep utllity options 225 ANSI # and ## operators not supported


before the new prefix is added. Do not include blanks in the prefix.

Passing parameters in registers produces a faster, smaller executable
module.315 Using Assembly Language with C Language

defining the data with an XDEF statement. The following code defines
two variables in assembly language and shows how to declare them in
 -m2 option 325 at sign ((?)
 -m4 option 326replacing underscore in function names
 -o option 326  for compiler 318
If you include >listfile, the assembler sends the source listing and
 See braces ({})  debugging environment, setting up 73-94
cllrrellt task, displaying 89alias command 89 92
 oml utility252changing default environment
 short form of display command 30with -cli and wb options 11
-d Option choosing command-line options 78-81
 asm command 324  context option 85
point are assigned to registers. For example, variables occurring in330 Chapter12
 addresses, specifying with CSECT

a C function.

 specifies that the sections designated by x are to be loaded into
  In Assembly Language  In C Language
CSECT data  extern long VAR1;
 loops are more likely to be assigned to registers. The global
 optimizer attempts to keep a variable assigned to a register for as
The global optimizer overrides the register keyword in the
 declarations of integer, double, and pointer variables. Because of
the listing file.
NOOBJ
Using the SECTION Directive
The SECTION directive follows this format:

 online help 26-27  array-slice parameter 119
 quitting the debugger 34command-line editing 16-19
 restart command 26command-line equivalents for menu items
 address parameter 40memory, dumping
Language and C Language
XDEF VAR1,VAR2,VAR3 extern long VAR2;
  VAR1 DC.L $4000
  In C Language In Assembly Language
 compared with proceed command 44,  displaying value and type 32
 directive 311 314B
 assembler directives 304-308
 assembler statements, writing 300-304-b option
 __asm keyword 319-320  diff utility  219
 fullctions 322 non-expansion of escaped macro
whatis command 68-69, 197 Z
_ (underscore)
 optdepth option 335  specifying 231
control flow transformations 333cross-development mode  95-100
CTRL-C, terminating CPRK and CPRX  99using 76
 syntax and description 68, 197
when option
 break command 49, 135

  optimized code. You may want to use the optimizer only after the main

 the portability of the C language, it is difficult for a programmer to
name= option, gst utility 238 terminating 251
 optrdepth option 336 redirecting output 224
  long VAR1=0x4000; XREF VAR1,VAR2
  long VAR1=0x4000; .
 definition and rightvar will not change before each use. This
 optimization supports other optimizations.

ignorepath option, opt command  85, 166oml utility 251
57-72 precautions 111-112
image 6 libraries
integers, dumping 65link library 250
data  actual data you want loaded into the register
 Dna data register (d0--d7)
uninitialized data section (like the udata section used by the


b bss or uninitialized data
The following list describes each of the parameters.
Ctrl-L key 23when to use 76-77
interlace mode  link option 9, 25

Specifying Addresses with the CSECT Directive

 (back-tick character)
 See -i command-line option linker
 grep search pattern 225, 226, 230-231  defining aliases 90
 avoids bus contention between the processor and the custom
Ctrl-W key 23 debugger


 clearing watches and watch breaks 34port 262
"Defining Control Sections," later in this chapter, discusses the
brackets ([])C
 enclosing characters in grep search 226,
 228-230  C functions, calling
See calling assembler functions from
 branch instructionsC functions
  after option 49, 135  grep utility 225
 See also opt commandPeriod (.)
 know the number of available registers provided by the target
asm -ccdb prog.a

CSECT macro.
  The compiler accepts the following options to modify the operation of

-d
 register command 66-68scrolling 31350 Index
Dialog window (continued) special symbol in smake utility 277
 specifying start-up window coordinatesspecifying hexadecimal numbers in
 81 assembler statement expressions
 options supported 244  Modules window 15
 terminating CPRX  100  modifying  110358 Index
 once in a given asm file.
  the Program Counter (PC).
activates the debugging mode.

 compiler uses the more advanced registration allocation algorithms
  cmd0ist parameter 50, 135 smake utility 289
  quiet option 52 53, 135 calling an assembler module 316
optdepth

specifies a prefix that should be placed in front of filenames in
trailing slash (/). For example, you can assemble the file named
testprog. a with the following command:


  asm -imyinc/ -iyourinc/ testprog.a
-l[x][m][i]
code- or data-generated information beside the source line. The x,
m, and i produce the following slightly different listings:

i  lists the source for text from INCLUDE files as well as the

resident libraries, debugging 105-106lines.c 25
RemTask function 114  programs 36
  definition 5, 32, 47Calls window l4
  multitasking programs 108 grep search pattern 226
  catch command 107, 112, 139
  preventing debugger from stoppin 51 Catch New Devices option
  syntax 48-49, 135parameters=register option 318-319
  318
-buffer command-line option 78 79 characters and strings, dumping 65 66
262clear command SC SCMSG AREXX port
original source file.

-m0
 displaying arrays and structures 30-32 -wwatch 81
  purpose 202 Code Generation Options window 266
specifies that only 68000 instructions are allowed. This option
[label] DC[.size] expression[,expression] . . .
 tb utility 295compared with trace command 44,
  range is 0 to 6, and the default value is 3.
 label MACRO
begins a macro definition. The following section, "Defining and
 symload command 106  adding addsym option to slink
curly bracesSee CodeProbe
 smake utility 289current task 89
346 Index
CodeProbe 3-24command-line editing 16-19
 basic features 4editing function keys 17-18
 See also scopts utility  grep wildcard character 225, 228, 230
exits the macro expansion. This directive is a synonym for EXITM.


  Using the CSECT Directive
  The CSECT directive follows this format:

defines a constant value in memory.
ENDC

issues warning messages if, for example, you use instructions that
are only available on the 68020. This option is the default.
 changes and enhancements 5 escape characters in commands 19
-pipe command-line option 97
 cover utility options 217  plus sign (+)
 See cpr commandLinker Options window 267
linking programs 9, 25
LIST assembler directive 306
  The name and type parameters describe the control section being
  information in the section. The align parameter is ignored. The



 -s
[label] DS[.size] n
reserves (defines) n memory locations of the size indicated by .size.
ELSE
 NARG
includes the section name at the beginning of each hunk.

 -u
specifies that you want the assembler to prefix external references
external names with leading underscores. You should specify this
option when you assemble startup code.
 displaying variable values and types 32command output for AREXX macros
 executing breakpoints 32103-104
 source mode, setting 27-2820-22
 command line 16-19 escape sequences in character 
 compiling and linking programs 9 strings18 19

 definition 26, 36typical usage 9
  following list describes each of the parameters:
begins an alternative for the IF directive.
[label] END
defines the end of the program.
 in SAS/C software. Even though the compiler does not have
each of the IFxx directives.
ENDM
ends a macro definition.
label EQU expression
assigns permanently the value of expression to label.
 dynamic information about program execution that would indicate

optinline
 cpr command 9-10 using backslash (\) 18
 splat utility 291customizing Dialog window commands
label EQUR register
EXITM
 IFNC string,string
 nesting structure to make a reasonable approximation.

  align specifies the alignment requirements of the control section as a

  dead store elimination
 default options, displaying 82
 continuing execution 30-wregister 81
assembles if the strings are not identical.
assembles if the symbol is not defined.
 IFNE expression
assembles if the expression is not equal to 0.
 INCLUDE "filename"
 starting the debugger 25-26  customizing Dialog window commands
 stepping over code 29-30 89-94
  range parameter 121-122options supported 217
  register parameter 122-123running 216
  SC_SCMSG AREXX port 262-264syntax and description 216 217
  shortcuts for command names 16  cpr command 9-10


stops the production of the object file.
OFFSET n
defines a synonym for opcodes.
PAGE
 eliminates the assignment of a value to a variable if the value is not
  /* code that does not refer to index */
 -t option 244  multitasking programs, debugging 107-114
 See also AREXX macrosdesign considerations 113-114
NOFORMAT assembler directive 306OpenDevice function 114
NOLIST assembler directive 307  operand field, assembly language source
non-floating-point instructionsline 300
  assembler statement size suffixes 301  operation field, assembly language 
NOOB) assembler directive 307source line 300
NOPAGE assembler directive 307  operators
  oml utility 253 echo option 84, 166
 -b option 253source option 46, 77, 83, 84, 166, 336
  speclal parameterS 118-125 available command-line options 10
By specifying parameters in the CSECT directive, you can generate
the data=near (base-relative data) and code=near (program
includes external files into the source. You can nest INCLUDE
counter-relative addressing) compiler options.
  You can force address register-relative addressing of data in the BSS
section by specifying an rtype of 2 and an rsize of 2. Any XREF
  J list command 161 162
list option
  .
 index = 12;
331 Optimizing Your Code

 splat utility 291assigned to Return key 29

 eliminates definitions of the form leftvar = rightvar when all
  variable parameter 125  -wb option 11
statements for external data elements must appear after the CSECT
statement, and all data must be addressed relative to register A4. For

  >prompt 16  .cpr extension for macros 102

 communications parametersinitializing CodeProbe 81-82
  defining for cross debugging 97 suppresSing execution with -noprofile
 -device 97 option 79 80
 -pipe 97 CPRK
324debug= options 74-76
 See dump command debug=fullflush option 76349 Index

 debug=symbol option 75-76running CodeProbe 9-11
 define command 92-93 sample program 2 53-56
.
 ignorepath option 85 single stepping 44-47
 initializing CodeProbe  81-82starting the debugger 25-26
 source modes 83 84whatis command 68-69
 programs 36delete command, SC_SCMSG AREXX port
 compiling and linking programs 9, 25 263
 displaying arrays and structures 30-32dependent file, smake utility 273
 dump command 61-66definition 107
 examining data and data structuresexamples 142
 executing breakpoints 32 syntax 111, 142
Dialog window commands-$ option, grep utility 225
diff utility 219-223  characters and strings, dumping  65-66
 append block 221 compared with register command 77
.
.
 -c option 219decimal option 65
 change block 221 examples 147
 delete block 220 float option 64
  error messageS 222-223  floating-point numbers, dumping  64-65
profile scripts quit option, scmsg utility 255
jump command  89, 160 gst utility 237
  opt command 86, 166
 definition 40, 120See dump command
  -F option 219integers, dumping 65
 forms 40memset function 207
 function line parameter 41 menu accelerator keys  23-24, 29, 34
 function parameter 41, 42, 121 menus
 integer parameter 121  Message window 15
 line parameter 41See also wmsg command
 module parameter 42, 120MEXIT assembler directive306
 syntax 120 minus sign (-)
CSECT TEXT,0
MOVE.Ldata2(A4),D1
MOVE.Ld1,xdata(A4)
log command 163-164special symbol in smake utility  229, 277

  Note: If the XREF statement for the external data precedes the

  statement. and the function must be called relative to the program
CSECT  TEXT,0,,0,2
XREFcfunc
 d8an 8 bit displacement
