Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic undefined reference to / asm function (Read 6054 times)
David Brenchley
Newbies
*
Offline


Posts: 4
Joined: Jul 3rd, 2016
undefined reference to / asm function
Jul 3rd, 2016 at 10:56am
Print Post  
When attempting to build a project w/ an assembly function call I get the noted error.

in a header
Code (C++)
Select All
#ifndef leds_asm_isr_H_
#define leds_asm_isr_H_
extern "C" void ASM_ISR(uint32_t *, uint32_t **, uint32_t **, uint32_t **, uint32_t const *, uint32_t);
#endif /* leds_asm_isr_H_ */ 



in "main"
Code (C++)
Select All
#include "leds_asm_isr.h"

void TCC0_Handler(){ 	// Interrupt Service Routine (ISR) for timer TCC0
ASM_ISR(&iCount, &Strip4_mask_pntr, &Strip4_pntr, &Strip4_base_pntr, &Strip4_Num_LED, CC3_Addr);
} 



and in the asm func
Code (C++)
Select All
.text
.global ASM_ISR
/* R0 = iCount addr, R1=Strip4_mask_pntr addr, R2 = Strip4_pntr addr, R3 = Strip4_base_pntr addr, Stack = Strip4_Num_LED addr, CC addr */
ASM_ISR:
		cpsid i									@ disable all interrupts
		ldr r4, [r0, #0]						@ get iCounter
		cmp	r4,#0								@ is iCount = 0 ?
		beq	ext									@ exit routine if so
		pop {r4}								@ CC Addr
		pop {r5}								@ Num LEDs Addr
		push {r0}								@ Free r0 | iCount Addr on stack
		ldr r7, = 0x38							@ value for 1 CC PWM LED
		lsl r7, r7, #6							@ Position for CC reg
		ldr r0, [r1, #0]						@ get mask
		ldr r6, [r2, #0]						@ get array element
		and r6, r6, r0							@ test bit
		beq	jmp1								@ if it's 1 jmp
		lsr	r7, r7, #1							@ value for 0 CC PWM LED
jmp1:	str r7, [r4, #0]						@ set new CC val | open regs r4, r6
		lsr r0, r0, #1							@ shift mask bit
		cmp r0, #0								@ Did we empty mask reg
		bne	ext									@ if not we're done
		ldr r4, = 0x80							@ reinitialize mask | open regs r6
		lsl r4, r4, #16							@ 0x00800000
		mov r6, r2								@ get array pointer address
		add r6, #4								@ increment array pntr address
		lsl	r5, r5, #2							@ multi num leds x4 for address calculation
		add r5, r5, r3							@ point to end of array
		cmp r6, r5								@ are we at the last array element
		bne	jmp2								@ if not jmp
		ldr r6, [r3, #0]						@ array pointer back to top of array
jmp2:	str r4, [r1, #0]						@ mask reg to memory
		str r6, [r2, #0]						@ array pointer to memory
		pop {r0}								@ get iCount address
		ldr r4, [r0, #0]						@ get iCount
		sub r4, #1								@ Decrement iCount
		str r4, [r0, #0]						@ iCount to memory
ext:	cpsie i									@ Enable interrupts
		bx    lr								@ Exit
.end 



both the .ino and .S are members of one "solution" in Atmel Studio ..
Asm compiles fine
.ino compiles fine (if I comment out the asm call)

I'm at a loss .. I do note that the VS build, and the VM build store files at different locations .. ??
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: undefined reference to / asm function
Reply #1 - Jul 3rd, 2016 at 1:15pm
Print Post  
Hi,

Visual Micro performs an Arduino compatible build which Visual Studio can't do.

If you have a main.cpp in your project folder you should delete it. Atmel creates it automatically but it is invalid for Arduino. The next release shows messages in the output window letting you know to delete it. The current version should have prompted you to delete it but sometimes atmel recreates.

Output files are copied to the standard Visual Studio / Atmel Studio locations after successfull build

Does an example of your code compile okay in the arduino ide?
« Last Edit: Jul 3rd, 2016 at 1:45pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
David Brenchley
Newbies
*
Offline


Posts: 4
Joined: Jul 3rd, 2016
Re: undefined reference to / asm function
Reply #2 - Jul 3rd, 2016 at 3:19pm
Print Post  
There is no main. I was prompted and deleted.
VS build drops obj file into the release folder ,,
VM drops them in .. C:\Users\Dave\AppData\Local\V.Micro\Arduino\Builds

Arduino IDE gives a different error .. says it wants to see ( in front of "C" in the declaration ???
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: undefined reference to / asm function
Reply #3 - Jul 3rd, 2016 at 6:03pm
Print Post  
I asked about main because the code you published was entitled 

Quote:
in "main"
Code (C++):


I am weak on assembler so ignore me if I am wrong.. 

I searched google for a similar question in respect to Arduino. (Consider Visual Micro to be the same as the Arduino IDE when looking for assistance)

@RuggedCircuits might have an answer to your question in the Arduino forum here

It sounds like you need to use  a .c file. The .ino files are compiled as .cpp.

  
Back to top
WWW  
IP Logged
 
David Brenchley
Newbies
*
Offline


Posts: 4
Joined: Jul 3rd, 2016
Re: undefined reference to / asm function
Reply #4 - Jul 3rd, 2016 at 6:16pm
Print Post  
fallacious quotes ..  I understand the confusion .. will investigate TY ..
  
Back to top
 
IP Logged
 
David Brenchley
Newbies
*
Offline


Posts: 4
Joined: Jul 3rd, 2016
Re: undefined reference to / asm function
Reply #5 - Jul 3rd, 2016 at 7:33pm
Print Post  
That doesn't seem to be a viable solution .. his commentary on "native" seems to imply I couldn't past variables, something I need to do.

The extern "C" method seems to be the standard / common method .. I don't understand why I'm having issues .. 
as to C vs C++ file ext .. not sure that would be an issue as the "method" originated w/ C and is supported by C++

TY for your efforts













  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint