English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 11 October 2020, 05:37   #1
jordans1979
Registered User

 
Join Date: Feb 2019
Location: Adelaide / SA / Australia
Age: 41
Posts: 8
Disassembly of Amiga bootblocks on PC

Hey Guys,

I was wondering if you guys could help me, I was wondering if its possible to disassemble an Amiga bootblock using Visual Studio in VB or Python.

I have found a 'disassembly engine' called 'Capstone Engine' https://www.capstone-engine.org/ for this purpose but as I don't know assembler I am unable to ascertain if its outputting anything useful.

I have managed to code a Python script in order to do this:

from capstone import *
from capstone.m68k import *

import binascii

boot = open("c:\\temp\\boot.ABB", "rb") # Open bootblock

bootFile = boot.read(1024) # Read bootblock into bootFile

M68K_CODE = binascii.hexlify(bytearray(bootFile)) # Convert Binary array to Hexadecimal

md = Cs(CS_ARCH_M68K, CS_MODE_BIG_ENDIAN) # Create Cs object with architecture set to M68k and Big Endian
# print("Buffer Length:", len(bootFile))
address = 0x0000
md.detail = True
for insn in md.disasm(M68K_CODE, address): # dissassemble M68k code
print("0x%x:\t%s\t%s" % (insn.address, insn.mnemonic, insn.op_str)) # print each assembly instruction


I am still learning Python and I have no idea about assembler so please be gentle

I have attached a text file of output this code creates. I just need to know if this is useful or if its garbage.
Attached Files
File Type: txt output.txt (15.8 KB, 56 views)

Last edited by jordans1979; 11 October 2020 at 06:29. Reason: Edited: added output text file
jordans1979 is offline  
Old 11 October 2020, 09:15   #2
meynaf
son of 68k
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 47
Posts: 4,107
Sorry, the output isn't proper code. Looks like the input isn't binary.
meynaf is offline  
Old 11 October 2020, 09:37   #3
jordans1979
Registered User

 
Join Date: Feb 2019
Location: Adelaide / SA / Australia
Age: 41
Posts: 8
Hello Meynaf,

Oh ok - I didn't think it looked right.

Perhaps I am not using the capstone engine correctly.

Thanks.
jordans1979 is offline  
Old 11 October 2020, 11:05   #4
hmn
Registered User

 
Join Date: Nov 2016
Location: DE
Posts: 18
Are you sure you need to convert the binary to hex before disassembly?
Code:
Help on method disasm in capstone.Cs:

capstone.Cs.disasm = disasm(self, code, offset, count=0) unbound capstone.Cs method
    # Disassemble binary & return disassembled instructions in CsInsn objects
hmn is offline  
Old 11 October 2020, 11:20   #5
a/b
Registered User

 
Join Date: Jun 2016
Location: europe
Posts: 253
^^ This. You need binary data, not its hex dump.
Also:
Code:
boot.seek(12)
bootFile = boot.read(1024-12)
a/b is offline  
Old 11 October 2020, 15:58   #6
jordans1979
Registered User

 
Join Date: Feb 2019
Location: Adelaide / SA / Australia
Age: 41
Posts: 8
Hello Again,

Thankyou @a/b, this made the disassembler work now without having to convert the byte array to hex.

Presumably is this to set the pointer in the file past the 'DOS' word in the bootblock file?.

I have attached another file - please let me know if this looks like M68k assembly.

@hmn, I tried to use the code you provided but it could get past the 'unbound' part.
Attached Files
File Type: txt code.txt (5.5 KB, 51 views)
jordans1979 is offline  
Old 11 October 2020, 16:22   #7
a/b
Registered User

 
Join Date: Jun 2016
Location: europe
Posts: 253
Bootblock: +0 = id (typically 'DOS',version), +4 = checksum, +8 = root block (typically 880), +12 = code
Code looks OK, but it also contains some data between $3e and $4e so it's not 100% correct (disasm produced a few instructions of trash before getting back in sync, and lost one instruction in the process, clr.l d0 at $4e).
a/b is offline  
Old 11 October 2020, 16:36   #8
jotd
This cat is no more
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 49
Posts: 4,933
yeah, eternal issue with disassemblers... Note that you don't have to use python+capstone (very good solution, though) to disassemble a bootblock: just use IRA for windows

The advantage with IRA is that if there's a branch somewhere IRA knows that there's an instruction there. capstone doesn't, unless you perform an extra pass, storing the branch destinations and disassemble from there.
jotd is online now  
Old 12 October 2020, 07:58   #9
jordans1979
Registered User

 
Join Date: Feb 2019
Location: Adelaide / SA / Australia
Age: 41
Posts: 8
Hey jotd,

Thanks, looks like IRA is what I need its output easier than Capstone to understand and I don't need several passes to do the branches.

What I'm interested in doing is reading a bootblock into memory, Disassembling it and then matching certain lines in the assembly language with functions.

I have found several which appear to do the following:
bclr #1,$bfe001 = Enable filter
bset #1,$bfe001 = Disable Filter
bchg #1,$bfe001 = Switch Filter
move.w #$0000,COLOR00 = Specifies colour from palette register

Is there a standard list of functions to do things like 50/60hz switch and Drives off etc?

I have found several bootblocks in my search which don't appear to have any function but have a lot of data and would be nice to at least see what they are doing.

Any information would be appreciated.
jordans1979 is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
view edit bootblocks locksmith support.Apps 2 12 November 2016 23:08
complete disassembly of the Amiga 1.2 "exec" Vinvin support.WinUAE 3 13 January 2015 23:13
noob question regarding bootblocks Akira Coders. Asm / Hardware 13 27 March 2013 23:10
Amiga Bootblocks jasonver2.0 request.Apps 0 27 April 2010 16:13
How to make sense of disassembly? Jonathan Drain Coders. General 1 27 October 2009 23:57

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 13:28.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Page generated in 0.11191 seconds with 14 queries