6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 11:19 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: AVR -> 6502 reassembler
PostPosted: Fri Aug 11, 2017 8:04 pm 
Offline
User avatar

Joined: Fri Sep 19, 2014 6:19 pm
Posts: 2
Location: Santa Cruz, CA
I have started an AVR->6502 reassembler.

you can track changes here:
https://github.com/tweakoz/zed64/tree/master/reasm

My intentions for this are as a learning experience, and so I can use avr-g++
to generate code for my fpga based computer I am designing.

I certainly do not intend on using c++ code on 6502 for performance critical
situations, but since I am primarily a c++ programmer these days, I just
find it convenient and fast for noodling around, and I have used minimalist embedded friendly c++ on
Arduino's with some success..

I was kind of inspired by Jason Turners x86->6502 video at:
https://www.youtube.com/watch?v=nLv_INgaLq8

I figured the AVR->6502 approach should pan out fairly well, since AVR is 8 bit and avr-gcc has a decent sized community supporting 8bit targeted gcc which can be leveraged via reassembly. I do realize it would likely be more efficient at runtime to do the 6502 code generation in the compiler. I also know that there is an effort underway on gcc-6502 already...

I need instant gratification and I was able to get the 1st pass of the reassembler working in a few days. I still have more work to do in making it functional with a variety of relevant c++ source. I do not ever intend on supporting heap allocation or anything which can not actually run on a small device.

It works by mapping independent avr opcodes onto 1 or more 6502 opcodes - utilizing zero page as avr registers. Hardly runtime efficient - it is what it is...

The reassembler itself is written in python and expects avr assembly source files like that which would be generated from avr-gcc (gnu-assembler). It generates 6502 assembly in ca65 (cc65 assembler) format.

mtm


Last edited by tweakoz on Fri Aug 11, 2017 8:17 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 11, 2017 8:10 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Interesting! I quite like gluing tools together with some simple text processing, which might be something like what you're doing here.


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 12, 2017 2:00 am 
Offline

Joined: Sat May 02, 2015 6:59 pm
Posts: 134
Jason Turner gave a great talk on the subject at CppCon 2016 where he goes into a bit more detail.

CppCon 2016: Jason Turner “Rich Code for Tiny Computers: A Simple Commodore 64 Game in C++17”
https://www.youtube.com/watch?v=zBkNBP00wJE


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 12, 2017 8:03 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Interesting! Compiling to x86 then translating to 6502. Here are Jason's slides


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 25 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: