flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution
Because fasm is not a C compiler! fasm does not "look into" the strings and convert \r things to 0x13 like C does.
|
|||
![]() |
|
Borsuc
Why not define the string manually? You will have much more control over it that way
![]() e.g: Code: string db 'a = %s ',13,10,' b = %s' cinvoke printf,string, 'apple', 'boy' _________________ Previously known as The_Grey_Beast |
|||
![]() |
|
LocoDelAssembly
Also:
Code: cinvoke printf, <'a = %s', 13, 10, 'b = %s'>, 'apple', 'boy' But note that printf will expand 10 (\n) into CRLF when used on Windows so you don't need to do it explicitly and better you don't do it that way so you can reuse the code in Linux without any trouble. |
|||
![]() |
|
sleepsleep
Quote:
i know fasm is not c compiler. but isn't it the convert task should be done by that particular "function printf()" instead of compiler? i mean, it is that function job to detects "\n" in the string pointer and do the CRLF itself.. assembler/compiler just pass the string pointer to this function, so.. i don't quite get it when you said compiler does the conversion. |
|||
![]() |
|
revolution
A C compiler converts the backslash (\) escape codes at compile time.
printf converts the percent (%) escape codes at runtime. |
|||
![]() |
|
sleepsleep
ok, i think i get it.
but somehow i found it weird, why c compiler doesn't let printf handles backslash (\) at runtime. is there any specific reason or it just ... tradition? |
|||
![]() |
|
vid
Quote: is there any specific reason or it just ... tradition? Why should it be handled at runtime, if it can be handled once during compilation? You don't handle at runtime some thing whose result is same on every run. That is wasting of time. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.