65816-llvm-mos/tests/cxxSmoke/rangeFor.cpp
Scott Duensing da095402ec Updated
2026-06-02 23:17:57 -05:00

22 lines
608 B
C++

// 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;
}