How do you know which machine of the instruction set architecture is being implemented dynamically?
1) I would like to know if we can write a program in C to learn about the architecture of the machine's instruction set.
2) How does the operating system determine which instruction set architecture (ISA) is running during installation? If the OS needs to support two different ISAs, does the installation file contain assembly code for both architectures?
source to share
1) I would like to know if we can write a program in C to know about the architecture of the machine's instruction set.
A C program requires a compiler to compile, which converts the code to machine language, which is different for different architectures such as Sparc, x86, ARM
etc. Thus, you cannot run a C program if you are not aware of the architecture instruction set. C is different for different architectures.
But one thing can be done if you are confident in the system architecture and if you are using the compiler on that system. You can try these instructions on different operating systems to get information on different architectures.
You can get the system architecture information (not instruction set data) of this machine with
set
at windows command prompt (cmd)
cat /proc/cpuinfo
on unix / linux terminal
Now write a C program to execute this command in cmd / terminal depending on the OS of the system.
2) How does the operating system determine which Instruction Set Architecture (ISA) a computer is running on during installation? If the OS had support for two different ISAs, does the installation file contain assembly code for both architectures
The OS itself consists of pre-compiled binaries that run on specific architectures. Almost OS initialization files are all direct executables. If the architecture instruction set is incompatible with the operating system binaries, an installation error will be reported! The main architecture goal is to just run those binaries and do nothing.
If the OS needs to support two different ISAs, then also the architecture on which it is installed should simply run those binaries as instructed in the OS code.
A similar approach is discussed below. I'm just a student, so I don't have many build / machine level skills. I tried to answer this question with just my knowledge of computer architecture and 8086 programming.
Example: -
MOV AX,[76h] // lets' say opcode is 1001010 10011001, but it is probably wrong
Here it is for x86 systems / architecture! It is not suitable for Sparc processors as it has a different instruction set and therefore your OS will not install on Sparc processors.
Hope this is very clear. If you still have questions, leave a comment below!
source to share