• AVR Freaks

Helpful ReplyHot!assembly only mode.

Author
Joel_L
Starting Member
  • Total Posts : 10
  • Reward points : 0
  • Joined: 2020/08/03 06:47:41
  • Location: 0
  • Status: offline
2020/08/10 13:07:25 (permalink)
5 (1)

assembly only mode.

Hi,
I recently jumped on MPLAB X 5.4. After some teething pains with the switch from MPASM to pic-as I got that sorted out and is working well.
 
Now I'm on a project that will use a 24FJxxxxx. The project is only in assembly language, I don't care about C for this.
 
I set up a new project and it compiles OK with some short test code just to see, but I think it's still being treated as a C project. It only has one source file, test.s ( also tried upper case S ). What I notice,
 
When I build the project, xc16-gcc is being invoked and not xc16-as. What's odd is that I renamed xc16-as to something else and the build failed, so it seems it's being run from somewhere though I don't see it.
 
When I look at the program memory window, there is a whole bunch of code in there that I did not write. When I do something in assembly, I expect the only code in program memory to be what I actually wrote, no freebies.
 
All this makes me think I do not have something set right to be an assembly project, no C artifacts.
 
I'm still going through the xc16 assembly guide ( need to look at it when my brain is alert ), but any quick pointers appreciated
 
Thanks
Joel
#1
Antipodean
Super Member
  • Total Posts : 1906
  • Reward points : 0
  • Joined: 2008/12/09 10:19:08
  • Location: Didcot, United Kingdom
  • Status: offline
Re: assembly only mode. 2020/08/10 13:54:07 (permalink)
0
Joel_L
When I look at the program memory window, there is a whole bunch of code in there that I did not write. When I do something in assembly, I expect the only code in program memory to be what I actually wrote, no freebies.

 
What is the code you see? I suspect it is the interrupt jump table, and depending on the exact chip you are using it will be either 256 or 512 words plus a little extra for the default interrupt handler for unused interrupts.
 

Do not use my alias in your message body when replying, your message will disappear ...

Alan
#2
du00000001
Just Some Member
  • Total Posts : 3946
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: assembly only mode. 2020/08/10 14:55:32 (permalink)
+1 (1)
Anti podean
Do not use my alias in your message body when replying, your message will disappear ...

 
Any chance you could format this bold? Might help ...

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#3
Antipodean
Super Member
  • Total Posts : 1906
  • Reward points : 0
  • Joined: 2008/12/09 10:19:08
  • Location: Didcot, United Kingdom
  • Status: offline
Re: assembly only mode. 2020/08/10 15:05:24 (permalink)
+2 (2)
du00000001
Anti podean
Do not use my alias in your message body when replying, your message will disappear ...

 
Any chance you could format this bold? Might help ...

How is this now (looks like it affects the previous post as well) Smile: Smile
 

Do not use my alias in your message body when replying, your message will disappear ...

Alan
#4
ric
Super Member
  • Total Posts : 28378
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: assembly only mode. 2020/08/10 15:10:49 (permalink)
0
I suspect many new users don't know what "alias" means.
Maybe just spell it out.

If you quote my post, insert a space between "anti" and "podean" in the quote tag, or your post will vanish!


I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#5
dan1138
Super Member
  • Total Posts : 3843
  • Reward points : 0
  • Joined: 2007/02/21 23:04:16
  • Location: 0
  • Status: offline
Re: assembly only mode. 2020/08/10 15:37:21 (permalink) ☄ Helpfulby Joel_L 2020/08/10 20:20:32
+2 (4)
Joel_L
... I'm still going through the xc16 assembly guide ( need to look at it when my brain is alert ), but any quick pointers appreciated ...

Attached is an assembly language template I used for PIC24F16KA102 projects.
 
This should give you some idea of how to setup your project in MPLABX using the XC16 compiler.
 
To make this clear Microchip has decided to deprecate the use of assembly language directives to set the values for configuration words. This decision forces the developer to have at least one C language source file in an assembly language project. One other requirement is that the Power-On-Reset(POR) entry point must use the symbolic name: "__reset". Without this specific name the linker will include the C-Run-Time(CRT) code from the controller specific library when you use the default linker script for your project.
 
Before the old nit pickers chime in, what I have just said is not strictly true for all PIC24FJ controllers, and it is possible to create an assembly language source code only project if your target controller is ancient enough.
post edited by dan1138 - 2020/08/11 14:52:33
#6
ric
Super Member
  • Total Posts : 28378
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: assembly only mode. 2020/08/10 21:11:21 (permalink)
0
It appears Joel_L has ignored all the advice, and quoted a post from Anti podean without splitting his name.

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#7
du00000001
Just Some Member
  • Total Posts : 3946
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: assembly only mode. 2020/08/11 02:59:43 (permalink)
+1 (1)
Antediluvian?
du00000001
Anti podean
Do not use my alias in your message body when replying, your message will disappear ...

 
Any chance you could format this bold? Might help ...

