[M3devel] It's time to AMD_64. Modula-3 for Windows x64

vvm at tut.by vvm at tut.by
Sun Jan 20 11:16:45 CET 2019


Hi!


 It's time to AMD_64


I started from

https://modula3.elegosoft.com/cm3/uploaded-archives/

cm3-min-AMD64_NT-d5.9.0-VC110-20131012.msi
cm3-all-AMD64_NT-d5.9.0-VC110-20131012.zip


I have worked Modula-3 for Windows x64



There some must important patches:


==
--- RTExFrame.m3 cm3-4e08861fd36f23dcfac6e50e157b36eddf3989b7	Fri Jul 01 10:29:12 2016
+++ RTExFrame.m3	Tue Jun 21 11:59:05 2016
@@ -10,17 +10,17 @@
 (*----------------------------------------- compiler generated descriptors --*)
 
 (* This defines the low-level routines and data structures
    used by the exception runtime.
    See also m3middle/src/M3RT, which also describes these structures.
 *)
 
 (* RTExFrame.Alloca_jmpbuf and Target.Alloca_jmpbuf must match. *)
-CONST Alloca_jmpbuf = TRUE;
+CONST Alloca_jmpbuf = FALSE;
 
 TYPE
   ScopeKind = { Except, ExceptElse,
                 Finally, FinallyProc,
                 Raises, RaisesNone,
                 Lock };
 
 TYPE

==



==
--- Target.m3 cm3-4e08861fd36f23dcfac6e50e157b36eddf3989b7	Fri Jul 01 10:29:12 2016
+++ Target.m3	Tue Jun 21 11:59:05 2016
@@ -59,37 +59,37 @@
     System_name := SystemNames[sys];
 
     OS_name := in_OS_name;
 
     (* common values *)
 
     Atomic_lock_free :=
         ARRAY [CGType.Word8..CGType.Addr] OF BOOLEAN { TRUE, .. };
     (* this is overly optimistic... *)
 
     Allow_packed_byte_aligned := FALSE;
     All_floats_legal          := TRUE;
     PCC_bitfield_type_matters := TRUE;
     Structure_size_boundary   := 8;
     Little_endian             := TRUE;
     Setjmp                    := "_setjmp";
 
     (* RTExFrame.Alloca_jmpbuf and Target.Alloca_jmpbuf must match. *)
-    Alloca_jmpbuf             := TRUE;
+    Alloca_jmpbuf             := FALSE;
 
     (* There is no portable stack walker, and therefore few systems have one.
        Having a stack walker theoretically speeds up everything nicely.  If
        you are familiar with NT exception handling, all but x86 have a stack
        walker.  Not having a stack walker means that functions that have
        try/except/finally/raise incur a codegen cost even if there is never a
        raise -- for having the try.  Having a stack walker means "zero cost"
        for exception handling code that does not actually raise an exception.
 
        If there is NOT a stack walker, prologues/epilogues for functions that
        try/except/finally/raise call PushEFrame / PopEFrame, essentially to
        build a walkable parallel stack.
 
        If there is a stack walker, then raise can discover what PushEFrame /
        PopEFrame effectively recorded.
 
        NT/x86 has a highly optimized equivalent of PushEFrame / PopEFrame, not
        currently used by Modula-3. *)

==




==
--- LazyConsole.i3 000	Thu Nov 01 00:26:16 2018
+++ LazyConsole.i3	Thu Jan 17 13:19:20 2019
@@ -5,7 +5,7 @@
 
 IMPORT File, FileWin32, WinDef;
 
-PROCEDURE New (hd: WinDef.DWORD; ds: FileWin32.DirectionSet): File.T;
+PROCEDURE New (hd: WinDef.INT32; ds: FileWin32.DirectionSet): File.T;
 (* Returns a file that if ever written to or read from will allocate
    a fresh Windows console for the I/O.  *)
 
==




==
--- LazyConsole.m3 000	Thu Nov 01 00:26:16 2018
+++ LazyConsole.m3	Thu Jan 17 13:20:54 2019
@@ -7,7 +7,7 @@
 
 TYPE
   T = Terminal.T OBJECT
