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:
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?
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?