github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/targets/gameboy-advance.s (about)

     1  .section    .init
     2  .global     _start
     3  .align
     4  .arm
     5  
     6  _start:
     7      b       start_vector
     8  
     9      // ROM header
    10      .byte 0x24,0xff,0xae,0x51,0x69,0x9a,0xa2,0x21,0x3d,0x84,0x82,0x0a,0x84,0xe4,0x09,0xad
    11      .byte 0x11,0x24,0x8b,0x98,0xc0,0x81,0x7f,0x21,0xa3,0x52,0xbe,0x19,0x93,0x09,0xce,0x20
    12      .byte 0x10,0x46,0x4a,0x4a,0xf8,0x27,0x31,0xec,0x58,0xc7,0xe8,0x33,0x82,0xe3,0xce,0xbf
    13      .byte 0x85,0xf4,0xdf,0x94,0xce,0x4b,0x09,0xc1,0x94,0x56,0x8a,0xc0,0x13,0x72,0xa7,0xfc
    14      .byte 0x9f,0x84,0x4d,0x73,0xa3,0xca,0x9a,0x61,0x58,0x97,0xa3,0x27,0xfc,0x03,0x98,0x76
    15      .byte 0x23,0x1d,0xc7,0x61,0x03,0x04,0xae,0x56,0xbf,0x38,0x84,0x00,0x40,0xa7,0x0e,0xfd
    16      .byte 0xff,0x52,0xfe,0x03,0x6f,0x95,0x30,0xf1,0x97,0xfb,0xc0,0x85,0x60,0xd6,0x80,0x25
    17      .byte 0xa9,0x63,0xbe,0x03,0x01,0x4e,0x38,0xe2,0xf9,0xa2,0x34,0xff,0xbb,0x3e,0x03,0x44
    18      .byte 0x78,0x00,0x90,0xcb,0x88,0x11,0x3a,0x94,0x65,0xc0,0x7c,0x63,0x87,0xf0,0x3c,0xaf
    19      .byte 0xd6,0x25,0xe4,0x8b,0x38,0x0a,0xac,0x72,0x21,0xd4,0xf8,0x07
    20  
    21      // Game title
    22      .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
    23  
    24      // Game code
    25      .byte 0x00,0x00,0x00,0x00
    26  
    27      // Maker code
    28      .byte 0x00,0x00
    29  
    30      // Fixed value
    31      .byte 0x96
    32  
    33      // Main unit code
    34      .byte 0x00
    35  
    36      // Device type (0x00 retail, 0x80 debug)
    37      .byte 0x00
    38  
    39      // Reserved
    40      .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00
    41  
    42      // Software version
    43      .byte 0x00
    44  
    45      // Complement check
    46      .byte 0x51
    47  
    48      // Reserved area
    49      .space 98
    50  
    51  start_vector:
    52      // Configure stacks
    53      mov     r0, #0x12                      // Switch to IRQ Mode
    54      msr     cpsr, r0
    55      ldr     sp, =_stack_top_irq            // Set IRQ stack
    56      mov     r0, #0x1f                      // Switch to System Mode
    57      msr     cpsr, r0
    58      ldr     sp, =_stack_top                // Set user stack
    59  
    60      // Configure interrupt handler
    61      mov     r0, #0x4000000                 // REG_BASE
    62      ldr     r1, =handleInterruptARM
    63      str     r1, [r0, #-4]                  // actually storing to 0x03007FFC due to mirroring
    64  
    65      // Enable interrupts
    66      mov     r1, #1
    67      str     r1, [r0, #0x208]               // 0x04000208 Interrupt Master Enable
    68  
    69      // Jump to user code (switching to Thumb mode)
    70      ldr     r3, =main
    71      bx      r3
    72  
    73  // Small interrupt handler that immediately jumps to a function defined in the
    74  // program (in Thumb) for further processing.
    75  handleInterruptARM:
    76      ldr     r0, =handleInterrupt
    77      bx      r0