How is this now (looks like it affects the previous post as well) Smile

 
Now it's for the visually impaired. Won't help with the mentally impaired ones grin
 
And yes - seems that avatars and footnotes come live from the profile.
(In case of the avatars I'm sure, as the avatar changes depending on whether you're viewing a paged being logged-in or logged-out. (at least in my case.))
 
@ric
Looks as if ...: 7 replies, but only 7 messages displayed. One went down the gutter, and now the poor Joel_L might wait for an answer never to come...

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#8
Joel_L
Starting Member
  • Total Posts : 10
  • Reward points : 0
  • Joined: 2020/08/03 06:47:41
  • Location: 0
  • Status: offline
Re: assembly only mode. 2020/08/11 07:46:04 (permalink)
+1 (1)
LOL, crap, I did wonder why my reply vanished. What's the mechanism that makes that happen? And as far as all the noise, the only reply I tried to make was after Dans post.
 
Back on topic,
 
Alan - the gifted code seems to do some checks and clear and set bits in some registers like SPLIM, CORCON, and others. I'll look at it more closely and see if it correlates to some default config settings ( I have not set any yet ). The code starts at 0x200 and ends at 0x308, 0x200 sticks in my head as a default section for some something.
 
Dan - thanks for the project to peek at, I'll take a look. What I did notice is that without a __reset, address 0x0 jumps right to the gifted code. If I add a __reset section, 0x0 jumps to that and will go to where ever I set after that, the gifted code can be skipped all together.
 
Thanks!
post edited by Joel_L - 2020/08/11 07:48:31
#9
ric
Super Member
  • Total Posts : 28378
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: assembly only mode. 2020/08/11 13:22:24 (permalink)
0
Joel_L
LOL, crap, I did wonder why my reply vanished. What's the mechanism that makes that happen?

See: https://www.microchip.com/forums/FindPost/1149696
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#10
du00000001
Just Some Member
  • Total Posts : 3946
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: assembly only mode. 2020/08/11 13:36:33 (permalink)
0
ric
Joel_L
LOL, crap, I did wonder why my reply vanished. What's the mechanism that makes that happen?

See: https://www.microchip.com/forums/FindPost/1149696
 

 
Oh - it's the eyepod fraction ?  So it might be an advertising filter that's really no more require these days.
What about eye-phone? Should I change my username to try to create new troubles unknown until now (although I have 2 eyes but no eye* device) ?  Smile

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#11
rmh
Starting Member
  • Total Posts : 21
  • Reward points : 0
  • Joined: 2009/08/31 15:22:34
  • Location: 0
  • Status: offline
Re: assembly only mode. 2020/08/13 11:16:13 (permalink)
0
Joel_L, i recognise your problem to write full assembler. i use now mplab x ide v5.40, an xc16 v1.50 and i write still in full assembler.
in the past i found next problem

;  bits for adc mode 12 bits
;    bset    w0,#MODE12    ;=12bit mode did not work
    bset    w0,#10        ;=12bit mode bug in .inc

when i write full assembler for 'modern' types, the .inc file have to be modyfied
next example is for p24FJ128GA704.inc

;----- RPINR2 Bits ---------------#added--------------------------------------
        .equiv INT4R0,  0x0000
        .equiv INT4R1,  0x0001
        .equiv INT4R2,  0x0002
        .equiv INT4R3,  0x0003
        .equiv INT4R4,  0x0004
        .equiv INT4R5,  0x0005

with this code i can assign rpinr2 in assembler
it is a lot of work to find out, but it is a simple solution
yes and i use __ reset
regards
 
post edited by rmh - 2020/08/13 11:29:56
#12
Joel_L
Starting Member
  • Total Posts : 10
  • Reward points : 0
  • Joined: 2020/08/03 06:47:41
  • Location: 0
  • Status: offline
Re: assembly only mode. 2020/08/24 07:50:51 (permalink)
0
@rmh
 
When you do this, do you still get code you did not write yourself inserted?
I can work around not executing the code that was inserted but still would like it to not be there at all.
 
Thanks
Joel
#13
rmh
Starting Member
  • Total Posts : 21
  • Reward points : 0
  • Joined: 2009/08/31 15:22:34
  • Location: 0
  • Status: offline
Re: assembly only mode. 2020/08/24 10:42:38 (permalink)
0
ok good question.

this is one example, that is related to INT4, of pic24FJ128GA704
yes you can copy code from other projects. [from yourself or others]
but it is possible that you get compile errors.
in my example INT4R0 until INT4R5 are unknown, related to external interrupt 4
it is used in RPINR2, for remappable pins.
for each RPINRxx that you use, you have to find a solution.

you can study .inc files from older pic how to solve that.
after a few adjustmets/insert you know how to do that.

microchip forgot/forget to fulfill the .inc files.
maybe they dont have assembler boys or girls these days.

it would be nice that with new versions of mplabx the .inc files are updated for assembler, but i never checked it.
i can live with a modified .inc file.

