//  *********************************************************************************************
//  Description      : C Program to store the sentence 'hello world!' in a char array in memory
//  Project Version  : v1.0
//  Project          : [BCDC] Microtec Academy Course: Building a RISC-V CPU with SystemVerilog
//  -----
//  Copyright (c)    : 2025 Fraunhofer IIS, Department IDS
//  Created          : 15.Oct.2025  by Hussein Elzomor
//  Last Modified    : 15.Oct.2025  by Hussein Elzomor
//  -----
//  HISTORY          : Date         By         Comments
//                     -----------  ---------  -------------------------------------------------
//  *********************************************************************************************



asm(".global _start, halt; .set DataMem 0x1; _start: lui sp 0x2; addi sp sp -4; jal main;");
// DataMem address usage is set manually in the assembly code after its generation.

void storeChar(char c, char *location)
{
  *location = c;
}

int main()
{
  static char mem[13];

  storeChar('h', &mem[0]);
  storeChar('e', &mem[1]);
  storeChar('l', &mem[2]);
  storeChar('l', &mem[3]);
  storeChar('o', &mem[4]);
  storeChar(' ', &mem[5]);
  storeChar('w', &mem[6]);
  storeChar('o', &mem[7]);
  storeChar('r', &mem[8]);
  storeChar('l', &mem[9]);
  storeChar('d', &mem[10]);
  storeChar('!', &mem[11]);
  storeChar('\0', &mem[12]); // Don't forget the null terminator!

  return 0; // End the main function and return 0 on success
}
