mirror of
https://github.com/jefftranter/udis.git
synced 2025-08-08 02:25:09 +00:00
Look for pluging in same directory as executable.
This commit is contained in:
16
udis.py
16
udis.py
@@ -15,6 +15,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import fileinput
|
import fileinput
|
||||||
import argparse
|
import argparse
|
||||||
@@ -51,7 +52,9 @@ parser.add_argument("-i", "--invalid", help="Show invalid opcodes as ??? rather
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Load CPU plugin based on command line option.
|
# Load CPU plugin based on command line option.
|
||||||
plugin = args.cpu + ".py"
|
# Looks for plugin in same directory as this program.
|
||||||
|
dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
plugin = dir + os.sep + args.cpu + ".py"
|
||||||
try:
|
try:
|
||||||
exec(open(plugin).read())
|
exec(open(plugin).read())
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
@@ -110,6 +113,8 @@ while True:
|
|||||||
# Handle if opcode is a leadin byte
|
# Handle if opcode is a leadin byte
|
||||||
if opcode in leadInBytes:
|
if opcode in leadInBytes:
|
||||||
b = f.read(1) # Get next byte of extended opcode
|
b = f.read(1) # Get next byte of extended opcode
|
||||||
|
if len(b) == 0: # Unexpected EOF
|
||||||
|
break;
|
||||||
opcode = (opcode << 8) + ord(b)
|
opcode = (opcode << 8) + ord(b)
|
||||||
leadin = True
|
leadin = True
|
||||||
else:
|
else:
|
||||||
@@ -152,14 +157,19 @@ while True:
|
|||||||
# Get any operands and store in an array
|
# Get any operands and store in an array
|
||||||
for i in range(1, maxLength):
|
for i in range(1, maxLength):
|
||||||
if (i < length):
|
if (i < length):
|
||||||
# TODO: Could get EOF here
|
b = f.read(1)
|
||||||
op[i] = ord(f.read(1)) # Get operand bytes
|
if len(b) == 0: # Unexpected EOF
|
||||||
|
break;
|
||||||
|
op[i] = ord(b) # Get operand bytes
|
||||||
if args.nolist is False:
|
if args.nolist is False:
|
||||||
line += " {0:02X}".format(op[i])
|
line += " {0:02X}".format(op[i])
|
||||||
else:
|
else:
|
||||||
if args.nolist is False and leadin is False and i != length-1:
|
if args.nolist is False and leadin is False and i != length-1:
|
||||||
line += " "
|
line += " "
|
||||||
|
|
||||||
|
if len(b) == 0: # Unexpected EOF
|
||||||
|
break;
|
||||||
|
|
||||||
# Handle relative addresses. Indicated by the flag pcr being set.
|
# Handle relative addresses. Indicated by the flag pcr being set.
|
||||||
# Assumes the operand that needs to be PC relative is the last one.
|
# Assumes the operand that needs to be PC relative is the last one.
|
||||||
# Note: Needs changes if more flags are added.
|
# Note: Needs changes if more flags are added.
|
||||||
|
Reference in New Issue
Block a user