La última línea, ¿alguien puede explicarme qué hace? es la primera vez que veo una línea así :shock:
La parte de asm lo entiendo y lo mismo el mov pero ¿todo eso de los dos puntos? ¿qué es?
Muchas gracias.
Un saludo. :-/
Título: Re: No entiendo esa linea en assembler...
Publicado por: Nocturno en 29 de Diciembre de 2009, 15:42:14
¿Eso es C, verdad?, ¿para qué compilador está escrito? Sospecho que esa sintaxis es propia del compilador.
Título: Re: No entiendo esa linea en assembler...
Publicado por: Patoso en 29 de Diciembre de 2009, 16:17:21
es C30, pero hace un "asm" que es assembler, ¿no?
Título: Re: No entiendo esa linea en assembler...
Publicado por: Nocturno en 29 de Diciembre de 2009, 16:25:29
Sí, es ASM embebido dentro de un programa en C30.
Mira lo que dice el manual: 8.4 USING INLINE ASSEMBLY LANGUAGE Within a C function, the asm statement may be used to insert a line of assembly language code into the assembly language that the compiler generates. In-line assembly has two forms: simple and extended. In the simple form, the assembler instruction is written using the syntax: asm ("instruction"); where instruction is a valid assembly-language construct. If you are writing inline assembly in ANSI C programs, write __asm__ instead of asm. In an extended assembler instruction using asm, the operands of the instruction are specified using C expressions. The extended syntax is:
You must specify an assembler instruction template, plus an operand constraint string for each operand. The template specifies the instruction mnemonic, and optionally placeholders for the operands. The constraint strings specify operand constraints, for example, that an operand must be in a register (the usual case), or that an operand must be an immediate value. For example, here is how to use the dsPIC device’s swap instruction (which the compiler does not generally use):
Código: ASM
asm ("swap %0":"+r"(var));
Here var is the C expression for the operand, which is both an input and an output operand. The operand is constrained to be of type r, which denotes a register operand. The + in +r indicates that the operand is both an input and output operand.
Título: Re: No entiendo esa linea en assembler...
Publicado por: Patoso en 29 de Diciembre de 2009, 17:09:00
genial! muy útil!
muchas gracias! ¿de dónde te sacaste ese texto?
Título: Re: No entiendo esa linea en assembler...
Publicado por: Nocturno en 29 de Diciembre de 2009, 19:17:33
De la MPLAB® C COMPILER FOR PIC24 MCUs AND dsPIC® DSCs USER’S GUIDE (http://ww1.microchip.com/downloads/en/DeviceDoc/51284H.pdf)
Título: Re: No entiendo esa linea en assembler...
Publicado por: Patoso en 30 de Diciembre de 2009, 14:29:36
Ya estuve mirando :D
Sólo decir que era el capítulo 9.4 y no el 8.4, por si alguien quiere echarle un vistazo.
Un saludo :-/
Título: Re: No entiendo esa linea en assembler...
Publicado por: Nocturno en 30 de Diciembre de 2009, 14:38:22
Sí, porque el documento ya va por la revisión H y el que yo tenía en mi disco duro es la revisión B, cuando los dsPIC sólo eran 30F, y no existían ni los 24F, ni los 24H ni los 33F.