|
This www.mfatc.org page
contains source demo programs showing coding techniques in IBM mainframe assembler,
Intel assembler, C++ , COBOL, and Java programming languages using
the following free tools available for Windows 2000/XP using
InstallShield standard install software.
In the end
all higher level languages either generate machine specific assembler code or
portable pseudo code which results in calling machine specific
assembler code at execution time. All of the examples have
been compiled and executed using the above free tools. If
you find this page useful,
join the MFATC discussion group
and submit your
comments, questions, and suggestions.
Don
Higgins
| # |
Coding Technique |
z390 |
HLA |
Visual C++ |
FSC
COBOL |
J2SE Java |
| 1 |
"Hello
World" Demos
See links for source programs, generated output, and help with
installation and execution of demos. See notes on demo
below. |
-
MLC
-
BAL
-
PRN
-
LOG
-
HELP
5 lines |
- HLA
-
ASM
- LST
- MAP
-
HELP
5 lines |
-
CPP
-
ASM
-
HELP
5 lines |
- COB
- HELP
4 lines |
-
JAVA
-
VM
-
HELP
5 lines |
| |
"Hello
World" Demo Notes:
-
Each HELLO demo source program is only 4-5 lines,
-
Each HELLO demo uses system library macros and/or function
which in turn calls operating system service to display the
"Hello World" message.
-
The z390 mainframe assembler version uses
WTO write to operator macro and svc 35 service.
- The HLA Intel assembler version uses HLA printf
service which expands to MASM library call.
- The C++ version uses printf which also expands to
MASM library call.
- The COBOL version uses DISPLAY verb.
- The J2SE Java version uses println service.
|
| 2 |
Powers of 2 from 0 to 31 Demos
|
-
MLC
-
PRN
-
LOG
23 lines |
- HLA
- ASM
14 lines
|
- CPP
- ASM
9 lines
|
- COB
12 lines
|
- JAVA
- VM
11 lines
|
| |
Powers of 2 demo notes:
-
Each demo uses structured programming to perform iteration
without any go to branches.
-
The mainframe assembler version uses packed decimal edit
instructions to format output.
- All the other demos use system display services to
convert and display integer values.
|
| 3 |
Calculate MIP rate demos
|
- MLC
- PRN
- LOG
44 lines
1.2 MIPS |
- HLA
- ASM
43 lines
5840 MIPS |
- CPP
- ASM
28 lines
776 MIPS |
- COB
- ASM
70 lines
68 MIPS |
- JAVA
- VM
34 lines
1430 MIPS |
| |
MIPS
calculation demo notes:
-
Each of the 5 MIPS demo programs measures speed of instruction loop decrementing
a 32 bit integer
counter until 0. The results shown are for 3.05 GHZ Dell
Pentium 4.
-
The 1.2 MIP z390 mainframe assembler version is the slowest due to overhead of mainframe emulation.
However a free 1.2 MIPS mainframe on your Windows desktop is
more than enough speed for most applications which are
usually I/O bound anyway. Note this performance level
uses z390 v1.1.01.
-
The 5840 MIP native Intel assembler version is by far the
fastest due to Pentium 4 pipelining achieving close to 2
instructions per machine cycle.
-
The C++ generated native code is slower that the HLA version
due to extra memory and instruction fetches associated with
using memory variable field instead of cached register
storage.
- The COBOL generated native code is noticeable slower
than the C++ generated code since it does several
conversions from Big Indian integer storage to native Little
Indian integer storage in order to perform native decrements
and compares.
- The J2SE Java code outperforms the C++ code due to
J2RE runtime hotspot optimization feature. The ability
of a virtual machine runtime to outperform a native code
generating compiler is very impressive.
|
| 2 |
Square root of 2 Demos
|
-
MLC
-
PRN
-
LOG
58 lines for 32, 64, and 128 bit |
- HLA
- ASM
41 lines for 32, 64, and 80 bit
|
- CPP
- ASM
26 lines for 32 and 64 bit
|
- COB
16 lines for 32 and 64 bit
|
- JAVA
- VM
83 lines for 32, 64, 128 plus 80 digits
|
| |
Square root of 2 demo notes:
-
Each of the 5 demos calculates and displays the square root of 2 using
IEEE 32 bit
precision (EB short binary, real32, float, comp-1, and float
types respectively) and the
IEEE 64 bit
precision (DB long binary, real64, double, comp-2, and double
types respectively). The 32 bit format has about 8
decimal digit precision and the 64 bit format has about 15
decimal digit precision.
-
For verification of the results see
this
NASA web page with target value of the square root of 2.
-
HLASM and Java
demos also calculate the
IEEE 128 bit precision
(LB extended binary and BigDecimal MathContext DECIMAL128
respectively) square root of 2 which has about 34 decimal
digits. The z390 version also uses new CTD Convert to
Display macro and svc 170 to convert any 128 bit integer or
floating point value to EBCDIC display format. This
new service is in
z390 v1.1.01a. CTD supports both hex and binary
mainframe formats.
- The HLA demo also calculates the native Intel
floating point coprocessor 80 bit precision result which has
about 18 decimal digit precision. This format is used
on Intel for both 32 bit and 64 bit format native
calculations and then rounded to requested storage format as
required.
- The J2SE Java demo uses the arbitrary precision
BigDecimal class to calculate both the IEEE 128 bit
precision and also 80 decimal digit precision square root of
2. Note since there is no built in square root method
for BigDecimal class, the demo calculates an initial guess
using double precision build in function and then uses
Newton Raphson method to iterate to achieve requested
precision. The demo uses 2 iterations for 128 bit
precision and 3 iterations for the 80 digit precision
result.
|
|