flat assembler
Message board for the users of flat assembler.

Index > OS Construction > FASM + C/C++

Author
Thread Post new topic Reply to topic
b0b



Joined: 22 Jan 2005
Posts: 4
b0b
I have looked at some of the tutorials on the net and I have a large C/C++ background. I find it easier to program most of my OS in C/C++.

I read this tutorial and I wanted to use FASM. How would I impliment it though?
Post 22 Jan 2005, 04:37
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
Under which C compiler and host OS?
Post 22 Jan 2005, 12:45
View user's profile Send private message Visit poster's website Reply with quote
gunblade



Joined: 19 Feb 2004
Posts: 209
gunblade
If your looking just for that kernel_start.asm translated.. it should be:

Code:
format ELF
use32
public start
extrn _k_main

start:
call _k_main

cli
hlt    

(i know the use32 aint required, i still put it in though, try and stop me Very Happy )
as you see, very little differences.. check the manual for more info on syntax of fasm, etc..

oh, and there is a difference, this will create an ELF file, but if your on any modern linux distro, you'll be fine, the kernel can execute both aout and ELF fine (aout is becoming antiguated though (i cant spell... its getting old, and being used less, put it that way Smile))

so assemble that code with fasm kernel_start.asm ks.o

then the rest of the tutorial is the same

edit:
you might have problems with mixing aout and ELF.. but fasm doesnt have a format for aout, and i cant find the header reference, so i cant really code that up. But technically, you should use aout header (anyone else have it handy, feel free to paste it Smile)

oh, and you dont need the _ before the two k_main's when using ELF, but you do when using aout


Last edited by gunblade on 22 Jan 2005, 13:42; edited 1 time in total
Post 22 Jan 2005, 13:07
View user's profile Send private message Reply with quote
mike.dld



Joined: 03 Oct 2003
Posts: 235
Location: Belarus, Minsk
mike.dld
I was doing it like this with MSVC++. In FASM:
Code:
format MS COFF

include '%fasminc%\win32a.inc'

; if you want to use come WinAPI funcs, declare them like:
;extrn '__imp__MessageBoxA@16' as MessageBox:dword

macro p_cproc name,[arg] {
 common
  public name as '_'#`name
  cproc name,arg
}

section '.text' code readable executable

p_cproc m_strncpy,p_str1,p_str2,dw_num
    push    edi esi
     mov     edi,[p_str1]
        mov     esi,[p_str2]
        mov     ecx,[dw_num]
        cld
 rep     movsd
       pop     esi edi
     return
endp    

After that, C-code:
Code:
extern "C" dword m_strncpy(char*,char*,dword);    
Post 22 Jan 2005, 13:20
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
b0b



Joined: 22 Jan 2005
Posts: 4
b0b
Im on Windows XP, so I use the DJGPP tools (even if it's DOS).
Post 22 Jan 2005, 15:06
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
b0b, get the free vc2003 kit from microsoft - it's one of the best performing x86 compilers around, it's very standards compliant, and it's free and with a very liberal license (you can use it to develop your own OS if you want): http://msdn.microsoft.com/visualc/vctoolkit2003/
Post 23 Jan 2005, 12:27
View user's profile Send private message Visit poster's website Reply with quote
Juras



Joined: 18 Jun 2003
Posts: 23
Location: Belarus
Juras
what linker should then be used??? :-O
Post 22 Feb 2005, 21:16
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
SadKo



Joined: 22 Jun 2004
Posts: 5
Location: Russia
SadKo
I use Watcom C/C++ compiler (you can download it on http://www.openwatcom.org/).
Post 19 Nov 2005, 21:43
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
jdawg



Joined: 26 Jun 2005
Posts: 39
jdawg
One question. How did you get away from being forced to produce code for another executable image type than the standard ones for your O.S. using C/C++?
Post 03 Dec 2005, 09:35
View user's profile Send private message Reply with quote
DataHunter2009



Joined: 10 Jun 2005
Posts: 144
DataHunter2009
When I compile that code kernel_start.asm code, I get a "PE operations on Non-PE file" error in the linker. Any ideas?
Post 11 Dec 2005, 21:27
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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 YouTube, Twitter.

Website powered by rwasa.