flat assembler
Message board for the users of flat assembler.

Index > Main > Is possible to write an OS with Flat assembler? (_64BIT)

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
antos



Joined: 13 Jul 2016
Posts: 23
Location: Syria
antos
Is possible to write an OS with Flat assembler and if it is possible, how? I need to use which argument when compiling my code? What i need to notice? What is a variable and is possible to declare a variable in assembly? What is sections in Flat assembler. Where i can find a guide for _64BIT Intel assembly (Or even _32BIT)?

_________________
V0.01
Post 13 Jul 2016, 19:48
View user's profile Send private message Reply with quote
antos



Joined: 13 Jul 2016
Posts: 23
Location: Syria
antos
And i am not saying about C/C++ Macro like variables, i am saying about runtime declared variables.
Post 13 Jul 2016, 20:10
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Yes it is possible. Actually FASM is the best assembler for writing new OS, because it is very easy portable and this way the new OS will become self hosting very early.

More, there are already several OSes written with FASM - MenuetOS, KolibriOS(fork of Menuet), MikeOS and probably other I can't remember right now.

But, still writing OS is very serious and hard task. You probably will need to learn assembly language programming and computer architecture first.

Learning assembly language you can start with reading FASM manual (in every FASM package downloaded) and trying to compile, run and modify some of the included examples.
Post 13 Jul 2016, 20:33
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
antos



Joined: 13 Jul 2016
Posts: 23
Location: Syria
antos
And i need use which flags when compile my code? You know, i will not compile my code for an OS.
Post 13 Jul 2016, 21:30
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17714
Location: In your JS exploiting you and your system
revolution
antos: fasm doesn't use command line flags to control the assembly output. You use the "format" directive within the source code to define the output. This is also the same for 16-bit, 32-bit and 64-bit encodings, you use directives within the source code to select the encoding (code16, code32 and code64 respectively).
Post 14 Jul 2016, 02:08
View user's profile Send private message Visit poster's website Reply with quote
antos



Joined: 13 Jul 2016
Posts: 23
Location: Syria
antos
Thanks, i have a last question: i was reading x86-64 Machine-Level Programming book. And i see this line:

Much of (?) the program state is held in registers rather than on the stack. Integer and pointer procedure
arguments (up to 6) are passed via registers. Some procedures do not need to access the stack at all.

I know function arguments stored in register else of stack frame in x86-64 Assembly. What is stack frame exactly and what "Much of the program state" and "Some procedures do not need to access the stack at all" means?

And how long double variable type can store much than 64 bits?
Post 14 Jul 2016, 10:09
View user's profile Send private message Reply with quote
Trinitek



Joined: 06 Nov 2011
Posts: 257
Trinitek
A stack frame contains the arguments that are passed to a function and the function's local variables. Depending on the function, it may not have enough local variables to require the use of any of the local variable space provided by the stack frame, and it can use the registers to store them instead.

There are special FPU registers that are able to work with values wider than 64-bits.
Post 14 Jul 2016, 12:53
View user's profile Send private message Reply with quote
antos



Joined: 13 Jul 2016
Posts: 23
Location: Syria
antos
I know this is an unneedful question but: Is Floating Point Unit in ALU?

And can i write a Graphics API like OpenGL or Vulkan?
Post 14 Jul 2016, 16:07
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17714
Location: In your JS exploiting you and your system
revolution
The FPU is usually a separate unit from the ALU. Such internal details will be different for each CPU model and CPU make, and could change radically in future designs, and have changed radically from past designs. But such internal details shouldn't really be too much of a concern unless you are deep into optimisation.

You can write any API you wish to in assembly. But for GPUs and the like, obtaining the necessary internal details to write the code against will be a difficult task.
Post 14 Jul 2016, 16:14
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
antos wrote:
What i need to notice?


That OS development is hard as hell.
Post 16 Jul 2016, 08:47
View user's profile Send private message Reply with quote
antos



