Sorry, that's a bit late, I didn't have access to my PC these days.
It could be because of having the asm code inside a loop, that's just an idea but you could try :

 __asm__ __volatile__ (... Asm code here...);
Well, I tried using __volatile__ with the for loop but the problem continued. To solve this I tried re-writing the loop in assembly:


int main(void)
int x=1,y=1;
unsigned short color = COLOR_BLACK;

__asm__ __volatile__(   "MOV      #0,r3            ;"
               "MOV      #10,r4            ;"
               "CLRMAC                     ;"
               "trget:                     ;"
               "MOV.W      .width,r1         ;"
               "MULU.W     r1,%[y]            ;"
               "MOV.L      .vram,r1         ;"
               "STS         macl,r0            ;"
               "ADD         %[x],r0            ;"
               "SHLL      r0               ;"
               "MOV.W      %[color],@(r0,r1)   ;"
               "CLRMAC                     ;"
               "CMP/EQ      r3,r4            ;"
               "BF/S      trget            ;"
               "add      #1,r3            ;"
               ".align    1               ;"//
               ".width:                  ;"//
               ".short    384               ;"//
               ".align      2               ;"// data
               ".vram:                     ;"//
               ".long       -1476395008         ;"//
               :// no output
return 0;

This is still causing the calculator to crash with 00000000 as the TARGET and PC values. Does anyone have any ideas?
You're executing garbage when you fall off the end of your code and into the inline data:

    add #1, r3
.align 1
.width: .short 384
I'd pass the constants you need into the inline block as parameters, rather than putting them inline like that. That'll allow the compiler to possibly optimize the loads.

You should probably also add "memory" to your clobbers block, since you modify memory and there may be pointer aliases that you invalidate with this operation.

I can't quite tell what this code is supposed to do, but I expect there will be no benefit to writing this in assembly over letting the compiler do its thing and tuning high-level code so it generates good code. That should be easier to write and read in addition to allowing the optimizer to reason better about your code (as a rule, inline assembly is opaque to the optimizer so you're eliminating the possibility for low-hanging fruit like CSE and constant folding).
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 2
» All times are UTC - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum