I have started this new blog specifically relating to software that I will be trying to write with AI. So this blog will be documenting progress of what AI is capable of, or not. Overall it's a journey and just a bit of fun and experimentation. Will everything be perfect? likely not, but this is a journey rather than getting to a highly polished program right from the start. It could open the doors to more people doing software for our beloved machines.
My first AI test was already mentioned in my main blog
viewtopic.php?p=125691#p1256
I will get more and more complex routines done to see at what point it goes wrong. AI isn't going to write full blown programs. But being able to write even simple routines is a monumental step forward for me and likely others.
Exxos software blog
-
exxos
- Site Admin

- Posts: 28370
- Joined: 16 Aug 2017 23:19
- Location: UK
-
exxos
- Site Admin

- Posts: 28370
- Joined: 16 Aug 2017 23:19
- Location: UK
Re: Exxos software blog
My first AI program seems to work, but there's one bit which seems "wrong". Unless I am simply being stupid...
But copy 256K block, I need to set the total_bytes 2 bytes higher for it to work, but why ?
I assume the loop quits on the last address, rather than copying it ?
EDIT:
It seems the code only copies the first 4 bytes then nothing :roll:
But copy 256K block, I need to set the total_bytes 2 bytes higher for it to work, but why ?
I assume the loop quits on the last address, rather than copying it ?
Code: Select all
;Atari ST Assembly Program (Devpac compatible)
;Copies 256KB of TOS 2.06 from $E00000 to $4F00000 (79MB mark)
;Verifies copy using word accesses,reports failing address and data,waits for keypress
OPT W+ ;Enable warnings for debugging
SECTION TEXT
start:
;Print start message
lea start_msg(pc),a0
bsr print_string
;Initialize copy parameters
move.l #$E00000,source_addr ;TOS 2.06 start
move.l #$4F00000,dest_addr ;79MB mark
move.l #$40002,total_bytes ;256KB
;Comment out screen clear to avoid console issues
;move.w #2,-(sp) ;Console output
;move.w #$1B,d0 ;ESC code
;move.w #5,-(sp) ;Cconout
;trap #1
;addq.l #2,sp
;move.w #'E',d0 ;Clear screen
;move.w #5,-(sp)
;trap #1
;addq.l #2,sp
;Copy 256KB (word accesses)
move.l source_addr,a0
move.l dest_addr,a1
move.l total_bytes,d0
lsr.l #1,d0 ;Convert to words
subq.l #1,d0
copy_loop:
move.w (a0)+,(a1)+ ;Copy word
dbra d0,copy_loop
;Print copy complete
lea copy_done_msg(pc),a0
bsr print_string
;Verify copy (word accesses)
move.l #$E00000,a0 ;Source (TOS 2.06)
move.l #$4F00000,a1 ;Destination (79MB)
move.l total_bytes,d0
lsr.l #1,d0 ;Convert to words
subq.l #1,d0
verify_loop:
move.w (a0)+,d1 ;Source data
move.w (a1)+,d2 ;Destination data
cmp.w d1,d2
bne verify_fail
dbra d0,verify_loop
;Verification passed
lea verify_ok_msg(pc),a0
bsr print_string
bra.s wait_key
verify_fail:
;Report failing address and data
lea verify_fail_msg(pc),a0
bsr print_string
;Calculate failing address (destination base + offset)
move.l #$4F00000,a2 ;Destination base
move.l total_bytes,d3
lsr.l #1,d3 ;Total words
sub.l d0,d3 ;Words processed
subq.l #1,d3 ;Adjust for current
lsl.l #1,d3 ;Convert to bytes
add.l d3,a2 ;Failing address
;Print address
lea addr_msg(pc),a0
bsr print_string
move.l a2,d0
bsr print_hex_long
lea newline(pc),a0
bsr print_string
;Print source data
lea src_msg(pc),a0
bsr print_string
move.w d1,d0
bsr print_hex_word ;Print 16-bit data
lea newline(pc),a0
bsr print_string
;Print destination data
lea dst_msg(pc),a0
bsr print_string
move.w d2,d0
bsr print_hex_word ;Print 16-bit data
lea newline(pc),a0
bsr print_string
wait_key:
;Wait for keypress
lea keypress_msg(pc),a0
bsr print_string
move.w #1,-(sp) ;Cconin
trap #1
addq.l #2,sp
;Exit program
clr.w -(sp) ;Pterm0
trap #1
;Subroutine to print string
print_string:
move.l a0,-(sp) ;Push string address
move.w #9,-(sp) ;Cconws
trap #1
addq.l #6,sp
rts
;Subroutine to print longword as hex (8 digits)
print_hex_long:
move.l d0,-(sp) ;Save d0
lea hex_buffer(pc),a0
move.l d0,d1
moveq #7,d2 ;8 digits
hex_long_loop:
rol.l #4,d1 ;Get next nibble
move.b d1,d0
and.b #$0F,d0
cmp.b #10,d0
blt.s digit_long
add.b #'A'-10,d0
bra.s store_long
digit_long:
add.b #'0',d0
store_long:
move.b d0,(a0)+ ;Store in buffer
dbra d2,hex_long_loop
move.b #0,(a0) ;Null terminate
lea hex_buffer(pc),a0
bsr print_string
move.l (sp)+,d0 ;Restore d0
rts
;Subroutine to print word as hex (4 digits)
print_hex_word:
move.l d0,-(sp) ;Save d0
lea hex_buffer(pc),a0
move.w d0,d1
moveq #3,d2 ;4 digits
hex_word_loop:
rol.w #4,d1 ;Get next nibble
move.b d1,d0
and.b #$0F,d0
cmp.b #10,d0
blt.s digit_word
add.b #'A'-10,d0
bra.s store_word
digit_word:
add.b #'0',d0
store_word:
move.b d0,(a0)+ ;Store in buffer
dbra d2,hex_word_loop
move.b #0,(a0) ;Null terminate
lea hex_buffer(pc),a0
bsr print_string
move.l (sp)+,d0 ;Restore d0
rts
SECTION DATA
start_msg: dc.b "Copying TOS 2.06 to 79MB mark...",13,10,0
copy_done_msg: dc.b "Copy complete!",13,10,0
verify_ok_msg: dc.b "Verification passed!",13,10,0
verify_fail_msg: dc.b "Verification failed!",13,10,0
addr_msg: dc.b "Failing address: $",0
src_msg: dc.b "Source data: $",0
dst_msg: dc.b "Destination data: $",0
keypress_msg: dc.b "Press any key to exit...",13,10,0
newline: dc.b 13,10,0
hex_buffer: ds.b 9 ;8 digits + null
SECTION BSS
source_addr: ds.l 1
dest_addr: ds.l 1
total_bytes: ds.l 1
ENDEDIT:
It seems the code only copies the first 4 bytes then nothing :roll:
-
exxos
- Site Admin

