This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how do I check #pragma directives

Hello ! I have a some quetions.
I my project i write some math(on Assembler) library for using in C and Assembler.
I have some function, in C this function can be defined:

extern signed long add32(signed long var1, signed long var2)


of course, this mean I have to respectively describe the function in assembler:

;---------- Object name ---------------
NAME ADD32                                                                      ; Obj. name

;---------- Segment declaration -------
?PR?_add32?ADD32 SEGMENT CODE                   ; Segment defenition
?DT?_add32?ADD32 SEGMENT DATA OVERLAYABLE       ; Segment defenition for long var's.

;---------- Public symbols ------------
PUBLIC ?_add32?BYTE                             ; Public symbol for long var's
PUBLIC _add32                                   ; Public function symbol

;---------- Vars defenition -----------
RSEG ?DT?_add32?ADD32
?_add32?BYTE:
ORG 04H
OP_BYTE:                 ds 04H                 ; Second operand memory allocate

;---------- Function code  ------------
RSEG ?PR?_add32?ADD32
_add32:
                clr C                           ; clr Carry

                mov  A,R7                       ; load ACC with LSB first op.
                ADD  A,OP_BYTE +03H             ; ADD LSB second op.
                mov  R7,A                       ; save result to R7

                mov  A,R6                       ; load ACC with next byte first op.
                ADDC A,OP_BYTE +02H             ; ADD next byte second op. + Carry
                mov  R6,A                       ; save result to R7

                mov  A,R5                       ; load ACC with next byte first op.
                ADDC A,OP_BYTE +01H             ; ADD next byte second op. + Carry
                mov  R5,A                       ; save result to R7

                mov  A,R4                       ; load ACC with MSB first op.
                ADDC A,OP_BYTE +00H             ; ADDC MSB second op. + Carry
                mov  R4,A                       ; save result to R6
end_add32:
                ret
;--------------------------------------
END

and

;---------- Segment declaration -------
...
?DT?_add32?ADD32 SEGMENT DATA OVERLAYABLE
...
;---------- Public symbols ------------
PUBLIC ?_add32?BYTE                             ; Public symbol for long var's
...


;---------- Vars defenition ----------- RSEG ?DT?_add32?ADD32 ?_add32?BYTE: ORG 04H OP_BYTE: ds 04H ; Second operand memory allocate


this segment must be declared for passing variable in function with type long.

When i define ,example:

#pragma REGPARMS


this function working normaly, first long var placed to R4& R5& R6& R7, second lond var placed direc to memory segment ?DT?_add32?ADD32 with offset four bytes.
BUT when I want to like don't use register and pass all parametrs in memory, if i define

#pragma NOREGPARMS


first long var placed to ?DT?_add32?ADD32 without offset , second lond var placed direc to memory segment ?DT?_add32?ADD32 with offset four bytes, and my function don't work.

Quetions:
Possible to determine at compile time which #pragma directives are set, and on this corect source code.

This function only example, of course no need use this function in C.

Sorry for my english.:)
With best regards Artem Gusev.
Thanks for all.

Parents
  • The name of functions, at the assembler level, is different between REGPARMS and NOREGPARMS mode. That's how you would distinguish them.

    But the issue really doesn't exist. You can decide on one mode, and wrap your prototypes in

    #pragma save
    #pragma noregparms
    /*...*/
    #pragma restore
    

    to tell the compiler which one you used.

Reply
  • The name of functions, at the assembler level, is different between REGPARMS and NOREGPARMS mode. That's how you would distinguish them.

    But the issue really doesn't exist. You can decide on one mode, and wrap your prototypes in

    #pragma save
    #pragma noregparms
    /*...*/
    #pragma restore
    

    to tell the compiler which one you used.

Children