Task

Write a procedure which accepts as arguments another procedure and a positive integer.

The latter procedure is executed a number of times equal to the accepted integer.




	lea foo,a5            ;function to execute
	move.w #4-1,d7        ;times to repeat
	jsr Repeater
 
	jmp *                 ;halt the CPU, we're done
 
repeater:
	jsr repeaterhelper    ;this also need to be a call, so that the RTS of the desired procedure
                              ;returns us to the loop rather than the line after "jsr Repeater".
	DBRA D7,repeater
	rts
 
repeaterhelper:
	jmp (a5)       ;keep in mind, this is NOT a dereference, it simply sets the program counter equal to A5.
                       ;A bit misleading if you ask me.
foo:
	MOVE.B #'!',D0
	JSR PrintChar
	rts