Mail Archives: djgpp-workers/2001/02/02/15:11:44
Here's a partial patch for djasm.txi (the part that adds discussion
of enumeration type). Could a few extra eyes read this over before
I commit it? I'm not sure about some of the markup. Thanks.
(And thanks, Bill, for making it so easy ;-)
--
jtw
--- djasm.txi Sun Jan 14 16:45:43 2001
+++ ./my-djasm-docs/djasm.txi Fri Feb 2 14:00:07 2001
@@ -743,6 +783,76 @@
system tables).
@comment node-name, next, previous, up
+@node Enumerations
+@subsubsection Enumerations
+
+@pindex enumeration
+@cindex type AT r{, enumeration}
+
+The enumeration type allows arbitrary mnemonic identifiers (the
+`enumeration constants') to be mapped to a set of integer values.
+A textbook example is that of defining a boolean variable.
+The following construct defines @samp{boolean} as an enumeration
+type that can take the values 0 (false) or 1 (true).
+
+@example
+.enum boolean
+ false
+ true
+.ends
+@end example
+
+@noindent
+In this example, @samp{pets} is defined to be an enumeration type
+having integral values 0 (bird), 1 (cat), 2 (dog), or 3 (rock).
+
+@example
+.enum pets
+ bird
+ cat
+ dog
+ rock
+.ends
+@end example
+
+@noindent
+The above enumeration types could then be referenced as follows:
+
+@example
+.start
+ nop
+ mov ax,true ; ax <- 1
+ mov bx,pets.dog ; bx <- 2
+ mov cx,pets.rock ; cx <- 3
+ mov dx,pets.bird ; dx <- 0
+ int 0x20
+@end example
+
+If the enumeration constants are not explicitly initialized, then they
+are assigned consecutive integer values starting with zero.
+Explicitly and implicitly initialized enumeration constants can be
+used within the same enumeration type, in which case an enumeration
+constant without an initializer will be assigned either the predecessor
+or successor of the adjacent enumeration constant.
+
+In this example, the enumeration constants @samp{foo}, @samp{bar},
+and @samp{e} are implicitly initialized.
+The enumeration @samp{snafu} therefore takes one of the following integer
+values: foo (-1), bar (0), a (1), b (2), c (4), d (8), or e (9).
+
+@example
+.enum snafu
+ foo
+ bar
+ a=1
+ b=2
+ c=4
+ d=8
+ e
+.ends
+@end example
+
+@comment node-name, next, previous, up
@node Prefixes
@subsection Segment Override Prefixes
- Raw text -