6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Apr 27, 2024 5:58 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sat Feb 10, 2024 5:29 am 
Offline

Joined: Fri Jan 26, 2024 9:47 pm
Posts: 5
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.


Top
 Profile  
Reply with quote  
PostPosted: Sat Feb 10, 2024 7:37 am 
Offline

Joined: Thu Jan 21, 2016 7:33 pm
Posts: 269
Location: Placerville, CA
Generally speaking, when I have to review somebody or something's work to ensure that they have the slightest idea what they're talking about...

...I find I could've just done it myself from the get-go.


Top
 Profile  
Reply with quote  
PostPosted: Sat Feb 10, 2024 10:30 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
It does feel to me that the best case is where the chatbot outputs something which you can check and correct. If it outputs code, you can run it. But if it outputs comments, I'm not sure how you could be sure without proofreading and careful thought. You might save a bit of typing.


Top
 Profile  
Reply with quote  
PostPosted: Sat Feb 10, 2024 7:28 pm 
Offline
User avatar

Joined: Fri Jan 26, 2024 5:47 am
Posts: 37
Location: Prague; Czech Republic; Europe; Earth
I am using chatGPT for lot of things, but I did not yet get helpfull and fully correct answer on technical matter. It alway was more or less off in some aspects.
I use it anyway, as usually the answers are not totally off and lot of the letteres can be reuse, while some have to be thrown out and replaced. It sometimes may write lot of tediuos stuff and prepare ground for me to put straight and correct. But sometimes I have to throw out nearly everything it generates and write it myself. It still may be helpfull, if taken with a lot of caution.

_________________
http://micro-corner.gilhad.cz/, http://8bit.gilhad.cz/6809/Expanduino/Expanduino_I.html, http://comp24.gilhad.cz/Comp24-specification.html, and many others


Top
 Profile  
Reply with quote  
PostPosted: Sun Feb 11, 2024 1:21 am 
Offline

Joined: Fri Jan 26, 2024 9:47 pm
Posts: 5
Thanks everyone for their perspectives.

I've been using it a fair bit of in the following areas and it's been working well:

    Technical writing: When I have a few core ideas that need expanded on, supported, or clarified it does a fairly good job. In some ways, it's more tactful than me. I can tell it to emphasize some points, and place less on other things. Just like a human reviewer, I keep some of what it suggests, and throw out the rest.
    Python code writing: It usually does a pretty good job. I've used it with Pandas, OpenCV, PyMuPDF, and other libraries. It actually runs the code it creates before it sends it to you, and can detect/autocorrect mistakes it makes. Some of the solutions don't work, and like a human developer, you have iterate with it to get it perfect.
    Linux shell scripts: I'm constantly in need of mini utility scripts to process x, y, and z. It's very good at writing these, knows about popular non-default-utilities to address the problem etc.

Chatgpt 4 is better than 3.5. Much of what it produces I could have done myself with more time, research, trial and error. However, this allows me to iterate through a solution much faster. Instead of reading stack overflow, gobs or disorganized API documentation, people's half-answered blog posts --- it essentially does it for me.

One other point: you should be giving it acceptance criteria. For instance, it will accept excel spreadsheets, pdfs, or other .csv files etc. You can say "Your solution should be able to take column A as input, and come up with what's seen in column B." It will test its solution for you, and then iterate independently.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: bencoder and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: