error using in-line function

void test()
{
#pragma asm
MOV R0,#55H
#pragma endasm
}
this code generates A45 error:undefined symbol

Parents
  • You ARE using the SRC directive, aren't you?

    When I compile your example, I get the following .SRC file.

    ; .\main.SRC generated from: main.c
    ; COMPILER INVOKED BY:
    ;        C:\Keil\C51\BIN\C51.EXE main.c
    ;        BROWSE DEBUG OBJECTEXTEND CODE
    ;        PREPRINT SRC(.\main.SRC)
    
    
    NAME	MAIN
    
    ?PR?test?MAIN        SEGMENT CODE
    	PUBLIC	test
    ; void test()
    
    	RSEG  ?PR?test?MAIN
    test:
    			; SOURCE LINE # 1
    ; {
    			; SOURCE LINE # 2
    ; #pragma asm
    ; MOV R0,#55H
    	  MOV R0,#55H
    ; #pragma endasm
    ; }
    			; SOURCE LINE # 6
    	RET
    ; END OF test
    
    	END
    

    When I assemble the SRC file, I get the following:

    A51 MACRO ASSEMBLER  MAIN
    09/16/2004 10:10:27 PAGE     1
    
    
    MACRO ASSEMBLER A51 V7.09
    OBJECT MODULE PLACED IN main.OBJ
    ASSEMBLER INVOKED BY: C:\Keil\C51\BIN\A51.EXE main.SRC SET(SMALL) DEBUG EP
    
    LOC  OBJ            LINE     SOURCE
    
                           1     ; .\main.SRC generated from: main.c
                           2     ; COMPILER INVOKED BY:
                           3     ;        C:\Keil\C51\BIN\C51.EXE main.c
                                 ;        BROWSE DEBUG OBJECTEXTEND CODE
                                 ;        PREPRINT SRC(.\main.SRC)
                           4
                           5
                           6     NAME    MAIN
                           7
                           8     ?PR?test?MAIN        SEGMENT CODE
                           9             PUBLIC  test
                          10     ; void test()
                          11
    ----                  12             RSEG  ?PR?test?MAIN
    0000                  13     test:
                          14                             ; SOURCE LINE # 1
                          15     ; {
                          16                             ; SOURCE LINE # 2
                          17     ; #pragma asm
                          18     ; MOV R0,#55H
    0000 7855             19               MOV R0,#55H
                          20     ; #pragma endasm
                          21     ; }
                          22                             ; SOURCE LINE # 6
    0002 22               23             RET
                          24     ; END OF test
                          25
                          26             END
    
    SYMBOL TABLE LISTING
    ------ ----- -------
    
    
    N A M E             T Y P E  V A L U E   ATTRIBUTES
    
    ?PR?TEST?MAIN. . .  C SEG    0003H       REL=UNIT
    MAIN . . . . . . .  N NUMB   -----
    TEST . . . . . . .  C ADDR   0000H   R   SEG=?PR?TEST?MAIN
    
    
    REGISTER BANK(S) USED: 0
    
    
    ASSEMBLY COMPLETE.  0 WARNING(S), 0 ERROR(S)

    I get no errors or warnings. Perhaps you should post the listing file with the error message so one of us could give you more helpful feedback.

    Jon

Reply
  • You ARE using the SRC directive, aren't you?

    When I compile your example, I get the following .SRC file.

    ; .\main.SRC generated from: main.c
    ; COMPILER INVOKED BY:
    ;        C:\Keil\C51\BIN\C51.EXE main.c
    ;        BROWSE DEBUG OBJECTEXTEND CODE
    ;        PREPRINT SRC(.\main.SRC)
    
    
    NAME	MAIN
    
    ?PR?test?MAIN        SEGMENT CODE
    	PUBLIC	test
    ; void test()
    
    	RSEG  ?PR?test?MAIN
    test:
    			; SOURCE LINE # 1
    ; {
    			; SOURCE LINE # 2
    ; #pragma asm
    ; MOV R0,#55H
    	  MOV R0,#55H
    ; #pragma endasm
    ; }
    			; SOURCE LINE # 6
    	RET
    ; END OF test
    
    	END
    

    When I assemble the SRC file, I get the following:

    A51 MACRO ASSEMBLER  MAIN
    09/16/2004 10:10:27 PAGE     1
    
    
    MACRO ASSEMBLER A51 V7.09
    OBJECT MODULE PLACED IN main.OBJ
    ASSEMBLER INVOKED BY: C:\Keil\C51\BIN\A51.EXE main.SRC SET(SMALL) DEBUG EP
    
    LOC  OBJ            LINE     SOURCE
    
                           1     ; .\main.SRC generated from: main.c
                           2     ; COMPILER INVOKED BY:
                           3     ;        C:\Keil\C51\BIN\C51.EXE main.c
                                 ;        BROWSE DEBUG OBJECTEXTEND CODE
                                 ;        PREPRINT SRC(.\main.SRC)
                           4
                           5
                           6     NAME    MAIN
                           7
                           8     ?PR?test?MAIN        SEGMENT CODE
                           9             PUBLIC  test
                          10     ; void test()
                          11
    ----                  12             RSEG  ?PR?test?MAIN
    0000                  13     test:
                          14                             ; SOURCE LINE # 1
                          15     ; {
                          16                             ; SOURCE LINE # 2
                          17     ; #pragma asm
                          18     ; MOV R0,#55H
    0000 7855             19               MOV R0,#55H
                          20     ; #pragma endasm
                          21     ; }
                          22                             ; SOURCE LINE # 6
    0002 22               23             RET
                          24     ; END OF test
                          25
                          26             END
    
    SYMBOL TABLE LISTING
    ------ ----- -------
    
    
    N A M E             T Y P E  V A L U E   ATTRIBUTES
    
    ?PR?TEST?MAIN. . .  C SEG    0003H       REL=UNIT
    MAIN . . . . . . .  N NUMB   -----
    TEST . . . . . . .  C ADDR   0000H   R   SEG=?PR?TEST?MAIN
    
    
    REGISTER BANK(S) USED: 0
    
    
    ASSEMBLY COMPLETE.  0 WARNING(S), 0 ERROR(S)

    I get no errors or warnings. Perhaps you should post the listing file with the error message so one of us could give you more helpful feedback.

    Jon

Children
No data
More questions in this forum