- Posts: 28370
- Joined: 16 Aug 2017 23:19
- Location: UK
Re: Exxos software blog
All AI say it's correct BUT the dedicated 68k bot says..
I will try the fixed code tomorrow....DBRA only supports a range of -1 to 32767 in Dn (16-bit counter, signed). You're loading a value of 131072, which overflows the 16-bit word register part of d0, so DBRA effectively does just 1 iteration or zero.
-
chronicthehedgehog
- Site sponsor

- Posts: 383
- Joined: 08 May 2022 18:11
- Location: The Midlands
Re: Exxos software blog
I think...
dbra only uses a 16 bit counter and terminates at -1 (not zero)
so $40002 divided by 2 is $2 0001.
only the lower 2 bytes are used by the counter, so it will count down 1, 0 and then terminate at -1
I think if you just set d0 to $ffff, not do the right shift, that should work
dbra only uses a 16 bit counter and terminates at -1 (not zero)
so $40002 divided by 2 is $2 0001.
only the lower 2 bytes are used by the counter, so it will count down 1, 0 and then terminate at -1
I think if you just set d0 to $ffff, not do the right shift, that should work
-
exxos
- Site Admin

- Posts: 28370
- Joined: 16 Aug 2017 23:19
- Location: UK
Re: Exxos software blog
Yeh it's basically what the AI said. I'm only getting the first couple of addresses copied over.
Silly me only checked the first addresses were copied over. Then spent a couple hours thinking my firmware wasn't working :roll: I used a STOS program to clear few destination addresses. Then ran the program. Then output the first few adresss in STOS and I think the first 4 bytes were copied. The rest was still zeros.
Should be able to try the fixes when I get home this afternoon.
it's odd that Grok,GPT4,copiolet, didn't pick up on the problem.. BUT GPT 68K plugin did... It's odd as grok tries a lot harder to write code. I'll have to get the 68K plugin to write the same program. See if it works "out of the box". If it does, I'll have to go back to GPT stuff..
Grok and copilot don't seem to understand inversions in logic. Like it assumes reset signals are high, and when you tell them otherwise they rewrite code but it doesn't work and does weird things. When all it needed was ~RESET kinda thing. So it's like it can't understand different logic conditions. I've not gone into depth with it.. BUT I can tell GPT4 to invert the logic and it understands and does it.
But again, unless things have improved recently... GPT failed miserably at writing 68k code. The 68K plugin last time I tried it was no better. I couldn't even get a simple "hello word" working. It's why I moved to grok.
Silly me only checked the first addresses were copied over. Then spent a couple hours thinking my firmware wasn't working :roll: I used a STOS program to clear few destination addresses. Then ran the program. Then output the first few adresss in STOS and I think the first 4 bytes were copied. The rest was still zeros.
Should be able to try the fixes when I get home this afternoon.
it's odd that Grok,GPT4,copiolet, didn't pick up on the problem.. BUT GPT 68K plugin did... It's odd as grok tries a lot harder to write code. I'll have to get the 68K plugin to write the same program. See if it works "out of the box". If it does, I'll have to go back to GPT stuff..
Grok and copilot don't seem to understand inversions in logic. Like it assumes reset signals are high, and when you tell them otherwise they rewrite code but it doesn't work and does weird things. When all it needed was ~RESET kinda thing. So it's like it can't understand different logic conditions. I've not gone into depth with it.. BUT I can tell GPT4 to invert the logic and it understands and does it.
But again, unless things have improved recently... GPT failed miserably at writing 68k code. The 68K plugin last time I tried it was no better. I couldn't even get a simple "hello word" working. It's why I moved to grok.
-
exxos
- Site Admin

