Skip to content

Commit 1d529d3

Browse files
committed
Remove whitespace
1 parent 4dc47b6 commit 1d529d3

File tree

1 file changed

+67
-67
lines changed

1 file changed

+67
-67
lines changed

src/io_NataliaGilbertson.x68

+67-67
Original file line numberDiff line numberDiff line change
@@ -16,54 +16,54 @@ PageOfOutput EQU 20 * how many lines of disassembled code is printin
1616
START: * first instruction of program
1717
******************** Start*****************************************************
1818
LEA Stack,SP * load stack pointer value (A7 is stack pointer)
19-
19+
2020
LEA Welcome,A1 * print welcome message
2121
MOVE.B #14,D0
2222
TRAP #15
23-
23+
2424
restart LEA PromptStartAddr,A1 * load prompt to print, asking user for starting address
2525
MOVE.B #14,D0 * print string at A1 to console
2626
TRAP #15
27-
27+
2828
LEA StoreInputStartAddr,A1 * load address to store user input
2929
MOVE.B #2,D0 * read string from keyboard into (A1)
3030
TRAP #15 * length of string is stored at D1
3131
MOVE.B D1,D7 * store starting address length at D7 for now
32-
32+
3333
JSR ValidAddressChars * check if starting address is valid
34-
34+
3535
LEA StoreInputStartAddr,A4 * now convert input into hex address
3636
JSR TranslateInputToAddrReg
37-
38-
MOVE.L A6,D6 * move the returned address into a data register to perform a bit test
37+
38+
MOVE.L A6,D6 * move the returned address into a data register to perform a bit test
3939
BTST.L #0,D6 * check that the address is on a word boundary
4040
BNE ThrowInputError
4141
MOVEA.L A6,A0 * put the starting address (returned into A6) into A0
42-
42+
4343
LEA PromptEndAdder,A1 * load prompt to print, asking user for ending address
4444
MOVE.B #14,D0 * print string at A1 to console
4545
TRAP #15
46-
47-
LEA StoreInputEndAddr,A1
46+
47+
LEA StoreInputEndAddr,A1
4848
MOVE.B #2,D0 * read string from keyboard into (A1)
4949
TRAP #15 * length of string input is stored at D1
50-
50+
5151
JSR ValidAddressChars * check if ending address is valid
52-
52+
5353
LEA StoreInputEndAddr,A4 * now convert input into hex address
5454
JSR TranslateInputToAddrReg
55-
55+
5656
MOVE.L A6,D6 * move the returned address into a data register to perform a bit test
5757
BTST.L #0,D6 * check that the address is on a word boundary
58-
BNE ThrowInputError
58+
BNE ThrowInputError
5959
MOVEA.L A6,A3 * put the ending address at A3
60-
60+
6161
* pointer to next opcode is in A0
6262
* ending address is at A3
63-
63+
6464
CMPA.L A3,A0 * check that startAddress <= endAddress
6565
BGT endProg * exit program if start > end
66-
66+
6767
* clear some registers
6868
CLR.L D0
6969
CLR.L D4
@@ -73,55 +73,55 @@ restart LEA PromptStartAddr,A1 * load prompt to print, asking u
7373
MOVE.L #0,A4
7474
MOVE.L #0,A5
7575
MOVE.L #0,A6
76-
76+
7777
LEA PromptToPressENTER,A1 * prompt user to press ENTER for next page of data
7878
MOVE.B #14,D0
7979
TRAP #15
8080

81-
**************************************** printing out disassembled code ********************************************
81+
**************************************** printing out disassembled code ********************************************
8282
waitForENTER LEA OutputBuffer,A1
8383
MOVE.L #0,D2 * reset linesOutputted to 0
8484
MOVE.B #2,D0 * trap task for reading input
8585
TRAP #15 * read input, expecting ENTER from user to proceed disassembling
86-
86+
8787
loopPrintLines CMP.L A3,A0 * while pointerToNextOpcode <= ending address
8888
BGT endProg
89-
89+
9090
CMP.L #PageOfOutput,D2 * stop printing when linesOutputted == linesInAPage
9191
BEQ waitForENTER * go back to waiting for ENTER from user
9292
ADD.B #1,D2 * increment linesOutputted
93-
93+
9494
* prepare to call opcodes
95-
LEA OutputBuffer,A2 * set output buffer to A2
95+
LEA OutputBuffer,A2 * set output buffer to A2
9696
MOVEA.L A0,A6 * track current pointerToNextOpcode in case bad flag is set
9797

