Jump to content
Sign in to follow this  
erkle_01au

Inline Assembly

Recommended Posts

Would it be possible to get a switch on the linker/compiler that allows "untouched" inline assembly. e.g inline asm where the linker does not insert bank select instructions. The well documented case of where this would be useful is writing to flash. In the example the bank select between the MOVLW 0x55 and the MOVWF gbl_eecon2 violates the rules and so it would be useful to use "untouched" inline asm for this.

 

0E27  008C 	 MOVWF gbl_eedata
0E28  3055 	 MOVLW 0x55
0E29  1683 	 BSF STATUS, RP0
0E2A  008D 	 MOVWF gbl_eecon2
0E2B  30AA 	 MOVLW 0xAA
0E2C  008D 	 MOVWF gbl_eecon2
0E2D  148C 	 BSF gbl_eecon1,1
0E2E  0000 	 NOP
0E2F  0000 	 NOP

 

I realise that there is some risk involved with this hence the use of a switch but if I'm going to write inline asm I should be allowed to shoot myself in the foot if I want :)

 

Peter

Share this post


Link to post
Share on other sites

You mean like the _asm and asm wrappers that already exist?

The documentation starts on pg 60 of the BoostC user manual.

 

Should exist for others.

Edited by emte

Share this post


Link to post
Share on other sites
You mean like the _asm and asm wrappers that already exist?

Those automatically insert bank select instructions, which is what he doesn't want.

 

I didn't know there were rules that strict about the sequence. Does that actually fail to write?

 

Maybe for cases like this there could still be a banksel instruction. Instead of working like in MPASM:

banksel reg_a
movf reg_a, 0

it could force the bank select early like this:

banksel
movlw 0x55
movwf glb_eecon2

In other words, instead of meaning "switch to the bank of register XX now" it could mean "if the bank switches between here and the next register access, get the switch out of the way now". It could also accept an argument and ignore it so that the MPASM syntax would work.

Share this post


Link to post
Share on other sites
I didn't know there were rules that strict about the sequence.  Does that actually fail to write?

 

I was having all sorts of trouble writing to the flash. Then I read this thread(I hope i've pasted this link in right) and followed the workaround

 

http://forum.sourceboost.com/index.php?sho...8699entry8699

 

After doing this the problems seemed to go away. Now of course I was only changing one thing at a time :) so I am not exactly sure what fixed it.

 

Never the less I would still like to be able to write inline asm that is under my full control. I haven't worked out how to use MPLAB to write asm obj modules to link with boostc.

 

Peter

Share this post


Link to post
Share on other sites
Never the less I would still like to be able to write inline asm that is under my full control.
I was glad to leave page and bank concerns behind without bloating the assembly. I do see your point, though.

 

I haven't worked out how to use MPLAB to write asm obj modules to link with boostc.

Have a look at this thread: http://forum.sourceboost.com/index.php?showtopic=2227&hl=

Basically, you can't! The only way is inline.

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...