0001 *********************************************************************** 0002 * CML Lab 2 Program 9 June 1997 Michael Burke 0003 * Sample assembly language program to disassemble 0004 *********************************************************************** 0005 0006 *********************************************************************** 0007 * Initialization routine - jumps straight to the 0008 * beginning of code, with the data inbetween 0009 *********************************************************************** 0010 c000 ORG $C000 0011 c000 7e c0 38 [ 3 ] JMP START ; Go to the start of the program 0012 0013 *********************************************************************** 0014 * Data Segment - EQU's, constants and variables here 0015 *********************************************************************** 0016 0017 * Equates ("Magic Numbers" and BUFFALO routines) 0018 ffaf OUTPUT EQU $FFAF ; outputs a single character -> SCI 0019 ffc4 OUTCRLF EQU $FFC4 ; prints a LF and a CR 0020 0021 * ANSI Escape codes needed 0022 c003 1b YELLOW FCB $1B ; Make the cursor yellow 0023 c004 5b FCB $5B 0024 c005 33 FCB $33 0025 c006 33 FCB $33 0026 c007 3b FCB $3B 0027 c008 31 FCB $31 0028 c009 6d FCB $6D 0029 c00a 04 FCB $04 0030 c00b 1b CURCNTR FCB $1B ; Center the TEXT line on the screen 0031 c00c 5b FCB $5B ; { 12, 25 } position 0032 c00d 31 FCB $31 0033 c00e 31 FCB $31 0034 c00f 3b FCB $3B 0035 c010 32 FCB $32 0036 c011 35 FCB $35 0037 c012 48 FCB $48 0038 c013 04 FCB $04 0039 c014 1b CLRSCRN FCB $1B ; Clear the screen 0040 c015 5b FCB $5B 0041 c016 32 FCB $32 0042 c017 4a FCB $4A 0043 c018 04 FCB $04 0044 0045 * Constant strings that need memory allocated. 0046 c019 54 68 69 73 20 69 TEXT FCC `This is a sample line of text.` 73 20 61 20 73 61 6d 70 6c 65 20 6c 69 6e 65 20 6f 66 20 74 65 78 74 2e 0047 c037 04 FCB $04 0048 0049 *********************************************************************** 0050 * START Start of the program 0051 * Input: None 0052 * Output: A line of yellow text in the center of the screen 0053 *********************************************************************** 0054 c038 ce c0 14 [ 3 ] START LDX #CLRSCRN 0055 c03b bd c0 57 [ 6 ] JSR OUTTEXT ; Clear the screen 0056 c03e ce c0 03 [ 3 ] LDX #YELLOW 0057 c041 bd c0 57 [ 6 ] JSR OUTTEXT ; Make the cursor yellow 0058 c044 ce c0 0b [ 3 ] LDX #CURCNTR 0059 c047 bd c0 57 [ 6 ] JSR OUTTEXT ; Center the cursor 0060 c04a ce c0 19 [ 3 ] LDX #TEXT 0061 c04d bd c0 57 [ 6 ] JSR OUTTEXT ; Print the text 0062 c050 bd ff c4 [ 6 ] JSR OUTCRLF ; Skip a line 0063 c053 bd ff c4 [ 6 ] JSR OUTCRLF 0064 c056 3f [14 ] SWI ; End the program 0065 0066 *********************************************************************** 0067 * OUTTEXT Outputs a line of text to the terminal, terminated 0068 * with an EOT ($04) 0069 * Input: Starting location of text in Register X 0070 * Output: Text until $04 is reached 0071 *********************************************************************** 0072 c057 36 [ 3 ] OUTTEXT PSHA ; Save our registers (non-destructive) 0073 c058 3c [ 4 ] PSHX 0074 c059 a6 00 [ 4 ] OUTTXT1 LDAA 0,X ; Read a character into A 0075 c05b 81 04 [ 2 ] CMPA #$04 ; Is it the EOT character? (End-of-text) 0076 c05d 27 06 [ 3 ] BEQ OUTTXT2 ; If it is, end 0077 c05f bd ff af [ 6 ] JSR OUTPUT ; Output character 0078 c062 08 [ 3 ] INX 0079 c063 20 f4 [ 3 ] BRA OUTTXT1 ; loop 0080 c065 38 [ 5 ] OUTTXT2 PULX ; Restore our original registers 0081 c066 32 [ 4 ] PULA 0082 c067 39 [ 5 ] RTS ; Return to the calling address CLRSCRN c014 CURCNTR c00b OUTCRLF ffc4 OUTPUT ffaf OUTTEXT c057 OUTTXT1 c059 OUTTXT2 c065 START c038 TEXT c019 YELLOW c003