flat assembler
Message board for the users of flat assembler.
Index
> High Level Languages > Alternative to gcc Goto page 1, 2 Next |
Author |
|
revolution 14 Mar 2010, 02:21
For the second question: the C standard lib requires an already existing OS to function. Each version of the C lib is OS specific. So, no, you can't write an OS with the C lib functions.
|
|||
14 Mar 2010, 02:21 |
|
Tyler 14 Mar 2010, 05:54
Thanks. I guess it's also rather important to mention that the compiler needs to be available for linux.
On the topic of the C lib, most functions are straight forward, like printf(), I could do that in 30 minutes(after doing the real work like setting up a terminal), but, the one I mentioned above does not seem so easy. How would I go about allocating memory. What level does malloc effect, like when an app calls malloc, does the function call the kernel, which in turn would allocate the specified amount, which would effect the whole system, or is the memory allocated within the app's data segment, in which case malloc would only effect the specific segment? So far, in the function the kernel uses, I allocate byte by byte with an int variable to keep track of allocated bytes and an array to hold the actual locations of the allocated bytes. Is this an acceptable way? |
|||
14 Mar 2010, 05:54 |
|
revolution 14 Mar 2010, 06:02
Memory allocation is always done by the OS. The C lib will just pass on the request to the OS.
|
|||
14 Mar 2010, 06:02 |
|
rxantos 24 Apr 2010, 13:47
revolution wrote: Memory allocation is always done by the OS. The C lib will just pass on the request to the OS. Some OS'es only have calls to allocate memory in big chunks, and thus malloc/free have special code for doing smaller allocations. |
|||
24 Apr 2010, 13:47 |
|
LocoDelAssembly 24 Apr 2010, 14:32
And perhaps even in Windows LocalAlloc and such are resolved by the OS (by OS I mean non user-mode code) ONLY when it is time to allocate more memory pages?
|
|||
24 Apr 2010, 14:32 |
|
peter 26 Apr 2010, 02:04
AFAIK, there is no C compiler with FASM-like inline assembly syntax, but check Pelles C, which is small, C99-compliant, with MASM syntax (as opposed to GCC's AT&T syntax). Just like MSVC, it has no support for x86-64 inline assembly, unfortunately
|
|||
26 Apr 2010, 02:04 |
|
Tyler 26 Apr 2010, 02:34
I was just hoping to avoid AT&T syntax. It doesn't look too hard, just looks like it'd be annoying to type all the %s and other seemingly unnecessary characters.
Pelles C's homepage wrote:
Cool. I wonder if revolution knows about this. |
|||
26 Apr 2010, 02:34 |
|
Fanael 26 Apr 2010, 06:54
GNU assembler understands Intel syntax:
Code: asm volatile(".intel_syntax noprefix\n" /* or pass -masm=intel to GCC and then */ "lea eax, dword ptr [esi + ebx * 4]\n" ".att_syntax prefix\n" /* these two lines won't be necessary */); |
|||
26 Apr 2010, 06:54 |
|
Tyler 26 Apr 2010, 07:33
Are the "\n"s necessary?
|
|||
26 Apr 2010, 07:33 |
|
peter 26 Apr 2010, 12:46
Yes, it's necessary. GCC passes your assembly code to GNU assembler (use -S switch to view the generated assembly file, where your code is inserted). "\n" is used to separate lines; "\n\t" is also used to align them. See GCC manual.
Fanael, thanks, I did not know that it's possible to use Intel syntax with GCC. Much more readable than AT&T's percents and parentheses Code: lea eax, dword ptr [esi + ebx * 4 - 0x10] vs Code: leal -0x10(%esi, %ebx, 4), %eax |
|||
26 Apr 2010, 12:46 |
|
Tyler 26 Apr 2010, 20:55
So basically, I could use Intel syntax(*Fasm dialect*) with GAS? Not that I plan to defect, but the possibility to use headers in my assembly code would be nice at times, like when mixing asm and C. Either way, that's still good to know, thanks Fanael.
|
|||
26 Apr 2010, 20:55 |
|
vid 26 Apr 2010, 21:15
Quote: So basically, I could use Intel syntax(*Fasm dialect*) with GAS? If you added code for that to gcc... which would be quite bothersome. No, don't think of using FASM header directly in C source. Create a separate asm module, compile to proper object file format, create C header for it, and link it with C code. But FASM kinda sucks for being mixed with other languages, because you cannot control it from command line, as you do with all other languages. |
|||
26 Apr 2010, 21:15 |
|
baldr 27 Apr 2010, 08:01
vid,
Environment variable expansion in include and file directives' file name argument can be used to weaken SSSO principle. |
|||
27 Apr 2010, 08:01 |
|
vid 27 Apr 2010, 08:19
Yeah, but you still need to generate fasm header from something else that applies project-wide (command line options, common inter-language config file, etc.)
|
|||
27 Apr 2010, 08:19 |
|
Fanael 27 Apr 2010, 11:29
Tyler wrote: So basically, I could use Intel syntax(*Fasm dialect*) with GAS? |
|||
27 Apr 2010, 11:29 |
|
Tyler 28 Apr 2010, 03:12
vid wrote:
I know how tho mix fasm with C(your tut helped with that)but, I was saying that using C headers in my asm code would be useful. For example, being able to include "stdio.h" and then the assembler know what stdin and other variables defined in stdio are, would be great. |
|||
28 Apr 2010, 03:12 |
|
vid 28 Apr 2010, 08:20
Quote: I know how tho mix fasm with C(your tut helped with that)but, I was saying that using C headers in my asm code would be useful. For example, being able to include "stdio.h" and then the assembler know what stdin and other variables defined in stdio are, would be great. That is not always possible. Some "variables" are in fact defined as macros, that call some internal libc function (errno is usually defined this way). |
|||
28 Apr 2010, 08:20 |
|
baldr 28 Apr 2010, 08:28
Tyler wrote: …being able to include "stdio.h" and then the assembler know what stdin and other variables defined in stdio are… Win32 headers with their occasional L suffixes in constants confuse FASM as much. |
|||
28 Apr 2010, 08:28 |
|
Tyler 22 Jun 2010, 04:19
GCC accepts a "#" as a replacement for "\n\t". It's like the ";" for asm. How do I reference this variable("cur_val")?
Code: struct bigint_t init_bigint_t(unsigned long count, ...) { struct bigint_t new_bigint; for(;count > 0;count--) { block cur_val asm("_cur_val"); asm volatile ( "pop word ptr [cur_val]#" ); } } Right now, I'm getting an error saying cur_val is undefined. Do I need to use some mangled version? |
|||
22 Jun 2010, 04:19 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.