-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTeamVisualBasic_Disassembler.X68
More file actions
206 lines (128 loc) · 8.25 KB
/
TeamVisualBasic_Disassembler.X68
File metadata and controls
206 lines (128 loc) · 8.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
*-----------------------------------------------------------
* Title : Team Visual Basic's Disassembler
* Written by : Henry Hong, Dylan Desmond, Austin Abeyta
* Date : ?
* Description: CSS422 Final Project
* Machine code to Motorola 68000 Assembly
* Main Driver File
*-----------------------------------------------------------
START ORG $1000 ;Start @ address $1000
JSR DISP_INTRO ;Display Intro Message
JSR INPUT_ADDR ;Take start and ending address as user input
JSR MAIN_LOOP ;Meat of the program: Check for validity, OPCODE match, and print to screen
BRA END ;If loop improperly terminated, base case BRA to END program
*-Intro Message---------------------------------------------
DISP_INTRO LEA M_INTRO,A1 ;Load intro msg
MOVE.B #14,D0 ;Trap Task 14 displays null terminated string
TRAP #15
RTS ;Return to main START section
*-Press Enter to Continue message---------------------------
DISP_WAIT LEA M_WAIT,A1 ;Load wait message
MOVE.B #14,D0 ;Trap Task 14 displays null terminated string
TRAP #15
MOVE.B #5,D0 ;Trap Task 5 takes in a single character input (aka press enter)
TRAP #15
MOVE.B #11,D0 ;Clear screen
MOVE.W #$FF00,D1
TRAP #15
RTS
*-Main Loop-------------------------------------------------
MAIN_LOOP JSR DISP_WAIT ;Display Press Enter to Continue msg
MOVE.B #24,D4 ;D4 loop var - print 26 lines per page
NEXT_OP JSR BUILD_STR ;Build and accumulate the 0xADDR OPCODE $OPERAND string into memory @ OP_ADDR
JSR PRINT_OP ;Print the built string to console
JSR LOOP_COND ;Check if address is still valid. END program if it isnt
SUBI #1,D4 ;Decrement counter
CMP.B #0,D4 ;Is counter == 0?
BEQ MAIN_LOOP ;Then print the next page
BRA NEXT_OP ;Otherwise, in the same page, print the next OP
*-Loop Condition Logic--------------------------------------
LOOP_COND ADD.L D6,A5 ;Increment current address (A5) by the length of the last instruction + operand data (D6)
MOVE.L A5,D0
MOVE.L A6,D1
CMP.L D0,D1 ;If current address (A5) is now equal to or greater than end address (A6), end
BLE DSMBL_DONE ;<---------- check conditional
RTS
*-Print OPCODE STRING---------------------------------------
PRINT_OP MOVE.W #OP_ADDR,A1 ;Move the OPCODE's beginning addr to A1
MOVE.B #14,D0 ;Trap Task 14 displays null terminated string
TRAP #15
MOVE.W #M_NEWLINE,A1 ;Print a new line after this OPCODE line is finished
MOVE.B #14,D0 ;Trap Task 14 displays null terminated string
TRAP #15
RTS
*-Print to user DONE message--------------------------------
DSMBL_DONE LEA M_DONE,A1 ;Print DONE message
MOVE.B #14,D0 ;Trap Task 14 displays null terminated string
TRAP #15
JSR PROMPT_NEW ;Ask user if they want to restart
*-Ask user if they want to start program again--------------
PROMPT_NEW LEA M_NPROMPT,A1 ;Ask user if they would like to run program again
MOVE.B #14,D0 ;Trap Task 14 displays null terminated string
TRAP #15
CLR.L D1 ;Clear D1
MOVE.B #5,D0 ;Read user input into D1
TRAP #15
CMP.B #'y',D1 ;Is input y
BEQ P_RESTART ;if so restart program
CMP.B #'Y',D1 ;Is input Y capital
BEQ P_RESTART ;if so restart program
CMP.B #'n',D1 ;Is input n
BEQ END ;if so restart program
CMP.B #'N',D1 ;Is input N capital
BEQ END ;if so restart program
LEA M_ERR_GEN,A1 ;Input is invalid! Prompt again
MOVE.B #14,D0 ;Trap Task 14 displays null terminated string
TRAP #15
BRA PROMPT_NEW ;Re prompt
P_RESTART JSR DISP_WAIT
CLR.L D0
CLR.L D1
CLR.L D2
CLR.L D3
CLR.L D4
CLR.L D5
CLR.L D6
CLR.L D7
BRA START
*-END-------------------------------------------------------
END MOVE.B #9,D0 ;End program
TRAP #15
*-Variables and constants-----------------------------------
CR EQU $0D
LF EQU $0A
BYTE EQU $2
WORD EQU $4
LONG EQU $8
START_ADDR DS.B 30 ;Machine code start address stored here
END_ADDR DS.B 30 ;Machine code end address stored here
OP_ADDR DS.B 30 ;Storage to accumulate OPCODE address, name, and data string at
*-Strings---------------------------------------------------
M_INTRO DC.B 'Team Visual Basic',CR,LF
DC.B 'Motorola 68000 Disassembler',CR,LF
DC.B 'By Austin Abeyta, Dylan Desmond, and Henry Hong',CR,LF,CR,LF,0
M_IN_RULES DC.B 'Please limit address input to numeric (0-9) and/or alphabet A-F',CR,LF
DC.B 'Please limit address input to a range of [00005000-FFFFFFFF]!',CR,LF
DC.B 'Input less than 8 digits will be padded on left',CR,LF
DC.B 'Input greater than 8 digits will be truncated on the right',CR,LF,CR,LF,0
M_INPUT_S DC.B 'Please Input the Starting Address (test code is ORG @ 7F00): ',CR,LF,0
M_INPUT_E DC.B 'Please Input the Ending Address: ',CR,LF,0
M_WAIT DC.B CR,LF,'Press Enter to Continue!',CR,LF,0
M_INV_INPUT DC.B 'Input address is invalid! Please re-enter: ',CR,LF,CR,LF,0
M_ERR_ADDR1 DC.B 'ERR: START address > END address',CR,LF,0
M_ERR_ADDR2 DC.B 'ERR: START address too low, danger of overwriting program logic',CR,LF,0
M_ERR_ADDR3 DC.B 'ERR: ODD START address',CR,LF,0
M_ERR_ADDR4 DC.B 'ERR: ODD END address',CR,LF,0
M_NPROMPT DC.B 'Would you like to run program again @ another address? (y/n)',CR,LF,0
M_ERR_GEN DC.B CR,LF,'Invalid input!',CR,LF,0
M_DONE DC.B 'Done!',CR,LF,0
M_NEWLINE DC.B '',CR,LF,0
*-Files-----------------------------------------------------
INCLUDE 'TeamVisualBasic_Disassembler_Input.X68' ;Include Input class file
INCLUDE 'TeamVisualBasic_Disassembler_OutputBuilder.X68' ;Include OutputBuilder class file
INCLUDE 'TeamVisualBasic_JumpTable.X68' ;Include Jump Table file
END START ;last line of source
*~Font name~Courier New~
*~Font size~12~
*~Tab type~1~
*~Tab size~4~