We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi again, IÂ'm trying to compile the following code (with the SRC directive actived):
void alfa (void) { #pragma ASM JMP $ ; endless loop #pragma ENDASM }
but an error has occurred in other part of my source code. Exactly, where the line A DATA 0E0H appears. Any idea?
; .\list.SRC generated from: list.c ; COMPILER INVOKED BY: ; C:\Keil\C51\BIN\C51.EXE list.c LARGE OPTIMIZE(5,SIZE) BROWSE ORDER INCDIR(..\FreeRTOSV5.2.0\Source\include) DEBUG OBJECTEXTEND CODE LISTINCLUDE SYMBOLS PREPRINT SRC(.\list.SRC) $NOMOD51 NAME LIST A DATA 0E0H ADC_CHCTR0 DATA 0CAH ADC_CHCTR1 DATA 0CBH ...
Thanks in advance.
If you got any errors anywhere in the build, it is pointless to worry about the final output - it is erroneous!
Just fix the errors.
I trust you're doing that merely out of academic interest - there is absolutely no point whatsoever in doing that in assembler!
The following 'C' code will produce exactly the same result:
void alfa (void) { for( ;; ) /* endless loop */ ; }
and it won't destroy your debug information.
Hi Andy, the example explained above is just to check how to keil compile the asm code.
I want to put another assembly code, but I can not compile this simple example.
Any idea?
Not without you bothering to say what that error was that occured, no.
Hi Hans-Bernhard
The error found is the following:
list.src (9): error A9: SYNTAX ERROR
Line 9 is formed by the following line exactly:
A DATA 0E0H
I do not understand the error because the ".src" file is generated automatically. Thank you very much.
I think you'll find that 'A' is a reserved name in Keil's A51 assembler, but not in C51...
I strongly recommend that you stop messing about with inline assembler: if you need parts of your code in assembler, then write those parts in assembler and call them from 'C'...
See: http://www.keil.com/forum/docs/thread14827.asp
I found the solution to solve my problem. I have just created a file only with asm and C code and activated the SRC directive. With this configuration the project compiles, but if I mix the asm code with other C code, I get the error that I report before.
So, finally, I have a file called "port_asm.c" with the following code:
void alfa (void) { #pragma asm JMP $ ; endless loop #pragma endasm }
Thanks a lot for your support.
But you are still messing about with inline assembler - I recommended that you do not do that!
Haven't you already seen enough problems from using inline assembler to convince you?!
Instead, have (a) separate, pure assembler file(s) in which you write assembler functions that can be called from 'C'.
Create a C file with stub functions for the assembler functions you need to call from C.
Take the assembler output from the compiler as a reference and create a new assembler file, where you add the contents to the functions.
How to create a 'C'-callable assembler function, starting from a 'C' skeleton:
www.8052.com/.../149030
Thanks again for your support.