<aside> <img src="/icons/map-pin_gray.svg" alt="/icons/map-pin_gray.svg" width="40px" /> Relevant Notes/Resources:
4 Advanced Assembly Programming
</aside>
The concept is pretty similar to what we did for the midterm. The entirety of the question usually revolves around the instruction swi, which performs the following operation:

As noted in the operation, SP refers to the stack pointer. But, also as a reminder, a stack goes from a high address to low address. So when we subtract, we go “up” the table.

In general, the stack after swi is executed should look something like this:

I’ll provide a brief explanation on the first two operations, as the rest pretty much follow the same concept:
$(SP) - 2 \\implies SP;$
The stack pointer goes up the table, since $2500 - 2 = $24FE.

$RTN_H:RTN_L \\implies M_{(SP)}:M_{(SP+1)}$;
The following means to store $RTN_H$ in $M_{(SP)}$ and $RTN_L$ in $M_{(SP+1)}$. So how does that exactly translate to the stack content:

$M_{(SP)}$ is the memory of the stack pointer is at, which if you recall, was shifted up by 2.$M_{(SP+1)}$ is the memory below the stack pointer, because again as a reminder, the stack goes from high to low address. So by adding, you move down a row.Then, this repeats for $Y_H:Y_L$ , $X_H:X_L$ , $B:A$ and $CCR$. At which, you should obtain the following stack frame:

The solution for the other question is:
ldd #$7843 load register D with $7843.
$78 and accumulator B is $43.aba adds accumulator A and B, and loads the results to accumulator A.
$78 + $43 = $BB.$BB43, since accumulator A is $BB and accumulator B remains the same, which is $43.