-    hd    : WinDef.DWORD;
+    hd    : WinDef.INT32;
     setup : BOOLEAN := FALSE;
   OVERRIDES
     read   := Read;
@@ -16,7 +16,7 @@
     status := Status;
   END;
 
-PROCEDURE New (hd: WinDef.DWORD; ds: FileWin32.DirectionSet): File.T =
+PROCEDURE New (hd: WinDef.INT32; ds: FileWin32.DirectionSet): File.T =
   BEGIN
     RETURN NEW (T, ds := ds, hd := hd);
   END New;
==



==
--- m3makefile 000	Thu Nov 01 00:26:16 2018
+++ m3makefile	Thu Jan 17 14:09:22 2019
@@ -15,7 +15,7 @@
     cp_if(Name & ".i3.tmp", Name & ".i3")
 end
 
-if equal(TARGET, "NT386")
+if equal(TARGET, "AMD64_NT")
   MakeGrisuDisable("GrisuDisable", "TRUE")
 else
   MakeGrisuDisable("GrisuDisable", "FALSE")
==





Best regards, Victor Miasnikov


P.S.

 
 For best working with debugger:


--- RTOS.m3 000	Sun Jan 03 11:17:00 2016
+++ RTOS.m3	Fri Jan 04 13:15:50 2019
@@ -23,10 +23,12 @@
     IF WinBase.IsDebuggerPresent () # 0 THEN
       WinBase.DebugBreak ();
     END;
