From genna at atsi-tester.com Tue Sep 4 09:59:39 2007 From: genna at atsi-tester.com (Gennadiy Kiryukhin) Date: Tue Sep 4 10:10:32 2007 Subject: [Icc-arm] FIQ and custom startup file In-Reply-To: References: <20070829104230.6ad35664bad26f46d3fc32d9a902836c.3f08282f35.wbe@email.secureserver.net> <46D72EE5.6030008@atsi-tester.com> <01f101c7eb72$9d5bb2a0$1401a8c0@PrideDesktop> <46D81ECC.3080707@atsi-tester.com> <46D89379.70801@atsi-tester.com> Message-ID: <46DD8EFB.2050709@atsi-tester.com> Yes, I am using 7.08. Gennadiy Sergio Paulo Sider wrote: > Hi, > > I had similar problems with the beta version (7.08) and had to > roll-back to 7.07A. I think Richard is still fixing some problems. Are > you using the last beta version ? > > Regards, > Sergio. > > > > On 8/31/07, Gennadiy Kiryukhin wrote: > >>I have added some code to the my custom startup file (s file). When >>trying to compile it, I get error: >>Unable to fit C$$init section into memory. >> >>What is C$$init and how does it affect it? >>Where does C$$code start? >>Can I define my own "area" and place it at 0x00001C? How? >>Where can I get more information on how to write a startup file? >> >>I am trying to place my FIQ at that address. >> >>Here is what I have discovered so far. I have not tested the code, but >>it compiles without errors. >> >> IMPORT _main >> AREA "C$$init",CODE,READONLY >> >>// exception vector section >> LDR PC,cstart_addr // Reset >> SUB PC,PC,#8 // Undefined instruction >> SUB PC,PC,#8 // Software interrupt >>cstart_addr: DCD _cstart // In place of prefetch data abort >> SUB PC,PC,#8 // Data abort >> SUB PC,PC,#8 // Not used >> LDR PC,[PC,#-0xFF0] // IRQ Vector >> >> AREA "C$$code",CODE,READONLY >>_my_fiq_processor: >>; FIQ code is placed here >> >>// the rest of the file without change follows... >> >> >>I had to use the prefetch data abort vector for storing the address of >>_cstart label. The reason for this is if I tried to place the >>"cstart_addr ..." after the FIQ code, the compiler would give me an >>error because the offset was too big. Don't see the reason for the error >>since my FIQ was under 1K in size and LDR PC, xxx allows the address to >>be within 4K limit relative to the current command. >> >>There is one problem with that. I am not sure where 'C$$code' area >>starts. If I take that line out and make my FIQ to be a part of C$$init, >>the compiler says: >>!E Unable to fit C$$init section into memory >> >> >>Thanks, >> >>Gennadiy >> >>_______________________________________________ >>Icc-arm mailing list >>Icc-arm@imagecraft.com >>http://dragonsgate.net/mailman/listinfo/icc-arm >> > > > _______________________________________________ > Icc-arm mailing list > Icc-arm@imagecraft.com > http://dragonsgate.net/mailman/listinfo/icc-arm > From genna at atsi-tester.com Thu Sep 6 08:09:05 2007 From: genna at atsi-tester.com (Gennadiy Kiryukhin) Date: Thu Sep 6 08:19:52 2007 Subject: [Icc-arm] Inline asm with variables Message-ID: <46E01811.5090005@atsi-tester.com> Good (*whatever_time_of_day) everyone, I have a line in C that I would to write in assembly language using asm("..."). It is a simple assignment: a = b; where 'a' and 'b' are defined as global int. The compiler translates the code as follows: ------------------------------------------- ; a = b; ldr R0, LIT_my_interrupt+4 ldr R0,[R0,#0] ldr R1, LIT_my_interrupt str R0,[R1,#0] ; ... LIT_my_interrupt: DCD _a DCD _b ---------------------------------------------- That seems to be clear. Since we cannot access a variable in RAM directly, first we have to access it by loading the address of 'b' to R0. Then we load the actual value of 'b' to R0. Then, we load the address of 'a' to R1. Finally, we save value of 'b' from R0 register to [R1+0] memory location. Here is what I tried: asm("ldr R0,%b\n" "ldr R0,[R0,#0]\n" "ldr R1,%a\n" "str R0,[R1,#0]"); The compiler complains: "Undefined symbol _b". What is wrong? How can I access a variable from an inline assembly statement? Thanks, Gennadiy From harald.kipp at egnite.de Thu Sep 6 08:47:48 2007 From: harald.kipp at egnite.de (Harald Kipp) Date: Thu Sep 6 09:00:19 2007 Subject: [Icc-arm] Inline asm with variables In-Reply-To: <46E01811.5090005@atsi-tester.com> References: <46E01811.5090005@atsi-tester.com> Message-ID: <46E02124.7040105@egnite.de> Gennadiy Kiryukhin schrieb: > > Here is what I tried: > asm("ldr R0,%b\n" > "ldr R0,[R0,#0]\n" > "ldr R1,%a\n" > "str R0,[R1,#0]"); > > The compiler complains: "Undefined symbol _b". > You need to declare local variables as registers: register unsigned int a; register unsigned int b; Harald From genna at atsi-tester.com Thu Sep 6 09:31:14 2007 From: genna at atsi-tester.com (Gennadiy Kiryukhin) Date: Thu Sep 6 09:41:51 2007 Subject: [Icc-arm] Inline asm with variables In-Reply-To: <46E02124.7040105@egnite.de> References: <46E01811.5090005@atsi-tester.com> <46E02124.7040105@egnite.de> Message-ID: <46E02B52.8060209@atsi-tester.com> My variables are global and several functions have access to them. If I add a local declaration, I would not be able to access the global variables. Gennadiy Harald Kipp wrote: > Gennadiy Kiryukhin schrieb: > >> >> Here is what I tried: >> asm("ldr R0,%b\n" >> "ldr R0,[R0,#0]\n" >> "ldr R1,%a\n" >> "str R0,[R1,#0]"); >> >> The compiler complains: "Undefined symbol _b". >> > > You need to declare local variables as registers: > register unsigned int a; > register unsigned int b; > > > Harald > > _______________________________________________ > Icc-arm mailing list > Icc-arm@imagecraft.com > http://dragonsgate.net/mailman/listinfo/icc-arm > From genna at atsi-tester.com Thu Sep 6 10:06:15 2007 From: genna at atsi-tester.com (Gennadiy Kiryukhin) Date: Thu Sep 6 10:16:51 2007 Subject: [Icc-arm] Inline asm with variables In-Reply-To: <46E01811.5090005@atsi-tester.com> References: <46E01811.5090005@atsi-tester.com> Message-ID: <46E03387.2000005@atsi-tester.com> Is it even possible to access a global variable from an inline assembly? Gennadiy Gennadiy Kiryukhin wrote: > Good (*whatever_time_of_day) everyone, > > I have a line in C that I would to write in assembly language using > asm("..."). It is a simple assignment: > > a = b; > > where 'a' and 'b' are defined as global int. > > The compiler translates the code as follows: > > ------------------------------------------- > ; a = b; > ldr R0, LIT_my_interrupt+4 > ldr R0,[R0,#0] > ldr R1, LIT_my_interrupt > str R0,[R1,#0] > > ; ... > LIT_my_interrupt: > DCD _a > DCD _b > ---------------------------------------------- > > That seems to be clear. Since we cannot access a variable in RAM > directly, first we have to access it by loading the address of 'b' to > R0. Then we load the actual value of 'b' to R0. Then, we load the > address of 'a' to R1. Finally, we save value of 'b' from R0 register to > [R1+0] memory location. > > Here is what I tried: > asm("ldr R0,%b\n" > "ldr R0,[R0,#0]\n" > "ldr R1,%a\n" > "str R0,[R1,#0]"); > > The compiler complains: "Undefined symbol _b". > > What is wrong? > How can I access a variable from an inline assembly statement? > > Thanks, > Gennadiy > > _______________________________________________ > Icc-arm mailing list > Icc-arm@imagecraft.com > http://dragonsgate.net/mailman/listinfo/icc-arm > From harald.kipp at egnite.de Thu Sep 6 10:23:00 2007 From: harald.kipp at egnite.de (Harald Kipp) Date: Thu Sep 6 10:35:33 2007 Subject: [Icc-arm] Inline asm with variables In-Reply-To: <46E02B52.8060209@atsi-tester.com> References: <46E01811.5090005@atsi-tester.com> <46E02124.7040105@egnite.de> <46E02B52.8060209@atsi-tester.com> Message-ID: <46E03774.8000202@egnite.de> Gennadiy Kiryukhin schrieb: > My variables are global and several functions have access to them. If > I add a local declaration, I would not be able to access the global > variables. > Well, you could assign the contents of the global to the local variable first. But actually I mixed up AVR with ARM. Sorry for the confusion. I'd suggest to check the map file and make sure, that a and b are defined. Possibly the optimizer removed the variables, if they haven't been referenced in the C code. Just an assumption. Harald From genna at atsi-tester.com Thu Sep 6 12:20:38 2007 From: genna at atsi-tester.com (Gennadiy Kiryukhin) Date: Thu Sep 6 12:31:28 2007 Subject: [Icc-arm] Inline asm with variables In-Reply-To: <46E03774.8000202@egnite.de> References: <46E01811.5090005@atsi-tester.com> <46E02124.7040105@egnite.de> <46E02B52.8060209@atsi-tester.com> <46E03774.8000202@egnite.de> Message-ID: <46E05306.7080600@atsi-tester.com> Ooops, I was getting "Undefined symbol" error when using "mov R0, %b". Now, I get "Load offset out of range" for: asm("ldr R0, %b"); The reason is because the compiler tries to use an immediate offset to the PC register and tries to fit the offset into one command. The maximum immediate offset size 12 bit. So, the address from which the register can be read is [PC +/- offset_12]. However, the RAM on lpc2138 cannot be accessed with a 12 bit offset. That is why the linker gives that error. Right after a function, the compiler allocates constant pointers to the variables accessed by the function. If the function is less than 4K in size, those pointers can be accessed using an immediate offset. What I would like to do is to be able to reference that pointer. In that case, I would write something like this: asm("ldr R0, constant_pointer_to_b\n" "ldr R0, [R0, #0]"); The question now is how to reference that pointer. Thanks, Gennadiy Harald Kipp wrote: > Gennadiy Kiryukhin schrieb: > >> My variables are global and several functions have access to them. If >> I add a local declaration, I would not be able to access the global >> variables. >> > > Well, you could assign the contents of the global to the local variable > first. > > But actually I mixed up AVR with ARM. Sorry for the confusion. > > I'd suggest to check the map file and make sure, that a and b are > defined. Possibly the optimizer removed the variables, if they haven't > been referenced in the C code. Just an assumption. > > Harald > > _______________________________________________ > Icc-arm mailing list > Icc-arm@imagecraft.com > http://dragonsgate.net/mailman/listinfo/icc-arm > From richard-lists at imagecraft.com Thu Sep 6 14:23:06 2007 From: richard-lists at imagecraft.com (Richard) Date: Thu Sep 6 14:35:03 2007 Subject: [Icc-arm] Inline asm with variables In-Reply-To: <46E05306.7080600@atsi-tester.com> References: <46E01811.5090005@atsi-tester.com> <46E02124.7040105@egnite.de> <46E02B52.8060209@atsi-tester.com> <46E03774.8000202@egnite.de> <46E05306.7080600@atsi-tester.com> Message-ID: <200709062135.l86LZ1Z5038161@dragonsgate2.imagecraft.com> There really is no clean way to do that, because of the ARM limitations you found out. You can do something that the compiler sometimes does: asm(" ldr R0,[pc]\n" "mov pc,pc\n" "DCD %b\n") Of course, this assumes there is a reason you want to do that. Another possibility is to use asm module rather than inline asm, but the instructions will be very similar. At 12:20 PM 9/6/2007, Gennadiy Kiryukhin wrote: >Ooops, I was getting "Undefined symbol" error when using "mov R0, %b". > >Now, I get "Load offset out of range" for: >asm("ldr R0, %b"); >The reason is because the compiler tries to use an immediate offset >to the PC register and tries to fit the offset into one command. The >maximum immediate offset size 12 bit. So, the address from which the >register can be read is [PC +/- offset_12]. However, the RAM on >lpc2138 cannot be accessed with a 12 bit offset. That is why the >linker gives that error. > >Right after a function, the compiler allocates constant pointers to >the variables accessed by the function. If the function is less than >4K in size, those pointers can be accessed using an immediate offset. > >What I would like to do is to be able to reference that pointer. In >that case, I would write something like this: > >asm("ldr R0, constant_pointer_to_b\n" > "ldr R0, [R0, #0]"); > >The question now is how to reference that pointer. > >Thanks, >Gennadiy > >Harald Kipp wrote: >>Gennadiy Kiryukhin schrieb: >> >>>My variables are global and several functions have access to them. >>>If I add a local declaration, I would not be able to access the >>>global variables. >>Well, you could assign the contents of the global to the local >>variable first. >>But actually I mixed up AVR with ARM. Sorry for the confusion. >>I'd suggest to check the map file and make sure, that a and b are >>defined. Possibly the optimizer removed the variables, if they >>haven't been referenced in the C code. Just an assumption. >>Harald >>_______________________________________________ >>Icc-arm mailing list >>Icc-arm@imagecraft.com >>http://dragonsgate.net/mailman/listinfo/icc-arm > >_______________________________________________ >Icc-arm mailing list >Icc-arm@imagecraft.com >http://dragonsgate.net/mailman/listinfo/icc-arm // richard (This email is for mailing lists. To reach me directly, please use richard at imagecraft.com) From genna at atsi-tester.com Thu Sep 6 15:09:41 2007 From: genna at atsi-tester.com (Gennadiy Kiryukhin) Date: Thu Sep 6 15:20:22 2007 Subject: [Icc-arm] Inline asm with variables In-Reply-To: <200709062135.l86LZ1Z5038161@dragonsgate2.imagecraft.com> References: <46E01811.5090005@atsi-tester.com> <46E02124.7040105@egnite.de> <46E02B52.8060209@atsi-tester.com> <46E03774.8000202@egnite.de> <46E05306.7080600@atsi-tester.com> <200709062135.l86LZ1Z5038161@dragonsgate2.imagecraft.com> Message-ID: <46E07AA5.8020009@atsi-tester.com> My function (FIQ) is under 4K. After looking at the .s file I could write something like this: asm("ldr R0, LIT_my_fiq+\n" "ldr R0, [R0, #0]"); Here, LIT_my_fiq is a block of constants that are used by the my_fiq function. However, if I change definition of the variables, the listing of pointers may change as well and I would have to change to another value. Your code is an interesting solution. But I would like to eliminate the extra jump. I need to make my FIQ as fast as possible. I guess, may have to write the FIQ using an asm module. Thanks, Gennadiy Richard wrote: > There really is no clean way to do that, because of the ARM limitations > you found out. You can do something that the compiler sometimes does: > > asm(" ldr R0,[pc]\n" > "mov pc,pc\n" > "DCD %b\n") > > Of course, this assumes there is a reason you want to do that. Another > possibility is to use asm module rather than inline asm, but the > instructions will be very similar. > > At 12:20 PM 9/6/2007, Gennadiy Kiryukhin wrote: > >> Ooops, I was getting "Undefined symbol" error when using "mov R0, %b". >> >> Now, I get "Load offset out of range" for: >> asm("ldr R0, %b"); >> The reason is because the compiler tries to use an immediate offset to >> the PC register and tries to fit the offset into one command. The >> maximum immediate offset size 12 bit. So, the address from which the >> register can be read is [PC +/- offset_12]. However, the RAM on >> lpc2138 cannot be accessed with a 12 bit offset. That is why the >> linker gives that error. >> >> Right after a function, the compiler allocates constant pointers to >> the variables accessed by the function. If the function is less than >> 4K in size, those pointers can be accessed using an immediate offset. >> >> What I would like to do is to be able to reference that pointer. In >> that case, I would write something like this: >> >> asm("ldr R0, constant_pointer_to_b\n" >> "ldr R0, [R0, #0]"); >> >> The question now is how to reference that pointer. >> >> Thanks, >> Gennadiy >> >> Harald Kipp wrote: >> >>> Gennadiy Kiryukhin schrieb: >>> >>>> My variables are global and several functions have access to them. >>>> If I add a local declaration, I would not be able to access the >>>> global variables. >>> >>> Well, you could assign the contents of the global to the local >>> variable first. >>> But actually I mixed up AVR with ARM. Sorry for the confusion. >>> I'd suggest to check the map file and make sure, that a and b are >>> defined. Possibly the optimizer removed the variables, if they >>> haven't been referenced in the C code. Just an assumption. >>> Harald >>> _______________________________________________ >>> Icc-arm mailing list >>> Icc-arm@imagecraft.com >>> http://dragonsgate.net/mailman/listinfo/icc-arm >> >> >> _______________________________________________ >> Icc-arm mailing list >> Icc-arm@imagecraft.com >> http://dragonsgate.net/mailman/listinfo/icc-arm > > > // richard (This email is for mailing lists. To reach me directly, > please use richard at imagecraft.com) > _______________________________________________ > Icc-arm mailing list > Icc-arm@imagecraft.com > http://dragonsgate.net/mailman/listinfo/icc-arm > From richard at imagecraft.com Wed Sep 19 03:34:37 2007 From: richard at imagecraft.com (Richard) Date: Wed Sep 19 03:47:16 2007 Subject: [Icc-arm] ARM Compiler 7.08 Beta1 Message-ID: <200709191047.l8JAlEGL007731@dragonsgate2.imagecraft.com> http://www.imagecraft.com/pub/iccv7arm_v708_beta1.exe 7.08 Compiler - Added #pragma fiq_handler func1 func2 ... These behave just like interrupt handlers except that they do not save and restore R8-R12 - Fixed a bug under Thumb mode where the compiler was emitting "add R?,#0" forever. Asm/Linker etc. - DCB directive with more than 253 characters (e.g. C char array initialization) was not processed correctly by the assembler. - First release of ELF native asm and linker. The assembler is now called iasarm-elf.exe and the linker is ilinkarm-elf.exe. DBG2Dwarf.exe is no longer needed to generate debug file. // richard On-line orders, support, and listservers available on web site. [ For technical support on ImageCraft products, please include all previous replies in your msgs. ] From richard at imagecraft.com Mon Sep 24 14:29:07 2007 From: richard at imagecraft.com (Richard) Date: Mon Sep 24 14:40:44 2007 Subject: [Icc-arm] ARM Compiler 7.08 Beta2 Message-ID: <200709242140.l8OLefa8023955@dragonsgate2.imagecraft.com> Beta2 fixes a couple problems discovered in Beta1's asm and linker. Final release will probably be in a couple days, barring any new problems being discovered. http://www.imagecraft.com/pub/iccv7arm_v708_beta2.exe 7.08 Compiler - Added #pragma fiq_handler func1 func2 ... These behave just like interrupt handlers except that they do not save and restore R8-R12 - Fixed a bug under Thumb mode where the compiler was emitting "add R?,#0" forever. Asm/Linker etc. - DCB directive with more than 253 characters (e.g. C char array initialization) was not processed correctly by the assembler. - First release of ELF native asm and linker. The assembler is now called iasarm-elf.exe and the linker is ilinkarm-elf.exe. DBG2Dwarf.exe is no longer needed to generate debug file. // richard On-line orders, support, and listservers available on web site. [ For technical support on ImageCraft products, please include all previous replies in your msgs. ] From richard at imagecraft.com Wed Sep 26 23:57:45 2007 From: richard at imagecraft.com (Richard) Date: Thu Sep 27 00:09:28 2007 Subject: [Icc-arm] ARM Compiler 7.08 Released Message-ID: <200709270709.l8R79Q0m058789@dragonsgate2.imagecraft.com> 7.08 - Sept 25th 2007 Compiler - Added #pragma fiq_handler func1 func2 ... These behave just like interrupt handlers except that they do not save and restore R8-R12 - Fixed a bug under Thumb mode where the compiler was emitting "add R?,#0" forever. Asm/Linker etc. - DCB directive with more than 253 characters (e.g. C char array initialization) was not processed correctly by the assembler. - First release of ELF native asm and linker. The assembler is now called iasarm-elf.exe and the linker is ilinkarm-elf.exe. DBG2Dwarf.exe is no longer needed to generate debug file. // richard On-line orders, support, and listservers available on web site. [ For technical support on ImageCraft products, please include all previous replies in your msgs. ] From sergiosider at gmail.com Thu Sep 27 02:32:14 2007 From: sergiosider at gmail.com (Sergio Paulo Sider) Date: Thu Sep 27 02:44:13 2007 Subject: [Icc-arm] still compiling errors in ICC-ARM Message-ID: `Hi Richard & All, I am still getting the following compile errors in 2 of my projects: On the first, I got this error on the sixth C file on the list: The instruction at 0x0044adf6 referenced memory at 0x00000004.The memory could not be read.iccarm: can't execute `D:\iccv7arm\bin\iccomarm.exe' D:\iccv7arm\bin\imakew.exe: Error code 100 Done: there are error(s). Exit code: 100. Thu Sep 27 06:19:51 2007 and, on the 2nd project, after all compiling: !X The linker has encountered an internal error. Please report to "ImageCraft" support@imagecraft.com D:\iccv7arm\bin\imakew.exe: Error code 11 Done: there are error(s). Exit code: 11. Thu Sep 27 06:25:10 2007 The project files did not change since I sent some weeks ago, but if you want, I'll send it again. Thanks, Sergio Sidertech From richard-lists at imagecraft.com Thu Sep 27 02:41:55 2007 From: richard-lists at imagecraft.com (Richard) Date: Thu Sep 27 02:53:30 2007 Subject: [Icc-arm] still compiling errors in ICC-ARM In-Reply-To: References: Message-ID: <200709270953.l8R9rTiE060959@dragonsgate2.imagecraft.com> Yes, please send me the project files zipped off list. Thanks. At 02:32 AM 9/27/2007, Sergio Paulo Sider wrote: >`Hi Richard & All, > >I am still getting the following compile errors in 2 of my projects: > >On the first, I got this error on the sixth C file on the list: > >The instruction at 0x0044adf6 referenced memory at 0x00000004.The >memory could not be read.iccarm: can't execute >`D:\iccv7arm\bin\iccomarm.exe' >D:\iccv7arm\bin\imakew.exe: Error code 100 >Done: there are error(s). Exit code: 100. Thu Sep 27 06:19:51 2007 > >and, on the 2nd project, after all compiling: > >!X The linker has encountered an internal error. Please report to >"ImageCraft" support@imagecraft.com >D:\iccv7arm\bin\imakew.exe: Error code 11 >Done: there are error(s). Exit code: 11. Thu Sep 27 06:25:10 2007 > >The project files did not change since I sent some weeks ago, but if >you want, I'll send it again. > >Thanks, >Sergio >Sidertech > >_______________________________________________ >Icc-arm mailing list >Icc-arm@imagecraft.com >http://dragonsgate.net/mailman/listinfo/icc-arm // richard (This email is for mailing lists. To reach me directly, please use richard at imagecraft.com)