flat assembler
Message board for the users of flat assembler.
![]() Goto page Previous 1, 2, 3, 4, 5 Next |
Author |
|
vid 09 Apr 2006, 21:24
Vortex: how?
|
|||
![]() |
|
rugxulo 10 Apr 2006, 22:08
What GCC are you using? You forgot to strip the result (-s). I'm using DJGPP (GXX 4.01, haven't installed 4.10 yet) and it's only 377k (and only 135k after using UPX, which itself is written in C++). This bloat is atypical of larger programs, so I wouldn't worry about it. However, yes, I would suggest you study other languages before jumping on the C++ bandwagon completely. A little tinkering is okay, but don't put all your eggs in one basket (heh, Happy Easter!).
![]() Plue wrote:
|
|||
![]() |
|
Adam Kachwalla 03 May 2006, 06:24
Why bother with high-level languages? The file ends up being ten thousand times larger than it is supposed to be! Pure assembly language (and pure machine xode) is the best way to go, because you can control all the bytes placed in the file.
|
|||
![]() |
|
f0dder 03 May 2006, 10:59
How on earth can you get that simple C++ sample so large? Without using *ANY* tricks, it compiles and links to ~27kb with vc2003. It goes to ~73kb if I add
Code: cout << "Hello, world!\n"; or ~45kb if I use printf instead. If I skip the system() call and link with Jibz WCRT library instead of the default CRT, again using no dirty tricks like section merging, the exe is down to 3.072 bytes. And that's with the formatting power of printf... |
|||
![]() |
|
rugxulo 04 May 2006, 06:55
f0dder, I'm sure some of that functionality is in the OS, so the size comparison probably ain't entirely fair. Besides, there are better examples (see below) than this useless snippet we're referring to. Also, I wonder why it links in the whole printf() if the string requires nothing but a puts().
![]() Here's a better example (since UPX is written in C++): UPX 2.00 for DOS (DJGPP2/COFF): 647,168 bytes (277,676 packed) UPX 2.00 for Windows (WIN32/PE): 490,496 bytes (198,144 packed) EDIT: UPX for DOS supports "upx --best .../*.exe" for recursive dir searching/running, unlike the Win32 version. This should be taken into account when comparing filesizes. P.S. OpenWatcom 1.6 is released. You can also download individual .ZIPs for a partial install if you don't need everything (help docs, C++, Win32 target files, etc.). Last edited by rugxulo on 28 Dec 2006, 20:52; edited 1 time in total |
|||
![]() |
|
f0dder 04 May 2006, 09:27
Quote: f0dder, I'm sure some of that functionality is in the OS, so the size comparison probably ain't entirely fair. Well, if there's OS support, why not use it? ![]() But yes, iirc Jibz WCRT does use wsprintf - which also means it doesn't support floating point formatters. Jibz is working on that, though, but it's currently only in beta and he's hard pressed for time, real life and all that. Quote:
Glad to see I'm not the only one thinking that measuring "hello, world" size is useless. Quote:
Because I used `printf` and not `puts` ^_^ - on purpose, to show that you can get printf without very much overhead. Quote:
For DOS, you need a *lot* of code because there's not much OS support. The Windows version of UPX seems to be compiled with GCC, which isn't exactly known for good&tight code generation (comparing GCC3 to VC7+, that is - GCC4 is appearantly better, but I haven't found a win32 port yet so I haven't played with it myself.) But sure, UPX would be one of the somewhat large executables for what it does - it uses a bunch of not-so-trivial C++ features, and used those before the C++ community knew how to "do it well". If you look at the UPX source you'll see that it is *not* a very pretty sight ![]() Quote:
That's interesting - I haven't used Watcom for several years. How is it's code generation compared to VC7 and later? It used to be good in the DOS days, but last I checked Intel and Microsoft compilers produced quite better results. |
|||
![]() |
|
rugxulo 05 May 2006, 04:29
f0dder wrote:
Bah, and they say compilers know everything these days. ![]() Quote: For DOS, you need a *lot* of code because there's not much OS support. That's part of its charm. ![]() Quote: If you look at the UPX source you'll see that it is *not* a very pretty sight I only looked at a little, but it actually seemed pretty clean and nice, comparatively, to my eyes. Then again, C++ is all Greek to me. ![]() Quote: That's interesting - I haven't used Watcom for several years. How is it's code generation compared to VC7 and later? It used to be good in the DOS days, but last I checked Intel and Microsoft compilers produced quite better results. I don't have VC7 or Intel compilers, so I dunno. Anyways, Open Watcom seems pretty good to me, getting stronger with every new version. There really is no magic compiler: it all depends on what you know, what you intend, and how you use it. OW has been called the potential DJGPP killer (if you can believe that!). P.S. I know this is the wrong thread, but...UPX has no memory overhead for most formats. So, maybe using it blindly for everything would be bad, but most medium-sized, non-concurrent Win9x programs are okay. |
|||
![]() |
|
f0dder 05 May 2006, 10:46
Quote:
You can get VC7.1 (2003) from Microsoft for free - the full optimizing version. And the license is pretty liberal, you could even use the compiler to write your own OS. That's pretty interesting, since MS's for-free software downloads usually have very restrictive licenses. Quote:
I'm not too fond of DJGPP, although it was my main C++ compilers years back. Has to do with it's file format and the standard library. If I needed to do 32bit dos development these days, I would use Visual C++ and probably the HX dos extender. Quote:
Perhaps not overhead in the amount of bytes used (ie, "in-place decompression") - but for multitasking protected mode operating systems, it will result in "dirty pages", as mentioned before. Dirty pages are bad. |
|||
![]() |
|
rugxulo 09 May 2006, 13:05
Quote: I'm not too fond of DJGPP, although it was my main C++ compilers years back. Has to do with it's file format and the standard library. If I needed to do 32bit dos development these days, I would use Visual C++ and probably the HX dos extender. HX is useful in DOS for its Windows emulation. I like it. However, so far I've only bothered to run two programs with it: e3 (Win9x version, vi interface, mainly because the 16-bit DOS version stinks) and the Windows console version of 7-Zip. There are some other good DOS extenders, too (WDOSX, DOS/32A, Causeway, PMODE, etc.). If you don't like DJGPP, that's fine. It's not perfect (yet, heheheh), but it does have POSIX compatibility, supports LFNs, and is free. I've noticed that lots of my favorite DOS stuff was compiled by it. Plus, all those GNU utils don't hurt either. ![]() BTW, your VC link at http://f0dder.has.it is outdated. I'm not majorly interested in trying it (too huge!), since DJGPP and OpenWatcom are much more interesting to me for my hobbyist needs (for now): ![]() Quote:
|
|||
![]() |
|
f0dder 10 May 2006, 12:19
I used to use WDOSX myself, "back in the days" - but it's not been under development for quite some time. HX seems to be quite decent and still supported.
My main reason for not liking DJGPP is actually the POSIX stuff ![]() Quote:
Oh crap. So now you can't download the relatively small VC2003 package but have to get the full VC2005 Express... Well, check this link out: http://www.softpedia.com/get/Programming/Other-Programming-Files/Microsoft-Visual-C-Toolkit.shtml . EDIT: oh well, at least the express editions won't stop being free: Effective April 19th, 2006, all Visual Studio 2005 Express Editions are free permanently. -- http://msdn.microsoft.com/vstudio/express/support/faq/ |
|||
![]() |
|
OzzY 12 May 2006, 19:25
I was thinking about downloading the express edition, since it's now forever free... but it seems it requires winxp sp2, and mine is sp1
![]() |
|||
![]() |
|
f0dder 13 May 2006, 10:14
OzzY wrote: I was thinking about downloading the express edition, since it's now forever free... but it seems it requires winxp sp2, and mine is sp1 Get SP2 then ![]() It might be possible to manually extract the install files and get just the compiler, linker and libraries that way... haven't tried, though. _________________ ![]() |
|||
![]() |
|
OzzY 13 May 2006, 20:38
SP2 is a ruge download and I'm trying to keep my system as light as possible.
Does SP2 installation requires a serial number or something? Because I lost my serial. (Soon, I'm moving to Linux anyway...) How much time does it take to download and install SP2? Quote: It might be possible to manually extract the install files and get just the compiler, linker and libraries that way... haven't tried, though. What do you mean? I tried unpacking the internet-installer version (which downloads the files and install) with WinRAR and it extracted! But, are you talking about extracting the full ISO version? And how would be the setup of the files? (just unpack?) Thanks |
|||
![]() |
|
f0dder 13 May 2006, 20:58
If you're using a pirated XP with the "DevilsOwn" cdkey, then don't install SP2
![]() How much time it takes to download and install depends on your internet connection. It *is* rather large, close to 270 megabyte for the english version. As for install time, you can either apply SP2 to a currently installed XP, or you can slipstream the service pack and make a bootable windows install CD that includes it (http://www.nliteos.com + http://www.ryanvm.net/msfn/ makes for some very LEAN_AND_MEAN windows installs!). Quote:
I was thinking the ISO version, yes... I haven't really looked at it, but I guess MS uses cab files as usual, so it should be possible to locate compiler, linker, libraries, includes in there... if it's .MSI based you'll need different tools, but I think MSI decompilers are available nowadays? |
|||
![]() |
|
rugxulo 14 May 2006, 00:27
f0dder wrote: I used to use WDOSX myself, "back in the days" - but it's not been under development for quite some time. Feb. 2005 isn't really that long ago. But, yeah, development has apparently stopped. ![]() Quote: HX seems to be quite decent and still supported. Yes, it is. Go Japheth go! ![]() |
|||
![]() |
|
kohlrak 23 Jul 2006, 17:17
all a big read for me with such little time.
C is a fast HLL while C++ is a slower more secure HLL. Master them both, then use a disassembler and cut out what isn't used but still included anyway. Then clean "the garbage bytes". And yes, i'd know this would be hard. I'm sure you can do something like the following to find out where your program begins and ends or certain aspects of part of the program where you might wanna use faster or different calculation methods: Code: char identA[]="Alright, here i am. This is identA where you shall look for me using a hex editor or disassembler. Oh yea, and incase you forget what this line is, you can use the following password to find me faster: 7da33d"; // note: 7da33d is your favorite password. Note: The code won't include the in text newlines. lol |
|||
![]() |
|
f0dder 24 Jul 2006, 10:58
[quote=kohlrak]
C is a fast HLL while C++ is a slower more secure HLL. [/quote] Nonsense ![]() C++ is a multiparadigm language; you can write procedural code, object-oriented code, template metaprogramming code... it's speed depends on the code you write (and the compiler), nothing about C++ makes it automatically slower than C. Nor more secure, really, if you still use libc. And you can still write high-performance code even if it's object-oriented, you just need to know what you're doing (and use a non-retarded compiler). [quote=kohlrak] Master them both, then use a disassembler and cut out what isn't used but still included anyway. [/quote] That's silly. Just write your code properly instead. Use an alternative libc/runtime if the one you have isn't good enough. And if you really feel like doing the silly "cutting", use your compiler switch to generate an assembly listing instead of going through a disassembler. |
|||
![]() |
|
kohlrak 24 Jul 2006, 15:57
Quote: C++ is a multiparadigm language; you can write procedural code, object-oriented code, template metaprogramming code... it's speed depends on the code you write (and the compiler), nothing about C++ makes it automatically slower than C. Correct, but when you learn C++, most of the time thy don't tell you about printf over cout << or any other C equivalents, they just tell you the C++'s standard library (even though it's not part of the C++ language, and is only included with almost every compiler). That's the problem, they teach you the slow stuff... It was only by a random topic i found in another community that told me that the C equivalents were faster and that there even were any. Quote: Nor more secure, really, if you still use libc. I'm not sure how it works, but sometimes in C, you can make calls to functions and not fill all the parameters. It's this assembly too, not all macros or functions have to have their parameters filled. The alert boxes come to mind. That makes C++ a little easier to debug than C or assembly, which shouldn't really matter to the perfect coder, but everyone makes mistakes. Here's a tip for your friends though, make them learn assembly, cause you won't beleive how much un-worth it, it really is. Quote: 1 What's Wrong With Assembly Language Something i saw from a web page i'm learning Assembly off of. And it's very true that how many people who know C++ or such Curse at assembly. Why? the time consuming thing. I'm not kidding you, a C++ teacher at my school said he saw his friend coding in assembly and he thought it was crazy or insane. |
|||
![]() |
|
Patrick_ 24 Jul 2006, 22:12
Adam Kachwalla wrote: Why bother with high-level languages? The file ends up being ten thousand times larger than it is supposed to be! Pure assembly language (and pure machine xode) is the best way to go, because you can control all the bytes placed in the file. Assembly is great... it's my favorite language, even before C. But in some cases, dealing with APIs in assembly is just a pain in the butt. Therefore, a higher-level language is a bit more practical in that matter. Also, portability is an issue with assembly. For apps I know I don't want to run on Windows, I use assembly (I use Linux only). Otherwise, I'll probably use C, unless the program can run fine in LINE. When I code in C, I use the following flags, to create a very small executable (nowhere near as small as pure assembly, however): gcc -Os -s -fomit-frame-pointer -o app app.c;strip app;upx --brute app Last edited by Patrick_ on 25 Jul 2006, 14:31; edited 1 time in total |
|||
![]() |
|
Goto page Previous 1, 2, 3, 4, 5 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.