> I am working on a small OS for the msp430 and I have implemented two
> assembler routines to disable (EnterMonitor) and restore (LeaveMonitor)
> interrupts. The EnterMonitor() routine saves the current SR register on
> stack and disables the interrupt. The LeaveMonitor() restores the interrupt
> status by popping it from stack. (in a way like the RETI instruction does)
Actually, you can check setjmp/longjmp implementation how to set/get return
address of the function. Also, there was a discussion about frame address and
return address which summary can be found in doc.txt and FAQ. Small Operating
System which reference can be found in the list also provides very good
example how to do unusual saves/returns.
> This LeaveMonitor() function does not enable the interrupts when interrupts
> were disabled before calling the EnterMonitor() function. Now, this
There are two function attributes: critical and reentrant (may be we have to
rename this to persistant?) which do something you want.
> implementation only works when it is used in a function without local
> variables on stack ... because the compiler does not know that when
Obviously, the compiler does know almost _everything_ about the function
called. Two consts are set before function prologue:
.L__FrameSize__XXX__
and
.L__FrameOffset__XXX__
which meaning are explained in doc.txt and were discussed here.
Finally,
the one you need is 'critical' which explained in doc.txt.
cheers,
~d
> EnterMonitor() is called, the SP is decreased by one word. Does someone
> have a suggestion on how to solve this problem?
>
>
> static void __attribute__( (naked) )
> EnterMonitor
> (
> void
> )
>
> {
> asm volatile( "\t MOV R2, R15 ; Copy the contents of the \n"\
> "\t DINT ; status register to R15 and \n"\
> "\t NOP ; disable the interrupts. \n"\
> "\t POP R14 ; Get the return address \n"\
> "\t PUSH R15 ; and push the SR value to \n"\
> "\t BR R14 ; stack and return. \n"
> ); }
>
> static void __attribute__( (naked) )
> LeaveMonitor
> (
> void
> )
>
> {
> asm volatile( "\t POP R14 ; Get the return address and \n"\
> "\t POP R15 ; the contents of the status \n"\
> "\t MOV R15, R2 ; register from stack and \n"\
> "\t BR R14 ; return to caller. \n"
> ); }
>
>
> I have also worked with a ICC7700 compiler that knew the "monitor" keyword:
>
> char monitor foo( void )
> {
> char a;
> a = 3;
> return a;
> }
>
> The prologue of the function was a push operation of the status register
> and a disable interrupts instruction. The epilogue restored the old status
> and this way also restored the interrupt status. Does gcc also supports
> this kind of function?
>
>
> Sipke
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Mspgcc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
--
/********************************************************************
("`-''-/").___..--''"`-._ (\ Dimmy the Wild UA1ACZ
`6_ 6 ) `-. ( ).`-.__.`) Enterprise Information Sys
(_Y_.)' ._ ) `._ `. ``-..-' Nevsky prospekt, 20 / 44
_..`--'_..-_/ /--'_.' ,' Saint Petersburg, Russia
(il),-'' (li),' ((!.-' +7 (812) 3468202, 5585314
********************************************************************/