Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 1st, 2006, 6:47 PM   #1
GoldenArms
Newbie
 
Join Date: Jul 2006
Posts: 8
Rep Power: 0 GoldenArms is on a distinguished road
quick question

If I write the same exact program in these three asm translators : nasm, fasm, masm, will the executable code generated by the assembler be the same? (and they're all assembled on the same platform, same processor)
GoldenArms is offline   Reply With Quote
Old Jul 1st, 2006, 6:50 PM   #2
Wizard1988
Professional Programmer
 
Wizard1988's Avatar
 
Join Date: Oct 2005
Location: Chitown
Posts: 416
Rep Power: 3 Wizard1988 is on a distinguished road
Send a message via AIM to Wizard1988
You should try it and see for yourself using a hex editor
Wizard1988 is offline   Reply With Quote
Old Jul 1st, 2006, 8:41 PM   #3
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 3 Narue is on a distinguished road
Unless it's an extremely trivial program, I wouldn't count on it. But this is easily testable.
__________________
Even if the voices aren't real, they have some pretty good ideas.
Narue is offline   Reply With Quote
Old Jul 2nd, 2006, 9:46 AM   #4
uman
Expert Programmer
 
Join Date: Dec 2004
Posts: 794
Rep Power: 4 uman is on a distinguished road
Why not? Isn't asm little more than a set of mnemonics for machine language (or as most retards call it, "binary")? How could it be translated in different ways by different assemblers?

By the way, the exact same source text wouldn't even be assembled by each of those assemblers, I assume you meant that you would write a NASM, TASM and MASM version of the same program.
__________________
Few people deserve to be compared to (Rush) Limbaugh, most of them were convicted at the Nuremburg trials.
--WilliamSChips on Slashdot
uman is offline   Reply With Quote
Old Jul 2nd, 2006, 11:23 AM   #5
Wizard1988
Professional Programmer
 
Wizard1988's Avatar
 
Join Date: Oct 2005
Location: Chitown
Posts: 416
Rep Power: 3 Wizard1988 is on a distinguished road
Send a message via AIM to Wizard1988
The assembler specifics would have to be different but the code itself would be different. Golden was asking if that would produce identical executables.
Wizard1988 is offline   Reply With Quote
Old Jul 2nd, 2006, 11:36 AM   #6
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
It isn't a simple yes-or-no answer, even though the OP specified the assemblers to consider and that the platforms and processors were identical. Consider that it's a Pentium processor but that one of the assemblers is set to produce code that will run on an 8086 while another is not. In some instances, simple code would produce identical outputs; in others, it would not.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 2nd, 2006, 3:26 PM   #7
GoldenArms
Newbie
 
Join Date: Jul 2006
Posts: 8
Rep Power: 0 GoldenArms is on a distinguished road
thanks for all of your input.
I'd like to concentrate on learning nasm, but would it work on windows? Through some reading im under the impression that asm langs are specific to processors and the OS shouldn't matter?
GoldenArms is offline   Reply With Quote
Old Jul 2nd, 2006, 3:49 PM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
You need some more in-depth study. If you want your apps to work under Windows, regardless of the language you use to produce them, you have to interface with all that OS code that makes the system run. One can write directly for a platform/processor just about however they want, but you won't see much without a hell of a lot of work. If you want to mesh with an OS (whatever it is) to take advantage of the lebenty-zillion things they already did FOR you, then you play by their rules (or figure out how to break them without ill effects).
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 2nd, 2006, 4:00 PM   #9
GoldenArms
Newbie
 
Join Date: Jul 2006
Posts: 8
Rep Power: 0 GoldenArms is on a distinguished road
meaning id have to concentrate on the operating system's api almost as much as the assembly language?
does it matter which asm language i choose, i also read that its just up to ones preference and that as far as capabilities are concerned, they arent really different from each other.
GoldenArms is offline   Reply With Quote
Old Jul 2nd, 2006, 5:26 PM   #10
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
If you're into learning bare-bones assembly and not being constrained by an OS, buy an SBC, add an LED display and a 10-key pad. I don't know what you mean by "not different". At the simplest level, assembly language is a set of mnemonics representing the patterns of binary signals that trigger the hardware logic associated with the operations of the CPU. Sometimes, there's microcode involved, also. The bit patterns (bit meaning 'binary digit') that cause a particular operation (load a register with an immediate value, say) are rarely the same between microprocessors simply because the circuitry is laid out differently.

A modern, desktop OS is organizing the use of the CPU, providing interface capabilities, managing memory, and tons of other things that you have to work to get past if you want the lowest level of interaction with the CPU. Otherwise, you have to accomodate it or risk triggering destructive effects who's severity varies widely.

Incidentally, as you can see from the source of the word, 'bit', it isn't really retarded to refer to machine language as 'binary.'
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers

Last edited by DaWei; Jul 2nd, 2006 at 5:37 PM.
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:15 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC