After a lot of effort, z/PDOS-generic is now, like other
targets, able to handle Windows executables.

ie PE/COFF, using msvcrt.dll

All on glorious EBCDIC ...

enter a command
hexdump pdptest.exe 0 100
about to call app at address 04ECE7E0
000000  D4E90000 00000000 04000000 00000000  MZ..............
000010  00000000 00000000 00000000 00000000  ................
000020  00000000 00000000 00000000 00000000  ................
000030  00000000 00000000 00000000 40000000  ............ ...
000040  D7C50000 00000300 00000000 00000000  PE..............
000050  00000000 E0000203 0B01000F 00320000  ....\...........
000060  00020000                             ....
return from app is hex 0

enter a command


With entry point of:

w32start.c: void mainCRTStartup(void)

as seen here with a BALR R15,R0:

000200  47F0F00E 08D4C1C9 D5C3D9E3 E20090EC  .00..MAINCRTS...
000210  D00C18CF 58F0D04C 50D0F004 50F0D008  }....0}<&}0.&0}.
000220  18DF5AF0 C03050F0 D04C47F0 C0340000  ..!0{.&0}<.0{...
000230  00000080 05C018B1 58A0C06E 1F335030  .....{....{>..&.
000240  D07C4120 D0705020 D0584120 D0745020  }@..}.&.}...}.&.
000250  D05C4120 D0785020 D0605030 D0644120  }*..}.&.}-&.}...
000260  D07C5020 D0684110 D05858F0 C07205EF  }@&.}...}..0{...
000270  D203D058 D070D203 D05CD074 4110D058  K.}.}.K.}*}...}.
000280  58F0C076 05EF50F0 D0584110 D05858F0  .0{...&0}...}..0


And other glorious (and standard, if you allow for
a "register stack") hlasm:

         AMODE ANY
         RMODE ANY
         CSECT
* Program text area
         DS    0F
* X-func mainCRTStartup prologue
         ENTRY MAINCRTS
MAINCRTS DS    0H
         USING *,15
         B     @@FEO0
         DC    X'08'
         DC    C'MAINCRTS'
         DS    0H
@@FEO0   EQU   *
         STM   14,12,12(13)
         LR    12,15
         DROP  15
         USING MAINCRTS,12
         L     15,76(,13)
         ST    13,4(,15)
         ST    15,8(,13)
         LR    13,15
         A     15,=A(128)
         ST    15,76(,13)
         B     @@FEN0
         LTORG
@@FEN0   EQU   *
         DROP  12
         BALR  12,0
         USING *,12
@@PG0    EQU   *
         LR    11,1
         L     10,=A(@@PGT0)
* Function mainCRTStartup code
         SLR   3,3
         ST    3,124(13)



generated by gccmvs.

Both gccmvs and as370 are (now) written in C90, so can
be built anywhere, basically. Including on ASCII machines.



Result (renamed to win.exe):

pdlde --oformat coff -s -nostdlib --no-insert-timestamp --emit-relocs -o 
pdptest.exe w32start.obj
 mfsupa.obj pdptest.obj setjmp.obj msvcrt.lib
about to call app at address 04FC8BF0
about to call app at address 050BE6E0
return from app is hex 0
return from app is hex 0
return from app is hex 0

enter a command
copy pdptest.exe \dos\WIN.EXE

enter a command
win abc def
about to call app at address 04ED0000
welcome to pdptest
main function is at 04ED1380
allocating 10 bytes
m1 is 04DD8C50
allocating 20 bytes
m2 is 04DD8CA0
stack is around 00080E48
printing arguments
argc = 3
arg 0 is <win>
arg 1 is <abc>
arg 2 is <def>
return from app is hex 0

enter a command


msvcrt.dll functions:

003480  000050E6 000050F0 000050FA 00005104  ..&W..&0..&.....
003490  0000510E 00000000 0D006D6D 8785A394  ..........__getm
0034A0  81890000 25006D6D 8996827C 86A40000  ai....__iob@fu..
0034B0  6000C5E7 C9E30000 6400C6C3 D3D6E2C5  -.EXIT....FCLOSE
0034C0  00006600 C6C5D9D9 D6D90000 6D00C6D6  ....FERROR.._.FO
0034D0  D7C5D500 7100C6D9 C5C1C400 7900C6E6  PEN...FREAD.`.FW
0034E0  D9C9E3C5 00009900 D4C1D3D3 D6C30000  RITE..r.MALLOC..
0034F0  A700D7D9 C9D5E3C6 0000C200 E2E3D9C3  x.PRINTF..B.STRC
003500  D4D70000 C400E2E3 D9C3D7E8 0000C800  MP..D.STRCPY..H.
003510  E2E3D9D3 C5D50000 94A2A583 99A34B84  STRLEN..msvcrt.d
003520  93930000 00000000 00000000 00000000  ll..............
003530  00000000 00000000 00000000 00000000  ................


don't exceed the limits of IFOX or HLASM.

If using IFOX, you do need to have dummy amode/rmode macros though:

Provided here for your convenience:

type amode.mac
         MACRO
&NAME    AMODE
         MEND


type rmode.mac
         MACRO
&NAME    RMODE
         MEND


So, procedure to reproduce:

Download https://pdos.org/zpg.zip

You can use an emulator (mfemul.exe for x86 Windows) from
https://pdos.org/pdos.zip


Or you can run it in Hercules/380, in z/Arch mode:

ARCHMODE             z/Arch

CPU0000 PSW=0404100180000000 000000000493A008 64.......Z                    
instcount=111,642,780

Although it says 64-bit, it's effectively only 32-bit, as the
4 GiB to 8 GiB region is mapped to 0-4 so that negative
indexes go to the right spot.

Register sizes are all 32-bit, so this is definitely 32-bit,
not 64-bit.

With handwritten assembler you could use the 64-bit
registers (no need to switch to AM64 - it's permanently
in AM64) and use the 64-bit registers, but gccmvs won't
generate that for you.


Get the source code from sourceforge, and make sure it
is zipped without CRs, ie:

zip -9rX -ll temp pdos

copy that to \zpg\tapes\tapein.dat

If using mfemul, start mytest.bat and:

copy :tapein.dat temp.zip

If using Hercules/380, run "doit.bat", telnet to localhost 3270
and then do:

copy tap1c7: temp.zip

Then:

md devel
cd devel
hwzip extract \temp.zip
cd pdos
cd src
pdmake -f makek32.z32
cd ..
cd pdpclib
pdmake -f makefile.z32
copy pdptest.exe \dos\win.exe

win abc def


Hopefully the last 30+ years of my life wasn't a complete
waste of time.

Took ages to understand to understand all the concepts
required - such as what was restricting the mainframe to
31-bit and 3270 terminals (answer: nothing).

BFN. Paul.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to