Properly do bounds checking in CpuSet and CpuFastSet (fixes #81)

This commit is contained in:
Jeffrey Pfau 2014-07-05 03:52:07 -07:00
parent 34145543f2
commit 26c33b18e1
2 changed files with 55 additions and 51 deletions

View File

@ -2,7 +2,7 @@
#include "gba-memory.h"
const size_t hleBiosLength = 504;
const size_t hleBiosLength = 516;
const uint8_t hleBios[SIZE_BIOS] = {
0x06, 0x00, 0x00, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x05, 0x00, 0x00, 0xea,
0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x00, 0x00, 0xa0, 0xe1,
@ -15,7 +15,7 @@ const uint8_t hleBios[SIZE_BIOS] = {
0x00, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf4, 0x00, 0x00, 0x00,
0x88, 0x01, 0x00, 0x00, 0x0f, 0x50, 0x2d, 0xe9, 0x01, 0x03, 0xa0, 0xe3,
0x94, 0x01, 0x00, 0x00, 0x0f, 0x50, 0x2d, 0xe9, 0x01, 0x03, 0xa0, 0xe3,
0x00, 0xe0, 0x8f, 0xe2, 0x04, 0xf0, 0x10, 0xe5, 0x0f, 0x50, 0xbd, 0xe8,
0x04, 0xf0, 0x5e, 0xe2, 0x01, 0x00, 0xa0, 0xe3, 0x01, 0x10, 0xa0, 0xe3,
0x0c, 0x40, 0x2d, 0xe9, 0x00, 0x50, 0x4f, 0xe1, 0x1f, 0xf0, 0x29, 0xe3,
@ -25,25 +25,26 @@ const uint8_t hleBios[SIZE_BIOS] = {
0x01, 0x30, 0x23, 0x10, 0xb8, 0x30, 0x44, 0x11, 0x08, 0x22, 0xc4, 0xe5,
0xf7, 0xff, 0xff, 0x0a, 0x93, 0xf0, 0x29, 0xe3, 0x05, 0xf0, 0x69, 0xe1,
0x0c, 0x80, 0xbd, 0xe8, 0x00, 0x40, 0x2d, 0xe9, 0x00, 0x50, 0x4f, 0xe1,
0x1f, 0xf0, 0x29, 0xe3, 0x02, 0x36, 0xa0, 0xe1, 0x23, 0x36, 0xa0, 0xe1,
0x01, 0x04, 0x12, 0xe3, 0x0d, 0x00, 0x00, 0x0a, 0x01, 0x03, 0x12, 0xe3,
0x04, 0x00, 0x00, 0x0a, 0x04, 0x00, 0xb0, 0xe8, 0x04, 0x00, 0xa1, 0xe8,
0x01, 0x30, 0x53, 0xe2, 0xfc, 0xff, 0xff, 0x1a, 0x13, 0x00, 0x00, 0xea,
0x01, 0x00, 0xc0, 0xe3, 0x01, 0x10, 0xc1, 0xe3, 0xb0, 0x20, 0xd0, 0xe1,
0xb2, 0x20, 0xc1, 0xe0, 0x01, 0x30, 0x53, 0xe2, 0xfc, 0xff, 0xff, 0x1a,
0x0c, 0x00, 0x00, 0xea, 0x01, 0x03, 0x12, 0xe3, 0x04, 0x00, 0x00, 0x0a,
0x04, 0x00, 0xb0, 0xe8, 0x04, 0x00, 0xa1, 0xe8, 0x01, 0x30, 0x53, 0xe2,
0xfb, 0xff, 0xff, 0x1a, 0x05, 0x00, 0x00, 0xea, 0x01, 0x00, 0xc0, 0xe3,
0x01, 0x10, 0xc1, 0xe3, 0xb2, 0x20, 0xd0, 0xe0, 0xb2, 0x20, 0xc1, 0xe0,
0x01, 0x30, 0x53, 0xe2, 0xfb, 0xff, 0xff, 0x1a, 0x93, 0xf0, 0x29, 0xe3,
0x1f, 0xf0, 0x29, 0xe3, 0x02, 0x36, 0xa0, 0xe1, 0x01, 0x04, 0x12, 0xe3,
0x0f, 0x00, 0x00, 0x0a, 0x01, 0x03, 0x12, 0xe3, 0x05, 0x00, 0x00, 0x0a,
0x23, 0x35, 0x81, 0xe0, 0x04, 0x00, 0xb0, 0xe8, 0x03, 0x00, 0x51, 0xe1,
0x04, 0x00, 0xa1, 0xb8, 0xfc, 0xff, 0xff, 0xba, 0x16, 0x00, 0x00, 0xea,
0x01, 0x00, 0xc0, 0xe3, 0x01, 0x10, 0xc1, 0xe3, 0xa3, 0x35, 0x81, 0xe0,
0xb0, 0x20, 0xd0, 0xe1, 0x03, 0x00, 0x51, 0xe1, 0xb2, 0x20, 0xc1, 0xb0,
0xfc, 0xff, 0xff, 0xba, 0x0e, 0x00, 0x00, 0xea, 0x01, 0x03, 0x12, 0xe3,
0x05, 0x00, 0x00, 0x0a, 0x23, 0x35, 0x81, 0xe0, 0x03, 0x00, 0x51, 0xe1,
0x04, 0x00, 0xb0, 0xb8, 0x04, 0x00, 0xa1, 0xb8, 0xfb, 0xff, 0xff, 0xba,
0x06, 0x00, 0x00, 0xea, 0xa3, 0x35, 0x81, 0xe0, 0x01, 0x00, 0xc0, 0xe3,
0x01, 0x10, 0xc1, 0xe3, 0x03, 0x00, 0x51, 0xe1, 0xb2, 0x20, 0xd0, 0xb0,
0xb2, 0x20, 0xc1, 0xb0, 0xfb, 0xff, 0xff, 0xba, 0x93, 0xf0, 0x29, 0xe3,
0x05, 0xf0, 0x69, 0xe1, 0x00, 0x80, 0xbd, 0xe8, 0x00, 0x40, 0x2d, 0xe9,
0x00, 0x50, 0x4f, 0xe1, 0x1f, 0xf0, 0x29, 0xe3, 0xf0, 0x07, 0x2d, 0xe9,
0x01, 0x04, 0x12, 0xe3, 0x02, 0x36, 0xa0, 0xe1, 0x23, 0x26, 0xa0, 0xe1,
0x0b, 0x00, 0x00, 0x0a, 0x10, 0x00, 0xb0, 0xe8, 0x04, 0x50, 0xa0, 0xe1,
0x04, 0x30, 0xa0, 0xe1, 0x04, 0x60, 0xa0, 0xe1, 0x04, 0x70, 0xa0, 0xe1,
0x04, 0x80, 0xa0, 0xe1, 0x04, 0x90, 0xa0, 0xe1, 0x04, 0xa0, 0xa0, 0xe1,
0xf8, 0x07, 0xa1, 0xe8, 0x08, 0x20, 0x52, 0xe2, 0xfc, 0xff, 0xff, 0xca,
0x03, 0x00, 0x00, 0xea, 0xf8, 0x07, 0xb0, 0xe8, 0xf8, 0x07, 0xa1, 0xe8,
0x08, 0x20, 0x52, 0xe2, 0xfb, 0xff, 0xff, 0xca, 0xf0, 0x07, 0xbd, 0xe8,
0x01, 0x04, 0x12, 0xe3, 0x02, 0x36, 0xa0, 0xe1, 0x23, 0x25, 0x81, 0xe0,
0x0b, 0x00, 0x00, 0x0a, 0x00, 0x30, 0x90, 0xe5, 0x03, 0x40, 0xa0, 0xe1,
0x03, 0x50, 0xa0, 0xe1, 0x03, 0x60, 0xa0, 0xe1, 0x03, 0x70, 0xa0, 0xe1,
0x03, 0x80, 0xa0, 0xe1, 0x03, 0x90, 0xa0, 0xe1, 0x03, 0xa0, 0xa0, 0xe1,
0x02, 0x00, 0x51, 0xe1, 0xf8, 0x07, 0xa1, 0xb8, 0xfc, 0xff, 0xff, 0xba,
0x03, 0x00, 0x00, 0xea, 0x02, 0x00, 0x51, 0xe1, 0xf8, 0x07, 0xb0, 0xb8,
0xf8, 0x07, 0xa1, 0xb8, 0xfb, 0xff, 0xff, 0xba, 0xf0, 0x07, 0xbd, 0xe8,
0x93, 0xf0, 0x29, 0xe3, 0x05, 0xf0, 0x69, 0xe1, 0x00, 0x80, 0xbd, 0xe8
};

View File

@ -87,49 +87,52 @@ stmfd sp!, {lr}
mrs r5, spsr
msr cpsr, #0x1F
mov r3, r2, lsl #12
mov r3, r3, lsr #12
tst r2, #0x01000000
beq 0f
# Fill
tst r2, #0x04000000
beq 1f
# Word
add r3, r1, r3, lsr #10
ldmia r0!, {r2}
2:
stmia r1!, {r2}
subs r3, #1
bne 2b
cmp r1, r3
stmltia r1!, {r2}
blt 2b
b 3f
# Halfword
1:
bic r0, #1
bic r1, #1
add r3, r1, r3, lsr #11
ldrh r2, [r0]
2:
strh r2, [r1], #2
subs r3, #1
bne 2b
cmp r1, r3
strlth r2, [r1], #2
blt 2b
b 3f
# Copy
0:
tst r2, #0x04000000
beq 1f
# Word
add r3, r1, r3, lsr #10
2:
ldmia r0!, {r2}
stmia r1!, {r2}
subs r3, #1
bne 2b
cmp r1, r3
ldmltia r0!, {r2}
stmltia r1!, {r2}
blt 2b
b 3f
# Halfword
1:
add r3, r1, r3, lsr #11
bic r0, #1
bic r1, #1
2:
ldrh r2, [r0], #2
strh r2, [r1], #2
subs r3, #1
bne 2b
cmp r1, r3
ldrlth r2, [r0], #2
strlth r2, [r1], #2
blt 2b
3:
msr cpsr, #0x93
msr spsr, r5
@ -142,28 +145,28 @@ msr cpsr, #0x1F
stmfd sp!, {r4-r10}
tst r2, #0x01000000
mov r3, r2, lsl #12
mov r2, r3, lsr #12
add r2, r1, r3, lsr #10
beq 0f
# Fill
ldmia r0!, {r4}
mov r5, r4
mov r3, r4
mov r6, r4
mov r7, r4
mov r8, r4
mov r9, r4
mov r10, r4
ldr r3, [r0]
mov r4, r3
mov r5, r3
mov r6, r3
mov r7, r3
mov r8, r3
mov r9, r3
mov r10, r3
1:
stmia r1!, {r3-r10}
subs r2, #8
bgt 1b
cmp r1, r2
stmltia r1!, {r3-r10}
blt 1b
b 2f
# Copy
0:
ldmia r0!, {r3-r10}
stmia r1!, {r3-r10}
subs r2, #8
bgt 0b
cmp r1, r2
ldmltia r0!, {r3-r10}
stmltia r1!, {r3-r10}
blt 0b
2:
ldmfd sp!, {r4-r10}
msr cpsr, #0x93