*********************************************************************** * CML Lab 2 Program 9 June 1997 Michael Burke * Sample assembly language program to disassemble *********************************************************************** *********************************************************************** * Initialization routine - jumps straight to the * beginning of code, with the data inbetween *********************************************************************** ORG $C000 JMP START ; Go to the start of the program *********************************************************************** * Data Segment - EQU's, constants and variables here *********************************************************************** * Equates ("Magic Numbers" and BUFFALO routines) OUTPUT EQU $FFAF ; outputs a single character -> SCI OUTCRLF EQU $FFC4 ; prints a LF and a CR * ANSI Escape codes needed YELLOW FCB $1B ; Make the cursor yellow FCB $5B FCB $33 FCB $33 FCB $3B FCB $31 FCB $6D FCB $04 CURCNTR FCB $1B ; Center the TEXT line on the screen FCB $5B ; { 12, 25 } position FCB $31 FCB $31 FCB $3B FCB $32 FCB $35 FCB $48 FCB $04 CLRSCRN FCB $1B ; Clear the screen FCB $5B FCB $32 FCB $4A FCB $04 * Constant strings that need memory allocated. TEXT FCC `This is a sample line of text.` FCB $04 *********************************************************************** * START Start of the program * Input: None * Output: A line of yellow text in the center of the screen *********************************************************************** START LDX #CLRSCRN JSR OUTTEXT ; Clear the screen LDX #YELLOW JSR OUTTEXT ; Make the cursor yellow LDX #CURCNTR JSR OUTTEXT ; Center the cursor LDX #TEXT JSR OUTTEXT ; Print the text JSR OUTCRLF ; Skip a line JSR OUTCRLF SWI ; End the program *********************************************************************** * OUTTEXT Outputs a line of text to the terminal, terminated * with an EOT ($04) * Input: Starting location of text in Register X * Output: Text until $04 is reached *********************************************************************** OUTTEXT PSHA ; Save our registers (non-destructive) PSHX OUTTXT1 LDAA 0,X ; Read a character into A CMPA #$04 ; Is it the EOT character? (End-of-text) BEQ OUTTXT2 ; If it is, end JSR OUTPUT ; Output character INX BRA OUTTXT1 ; loop OUTTXT2 PULX ; Restore our original registers PULA RTS ; Return to the calling address