Skip to main content
gamedev.net
🔒 Locked

Assembly

Started by Tiger99 4 replies 250+ views
Original Post
Tiger99
Tiger99
Hello I am not familiar with assembly language. Can someone please explain what the following inline assembly is doing VOID rtx_dbug_out_char( CHAR c ) { asm( "sub.l #60, %a7" ); asm( "movem.l %d0-%d7/%a0-%a6, (%a7)" ); asm( "move.l 8(%a6), %d1" ); asm( "move.l #0x13, %d0" ); asm( "trap #15" ); asm( "movem.l (%a7), %d0-%d7/%a0-%a6" ); asm( "add.l #60, %a7" ); } I am trying to build a simple real time OS. I need to allocate memory for all the OS processes. Should I do the allocation in C or assembly? Some sample code will be helpful Thanks in advance
Nypyren
Nypyren
OMFG! I don''t know that form of assembly syntax... and I know AT&T and Intel syntax...
Tiger99
Tiger99
Come on, someone here must know assembly language for ColdFire board

Any help will be very appreciated
ThoughtCriminal
ThoughtCriminal
quote:
Original post by Tiger99
Hello
I am not familiar with assembly language. Can someone please explain what the following inline assembly is doing

VOID rtx_dbug_out_char( CHAR c )
{

asm( "sub.l #60, %a7" );
^^^making space on the stack
asm( "movem.l %d0-%d7/%a0-%a6, (%a7)" );
^^^move multiple regs on the stack(store all regs on stack)
asm( "move.l 8(%a6), %d1" );
^^^move dword value at A6+8 to data reg D1
asm( "move.l #0x13, %d0" );
^^^move immediate hex val 13h to data reg D0
asm( "trap #15" );
^^^trap is like an x86 int
asm( "movem.l (%a7), %d0-%d7/%a0-%a6" );
^^^move multiple from stack to regs(restore regs)
asm( "add.l #60, %a7" );
^^^fix stack(balance stack)
}

I am trying to build a simple real time OS. I need to allocate memory for all the OS processes. Should I do the allocation in C or assembly? Some sample code will be helpful

Thanks in advance



It looks like 68k code. Look for some docs for trap #15 function 13h to tell what it does. Guessing buy the function name, I'd say it will out put the character at address reg A6+8 to the terminal.





[edited by - ThoughtCriminal on March 11, 2003 4:13:37 AM]
tok_junior
tok_junior
It''s most certainly motorola code, i''m not so sure it''s for the 68k line though...
What is your target architecture?

--
MFC is sorta like the swedish police... It''''s full of crap, and nothing can communicate with anything else.
Sneftel
Sneftel
it certainly looks 68k from here; what it is doing is saving all variables onto the stack, then setting registers D0 and D1 (D0 it initializes to the constant 0x13; D1 most likely refers to a local variable). Then it calls trap 15 (kind of like an int call under x86 assembly. When the trap returns, it restores all variables from the stack.

This is the sort of code one would use to access OS functions.

Edit: Okay, ThoughtCriminal's waaaay ahead of me here. Listen to him.


But... but that's what HITLER would say!!


[edited by - sneftel on March 11, 2003 4:41:56 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.