I've added a fairly basic article on ARM System Calls, like the ARM Bare Bones, it's still a work in progress.
So far it features a basic introduction to making system calls on ARM. It also shows how to create system calls.
ARM System Calls
Added article on ARM System Calls.
Re: Added article on ARM System Calls.
With SWI, LR points to the next instruction, so it should end with MOVS PC, LR, not SUBS PC, LR, #4.
To have SWI work in both ARM and Thumb mode, one can place the system call number in bits 16-23 and fetch it with LDRB R0, [LR,#-2].
To have SWI work in both ARM and Thumb mode, one can place the system call number in bits 16-23 and fetch it with LDRB R0, [LR,#-2].
Re: Added article on ARM System Calls.
Thanks, I've changed it.Gigasoft wrote:With SWI, LR points to the next instruction, so it should end with MOVS PC, LR, not SUBS PC, LR, #4.
To have SWI work in both ARM and Thumb mode, one can place the system call number in bits 16-23 and fetch it with LDRB R0, [LR,#-2].
Re: Added article on ARM System Calls.
The last section about shifting left 16-bits is unclear. It is unclear as to whether this shift MUST be done in inline assembly or if it can be done in C.
Re: Added article on ARM System Calls.
You can't get at the return address from C anyway, so you have to use assembly. But then again, there is no guarrantee that LR will contain the return address once it gets to that statement, so preferably the entire SWI handler should be written in assembly.
Note that fetching the entire word and shifting it manually will not work because the address could be unaligned.
Note that fetching the entire word and shifting it manually will not work because the address could be unaligned.