/* * LAB 7 * factorial and fibonacci, with LCDINT * updated 11/29/01 (talby) */ #include .sect .data // START DO NOT MODIFY **************************** numprompt: .asciz "ENTER when ready" factprompt: .asciz "Fact(" fibprompt: .asciz "Fib(" spaces: .asciz " " .sect .text main: ldx #spaces // a bunch of initializations ldaa #1 jsr LCDLINE ldx #spaces ldaa #2 jsr LCDLINE mainloop: jsr getnum // returns B jsr clearend jsr putfact // expects B jsr clearend // UNCOMMENT (and implement) FOLLOWING CODE FOR A X+ // jsr getnum // jsr clearend // jsr putfib // jsr clearend bra mainloop getnum: //Expects: nothing //Returns: SWITCHES in ACCB //Notes: prompts, waits for a keypress. clobbers A,X ldx #numprompt ldaa #1 jsr LCDLINE // display a null-terminated string jsr GETCHAR // faking an interrupt clra ldab SWITCHES rts putfact: //Expects: user input in ACCB //Returns: nothing //Notes: prints ACCB (user input), then calculates & prints fact(B) ldx #factprompt ldaa #2 jsr LCDLINE clra jsr LCDINT // expects :-D ldaa #')' jsr LCD_CHAR ldaa #'=' jsr LCD_CHAR tba jsr factorial // expects: B jsr LCDINT // expects: D rts putfib: //Expects: user input in ACCB //Returns: nothing //Notes: prints ACCB (user input), then calculates & prints fib(B) ldx #fibprompt ldaa #2 jsr LCDLINE clra jsr LCDINT ldaa #')' jsr LCD_CHAR ldaa #'=' jsr LCD_CHAR tba jsr fibonacci jsr LCDINT rts clearend: //Expects: nothing //Returns: nothing //Notes: prints spaces to clear the end of a previously written line ldaa #' ' jsr LCD_CHAR jsr LCD_CHAR jsr LCD_CHAR jsr LCD_CHAR rts // END DO NOT MODIFY **************************** factorial: //Expects: unsigned integer in ACCA //Returns: fact(A) in ACCD //Notes: If ACCA contains a negative number, return 0. rts fibonacci: // For X+ //Expects: unsigned integer in ACCA //Returns: fib(A) in ACCD //Notes: If ACCA contains a negative number, return 0. rts