Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check your CPU type 1

Status
Not open for further replies.

Truusvlugindewind

Programmer
Jun 5, 2002
350
0
0
NL
One of the big advantages of COBOL is it's portability. It runs on all kind of machines. If you need to know on what kind of machine your code is running, you can add this piece of code. You can test whether it is a "big endian" type of CPU or not.
In my case, I develop on a window$ machine and the target platform is AIX. This kind of info is very usefull when you have to call dedicated API's.
Code:
       01  Machinetest.
           03 binair-0000-0100-pic-X   pic X(2)  value X'0004'.
           03 which-endian             redefines
              binair-0000-0100-pic-X   pic S9(4) comp-5.

           03 B-I-G-endian value +0004 pic S9(4) comp-5.
           03 litle-endian value +1024 pic S9(4) comp-5.
       PROCEDURE DIVISION.
      ********************
       000-MAIN Section.
       000-010.
            evaluate which-endian
               when B-I-G-endian
                   display "this is the AIX (powerPC)"
               when litle-endian
                   display "this is a PC (intel inside!)"
               when other
                   display "how the *beep* do you run this program?"
            end-evaluate.

Yes, I know: little is misspelled. But for me a nice outline is more important than correct spelling of the field....
 
Very Smart! You get my vote!

Regards,

Crox
 
This is a very helpful/expert post!

Thank you very much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top