SHARE
TWEET

spsr_usrsys.asm

a guest Jan 19th, 2020 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. format binary as 'gba'
  2.  
  3. gba_header:
  4.         ; Branch to 0x080000C0 (4 bytes)
  5.         dw      0xEA00002E
  6.  
  7.         ; Nintendo logo (156 bytes)
  8.         db      0x24,0xFF,0xAE,0x51,0x69,0x9A,0xA2,0x21,0x3D,0x84
  9.         db      0x82,0x0A,0x84,0xE4,0x09,0xAD,0x11,0x24,0x8B,0x98
  10.         db      0xC0,0x81,0x7F,0x21,0xA3,0x52,0xBE,0x19,0x93,0x09
  11.         db      0xCE,0x20,0x10,0x46,0x4A,0x4A,0xF8,0x27,0x31,0xEC
  12.         db      0x58,0xC7,0xE8,0x33,0x82,0xE3,0xCE,0xBF,0x85,0xF4
  13.         db      0xDF,0x94,0xCE,0x4B,0x09,0xC1,0x94,0x56,0x8A,0xC0
  14.         db      0x13,0x72,0xA7,0xFC,0x9F,0x84,0x4D,0x73,0xA3,0xCA
  15.         db      0x9A,0x61,0x58,0x97,0xA3,0x27,0xFC,0x03,0x98,0x76
  16.         db      0x23,0x1D,0xC7,0x61,0x03,0x04,0xAE,0x56,0xBF,0x38
  17.         db      0x84,0x00,0x40,0xA7,0x0E,0xFD,0xFF,0x52,0xFE,0x03
  18.         db      0x6F,0x95,0x30,0xF1,0x97,0xFB,0xC0,0x85,0x60,0xD6
  19.         db      0x80,0x25,0xA9,0x63,0xBE,0x03,0x01,0x4E,0x38,0xE2
  20.         db      0xF9,0xA2,0x34,0xFF,0xBB,0x3E,0x03,0x44,0x78,0x00
  21.         db      0x90,0xCB,0x88,0x11,0x3A,0x94,0x65,0xC0,0x7C,0x63
  22.         db      0x87,0xF0,0x3C,0xAF,0xD6,0x25,0xE4,0x8B,0x38,0x0A
  23.         db      0xAC,0x72,0x21,0xD4,0xF8,0x07
  24.  
  25.         db      'spsr_usrsys', 0   ; Game title (12 bytes)
  26.         db      '0000'             ; Game code (4 bytes)
  27.         db      'AN'               ; Make code (2 bytes)
  28.         db      0x96               ; Fixed (1 byte)
  29.         db      0x00               ; Unit code (1 byte)
  30.         db      0x80               ; Device type (1 byte)
  31.         db      0,0,0,0,0,0,0      ; Unused (7 bytes)
  32.         db      0x00               ; Game version (1 byte)
  33.         db      0xa2               ; Complement (1 byte)
  34.         db      0,0                ; Reserved (2 bytes)
  35.  
  36. _start:
  37.     ; Reset r2
  38.     mov r2, 0
  39.  
  40.     ; Setup DISPCNT
  41.     mov r0, 0x00000400
  42.     orr r0, 0x00000004
  43.     mov r1, 0x04000000
  44.     strh r0, [r1]
  45.  
  46. test1:
  47.     ; Here, CPSR should be equal to 0x4000001f
  48.     ; Copy a value to SPSR
  49.     mov r0, 0xb0000000
  50.     orr r0, 0x00000010
  51.     msr spsr, r0
  52.  
  53.     ; Compare the value in SPSR with the value in CPSR
  54.     mrs r1, cpsr
  55.     teq r0, r1
  56.     bne test2
  57.  
  58.     ; The value written to SPSR was (also?) written in CPSR.
  59.     orr r2, 0x001f
  60.  
  61. test2:
  62.     ; Copy a value to CPSR
  63.     mov r0, 0x70000000
  64.     orr r0, 0x0000001f
  65.     msr cpsr, r0
  66.  
  67.     ; Check the value in SPSR
  68.     mrs r1, spsr
  69.     teq r0, r1
  70.     bne test3
  71.  
  72.     ; The value written to CPSR was also written in SPSR.
  73.     orr r2, 0x03e0
  74.  
  75. test3:
  76.     ; Copy a value to SPSR
  77.     mov r0, 0xc0000000
  78.     orr r0, 0x0000001f
  79.     msr spsr, r0
  80.  
  81.     ; Go to user mode
  82.     mrs r1, cpsr
  83.     mov r3, 0x80000000
  84.     mov r3, r3, asr 24
  85.     and r1, r3
  86.     orr r1, 0x00000010
  87.     msr cpsr, r1
  88.  
  89.     ; Load SPSR in user mode
  90.     mrs r1, spsr
  91.     teq r0, r1
  92.     bne displayResult
  93.  
  94.     ; The SPSR is the same
  95.     orr r2, 0x7c00
  96.  
  97. displayResult:
  98.     mov r0, 0x05000000
  99.     strh r2, [r0]
  100.  
  101. halt:
  102.     b halt
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top