User:New16: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
Content deleted Content added
No edit summary
m Bot: Replace deprecated source tag with syntaxhighlight
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Opcode Programming]]
[[Instruction Set Architecture]]
{{stub}}


Any beginner should start here.
This page is intended to provide an explanation of the various instruction set architecture principles such as Complex Instruction Set, Reduced Instruction Set, Writable Instruction Set, Single Instruction Set, etc. The instruction sets are named beginning with the simplest toward the complexest set.


Before starting assembly or high-level language programming you should know: The processor does only understand opcode. Simply consider this languages named above to be helpful, but they must be interpreted by so called compilers, linkers and assemblers to create the necessary opcode.<br>
==Church-Turing Thesis==


So just grab an instance of "<b>Intel® 64 and IA-32 Architectures Software Developer’s Manual</b>", with the subtitle: "<b>Combined Volumes: 1, 2A, 2B, 2C, 3A, 3B, 3C and 3D</b>" (4618 pages in June 2016), and go on with this tutorial.<br>
For the beginning of theoretical informatics Alan Turing was maybe the most important person. The Church-Turing thesis states that any algorithm computable by humans (without time and memory limitaions and of course failure free) is computable by an Church-Turing powerful<!-- #?-language (powerful, mighty, cardinality)--> machine.<br>
:(Just type the title in the search at "intel.com" .)
To be Church-Turing mighty, it is sufficient to be able to load data, change it in any possible way and store it afterwards. Saving and Storeing a value is selfexplaining, the interesting part is the processing.<br>
Common algorithms:
*logic functions: One might not notice, but f.e. brains use in daily challenges for decisions simple state machines and every state machine can be expressed by logic functions.
*comparisions: Is this red brighter than this? Answer: Yes or No. See example above. This is implemented by an addition or rather a substraction. Can be implemented by logical functions (see below).
*multiplications/divisions: Used f.e. in case of weights. Can be implemented by addition and substraction (Think about it!), and addition can be implemented by logic functions, so...
*integration/differentiation: Any physic law may be implemented by using integration and differentiation. Can be implemented by multiplication or rather division, and this can be implemented by ...
As you might have noticed everything can be implemented by logic functions. This is important: To be able to do any logic function means to be Church-Turing mighty.


==Basics==
To be exact only (f.e.) the NAND function with two inputs and one output is needed. Other sets of logic functions can be found, but the most common is the NAND function.


You should read at least the following sections (I recommend this order.):
==Flynn's Bottleneck and Fisher's Optimism==


*[[Introduction]]
Michael J. Flynn(*1934) found a very interesting fact: If one fetch(load) only one instruction per cycle, one will never get more than one executed instruction per cycle. (This is valid for each physical core.)(Think about it!)<br>
*[[BIOS]]
*[[Boot Sequence]]
*[[Real Mode]]
*[[Assembly]]


You might want to run the following code in an emulator. For windows user I recommend [[VirtualBox]]: Set up a new machine with "Typ: Other" and "Version: Other/Unknown (64-bit)" and make sure you find a floppy-controller under section "Storage".<br>
You also need a hex-editor (f.e. "https://hexed.it/").<br>
After editing and saveing the file, named: "something.img", you should close the hex-editor (-website).


==First Program==
==One Instruction Set==


Type in the hex editor (without the leading zero and the "h" at the end):
The so called Ultimate Reduced Instruction Set Computer (URISC) is programmed by only one instruction. This instruction must be possible however to decide, to move data, to jump to different targets in the instruction stream and to calculate. This is only possible with a complex instruction.<br>
Applications for a computer programmed by this ISA have a huge-sized code, so that this ISA is only of theoretical interest. For further information refer to [https://en.wikipedia.org/wiki/One_instruction_set_computer].


<syntaxhighlight lang="asm">
==Minimal Instruction Set==


0EBh, 0FEh
Is defined by less than 32 instructions (It can't be realy distinguished between MIS and RIS.). Mostly MISCs are Stackmachines. Owing to missing security features and the huge code size this ISA is not used anymore. For further information refer to [https://en.wikipedia.org/wiki/Minimal_instruction_set_computer].
;now expand this file with zeros until you reached address 510 (01FEh)
0, 0, ...
;at address 510 (01FEh) insert:
0AAh
;at adress 511 (01FFh) insert:
055h
</syntaxhighlight>


Add this file to you floppy controller in your emulator (f.e. VirtualBox).<br>
==Reduced Instruction Set==
Run your virtual machine.<br>

And you will see: nothing. But you will be able to notice a massive CPU-usage.<br>

It worked! Whatever you have done...<br>

====Explanation====
Examples: ARM, MIPS
Lets start from the beginning, 0xEB and 0xFE is a JMP opcode which makes the computer execute this code over and over.<br>

The last 2 bytes are the boot signature, for the computer to understand that this floppy is a bootable floppy disk.
==Complex Instruction Set==

Example: x86

Latest revision as of 06:49, 9 June 2024

Opcode Programming

Any beginner should start here.

Before starting assembly or high-level language programming you should know: The processor does only understand opcode. Simply consider this languages named above to be helpful, but they must be interpreted by so called compilers, linkers and assemblers to create the necessary opcode.

So just grab an instance of "Intel® 64 and IA-32 Architectures Software Developer’s Manual", with the subtitle: "Combined Volumes: 1, 2A, 2B, 2C, 3A, 3B, 3C and 3D" (4618 pages in June 2016), and go on with this tutorial.

(Just type the title in the search at "intel.com" .)

Basics

You should read at least the following sections (I recommend this order.):

You might want to run the following code in an emulator. For windows user I recommend VirtualBox: Set up a new machine with "Typ: Other" and "Version: Other/Unknown (64-bit)" and make sure you find a floppy-controller under section "Storage".
You also need a hex-editor (f.e. "https://hexed.it/").
After editing and saveing the file, named: "something.img", you should close the hex-editor (-website).

First Program

Type in the hex editor (without the leading zero and the "h" at the end):

0EBh, 0FEh
;now expand this file with zeros until you reached address 510 (01FEh)
0, 0, ...
;at address 510 (01FEh) insert:
0AAh
;at adress 511 (01FFh) insert:
055h

Add this file to you floppy controller in your emulator (f.e. VirtualBox).
Run your virtual machine.
And you will see: nothing. But you will be able to notice a massive CPU-usage.
It worked! Whatever you have done...

Explanation

Lets start from the beginning, 0xEB and 0xFE is a JMP opcode which makes the computer execute this code over and over.
The last 2 bytes are the boot signature, for the computer to understand that this floppy is a bootable floppy disk.