Joined: 13 Jul 2016
Posts: 23
Location: Syria
antos
I know this hard as hell. OS development needs organization, one person can't do anything interesting. But Linux 0.01 wrote by only one person. Invent the wheel again, but do it better from the first wheel.
Post 16 Jul 2016, 12:29
View user's profile Send private message Reply with quote
antos



Joined: 13 Jul 2016
Posts: 23
Location: Syria
antos
And:

the second byte (?) of registers %rax,%rcx , %rdx, and %rbx can be directly accessed by instructions having single-byte operands.

What second byte means? I know single-byte operands: "MOVB 5, %AX".
Post 16 Jul 2016, 13:16
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1155
ManOfSteel
antos wrote:
What second byte means? I know single-byte operands: "MOVB 5, %AX".

Perhaps you're referring to the low and high bytes (al and ah)?
Post 17 Jul 2016, 08:34
View user's profile Send private message Reply with quote
antos



Joined: 13 Jul 2016
Posts: 23
Location: Syria
antos
ManOfSteel wrote:
antos wrote:
What second byte means? I know single-byte operands: "MOVB 5, %AX".

Perhaps you're referring to the low and high bytes (al and ah)?


Okey. I got, but 64 bit and 32 bit registers does not have low and high bytes like 16 bit registers, or is it? Can you give a example prograrm?

_________________
V0.01
Post 17 Jul 2016, 10:49
View user's profile Send private message Reply with quote
antos



Joined: 13 Jul 2016
Posts: 23
Location: Syria
antos
UP UP UP
Post 17 Jul 2016, 15:28
View user's profile Send private message Reply with quote
Trinitek



Joined: 06 Nov 2011
Posts: 257
Trinitek
EAX access the lower end of RAX. There is no register that accesses the higher end of RAX.
AX access the lower end of EAX. There is no register that accesses the higher end of EAX.
AL accesses the lower end of AX. AH accesses the higher end of AX.

This applies to all of the other general purpose registers.

See: https://en.wikipedia.org/wiki/X86#/media/File:Table_of_x86_Registers_svg.svg
Post 17 Jul 2016, 19:09
View user's profile Send private message Reply with quote
antos



Joined: 13 Jul 2016
Posts: 23
Location: Syria
antos
Trinitek wrote:
EAX access the lower end of RAX. There is no register that accesses the higher end of RAX.
AX access the lower end of EAX. There is no register that accesses the higher end of EAX.
AL accesses the lower end of AX. AH accesses the higher end of AX.

This applies to all of the other general purpose registers.

See: https://en.wikipedia.org/wiki/X86#/media/File:Table_of_x86_Registers_svg.svg


Well, we can not access directly to higher end of these register, but maybe we can access it indirect. Like this:

SUB AX, AX ;AX equal to 1
BSWAP EAX ;And we change the value of higher end of EAX, and lower end too

Is it possible?

_________________
V0.01
Post 17 Jul 2016, 22:01
View user's profile Send private message Reply with quote
Trinitek



Joined: 06 Nov 2011
Posts: 257
Trinitek
antos wrote:
Well, we can not access directly to higher end of these register, but maybe we can access it indirect. Like this:

SUB AX, AX ;AX equal to 1
BSWAP EAX ;And we change the value of higher end of EAX, and lower end too

Is it possible?
Yes, or you could rotate the register with RTL or RTR, or you could discard the lower half entirely with SHR...
Post 17 Jul 2016, 22:21
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17714
Location: In your JS exploiting you and your system
revolution
Trinitek wrote:
... or you could rotate the register with RTL or RTR, ...
Perhaps you mean ROL or ROR?
Post 17 Jul 2016, 23:41
View user's profile Send private message Visit poster's website Reply with quote
Trinitek



Joined: 06 Nov 2011
Posts: 257
Trinitek
revolution wrote:
Trinitek wrote:
... or you could rotate the register with RTL or RTR, ...
Perhaps you mean ROL or ROR?
Woops. Yeah, that.
Post 18 Jul 2016, 02:33
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.