Direct Calls

6.4 Direct Calls

Another operation that will be familiar to seasoned programmers is the LCALL instruction. This is similar to a “GOSUB” command in Basic.

When the MSC1210 executes an LCALL instruction, it immediately pushes the current PC onto the stack and then continues executing code at the address indicated by the LCALL instruction.

6.5 Returns From Routines

Another structure that can cause program flow to change is the “Return from Subroutine” instruction, known as RET in Assembly language. The RET in- struction, when executed, returns to the address following the instruction that called the given subroutine. More accurately, it returns to the address that is stored on the stack.

The RET command is direct in the sense that it always changes program flow without basing it on a condition, but is variable in the sense that where program flow continues can be different each time the RET instruction is executed, de- pending on where the subroutine was originally called from.

6.6 Interrupts

An interrupt is a special feature that allows the MSC1210 to break from its nor- mal program flow to execute an immediate task, providing the illusion of multi- tasking. The word interrupt can often be substituted with the word event.

An interrupt is triggered whenever a corresponding event occurs. When the event occurs, the MSC1210 temporarily puts the normal execution of the pro- gram on hold and executes a special section of code referred to as an interrupt handler. The interrupt handler performs whatever special functions are re- quired to handle the event and then returns control to the MSC1210, at which point program execution continues as if it had never been interrupted.

The topic of interrupts is somewhat tricky and very important. For that reason, Chapter 10 is dedicated to the topic.

6-4

Page 64
Image 64
Texas Instruments MSC1210 manual Direct Calls, Returns From Routines, Interrupts