forum.gifForum - Technical - Topic #102

 

Forum - Forum
Technical - Technical


closed by PPA   2010.03.20   7:16 PM  Topic # 102  Assembler Routines within Pascal Project

2010.02.03 4:38 PM
by stefanhanoi



7 messages

Join Date 2010.01.19

Location: Hanoi, Vietnam


Hi,

would be nice to have some examples of how to integrate assembler into a Pascal project, especially how parameters are passed to assembler procedures and functions, and how they get back into Pascal.

I see three scenarios:

- assembler inline of Pascal source -> handled by PMP
- separate assembler source
- separate pre-compiled code -> handled by linker

The documentation currently doesn't say much.

 

Thanks a lot!

Stefan

Write to stefanhanoi  topic closed  Top
Answer n° 1
--------
2010.02.03 8:52 PM
by PPA

Porting to 64 bits PICs is a piece of cake...

Administrator
161 messages

Join Date 2008.12.21

Location: France, IDF

Hi,

Thanks for this feedback.

Naming convention is documented.

Parameter passing is implicitly documented: default is by value in a procedure/function specific variable. VAR parameters are passed as pointers (1 or 2 bytes depending on $POINTERS), CONST parameters are passed by value for simple types, by a pointer for records or arrays. VAR boolean are not passed as pointers (meaningless) but copied before and after call (documented).

For PIC18, current bank may be unknown at procedure entry and exit.

For other processors, current bank is always 0 upon procedure entry and exit. The optimizer needs this. Nevertheless if an asm block is inserted in a procedure, the optimizer will assume that the current bank is unknown at the end of the block.

PMP does not analyze an asm block, it is passed as is to the assembler.

You may search the manual for procedure definition with "external" keyword.

Memory allocation for variables should always be done by PMP, or the used memory should be $RESERVED before any PMP variable allocation so that PMP cannot use it.

I will upgrade the documentation.

Regards,


PMP team leader

Write to PPA   Web site PPA closed by PPA   2010.03.20   7:16 PM  Top
Answer n° 2
--------
2010.02.04 11:03 AM
by stefanhanoi



8 messages

Join Date 2010.01.19

Location: Hanoi, Vietnam

Hi PPA,

I am no prof. programmer, just a hacker who does most by "copy and learn".

Yes, some hints are in the present documentation already, and - since the intermediate files are available - I can look to get something out by kind of "reverse engineering", i.e. look how the assembler code looks like that PMP passes to the MPASM.

I just thought, in case you have already some examples available, that would make it easy: just look how it is done there.

Anyway, I can try, and wait for the next release of the documentation.

Thanks!

Stefan

Write to stefanhanoi   closed by PPA   2010.03.20   7:16 PM  Top
Answer n° 3
--------
2010.02.04 5:05 PM
by PPA

Porting to 64 bits PICs is a piece of cake...

Administrator
165 messages

Join Date 2008.12.21

Location: France, IDF

Another tip: asm blocks should be carefully inserted in an interrupt procedure because PMP cannot know which registers are used and what to backup. Samething applies to a full assembler routine called from an interrupt procedure.

Regards,


PMP team leader

Write to PPA   Web site PPA closed by PPA   2010.03.20   7:16 PM  Top
active topic active   closed topic closed   Sticky Sticky   New New message   -   Correct Correct message   Close Close topic   Make sticky Make sticky
[]
Forum Topic  Forum 




Sentence to think about :     
^ Top ^