// rangeFor.cpp — Phase 2.7 cxxSmoke check 1.
//
// Exercises range-based for over an etl::array<int, 5>.  Writes the sum of
// the elements to bank 2 at 0x025000 and the success sentinel 0x0099 to
// 0x025002 once the loop completes.
//
//   $025000 = 0x000F  (sum of 1..5 = 15)
//   $025002 = 0x0099  success marker
#include <stdint.h>
#include "etl/array.h"


int main(void) {
    etl::array<int, 5> a = { 1, 2, 3, 4, 5 };
    int sum = 0;
    for (int v : a) {
        sum += v;
    }
    *(volatile uint16_t *)0x025000UL = (uint16_t)sum;
    *(volatile uint16_t *)0x025002UL = 0x0099;
    return 0;
}