regards
#14
Joel_L
Starting Member
  • Total Posts : 10
  • Reward points : 0
  • Joined: 2020/08/03 06:47:41
  • Location: 0
  • Status: offline
Re: assembly only mode. 2020/08/25 17:53:56 (permalink)
0
I'm not talking about copying other code and include file issues. When I compile my project there is code inserted that is not in any of my source files. Dan above suggested it is the linker inserting some CRT code. I would like a way to turn that off. I don't need or want the CRT code, if that's where it's really coming from.
 
On the topic of include files, when I converted an old project to the new paradigm, I initially thought things were missing, ends up things were just different. I don't mind the new way, but things should have been better described and maybe a flag to use the old include instead.
 
an example,
 
old code snippet,
 
The old include file defines GP0 as 0x00 and PORTB as 0x0006
 
#define    myFlag GP0
 
btfsc PORTB, myFlag
 
In the new include file, GP0 is defined as BANKMASK(GPIO), 0x00. In this case GPIO and the previous PORTB are the same 0x0006.
 
I initially did as you did and put in the missing definitions I wanted, I then decided I really didn't have that many old projects I cared about, so I modified them to be the new way instead. So,
 
#define myFlag GP0
 
btfsc PORTB, myFlag ; GPO is 0x00
 
became
 
btfsc myFlag ; GP0 is BANKMASK(GPIO), 0x00
 
 Either way I don't care, the transition could have been better, maybe it is, I just don't know what that is.
post edited by Joel_L - 2020/08/25 17:55:06
#15
dan1138
Super Member
  • Total Posts : 3843
  • Reward points : 0
  • Joined: 2007/02/21 23:04:16
  • Location: 0
  • Status: offline
Re: assembly only mode. 2020/08/26 14:16:42 (permalink)
0
Joel_L
I'm not talking about copying other code and include file issues. When I compile my project there is code inserted that is not in any of my source files. Dan above suggested it is the linker inserting some CRT code. I would like a way to turn that off. I don't need or want the CRT code, if that's where it's really coming from.
 
On the topic of include files, when I converted an old project to the new paradigm, I initially thought things were missing, ends up things were just different. I don't mind the new way, but things should have been better described and maybe a flag to use the old include instead.
 
an example,
 
old code snippet,
 
The old include file defines GP0 as 0x00 and PORTB as 0x0006
 
#define    myFlag GP0
 
btfsc PORTB, myFlag
 
In the new include file, GP0 is defined as BANKMASK(GPIO), 0x00. In this case GPIO and the previous PORTB are the same 0x0006.
 
I initially did as you did and put in the missing definitions I wanted, I then decided I really didn't have that many old projects I cared about, so I modified them to be the new way instead. So,
 
#define myFlag GP0
 
btfsc PORTB, myFlag ; GPO is 0x00
 
became
 
btfsc myFlag ; GP0 is BANKMASK(GPIO), 0x00
 
 Either way I don't care, the transition could have been better, maybe it is, I just don't know what that is.



WTF Joel_L?
 
You posted this in the XC16 tools forum and now you are using XC8/pic-as(v2.20) assembly language statements.
 
Do you in fact have a sane question you can ask?
#16
Joel_L
Starting Member
  • Total Posts : 10
  • Reward points : 0
  • Joined: 2020/08/03 06:47:41
  • Location: 0
  • Status: offline
Re: assembly only mode. 2020/08/26 15:41:26 (permalink)
+1 (1)
You guys really need to chill, it was just an example of things I have noticed change wrt include files, don't think it's limited to xc8, xc16, or xc32. It was in case the other poster found a similar thing is his project.
 
As far as the unwanted CRT code ( if that is where it is really coming from ), that's still an issue
post edited by Joel_L - 2020/08/26 15:58:47
#17
mskala
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2018/11/16 14:54:23
  • Location: Toronto
  • Status: offline
Re: assembly only mode. 2020/08/28 06:12:09 (permalink)
0
Joel_L
As far as the unwanted CRT code ( if that is where it is really coming from ), that's still an issue



I don't know exactly what's causing your issue, but having no C-related code at all in the linker output is definitely possible.  I'm doing it.
 
I am setting the configuration words manually, not with the "config" macro, to avoid deprecation complaints.  If you read the .inc file for your processor, where the "config" macro is defined, there is a comment on "Setting configuration words without using macros" which explains how to do this - it basically just comes down to writing the code that the macro would have generated, without the deprecation stuff.
 
I'm also using the --no-data-init linker option to prevent the linker from generating data init code.  That's quite possibly the unwanted code you're seeing.  Of course, without the auto-generated init code, you must do all your data initialization yourself.  I am using the --isr option to ask the linker to provide a dummy interrupt service routine but that can be turned off as well (probably "--no-isr").  The auto-generated data initialization is discussed in detail in section 10.8 of the linker manual (at least in my printout, which is a few years old now).
#18
Jump to:
© 2020 APG vNext Commercial Version 4.5