9898
JSR AddCurrAddressToBuffer * put current address into the output buffer
99-
99+
100100
MOVEM.L D1-D7/A1/A3-A6,-(SP) * save all registers except A0 (pointerToNextOpcode),
101101
* A2 (output buffer pointer),
102102
* D0 (bad flag)
103103
MOVE.B #0,D0 * clear bad flag
104-
104+
105105
JSR OP_START * call opcodes
106-
106+
107107
MOVEM.L (SP)+,D1-D7/A1/A3-A6 * restore all registers except A0,A2,D0
108-
108+
109109
CMP.B #0,D0 * bad flag set?
110110
BEQ noFlagSet
111111
JSR HandleBadFlag * handle bag flag if it was set
112-
112+
113113
noFlagSet MOVE.B #0,(A2)+ * null terminate the string stored at (A2)
114-
114+
115115
JSR OutputTheBuffer
116-
117-
BRA loopPrintLines * go back to process and print another line
118-
116+
117+
BRA loopPrintLines * go back to process and print another line
118+
119119
*******************************************************************************
120-
******************** FIN ******************************************************
120+
******************** FIN ******************************************************
121121
endProg LEA EOF,A1 * print end of file message
122122
MOVE.B #14,D0
123123
TRAP #15
124-
124+
125125
STOP #3000 * end program
126126

127127
*******************************************************************************
@@ -130,7 +130,7 @@ ThrowInputError LEA InvalidInputError,A1 * load address that holds error st
130130
MOVE.B #0,D0 * print the string
131131
MOVE.B #155,D1
132132
TRAP #15
133-
133+
134134
CLR.L D0
135135
CLR.L D1
136136
CLR.L D2
@@ -141,25 +141,25 @@ ThrowInputError LEA InvalidInputError,A1 * load address that holds error st
141141
MOVE.L #0,A4
142142
MOVE.L #0,A5
143143
MOVE.L #0,A6
144-
144+
145145
MOVE.B #CR,(A1)+
146146
MOVE.B #LF,(A1)+
147147
MOVE.B #0,D0 * print the string
148148
MOVE.B #0,D1
149149
TRAP #15
150-
151-
BRA restart
150+
151+
BRA restart
152152

153153
*******************************************************************************
154154
******************** Method ***************************************************
155155

156156
* load the string you want to check for validity into A1 before calling the method
157157
* load the length of the string into D1
158-
ValidAddressChars CMP.B #1,D1 * must have b/t 1 and 8 characters in address
158+
ValidAddressChars CMP.B #1,D1 * must have b/t 1 and 8 characters in address
159159
BLT ThrowInputError * error if less than 1
160-
CMP.B #8,D1
160+
CMP.B #8,D1
161161
BGT ThrowInputError * error if greater than 8
162-
162+
163163
VACloop CMP.B D1,D3 * D3 is loop counter
164164
BEQ endMethodVAC
165165
MOVE.B (A1)+,D2 * D2 holds current byte to check
@@ -171,9 +171,9 @@ VACloop CMP.B D1,D3 * D3 is loop counter
171171
BEQ ThrowInputError
172172
ADDQ #1,D3 * increment counter
173173
BRA VACloop
174-
174+
175175
endMethodVAC MOVE.L #0,D3 * clear out counter data reg
176-
RTS
176+
RTS
177177

178178

179179
* translate the address into register A0
@@ -183,27 +183,27 @@ TranslateInputToAddrReg CLR.L D7
183183
MOVEA.L A4,A5 * remember the start address
184184
MOVE.B D1,D4 * remember the char count
185185
TITARloop1 CMP.B D1,D3 * while loop counter < address length in chars
186-
BEQ endTITARloop1
186+
BEQ endTITARloop1
187187
CMP.B #$40,(A4) * greater than $40? translate A-F
188-
BGT handleAThroughF
188+
BGT handleAThroughF
189189
SUB.B #$30,(A4) * subtract $30 from the 0-9 char in ASCII
190190
BRA digitBt0And9 * handle characters between 0 and 9
191191
handleAThroughF SUB.B #$37,(A4) * subtract $37 from the A-F char in ASCII
192192
digitBt0And9 ADD.B (A4),D7 * add the translated byte into D7
193193
ADDA.L #1,A4 * increment A4
194194
SUB.B #1,D1 * decrement counter
195195
CMP.B D1,D3 * do not shift when we reach the last char in the address
196-
BEQ doNotShiftThisTime
196+
BEQ doNotShiftThisTime
197197
LSL.L #$04,D7 * shift the translated part of the address four bits to the left
198198
doNotShiftThisTime BRA TITARloop1 * shifting allows adding the next nibble of the translated address to D7
199-
199+
200200
endTITARloop1 CMP.B #4,D4
201201
BGT moveLongAddress * if the address is >4 hex chars long move it into an address reg as a long
202202
MOVEA.W D7,A6 * if the address is <=4 hex chars move it as a word (supports sign extension)
203-
BRA endMethodTITAR
203+
BRA endMethodTITAR
204204
moveLongAddress MOVEA.L D7,A6 * move the translated address into an address register
205205
endMethodTITAR RTS
206-
206+
207207
* each disassembled line needs the address of the instruction in memory
208208
* printed on the left side, this method loads the address into the output buffer
209209
* current address is stored at A0
@@ -216,31 +216,31 @@ loopACATB CMP.B #8,D3 * while not all 8 char
216216
MOVE.B D4,D5 * move the first byte of D4 into D5
217217
AND #%00001111,D5 * bit mask the second nibble out of the byte
218218
MOVEA D5,A5 * move the nibble in question into A5
219-
MOVE.B (NumbersToASCII,A5),(A2)+ * displace the nibble value into the string hashtable and put
219+
MOVE.B (NumbersToASCII,A5),(A2)+ * displace the nibble value into the string hashtable and put
220220
BRA loopACATB * the hash result into the output buffer
221221
* do this for all characters in the address
222-
222+
223223
*Tab, put a full tab into the output buffer for output formatting
224224
endMethodACATB MOVE.B #$20,(A2)+
225225
MOVE.B #$20,(A2)+
226226
MOVE.B #$20,(A2)+
227227
MOVE.B #$20,(A2)+
228228
RTS
229-
229+
230230
* handles problems encountered by opcodes and effective addressing for the output buffer
231-
* the bad flag is stored at D0
231+
* the bad flag is stored at D0
232232
HandleBadFlag LEA OutputBuffer,A2 * reset the output buffer to overwrite any bad data
233233
ADDA #12,A2 * don't overwrite the address location which is already in there
234234

