For school we're writing a simple OS for Motorola Coldfire 68k boards, and I'm responsible for context switching. My question concerns how to access c variables inside of my inline assembly. I'm also still figuring out what I should store as the Process' Program Counter when its switched out, and where it'll lie on the stack.
Anyway onto the assembly. So I have a global pointer variable to a ProcessControlBlock (PCB) struct. Now I want to assign certain members of that PCB pointer for saving when that process gets switched back in... so what's the inline assembly for that?
Do I use the member as an address or as referable data itself or as immediate data?
So I guess here are my three options
Member as address
Memory location directly
immediate address
And I guess there's one more option which is using gCurrentPCB pointer as an address and then figuring out what offset is the correct member field and setting that, and so.
I'm fully aware that Motorola Coldfire boards are from the stone ages, but if anybody could help me out at all I'd be extremely grateful. I've been looking at the course documentation and trying to find information online but thus far I've been totally unlucky. Thanks in advance!
Anyway onto the assembly. So I have a global pointer variable to a ProcessControlBlock (PCB) struct. Now I want to assign certain members of that PCB pointer for saving when that process gets switched back in... so what's the inline assembly for that?
Do I use the member as an address or as referable data itself or as immediate data?
So I guess here are my three options
Member as address
Code:
asm("movea.l gCurrenPCB->fPC, %a0");
asm("move.l %pc, (%a0)");
Memory location directly
Code:
asm("move.l %pc, gCurrentPCB->fPC");
immediate address
Code:
asm("move.l #gCurrentPCB->fPC, %a0");
asm("move.l %pc, (%a0)");
And I guess there's one more option which is using gCurrentPCB pointer as an address and then figuring out what offset is the correct member field and setting that, and so.
Code:
asm("move.l gCurrentPCB, %a0")
asm("move.l %pc, 8(%a0)")
I'm fully aware that Motorola Coldfire boards are from the stone ages, but if anybody could help me out at all I'd be extremely grateful. I've been looking at the course documentation and trying to find information online but thus far I've been totally unlucky. Thanks in advance!