From: cuz Date: Fri, 5 Dec 2003 22:30:18 +0000 (+0000) Subject: Explain more new stuff X-Git-Tag: V2.12.0~1087 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=35e639aac6d4a20aabe10ddfbd4daa232d5c4d62;p=cc65 Explain more new stuff git-svn-id: svn://svn.cc65.org/cc65/trunk@2715 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 4cf141916..70bb5d177 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -800,22 +800,139 @@ id="scopesearch" name=""Scope search order"">). Structs, unions and enums

+Structs, unions and enums are explained in a , I do only cover them here, because if they are declared with a +name, they open a nested scope, similar to /. However, when no name is specified, the behaviour is +different: In this case, no new scope will be opened, symbols declared within +a struct, union, or enum declaration will then be added to the enclosing scope +instead. +Explicit scope specification

+Accessing symbols from other scopes is possible by using an explicit scope +specification, provided that the scope where the symbol lives in has a name. +The namespace token ( + .scope foo + bar: .word 0 + .endscope -Explicit scope specification

+ ... + lda foo::bar ; Access foo in scope bar + + +The only way to deny access to a scope from the outside is to declare a scope +without a name (using the / command). + +A special syntax is used to specify the global scope: If a symbol or scope is +preceeded by the namespace token, the global scope is searched: + + + bar = 3 + + .scope foo + bar = 2 + lda #::bar ; Access the global bar (which is 3) + .endscope + Scope search order

+The assembler searches for a scope in a similar way as for a symbol. First, it +looks in the current scope, and then it walks up the enclosing scopes until +the scope is found. +However, one important thing to note when using explicit scope syntax is, that +a symbol may be accessed before it is defined, but a scope may + .scope foo + bar = 3 + .endscope -Address sizes -

+the reference to the scope + .scope foo + .scope outer + .scope inner + bar = 1 + .endscope + .endscope + .scope another + .scope nested + lda #outer::inner::bar ; 1 + .endscope + .endscope + .endscope + + .scope outer + .scope inner + bar = 2 + .endscope + .endscope + + +When + .scope foo + .scope outer + .scope inner + bar = 1 + .endscope + .endscope + .scope another + .scope nested + lda #::outer::inner::bar ; 2 + .endscope + .endscope + .endscope + + .scope outer + .scope inner + bar = 2 + .endscope + .endscope + + + +Address sizes

@@ -2493,6 +2610,51 @@ Here's a list of all control commands and a description, what they do: +.SIZEOF

+ + + .struct Point ; Struct size = 4 + xcoord .word + xcoord .word + .endstruct + + P: .tag Point ; Declare a point + + .code + .proc Code ; 3 bytes + nop + nop + nop + .endproc + + .proc Data ; 4 bytes + .data ; Segment switch!!! + .res 4 + .endproc + + lda #.sizeof(Point) ; Loads 4 + lda #.sizeof(Point::xcoord) ; Loads 2 + lda #.sizeof(P) ; Loads 4 + lda #.sizeof(Code) ; Loads 3 + lda #.sizeof(Data) ; Loads 0 + + + .SMART

Switch on or off smart mode. The command must be followed by a '+' or @@ -2500,13 +2662,21 @@ Here's a list of all control commands and a description, what they do: is off (that is, the assembler doesn't try to be smart), but this default may be changed by the -s switch on the command line. - In smart mode the assembler will track usage of the + Track usage of the In 65816 mode, replace a Example: @@ -2515,6 +2685,11 @@ Here's a list of all control commands and a description, what they do: .smart - ; Stop being smart + See: , + , + , + + .STRAT