Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- push {r0, r1} // Free up some registers for us to use
- ldr r0, =current_thread
- ldr r0, [r0] // turn the symbol current_thread into its value (a pointer to struct Thread)
- ldr r0, [r0] // take the first word in the struct- a pointer to struct ThreadState. 196 bytes long, exactly: uint32_t core_registers[16]; uint32_t cpsr; uint64_t ext_registers[16];
- pop {r1} // note that the program's r0 is now in r1
- stmia r0, {r1}^ // Store only r0
- pop {r1}
- add r0, r0, #4 // no writeback on stm for user registers
- stmia r0, {r1-r14}^ // Store r1-r14
- add r0, r0, #56 // again, no writeback. 14 4-byte registers = 56 bytes. r0 is currently offset 60 bytes.
- stmia r0!, {lr} // store our lr- which is the interrupted thread's pc (plus an offset, but ignore that for now). r0 is now offset 64 bytes, past ThreadState->core_registers
- mrs r1, spsr
- str r1, [r0, #4]! // Hooray, writeback. r0 is now offset 68 bytes, past ThreadState->cpsr
- vstmia r0!, {q0-q15} // more writeback. r0 is now offset 128 (16 8-byte registers) more bytes, past ThreadState->ext_registers, for a grand total of 196 bytes!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement