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
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
[[Opcode Programming]]
[[Opcode Programming]]

{{stub}}


Any beginner should start here.
Any beginner should start here.


Befor 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 neccessary opcode.<br>
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>


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>
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>
Line 24: Line 22:
After editing and saveing the file, named: "something.img", you should close the hex-editor (-website).
After editing and saveing the file, named: "something.img", you should close the hex-editor (-website).


==First Programm==
==First Program==


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


<source lang="asm">
<syntaxhighlight lang="asm">


0EBh, 0FEh
0EBh, 0FEh
Line 37: Line 35:
;at adress 511 (01FFh) insert:
;at adress 511 (01FFh) insert:
055h
055h
</syntaxhighlight>
</source>


Add this file to you floppy controller in your emulator (f.e. VirtualBox).<br>
Add this file to you floppy controller in your emulator (f.e. VirtualBox).<br>
Line 43: Line 41:
And you will see: nothing. But you will be able to notice a massive CPU-usage.<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>
It worked! Whatever you have done...<br>
====explanation====
====Explanation====
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.

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.