Go Down

Topic: The VideoBlaster Hi Resolution TVout platform (Read 11159 times) previous topic - next topic

mrburnette

Quote
Not in the Arduino IDE it isn't.


I really do not see the distinction being made here...
if one follows the work done in the USB keyboard project for V-USB, the assembly code is inline in an external <foo>.S file which is pulled in through inclusion in a <foo>.asm file which is pulled in by inclusion in a <foo1>.C file which is referenced through extern "C"{ in a standard header file for Arduino.  It's just a chained library, and the Arduino 1.0.5 environment is compiling the assembler automatically through the Arduino GUI.  The fact that it must be inline in an external library is not of significance, IMO.

I did not say it was easy, I said it was do-able.

Here is a note from rancidbacon in a notes file:
Quote
* Versions of the Arduino IDE prior to 0018 won't compile our library
 so it needs to be pre-compiled with:

   avr-g++  -Wall -Os -I. -DF_CPU=16000000 -mmcu=atmega168  -c usbdrvasm.S  -c usbdrv.c


Ray

Reference this line below: C:\Users\owner\Documents\Arduino\libraries\UsbKeyboard\usbdrvasm.S -oC:\Users\owner\AppData\Local\Temp\build7593064582256327132.tmp\UsbKeyboard\usbdrvasm.S.o

Successful compile:
Code: [Select]
C:\Program Files\Arduino_105\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -IC:\Program Files\Arduino_105\hardware\arduino\cores\arduino -IC:\Program Files\Arduino_105\hardware\arduino\variants\standard -IC:\Users\owner\Documents\Arduino\libraries\UsbKeyboard C:\Users\owner\AppData\Local\Temp\build7593064582256327132.tmp\USB_HID_AnalogX6_D8.cpp -o C:\Users\owner\AppData\Local\Temp\build7593064582256327132.tmp\USB_HID_AnalogX6_D8.cpp.o
In file included from USB_HID_AnalogX6_D8.ino:8:

C:\Program Files\Arduino_105\hardware\tools\avr\bin\avr-gcc -c -g -assembler-with-cpp -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=105 -DUSB_VID=null -DUSB_PID=null -IC:\Program Files\Arduino_105\hardware\arduino\cores\arduino -IC:\Program Files\Arduino_105\hardware\arduino\variants\standard -IC:\Users\owner\Documents\Arduino\libraries\UsbKeyboard -IC:\Users\owner\Documents\Arduino\libraries\UsbKeyboard\utility C:\Users\owner\Documents\Arduino\libraries\UsbKeyboard\usbdrvasm.S -oC:\Users\owner\AppData\Local\Temp\build7593064582256327132.tmp\UsbKeyboard\usbdrvasm.S.o
...
STUFF TOO LONG TO SHOW
...
C:\Users\owner\AppData\Local\Temp\build7593064582256327132.tmp\USB_HID_AnalogX6_D8.cpp.elf C:\Users\owner\AppData\Local\Temp\build7593064582256327132.tmp\USB_HID_AnalogX6_D8.cpp.hex
Binary sketch size: 8,284 bytes (of a 30,720 byte maximum)

janost

I understand you but the Arduino IDE doesnt work with S files without modification.

And to ask people to modify the IDE or the code wont compile is asking to much.

mrburnette

Quote
I understand you but the Arduino IDE doesnt work with S files without modification.

And to ask people to modify the IDE or the code wont compile is asking to much.


Are you even looking at the output from the compiler which was done under 1.0.5 GUI?  It clearly shows that the unmodified installation is clearly picking up and compiling and linking he <foo>.S file.
IT WORKS UNMODIFIED.

Ray

janost

And how many are using IDE 1.0.5?

I am but just because I have a Due also.

People arent using that high versions of the Arduino IDE.

janost

My plan is to make an Arduino compatible board and add a composite video out, a ps2 connector for keyboard and mouse and SD/Micro-SD adapter.

All shield pins as the Uno.
And onboard IDE/compiler.

But I will use an ATmega644 and Clock it at 32MHz.

This means you can boot and develop with it without a PC.

mrburnette

Quote
And how many are using IDE 1.0.5?
I am but just because I have a Due also.
People arent using that high versions of the Arduino IDE.


You do not want to acknowledge inline works, fine.  The facts as presented by rancidbacon indicate that GUI version * Versions of the Arduino IDE prior to 0018 won't compile our library but I can attest to versions 1.0.1, 1.0.3, and 1.0.5 working as described.  Anyone below 0018 probably is not wanting forum support.

I do not understand your attitude, but it is your project and you can do what the heck you want - my post was only to disprove the false reasoning that Arduino GUI had to be modified to compile inline assembler - it does not.  The workaround is to put the assembler in an <extern>.S file and follow the process used by rancidbacon in the link I provided earlier.


Ray

fungus


Are you even looking at the output from the compiler which was done under 1.0.5 GUI?  It clearly shows that the unmodified installation is clearly picking up and compiling and linking he <foo>.S file.
IT WORKS UNMODIFIED.


Yep, it seems to work.

I haven't figured out the mechanism yet and the .S file isn't explicitly included anywhere that I can see. The IDE must be doing some magic, it adds "-assembler-with-cpp" to the compile line for that file.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

fungus

I've just been playing and I figured out how to use .S files directly from the IDE. It can be done, but only inside a library (which means you have to use an external editor to edit the files).

Below is the most minimal example I could make, it's the blink sketch with some assembly code...  :)

Extract the zip file into your 'libraries' folder then open "libraries->asm_test->blink".

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

mrburnette

#38
Nov 24, 2013, 08:09 pm Last Edit: Nov 26, 2013, 03:58 pm by mrburnette Reason: 1
Quote
I've just been playing and I figured out how to use .S files directly from the IDE. It can be done, but only inside a library (which means you have to use an external editor to edit the files).


:D  There is a fungus among us!   :D

Thanks for the validation.  I suspect most members would prefer to use their own editor to edit assembly files, anyway.


Ray

PS: You should post this in the Exhibition / Gallery
Edit: I only knew it was possible because I use V-USB often and was aware of the foo.S implementation.  I do not know if rancidbacon was lead to this implementation, figured it out, or both... but it seems to be knowledge not widely known.

Super-Dupper BIG edit - check out
http://ucexperiment.wordpress.com/2013/05/31/arduino-blink-using-gcc-inline-assembly/
Code: [Select]


void setup() {
 asm volatile (
   "sbi %0, %1 \n\t"           //pinMode(13, OUTPUT);
   :: "I" (_SFR_IO_ADDR(DDRB)), "I" (DDB5)
 );
}

void loop() {
 asm volatile (
    "sbi %0, %1 \n\t"          //LED on
    "call OneSecondDelay \n\t" //delay
    "cbi %0, %1 \n\t"          //LED off
    "call OneSecondDelay \n\t" //delay
    "rjmp 4f \n\t"             //exit

 "OneSecondDelay: \n\t"
    "ldi r18, 0 \n\t"          //delay 1 second
    "ldi r20, 0 \n\t"
    "ldi r21, 0 \n\t"

 "1: ldi r24, lo8(400) \n\t"
    "ldi r25, hi8(400) \n\t"
 "2: sbiw r24, 1 \n\t"         //10x around this loop = 1ms
    "brne 2b \n\t"
    "inc r18 \n\t"
    "cpi r18, 10 \n\t"
    "brne 1b \n\t"

    "subi r20, 0xff \n\t"      //1000 x 1ms = 1 second
    "sbci r21, 0xff \n\t"
    "ldi r24, hi8(1000) \n\t"
    "cpi r20, lo8(1000) \n\t"
    "cpc r21, r24 \n\t"
    "breq 3f \n\t"

    "ldi r18, 0 \n\t"
    "rjmp 1b \n\t"

 "3: \n\t"
    "ret \n\t"

 "4: \n\t"                     //exit

    :: "I" (_SFR_IO_ADDR(PORTB)), "I" (PORTB5)
    : "r18", "r20", "r21", "r24", "r25"
 );
}


GCC ref: http://www.nongnu.org/avr-libc/user-manual/inline_asm.html

janost


I've just been playing and I figured out how to use .S files directly from the IDE. It can be done, but only inside a library (which means you have to use an external editor to edit the files).

Below is the most minimal example I could make, it's the blink sketch with some assembly code...  :)

Extract the zip file into your 'libraries' folder then open "libraries->asm_test->blink".




Thanks, I like that one.
If you want to use it as a funtion or pass parameters, how do you do that?

And, I'm sorry, mrburnette, I just plain did not know.
No hard feelings, I do now and stand corrected :)

