* easy68k version of code from lecture 9/2 * * NOTE: assembler directives and system traps are different from those * used with the boards in the lab org $3000 START _main link a6,#-2 ; allocate space for i clr.w -2(a6) ; i = 0 pea -2(a6) ; push &i as only argument jsr _f adda.l #4,sp ; restore stack clr.l d0 ; clear all of d0, so that... move.w -2(a6),d0 ; ...loading i (a short) into d0... move.l d0,-(sp) ; ...can be treated as a long for printing jsr printn ; print a number adda.l #4,sp ; restore the stack unlk a6 ; deallocate stack frame move.b #9,d0 ; exit according to easy68k's requirements trap #15 ************************************************************ * f(short * j): *j = *j + 1 * In: pointer to short * Out: nothing ************************************************************ _f move.l 4(sp),a0 ; load pointer addi.w #1,(a0) ; increment value pointed to rts printn move.l 4(sp),d1 ; use easy68k's way of printing a number move.l #3,d0 trap #15 rts end START