I saw this article and though it was relevant here:
Converting GW-BASIC to the Z80
Summarizing some myself:

GW-BASIC was bundled many versions of MS-DOS, which made it widely used during the 80s because it was readily available. Microsoft released the source code to version 1.0 earlier this year. Interestingly, much of the code (all 8086 assembly) appears to have been translated from 8080 code, since it contains a lot of references to 8080 register names and is documented to have been automatically translated by some other tool:
Code:
;
; FIND A "FOR" ENTRY ON THE STACK WITH THE VARIABLE POINTER
; PASSED IN [D,E].
;
PUBLIC  FNDFOR
FNDFOR: MOV     BX,OFFSET 4+0   ;IGNORING EVERYONES "NEWSTT"
                                ;AND THE RETURN ADDRESS OF THIS
        ADD     BX,SP           ;SUBROUTINE, SET [H,L]=SP

Our enterprising author looks at this and says "why not write the reverse converter?" The ongoing result is a purpose-built program that translates 8086 instruction sequences using the idioms in the GW-BASIC source code to Z80 while preserving other information like comments.

The author also calls out several resources that come from the TI community as useful: WikiTI and Z80 Heaven.


I'm not sure I would have chosen to build a translator in the same way; it seems rather fragile to match on specific instruction sequences rather than some kind of more abstract control flow graph, but maybe that's easier to work with (get running quickly) and maintain a correspondence with original comments and such.

The ultimate goal is to make a version that run on MSX, but I wonder if a calculator port would be feasible too?
Tari wrote:
The ultimate goal is to make a version that run on MSX, but I wonder if a calculator port would be feasible too?

Assuming the z80 port to MSX is done and works, I would expect at the very least that a compatibility layer for a subset (https://github.com/microsoft/GW-BASIC/blob/09ad7bc671c90f0eeff4cb7593121ad6f170d903/MSDOSU) of the DOS API would be required since GW-BASIC is a MS-DOS 1.0 program. That should be possible in theory since MS-DOS 1.x on the 8086 is a close match to CP/M on the 8080. To what the DOS API would map on the calculator is another story.
Hnnng, I wish I had more free time to devote to this. I emailed the author to alert them to this thread as well as point then to a couple of resources that might be handy.
I've stumbled upon an analysis of GW-BASIC's source code. Apparently the source code is a bit messy, but the bit that stood out to me is:
Quote:
The code contains a nice collection of “what not to do” Intel recommendations. To be fair, those recommendations don’t really apply to the 8086. The style violations include mixing of code and data and jumping into the middle of an instruction.

It seems that simply translating the 8086 assembly into 8080/z80 will probably not yield a working program by itself if stuff like that is hiding in the code...
Oh, that's an interesting point. I imagine most of it can be automated, but yeah, some of it will need to be manually translated.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
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 vote in polls in this forum

 

Advertisement