From: cuz Date: Tue, 2 Oct 2001 16:41:31 +0000 (+0000) Subject: Explain the new inline assembler syntax X-Git-Tag: V2.12.0~2593 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=30388bcf0bfc3d6f10c5041ceb04857caf662a6e;p=cc65 Explain the new inline assembler syntax git-svn-id: svn://svn.cc65.org/cc65/trunk@995 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/doc/cc65.sgml b/doc/cc65.sgml index cbe9f19b9..90e8bbde5 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -194,7 +194,7 @@ Here is a description of all the command line options: atari c64 c128 - plus4 + plus4 cbm510 (CBM-II series with 40 column video) cbm610 (all CBM-II II computers with 80 column video) pet (all CBM PET systems except the 2001) @@ -399,22 +399,18 @@ This cc65 version has some extensions to the ISO C standard. file. The syntax is - asm (<string literal>) ; + asm (<string literal>[, optional parameters]) ; or - __asm__ (<string literal>) ; + __asm__ (<string literal>[, optional parameters]) ; The first form is in the user namespace and is disabled if the .

There is a special calling convention named "fastcall". This calling @@ -727,6 +723,80 @@ id="pragma-staticlocals"

+Inline assembler

+ +The compiler allows to insert assembler statements into the output file. The +syntax is + + + asm (<string literal>[, optional parameters]) ; + +or + + __asm__ (<string literal>[, optional parameters]) ; + +

+ +The first form is in the user namespace and is disabled by . + +The asm statement may be used inside a function and on global file level. An +inline assembler statement is a primary expression, so it may also be used as +part of an expression. Please note however that the result of an expression +containing just an inline assembler statement is always of type +

+ +Using these format specifiers, you can access C + #define OFFS 23 + __asm__ ("ldy #%b", OFFS); + + +Or, to access a struct member of a static variable: + + + typedef struct { + unsigned char x; + unsigned char y; + unsigned char color; + } pixel_t; + static pixel_t pixel; + __asm__ ("ldy #%b", offsetof(pixel, color)); + __asm__ ("lda %v,y", pixel); + +

+ + + Bugs/Feedback

If you have problems using the compiler, if you find any bugs, or if you're