Tiny Code for dumping Flash Memory
I'm not used to program for ARM processors and don't know which compiler you use, so maybe the proposed changes does nothing at all, but hey, at least let's try!

1-Inline your functions:

A good compiler should already inline a function if optimizations are well set, but it's worth to inline it so you remove the call's and ret's

2-Avoid branching:

In some architectures an IF can be translated in: load, test, branch, three instructions, if you can do it without branching it can use less instructions.

So, the proposed code is:

    int main() 
    {
      // start dumping at memory address 0x08000000
      unsigned int *p;
      int i;

      p = (uint32_t *)(0x08000000u);

      // configure pin 1.0 and pin 1.1 as output (push-pull)
      PORT1-&gt;IOCR0 = 0x8080UL;

      do
      {
        for (i = 0; i &lt; 32; i++)
        {
          // set pin 1.1 to low (SPI clock)
          PORT1-&gt;OUT &amp;= (~0x2UL);
          PORT1-&gt;OUT = (PORT1-&gt;OUT &amp; 0xFFFE) | (data &amp; 0x01)
          PORT1-&gt;OUT |= 0x2UL;
          data &gt;&gt;= 1;
        }

      }while(p++)
    }


Give it a try and comment the results.