xref: /netbsd-src/external/gpl3/binutils/dist/gas/doc/c-m32c.texi (revision cb63e24e8d6aae7ddac1859a9015f48b1d8bd90e)
1*cb63e24eSchristos@c Copyright (C) 2005-2024 Free Software Foundation, Inc.
22a6b7db3Sskrll@c This is part of the GAS manual.
32a6b7db3Sskrll@c For copying conditions, see the file as.texinfo.
42a6b7db3Sskrll@ifset GENERIC
52a6b7db3Sskrll@page
62a6b7db3Sskrll@node M32C-Dependent
72a6b7db3Sskrll@chapter M32C Dependent Features
82a6b7db3Sskrll@end ifset
92a6b7db3Sskrll@ifclear GENERIC
102a6b7db3Sskrll@node Machine Dependencies
112a6b7db3Sskrll@chapter M32C Dependent Features
122a6b7db3Sskrll@end ifclear
132a6b7db3Sskrll
142a6b7db3Sskrll@cindex M32C support
152a6b7db3Sskrll
162a6b7db3Sskrll@code{@value{AS}} can assemble code for several different members of
172a6b7db3Sskrllthe Renesas M32C family.  Normally the default is to assemble code for
182a6b7db3Sskrllthe M16C microprocessor.  The @code{-m32c} option may be used to
192a6b7db3Sskrllchange the default to the M32C microprocessor.
202a6b7db3Sskrll
212a6b7db3Sskrll@menu
222a6b7db3Sskrll* M32C-Opts::                   M32C Options
23883529b6Schristos* M32C-Syntax::                 M32C Syntax
242a6b7db3Sskrll@end menu
252a6b7db3Sskrll
262a6b7db3Sskrll@node M32C-Opts
272a6b7db3Sskrll@section M32C Options
282a6b7db3Sskrll
292a6b7db3Sskrll@cindex options, M32C
302a6b7db3Sskrll@cindex M32C options
312a6b7db3Sskrll
322a6b7db3SskrllThe Renesas M32C version of @code{@value{AS}} has these
332a6b7db3Sskrllmachine-dependent options:
342a6b7db3Sskrll
352a6b7db3Sskrll@table @code
362a6b7db3Sskrll@item -m32c
372a6b7db3Sskrll@cindex @samp{-m32c} option, M32C
382a6b7db3Sskrll@cindex architecture options, M32C
392a6b7db3Sskrll@cindex M32C architecture option
402a6b7db3SskrllAssemble M32C instructions.
412a6b7db3Sskrll
422a6b7db3Sskrll@item -m16c
432a6b7db3Sskrll@cindex @samp{-m16c} option, M16C
442a6b7db3Sskrll@cindex architecture options, M16C
452a6b7db3Sskrll@cindex M16C architecture option
462a6b7db3SskrllAssemble M16C instructions (default).
472a6b7db3Sskrll
482a6b7db3Sskrll@item -relax
492a6b7db3SskrllEnable support for link-time relaxations.
502a6b7db3Sskrll
512a6b7db3Sskrll@item -h-tick-hex
522a6b7db3SskrllSupport H'00 style hex constants in addition to 0x00 style.
532a6b7db3Sskrll
542a6b7db3Sskrll
552a6b7db3Sskrll@end table
562a6b7db3Sskrll
57883529b6Schristos@node M32C-Syntax
58883529b6Schristos@section M32C Syntax
59883529b6Schristos@menu
60883529b6Schristos* M32C-Modifiers::              Symbolic Operand Modifiers
61883529b6Schristos* M32C-Chars::                  Special Characters
62883529b6Schristos@end menu
63883529b6Schristos
642a6b7db3Sskrll@node M32C-Modifiers
65883529b6Schristos@subsection Symbolic Operand Modifiers
662a6b7db3Sskrll
672a6b7db3Sskrll@cindex M32C modifiers
68883529b6Schristos@cindex modifiers, M32C
692a6b7db3Sskrll
702a6b7db3SskrllThe assembler supports several modifiers when using symbol addresses
712a6b7db3Sskrllin M32C instruction operands.  The general syntax is the following:
722a6b7db3Sskrll
732a6b7db3Sskrll@smallexample
742a6b7db3Sskrll%modifier(symbol)
752a6b7db3Sskrll@end smallexample
762a6b7db3Sskrll
772a6b7db3Sskrll@table @code
782a6b7db3Sskrll@cindex symbol modifiers
792a6b7db3Sskrll
802a6b7db3Sskrll@item %dsp8
812a6b7db3Sskrll@itemx %dsp16
822a6b7db3Sskrll
832a6b7db3SskrllThese modifiers override the assembler's assumptions about how big a
842a6b7db3Sskrllsymbol's address is.  Normally, when it sees an operand like
852a6b7db3Sskrll@samp{sym[a0]} it assumes @samp{sym} may require the widest
862a6b7db3Sskrlldisplacement field (16 bits for @samp{-m16c}, 24 bits for
872a6b7db3Sskrll@samp{-m32c}).  These modifiers tell it to assume the address will fit
882a6b7db3Sskrllin an 8 or 16 bit (respectively) unsigned displacement.  Note that, of
892a6b7db3Sskrllcourse, if it doesn't actually fit you will get linker errors.  Example:
902a6b7db3Sskrll
912a6b7db3Sskrll@smallexample
922a6b7db3Sskrllmov.w %dsp8(sym)[a0],r1
932a6b7db3Sskrllmov.b #0,%dsp8(sym)[a0]
942a6b7db3Sskrll@end smallexample
952a6b7db3Sskrll
962a6b7db3Sskrll@item %hi8
972a6b7db3Sskrll
982a6b7db3SskrllThis modifier allows you to load bits 16 through 23 of a 24 bit
992a6b7db3Sskrlladdress into an 8 bit register.  This is useful with, for example, the
1002a6b7db3SskrllM16C @samp{smovf} instruction, which expects a 20 bit address in
1012a6b7db3Sskrll@samp{r1h} and @samp{a0}.  Example:
1022a6b7db3Sskrll
1032a6b7db3Sskrll@smallexample
1042a6b7db3Sskrllmov.b #%hi8(sym),r1h
1052a6b7db3Sskrllmov.w #%lo16(sym),a0
1062a6b7db3Sskrllsmovf.b
1072a6b7db3Sskrll@end smallexample
1082a6b7db3Sskrll
1092a6b7db3Sskrll@item %lo16
1102a6b7db3Sskrll
1112a6b7db3SskrllLikewise, this modifier allows you to load bits 0 through 15 of a 24
1122a6b7db3Sskrllbit address into a 16 bit register.
1132a6b7db3Sskrll
1142a6b7db3Sskrll@item %hi16
1152a6b7db3Sskrll
1162a6b7db3SskrllThis modifier allows you to load bits 16 through 31 of a 32 bit
1172a6b7db3Sskrlladdress into a 16 bit register.  While the M32C family only has 24
1182a6b7db3Sskrllbits of address space, it does support addresses in pairs of 16 bit
1192a6b7db3Sskrllregisters (like @samp{a1a0} for the @samp{lde} instruction).  This
1202a6b7db3Sskrllmodifier is for loading the upper half in such cases.  Example:
1212a6b7db3Sskrll
1222a6b7db3Sskrll@smallexample
1232a6b7db3Sskrllmov.w #%hi16(sym),a1
1242a6b7db3Sskrllmov.w #%lo16(sym),a0
1252a6b7db3Sskrll@dots{}
1262a6b7db3Sskrlllde.w [a1a0],r1
1272a6b7db3Sskrll@end smallexample
1282a6b7db3Sskrll
1292a6b7db3Sskrll@end table
130883529b6Schristos
131883529b6Schristos@node M32C-Chars
132883529b6Schristos@subsection Special Characters
133883529b6Schristos
134883529b6Schristos@cindex line comment character, M32C
135883529b6Schristos@cindex M32C line comment character
136883529b6SchristosThe presence of a @samp{;} character on a line indicates the start of
137883529b6Schristosa comment that extends to the end of that line.
138883529b6Schristos
139883529b6SchristosIf a @samp{#} appears as the first character of a line, the whole line
140883529b6Schristosis treated as a comment, but in this case the line can also be a
141883529b6Schristoslogical line number directive (@pxref{Comments}) or a
142883529b6Schristospreprocessor control command (@pxref{Preprocessing}).
143883529b6Schristos
144883529b6Schristos@cindex line separator, M32C
145883529b6Schristos@cindex statement separator, M32C
146883529b6Schristos@cindex M32C line separator
147883529b6SchristosThe @samp{|} character can be used to separate statements on the same
148883529b6Schristosline.
149