mrburnette

Quote
No hard feelings, I do now and stand corrected smiley


Of course, not.  We are all here to share experiences in a collective environment and to learn from others that have stumbled before us  :D


Ray

fungus



I've just been playing and I figured out how to use .S files directly from the IDE. It can be done, but only inside a library (which means you have to use an external editor to edit the files).

Below is the most minimal example I could make, it's the blink sketch with some assembly code...  :)

Extract the zip file into your 'libraries' folder then open "libraries->asm_test->blink".




Thanks, I like that one.
If you want to use it as a funtion or pass parameters, how do you do that?


I haven't figured that out yet. I'll have another play later....
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

fungus


PS: You should post this in the Exhibition / Gallery


I will when I've figured out more detail, eg. How to pass parameters to the function, how to return values to the caller, if there's a nice header file out there with hardware register names, etc.


I only knew it was possible because I use V-USB often and was aware of the foo.S implementation.  I do not know if rancidbacon was lead to this implementation, figured it out, or both... but it seems to be knowledge not widely known.


I've never seen it done so I assumed the IDE was against it (obviously you can do it at command-line level...)

It's a shame you can't just drop .S files in the IDE and use them. According to various sites you only need to change two lines of code to make that work.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

fungus

This document has info on passing parameters, etc.

http://www.atmel.com/images/doc42055.pdf

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

fungus

I've done a bit more investigating. The version below passes parameters to assembly language, accesses global variables and has a header file with port mappings.

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Go Up