summaryrefslogtreecommitdiff
path: root/x86
diff options
context:
space:
mode:
authorAutechre2021-03-09 20:31:50 +0100
committerGitHub2021-03-09 20:31:50 +0100
commit45c8ef0a0bdf0557ab9c1153b5a6e77298cca34a (patch)
tree45b66118646d122a395cfecf2d740bed854c4e45 /x86
parent6a8aa84200eb92a7f3f1b4befb0630d95ad59b8e (diff)
parent0522d9a4f535a61953da64518097fc7f64d7120c (diff)
downloadpicogpsp-45c8ef0a0bdf0557ab9c1153b5a6e77298cca34a.tar.gz
picogpsp-45c8ef0a0bdf0557ab9c1153b5a6e77298cca34a.tar.bz2
picogpsp-45c8ef0a0bdf0557ab9c1153b5a6e77298cca34a.zip
Merge pull request #101 from davidgfnet/master
Remove libco
Diffstat (limited to 'x86')
-rw-r--r--x86/x86_stub.S44
1 files changed, 40 insertions, 4 deletions
diff --git a/x86/x86_stub.S b/x86/x86_stub.S
index dd98f7a..ba997ba 100644
--- a/x86/x86_stub.S
+++ b/x86/x86_stub.S
@@ -95,6 +95,7 @@
.equ CPU_MODE, (29 * 4)
.equ CPU_HALT_STATE, (30 * 4)
.equ CHANGED_PC_STATUS, (31 * 4)
+.equ COMPLETED_FRAME, (32 * 4)
# destroys ecx and edx
@@ -150,6 +151,11 @@ _x86_update_gba:
call _update_gba # process the next event
mov %eax, %edi # edi = new cycle count
+
+ # did we just complete a frame? go back to main then
+ cmpl $0, COMPLETED_FRAME(%ebx)
+ jne return_to_main
+
# did the PC change?
cmpl $1, CHANGED_PC_STATUS(%ebx)
je lookup_pc
@@ -197,6 +203,10 @@ write_epilogue:
alert_loop:
call _update_gba # process the next event
+
+ # did we just complete a frame? go back to main then
+ cmpl $0, COMPLETED_FRAME(%ebx)
+ jne return_to_main
# see if the halt status has changed
mov CPU_HALT_STATE(%ebx), %edx
@@ -509,24 +519,50 @@ lookup_pc_arm:
# eax: cycle counter
_execute_arm_translate:
- movl (_reg), %ebx # load base register
+ # Save main context, since we need to return gracefully
+ pushl %ebx
+ pushl %esi
+ pushl %edi
+ pushl %ebp
+
+ movl $_reg, %ebx # load base register
extract_flags # load flag variables
movl %eax, %edi # load edi cycle counter
movl REG_PC(%ebx), %eax # load PC
+ # (if the CPU is halted, do not start executing but
+ # loop in the alert loop until it wakes up)
+ cmp $0, CPU_HALT_STATE(%ebx)
+ je 1f
+ call alert_loop # Need to push something to the stack
+
+1:
testl $0x20, REG_CPSR(%ebx)
- jnz 1f
+ jnz 2f
call _block_lookup_address_arm
jmp *%eax # jump to it
-1:
+2:
call _block_lookup_address_thumb
jmp *%eax
+return_to_main:
+ add $4, %esp # remove current return addr
+ popl %ebp
+ popl %edi
+ popl %esi
+ popl %ebx
+ ret
+
+.data
+.align 64
+
+_reg:
+ .space 0x100, 0
+
.comm _memory_map_read 0x8000
.comm _memory_map_write 0x8000
-.comm _reg 4