- Posts: 28370
- Joined: 16 Aug 2017 23:19
- Location: UK
Re: Exxos software blog
So the code GPT 68K wrote, loaded, but locked up with a couple letters garbage on the screen.
I told Grok of the errors GTP said and its wrote new code. Now it seems to work!
Though oddly if I run the program a second time, verify fails...hmmm...
EDIT:
Explained the problem and Grok did new code which seems to work now.. Will do more testing :)
I told Grok of the errors GTP said and its wrote new code. Now it seems to work!
Though oddly if I run the program a second time, verify fails...hmmm...
EDIT:
Explained the problem and Grok did new code which seems to work now.. Will do more testing :)
-
exxos
- Site Admin

- Posts: 28370
- Joined: 16 Aug 2017 23:19
- Location: UK
Re: Exxos software blog
So the plot thickens :roll:
If I turn off the cache, the program now works, but with the cache turned on, it seems to overshoot the end address that its supposed to be copying and verify fails :shrug:
:WTF: :dizzy:
If I turn off the cache, the program now works, but with the cache turned on, it seems to overshoot the end address that its supposed to be copying and verify fails :shrug:
:WTF: :dizzy:
-
exxos
- Site Admin

- Posts: 28370
- Joined: 16 Aug 2017 23:19
- Location: UK
Re: Exxos software blog
Is really quite bizarre !
I copy 512KB from ROM to TTram.. and the same 2 long words fail every time.
BUT, if my manually "peek and poke" the RAM, the values are fine, so it's not like the RAM is bad I think :shrug:
BUT if the copy routine was bad, why only those 2 addresses, and on the border of the 256K ROM space as well..
EDIT:
Found one problem :roll: my AUTOEXEC.BAS which dumped some values, also set a address to "1234" which probably isn't helping :lol: :pullhair: :headbang:
I copy 512KB from ROM to TTram.. and the same 2 long words fail every time.
BUT, if my manually "peek and poke" the RAM, the values are fine, so it's not like the RAM is bad I think :shrug:
BUT if the copy routine was bad, why only those 2 addresses, and on the border of the 256K ROM space as well..
EDIT:
Found one problem :roll: my AUTOEXEC.BAS which dumped some values, also set a address to "1234" which probably isn't helping :lol: :pullhair: :headbang:
You do not have the required permissions to view the files attached to this post.
-
Steve
- Posts: 3307
- Joined: 15 Sep 2017 11:49
Re: Exxos software blog
I wonder if certain programming languages are more likely to be more accurate and easy for the AI to work with, I assume something a little obscure like STOS isn't something AI has had much resources to digest, where as something like C or GFA Basic might be a better choice? Not sure.
-
exxos
- Site Admin

- Posts: 28370
- Joined: 16 Aug 2017 23:19
- Location: UK
Re: Exxos software blog
C might be more common. The assembly is finished and working fine now. Most of the problems were my fault though :roll:Steve wrote: 12 May 2025 20:36 I wonder if certain programming languages are more likely to be more accurate and easy for the AI to work with, I assume something a little obscure like STOS isn't something AI has had much resources to digest, where as something like C or GFA Basic might be a better choice? Not sure.
Who is online
Users browsing this forum: apple [bot], ClaudeBot, Icky, Steve and 37 guests