-    RTThread.SuspendOthers ();
-    RTMachInfo.DumpStack (LOOPHOLE (Crash, ADDRESS), fp);
+ (*    RTThread.SuspendOthers ();
+    RTMachInfo.DumpStack (LOOPHOLE (Crash, ADDRESS), fp); *)
+    (** RTThread.ResumeOthers ();
     RTSignal.RestoreHandlers (); (* so we really do crash... *)
-    Exit (-1);
+  ***)
+    Exit (4000);  (*** 0 not -1   ***)
   END Crash;
 
 (*********************
 



 Some trivial patches to .cmd:



--- cm3CommandShell.CMD-000     Sun Jan 03 11:17:00 2016
+++ cm3CommandShell.CMD Wed Jan 02 15:24:30 2019
@@ -96,2 +96,3 @@
 echo %_cm3_ThisOS_Long% | (find /I "Windows 7"           >NUL:) && ((set _cm3_ThisOS=Win7)  & goto ver_7)
+echo %_cm3_ThisOS_Long% | (find /I "Windows 10"           >NUL:) && ((set _cm3_ThisOS=Win7)  & goto ver_7)
 echo %_cm3_ThisOS_Long% | (find /I "Windows Server 2008" >NUL:) && ((set _cm3_ThisOS=2008)  & goto ver_2008)
[/code]



--- do-cm3.cmd 000      Sun Jan 03 11:17:00 2016
+++ do-cm3.cmd  Sat Dec 29 11:46:06 2018
@@ -85,6 +85,7 @@
 if NOT exist %SystemRoot%\system32\systeminfo.exe goto ver_NoSysInfo
 FOR /F "usebackq tokens=3* delims=: " %%i IN (`systeminfo ^| find /I "OS Name"`) DO set _cm3_ThisOS_Long=%%i %%j
 echo %_cm3_ThisOS_Long% | (find /I "Windows Vista"       >NUL:) && ((set _cm3_ThisOS=Vista) & goto ver_Vista)
+echo %_cm3_ThisOS_Long% | (find /I "Windows 10"           >NUL:) && ((set _cm3_ThisOS=Win7)  & goto ver_7)
 echo %_cm3_ThisOS_Long% | (find /I "Windows 7"           >NUL:) && ((set _cm3_ThisOS=Win7)  & goto ver_7)
 echo %_cm3_ThisOS_Long% | (find /I "Windows Server 2008" >NUL:) && ((set _cm3_ThisOS=2008)  & goto ver_2008)




--- RCC_upgradeCM3.cmd 000	Sun Jan 03 11:17:00 2016
+++ RCC_upgradeCM3.cmd	Wed Jan 02 16:45:50 2019
@@ -48,7 +48,7 @@
 set _cm3_Repeat=1
 set _cm3_DO=
 set _z_ctrlArgs=
-set _z_Stage3=min
+set _z_Stage3=all
 
 
 
@@ -113,7 +113,7 @@
 if exist "bin\cm3.exe" if exist "pkg" set CM3_ROOT=%CD%& popd & goto FoundRoot
 cd ..
 if exist "bin\cm3.exe" if exist "pkg" set CM3_ROOT=%CD%& popd & goto FoundRoot
-if exist "C:\cm3\bin\cm3.exe" if exist "C:\cm3\pkg" set CM3_ROOT=C:\cm3& popd & goto FoundRoot
+if exist "D:\cm3\bin\cm3.exe" if exist "D:\cm3\pkg" set CM3_ROOT=D:\cm3& popd & goto FoundRoot
 popd
 rem otherwise, search the existing PATH environment variable to try and find the root of the cm3 installation
 for %%F in (cm3.exe) do set CM3_ROOT=%%~dp$PATH:F..
@@ -138,7 +138,7 @@
 if /I "%_cm3_CommandReady%"=="TRUE" goto FindPkgInfo
 echo Setting up environment variables for CM3 ...
 echo.
-call c:\cm3\bin\cm3CommandShell.CMD SameWindow
+call d:\cm3\bin\cm3CommandShell.CMD SameWindow
 @echo off
 if /I not "%_cm3_CommandReady%"=="TRUE" goto FatalSetupCM3
 
@@ -237,7 +237,7 @@
 echo Creating "%CM3_ROOT%\bin\cm3.cfg" ...
 if exist "%CM3_ROOT%\bin\cm3.cfg" del /f %CM3_ROOT%\bin\cm3.cfg
 REM OLD: echo INSTALL_ROOT = path() ^& "/..">%CM3_ROOT%\bin\cm3.cfg
-REM OLD: echo include(path() ^& "/config/NT386")>>%CM3_ROOT%\bin\cm3.cfg
+REM OLD: echo include(path() ^& "/config/AMD64_NT")>>%CM3_ROOT%\bin\cm3.cfg
 copy /y %_cm3_PkgTree%m3-sys\cminstall\src\config-no-install\cm3.cfg %CM3_ROOT%\bin\cm3.cfg
 if errorlevel 1 echo ERROR:  Problem copying files. & (set _cm3_ExitCode=5) & goto END
 if not exist "%CM3_ROOT%\bin\cm3.cfg" echo ERROR:  Problem copying files. & (set _cm3_ExitCode=5) & goto END
@@ -287,12 +287,12 @@
 :FN_FinishStage
 :--------------
 if "%_cm3_CM3Failure%"=="TRUE" echo ...skipping installation of cm3.exe due to errors... & goto :EOF
-if not exist "%_cm3_PkgTree%m3-sys\cm3\NT386\cm3.exe" goto StageFailure
+if not exist "%_cm3_PkgTree%m3-sys\cm3\AMD64_NT\cm3.exe" goto StageFailure
 echo ...installing new cm3.exe as "%CM3_ROOT%\bin\cm3.exe" ...
 if exist "%CM3_ROOT%\bin\cm3.exe" del /f "%CM3_ROOT%\bin\cm3.exe"
 if exist "%CM3_ROOT%\bin\cm3.pdb" del /f "%CM3_ROOT%\bin\cm3.pdb"
-copy "%_cm3_PkgTree%m3-sys\cm3\NT386\cm3.exe" "%CM3_ROOT%\bin\cm3.exe"
-if exist "%_cm3_PkgTree%m3-sys\cm3\NT386\cm3.pdb" copy "%_cm3_PkgTree%m3-sys\cm3\NT386\cm3.pdb" "%CM3_ROOT%\bin\cm3.pdb"
+copy "%_cm3_PkgTree%m3-sys\cm3\AMD64_NT\cm3.exe" "%CM3_ROOT%\bin\cm3.exe"
+if exist "%_cm3_PkgTree%m3-sys\cm3\AMD64_NT\cm3.pdb" copy "%_cm3_PkgTree%m3-sys\cm3\AMD64_NT\cm3.pdb" "%CM3_ROOT%\bin\cm3.pdb"
 if not exist "%CM3_ROOT%\bin\cm3.exe" goto StageFailure
 goto :EOF



More information about the M3devel mailing list