I've been recently messing around with disassembling some printer firmware. I've added rudimentary support for the M50734 processor into Mike's m740dasm. I don't know if I've got it fully right yet, but it seems to work.
I've been playing with ChatGPT AI, and I've had some luck giving it straight machine code, and having chatgpt disassemble it. It kinda works but requires a lot of prompting. I'm feeding it a datasheet on the processor, and a Melps 740 instruction set manual. Nothing easily digestible yet, but I think there's a real possibility of getting that to work.
What I also did was take a code snippet from m740dasm, and tell chatgpt to analyze it for me, and describe what's happening.
Here's what I asked:
Can you describe in English what's happening in this block of code?
Code:
nop ;8130 ea
clc ;8131 18
cld ;8132 d8
cli ;8133 58
clt ;8134 12
ldx #0xff ;8135 a2 ff
txs ;8137 9a
ldm #0xff,WDT ;8138 3c ff fc
ldx #0x00 ;813b a2 00
lda #0x00 ;813d a9 00
Its response was:
Code:
The block of code in question is performing initial setup and configuration for the program. Here's an expanded description of what it does as a whole:
Processor and Flag Initialization:
The nop, clc, cld, cli, and clt instructions are used to initialize the processor. They ensure that no operations are pending (nop), the carry flag is cleared (clc), decimal mode is turned off (cld), interrupts are enabled (cli), and the index X mode flag is cleared (clt). This sets up a known, clean state for the processor, ensuring that subsequent operations aren't affected by any previous state or settings.
Stack Pointer Setup:
The instructions ldx #0xff and txs set up the stack pointer. ldx #0xff loads the X register with the value 0xFF, and txs transfers this value to the stack pointer. This effectively initializes the stack pointer to a specific location in memory, determined by the value 0xFF.
Watchdog Timer Configuration:
The instruction ldm #0xff,WDT loads the immediate value 0xFF into the Watchdog Timer (WDT). This is a configuration step for the WDT, which is typically used to recover from malfunctions like software lock-ups or infinite loops. Setting the WDT can be crucial for ensuring the system's reliability and preventing it from hanging indefinitely.
Register Initialization:
The final instructions ldx #0x00 and lda #0x00 reset the X register and the accumulator to 0. This is a common practice in assembly programming to initialize registers to a known value at the start of a program.
Overall, this code snippet is focused on initializing and configuring the processor, its registers, and some of its features (like the Watchdog Timer) to a known state. This kind of initialization is typically done at the start of a program to ensure that the program runs in a controlled and predictable environment
While ChatGPT is often confidently incorrect about something, or some details are wrong -- it overall gets the gist of the code. You have the ability, after the fact, to ask clarifying questions about the results, give it more input data to reconsider questions you ask, and so on.
This seems REALLY powerful to me, and I'm using the tool for a bunch of different computing tasks. Fwiw, it wrote some configuration lines to feed into m740dasm. I could have done it manually, it spit them out instantly..... saving me time and trouble.