-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisassembler.X68
More file actions
145 lines (117 loc) · 5.39 KB
/
Disassembler.X68
File metadata and controls
145 lines (117 loc) · 5.39 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
******************************************************************************
* Title : 68k Disassembler
* Written by : Brandon Authier (Hblkr), Jack S. Eldridge
* (JackScottie), Marijn Burger (marijnburger)
* Date : 16 May 2016
* Description: An inverse assembler that will convert a memory
* image of instructions and data back to the display.
* The following will be decoded:
*
* Addressing Modes
*
* Data Register Direct
* Address Register Direct
* Address Register Indirect
* Immediate Data
* Address Register Indirect with Post Increment
* Address Register Indirect with Pre Decrement
* Absolute Long Address
* Absolute Word Address
*
* Instructions
*
* NOP
* MOVE
* MOVEA
* MOVEQ
* MOVEM
* ADD
* ADDA
* ADDI
* ADDQ
* SUB
* MULS
* DIVU
* LEA
* CLR
* AND
* OR
* LSL
* LSR
* ASR
* ASL
* ROL
* ROR
* CMP
* Bcc (BCC, BGT, BLE)
* JSR
* RTS
*
******************************************************************************
******************************************************************************
* DEFINITIONS *
******************************************************************************
STACK EQU $7000 * Beginning address for stack pointer
BEGINADDR EQU $5000 * Variable to hold beginning address value
ENDADDR EQU $5010 * Variable to hold ending address value
RUNAGAIN EQU $6000 * Run program again variable
RCOUNT EQU 30 * Row counter
START ORG $1000 * Program begins at address 1000
*********** END DEFINITIONS **************************************************
******************************************************************************
* BEGIN CODE *
******************************************************************************
*---------- START ------------------------------------------------------------
* Begins program's logical flow. Similar to main in C/C++
*-----------------------------------------------------------------------------
LEA STACK,SP * SP is stored in A7
JSR GET_ADDRESSES * Runs GET_ADDRESSES and IO_WELCOME
MOVEA.L BEGINADDR,A6 * Assign beginning address to A6 for use
* Set up I/O
LEA BUFFER, A2
JSR CLEAN_BUFF
MOVE.B #RCOUNT, D2 * Row counter
LOOP
LEA BUFFER, A2 * Create a pointer to BUFFER
JSR WRITE_BEGINL * Write address to BUFFER
JSR OC_PARSE * Determine if there is an initial opcode match
JSR WRITE_ENDL * Write an endline for A1 to BUFFER
JSR PRINTLN * Print the BUFFER to user
JSR CLEAN_BUFF * Clean the BUFFER for reuse
SUBI.B #1, D2 * Decrement row counter
CMPI.B #0, D2 * Is D2 = 0?
BNE LOOP_CHECK * If counter != 0, continue with normal loop check
JSR NEW_PAGE * Else (counter == 0), prompt for new page
MOVE.B #RCOUNT, D2 * Reset row counter
LOOP_CHECK
CMPA.L ENDADDR,A6 * Is pointer less than the end address?
BLT LOOP * If not, continue processing addresses
END_LOOP * Else, end loop
JSR RERUN * Does the user want to run program again
CMPI.B #1,(RUNAGAIN) * Does RUNAGAIN = TRUE?
BEQ START * If yes, rerun program
STOP #$3000 * Else, end program
*---------- END - START ------------------------------------------------------
*********** END BEGIN CODE ***************************************************
******************************************************************************
* INCLUDES *
******************************************************************************
INCLUDE 'IO.X68'
INCLUDE 'OpCodes.X68'
INCLUDE 'EA.X68'
INCLUDE 'IOMessages.X68'
INCLUDE 'OCMessages.X68'
INCLUDE 'EAMessages.X68'
*********** END INCLUDES *****************************************************
*---------- Reserved Registers -----------------------------
* A7: stack pointer
* A6: current address (updated by subroutines)
* D0: instruction validity flag (reset by main control
* code, can be set to false by subroutines)
*-----------------------------------------------------------
*---------- End --------------------------------------------
END START * Last line of source
*~Font name~Courier New~
*~Font size~10~
*~Tab type~1~
*~Tab size~4~