flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > C++ or ASM

Goto page Previous  1, 2, 3, 4, 5  Next
Author
Thread Post new topic Reply to topic
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak
but i am right, right? It is nothing more than sending EAX data which is never used or looked at, just eventually written over.
Post 27 Jul 2006, 20:20
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
As I already explained, the return value (EAX, yes) is used as the system errorlevel. This is generally used to check whether a child app has succeeded or failed. Besides, there are more compilers than MSVC and GCC, and more platforms than 32bit x86... so if you're going to use a language that has a standard, better follow the standard.
Post 27 Jul 2006, 20:27
View user's profile Send private message Visit poster's website Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 382
Location: Finland
okasvi
f0dder wrote:
if you're going to use a language that has a standard, better follow the standard.


Agreed.


kohlrak wrote:
If "the program crashes" it's the same as a program that "crashes" using "int" type.


No, the program should have enough error-checking/use SEH to prevent crashing, and instead of crashing try to fix the problem on it's own(alloc more mem or something like that), and if it doesnt work maybe printf/msgbox and return false to indicate that it was _not_ successfully ran.

_________________
When We Ride On Our Enemies
support reverse smileys |:
Post 27 Jul 2006, 20:37
View user's profile Send private message MSN Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
f0dder: there is absolutely straightforward analogy between calling function about which you know that doesn't return anything, and calling app about which you know it doesn't call anything.

Behavior is undefined SAME way as within application using void funcs. Caller should know what his child returns. It would be something other if system, or somebody who awaits something exact returned, would check your apps returns code, but can you give me some real-world example where this happens
Post 28 Jul 2006, 08:30
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
vid wrote:

would check your apps returns code, but can you give me some real-world example where this happens

I already did - make.exe when processing makefiles. If an application returns a non-zero code, the make process will terminate. Fortunately, both MSVC and GCC work around broken code(!) by making "void main()" returning 0, but there's no guarantee that all C compilers will do this.

And for C++, it's actually a violation of The Standard(TM) to have main return anything but int (GCC enforces this, MSVC doesn't even give a warning).
Post 28 Jul 2006, 11:29
View user's profile Send private message Visit poster's website Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak
okasvi wrote:
kohlrak wrote:
If "the program crashes" it's the same as a program that "crashes" using "int" type.


No, the program should have enough error-checking/use SEH to prevent crashing, and instead of crashing try to fix the problem on it's own(alloc more mem or something like that), and if it doesnt work maybe printf/msgbox and return false to indicate that it was _not_ successfully ran.


Then the program would go through it's error checking and such and close, then having not point to the return code anyway.

Quote:
Behavior is undefined SAME way as within application using void funcs. Caller should know what his child returns. It would be something other if system, or somebody who awaits something exact returned, would check your apps returns code, but can you give me some real-world example where this happens


You mean runtime, correct?

Quote:
I already did - make.exe when processing makefiles. If an application returns a non-zero code, the make process will terminate. Fortunately, both MSVC and GCC work around broken code(!) by making "void main()" returning 0, but there's no guarantee that all C compilers will do this.

And for C++, it's actually a violation of The Standard(TM) to have main return anything but int (GCC enforces this, MSVC doesn't even give a warning).


But you don't compile the app at runtime do you? You just use the EXE. He means runtime, i do beleive. So can you provide an example during runtime that is waiting for the return value?
Post 30 Jul 2006, 07:40
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
kohlrak: it IS valid example, think about writing some utility that will be used in makefile

btw, "void main" is discussed here by some guy Twisted Evil Wink
Post 30 Jul 2006, 16:12
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Hehe, "some guy" Wink
Post 30 Jul 2006, 19:45
View user's profile Send private message Visit poster's website Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak
Well, then, if you're not using the makefile, nothin' wrong with it, eh?
Post 31 Jul 2006, 00:24
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Read the link vid posted, kohlrak. The text is by the guy who made C++.
Post 31 Jul 2006, 01:45
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Quote:
Well, then, if you're not using the makefile, nothin' wrong with it, eh?