235235
* reset the flag
236236
MOVE.B #0,D0
237-
237+
238238
* put 'DATA' into the output buffer
239239
MOVE.B #$44,(A2)+
240240
MOVE.B #$41,(A2)+
241241
MOVE.B #$54,(A2)+
242242
MOVE.B #$41,(A2)+
243-
243+
244244
* put space formatting into the output buffer
245245
MOVE.B #$20,(A2)+
246246
MOVE.B #$20,(A2)+
@@ -249,15 +249,15 @@ HandleBadFlag LEA OutputBuffer,A2 * reset the output buf
249249
MOVE.B #$20,(A2)+
250250
MOVE.B #$20,(A2)+
251251
MOVE.B #$20,(A2)+
252-
252+
253253
* add the $ to the buffer to show the hex value
254254
MOVE.B #$24,(A2)+
255-
255+
256256
* get the instruction word that could not be disassembled
257257
MOVE.W (A6),D1 * A6 stores the saved pointerToNextOpcode before opcodes was called
258258
LSL.L #$08,D1 * shift the value left a word
259259
LSL.L #$08,D1
260-
260+
261261
* put the bad instruction word into the output buffer
262262
MOVE.B #0,D3 * reset loop counter
263263
loopHBF CMP.B #4,D3 * loop for each hex character in the word
@@ -269,36 +269,36 @@ loopHBF CMP.B #4,D3 * loop for each hex ch
269269
MOVEA D4,A5 * move the single hex char into A5
270270
MOVE.B (NumbersToASCII,A5),(A2)+ * displace the hex value into the string hashtable and load the result
271271
BRA loopHBF * into the output buffer
272-
272+
273273
endMethodHBF RTS
274-
275-
* print a disassembled instructions to the user
274+
275+
* print a disassembled instructions to the user
276276
OutputTheBuffer MOVE.B #0,D0 * load trap task for printing a string at A1
277277
LEA OutputBuffer,A1 * load output buffer into A1
278278
MOVEA.L A2,A5 * get the current pointer spot in the output buffer
279279
SUBA OutputBuffer,A5 * subtract the address of the beginning of the output buffer
280280
* from the address of the current pointer in the output buffer
281281
MOVE.W A5,D1 * this results in the number of characters in the buffer to print out
282282
TRAP #15 * which is stored in D1, telling TRAP how much to print
283-
283+
284284
RTS
285285

286286

287-
287+
288288
*******************************************************************************
289289
******************** variables and constants **********************************
290-
* string hashtable
290+
* string hashtable
291291
NumbersToASCII DC.B $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$41,$42,$43,$44,$45,$46
292292
* prompts to user
293-
PromptStartAddr DC.B 'Enter starting address of file, then press ENTER: ',0
293+
PromptStartAddr DC.B 'Enter starting address of file, then press ENTER: ',0
294294
PromptEndAdder DC.B 'Enter ending address of file, then press ENTER: ',0
295295
PromptToPressENTER DC.B 'Press ENTER to get the next page of disassembled code.',0
296296
Welcome DC.B 'Welcome to our disassembler!',CR,LF,'Created by Sexy8k: [Natalia Gilbertson][Thomas Kercheval][Saam Amiri]',CR,LF,'Please load your file into memory.',CR,LF,CR,LF,0
297297
EOF DC.B '~ End of file ~',0
298298
* error message
299-
InvalidInputError DC.B 'ERROR: Invalid input address. Addresses must be between 1 and 8 characters long, ',CR,LF,'at a word boundary, and containing only digits 0-9 and characters A-F.',0
299+
InvalidInputError DC.B 'ERROR: Invalid input address. Addresses must be between 1 and 8 characters long, ',CR,LF,'at a word boundary, and containing only digits 0-9 and characters A-F.',0
300300

301-
StoreInputStartAddr DC.L 0 * each address needs 8 bytes to be read into memory
301+
StoreInputStartAddr DC.L 0 * each address needs 8 bytes to be read into memory
302302
StoreInputStartAddr2 DC.L 0 * so more space is built in
303303
StoreInputEndAddr DC.L 0
304304
StoreInputEndAddr2 DC.L 0

0 commit comments

Comments
 (0)