; quadcall.asm ; ; this program sets up the paramaters and calls ; "quadr.asm" as a subroutine. ; ; set up the stack. org $0800 start: lds #$07ff ;init the stack pointer ; set up the stop bit so that the "stop" instruction ; will work tpa anda #$7f tap ; clear all the registers, so that when we try to ; save them on the stack, the simulator doesn't ; yell at us for tryting to use an uninitiated ; register. clra clrb ldx #0 ldy #0 ; set up the paramaters we need, and push them onto ; the stack. say a=2, b=5, c=4 and x=6 ldaa #!2 psha ldaa #!5 psha ldaa #!4 psha ldaa #!6 psha ; now add some room for the return address pshx ; and call the subroutine jsr quadratic ; after the subroutine is done, the value of f(x) ; should be on the top of the stack. let's pop it ; into "D" to look at it. pula pulb ; and for clenliness, let's empty the stack. There ; are 4 bytes left on the stack, so the easiest way ; is to pull X twice. pulx pulx ; we're done, so stop. stop ; now include the subroutine. $include 'quadr.asm' ; and finally setup the reset vector org $fffe reset: dw start