ibara / 8088ify

The famous Intel 8080 CP/M 2.2 to Intel 8086/8088 MS-DOS assembly language translator.
https://briancallahan.net/blog/20210606.html
ISC License
87 stars 4 forks source link

Tim Paterson's trans.asm #3

Closed tkchia closed 3 years ago

tkchia commented 3 years ago

Hello @ibara,

Cool program, thanks!

Out of curiosity, how does 8088ify compare with Tim Paterson's Z80-to-8086 translator trans.asm?

I see that Microsoft open-sourced the trans.asm code as part of their MS-DOS 1.x source release, though they did not really publicize this fact. I have managed to "port" trans.asm to assemble with nasm.

Thank you!

ibara commented 3 years ago

Hello --

Other than 8088ify being able to be built for any platform that has access to a C compiler and a minimal libc, I'm not sure. I only learned about trans.asm maybe an hour or two ago. I haven't tried it yet.

With mine, I followed the Intel EXACT translations and only the EXACT translations. The reading I've been doing suggests that APPROX would be fine most of the time but I can't confirm the validity of that. If trans.asm follows APPROX, it will generate slightly more compact code.

It is also possible that trans.asm targets the small memory model whereas I target the tiny memory model. I'd like to eventually move to at least having an option for the small memory model, since it will take care of those programs that just barely fit into CP/M (and therefore may just barely not fit into MS-DOS tiny model). DRI's XLT86 does some version of small memory model from what their documentation suggests.

ibara commented 3 years ago

Hello again --

I tried using your ported version of trans.asm but when I try to use it, it replaces the input file with a blank file of the same name. So I must have the invocation incorrect. Is it trans.asm <inputfile>? Or is there something more I need to do?

tkchia commented 3 years ago

Hello @ibara,

Thanks! I have not tested trans.asm very much --- I should probably do that more! --- but it seems that it needs the input to be in a file that has an extension other than .asm. The output file will have the same name stem but extension .asm. E.g. if you say

trans.asm foo.z80

then it will use foo.z80 as the input, and foo.asm as the output.

Thank you!

ibara commented 3 years ago

Hello --

I tried trans.com but it does not appear to work correctly (on DOSBox, at least).

For this Z80 assembly:

; Hello world for Zilog Z80 running CP/M
    ORG 100H
BDOS    EQU 0005H
START:  LD  HL,MSG
LOOP:   LD  C,02H
    LD  E,(HL)
    PUSH    HL
    CALL    BDOS
    POP HL
    INC HL
    LD  A,E
    CP  0AH
    JP  NZ,LOOP
    RET
MSG:    DB  'Hello, world from Assembler!',0DH,0AH
    END

You get this output from trans.com:

    ; Hello world for Zilog Z80 running CP/M
    ORG 100HCBDOS   0005H
START:  MOV BX,MSGCLOOP:    LD  C,02H
    MOV DL,[BX]C    PUSH    HL
    JA  L0000
    CALL    POP
L0000:      HL
    LAHF
    INC BXC
    SAHF    A,E
    CMP 0AHC,JP NZ,LOOP
RET

    AH

    DOS

    P

    OOP

    POP HL
    INC HL
    LD  A,E
    CP  0AH
    JP  NZ,LOOP
    RET
MSG:    DB  'Hello, world from Assembler!',0DH,0AH
    END

    HELLO   ASM

        ,
*** Opcode Error 
MSG:    DB  'Hello, world from Assembler!',0DH,0AH
END

    AH

    DOS

    P

    OOP

    POP HL
    INC HL
    LD  A,E
    CP  0AH
    JP  NZ,LOOP
    RET
MSG:    DB  'Hello, world from Assembler!',0DH,0AH
    END

    HELLO   ASM

        ,
*** Opcode Error 
                          
tkchia commented 3 years ago

Hello @ibara,

Perhaps try changing the line endings from LF to CRLF?

I am getting the following output, under both MS-DOS 2.11 and FreeDOS 1.3-rc4:

    ; Hello world for Zilog Z80 running CP/M
    ORG 100H
BDOS:   EQU 0005H
START:  MOV BX,MSG
LOOP:   MOV CL,02H
    MOV DL,[BX]
    PUSH    BX
    CALL    BDOS
    POP BX
    LAHF
    INC BX
    SAHF
    MOV AL,DL
    CMP AL,0AH
    JNZ LOOP
    RET
MSG:    DB  'Hello, world from Assembler!',0DH,0AH
    END ,
*** Opcode Error 
���������������������������������������������������������������������������������

(It does seem that TRANS.ASM is using EXACT translations, or something close to them.)

Thank you!

tkchia commented 3 years ago

Hello @ibara,

In any case, thanks very much for your earlier reply!

ibara commented 3 years ago

Hello --

Sorry for the delayed reply. I haven't gotten around to changing the LF to CRLF but I trust you that it works! I wonder how trans.asm handles the Z80 extensions. That would be good to know. But I can do that myself.