well, if you are not using your program from tools that await return value. but you never know who will use your tool, and he can stick to standard.

but this hole is IMHO finely fixed by making "void main()" always return 0. You don't care what it returns (thus "void"), and if caller cares he always gets 0
Post 31 Jul 2006, 11:39
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
rwalt



Joined: 27 Apr 2004
Posts: 19
Location: Illinois, USA
rwalt
The vast majority of all software is written in C++. Learn C++. Get really good at reading and writing C++ programs.

With the rise of Mac OS X's popularity (it just blows Windows away), another language to consider is Objective-C.

_________________
DarkStar
Post 20 Aug 2006, 20:16
View user's profile Send private message Reply with quote
Maverick



Joined: 07 Aug 2006
Posts: 251
Location: Citizen of the Universe
Maverick
Objective-C IMHO is inferior than C++. I see no point in learning Objective-C when you have access to good quality ISO C++ compilers.
Post 21 Aug 2006, 08:24
View user's profile Send private message Visit poster's website Reply with quote
rwalt



Joined: 27 Apr 2004
Posts: 19
Location: Illinois, USA
rwalt
Yes, I agree that C++ is better. The Cocoa.Framework for OS X is implemented in OC, you can use C/C++ for the Carbon.Framework though, it's more like the Win32 API in how you build .app files for OS 10.4.

Xcode is a really nice IDE.

_________________
DarkStar
Post 22 Aug 2006, 05:27
View user's profile Send private message Reply with quote
Maverick



Joined: 07 Aug 2006
Posts: 251
Location: Citizen of the Universe
Maverick
Yup, and it's free and, even better, comes with every Mac. Smile

Recall the 8bit home computer days when you got a BASIC manual (sometimes even the manual for a built-in assembler/monitor!) with the machine!

Per contra, on Windows the more the user is ignorant, the happier the selling company is. I guess that if every user was more or less a programmer would cut the earnings of many companies selling small, stupid programs.
Post 22 Aug 2006, 06:41
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Humm, what's the "new" GUI layer in OS X? Cocoa or Carbon?
/me forgot
Post 22 Aug 2006, 11:48
View user's profile Send private message Visit poster's website Reply with quote
rwalt



Joined: 27 Apr 2004
Posts: 19
Location: Illinois, USA
rwalt
Probably Cocoa, not sure on that.

You know, it would be cool if you could get FASM to work on the new Intel Macs, but at the Darwin Unix layer the system is 64 bit.

_________________
DarkStar
Post 22 Aug 2006, 18:30
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
It doesn't have a compatibility layer for 32bit apps?

I guess it's not that high priority for Apple... just like it's not high priority having lots of hardware support (actually you could say it's high priority NOT having lots of hardware support, until they give in and let people run x86 OS X on 'standard' PCs).
Post 22 Aug 2006, 21:46
View user's profile Send private message Visit poster's website Reply with quote
rwalt



Joined: 27 Apr 2004
Posts: 19
Location: Illinois, USA
rwalt
Your right, they need to give in and package X for PCs

On the Darwin thing, this is what I get trying to link fasm.o using gcc...

$ gcc fasm.o -o fasm
/usr/bin/ld: fasm.o bad magic number (not a Mach-O file)
collect2: ld returned 1 exit status

At the Unix level X is 64, Cocoa and Carbon are 32. The release next year of 10.5 Leopard promises fully 64 bit up thru the GUI layers, with 32 bit compatibility. And again I agree, they need to package it for PCs too. The next release would be a good start to do just that.

_________________
DarkStar
Post 23 Aug 2006, 05:15
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
The default format for OSX is Apple's Mach-O format, not ELF... dunno if there's a compatbility layer for elf? Or if you could build a cross-compiler version of GCC that supports ELF input but can build Mach-O output.

Btw when saying "At the Unix level X is 64", I hope you're not meaning X11, but rather the "core" of OSX Smile
Post 23 Aug 2006, 10:49
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4, 5  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.