Author Topic: Beginner question - would this work on any CPU?  (Read 361 times)

securityaudit

  • Regular Member
  • *
  • Posts: 5
Beginner question - would this work on any CPU?
« on: June 18, 2018, 09:44:30 PM »
Hello MASM32,

I have spent a few years coding in C and Java. I enjoy how I can make a program display a message box or perform some file operations and it works on every (I think?) CPU without any dramas. Although I have never coded anything advanced.

I want to learn assembly, to make programs for Windows only. I believe I should learn MASM32?

My question: provided I do not want to do something too crazy or obscure, will programs I create work on every CPU? My focus is on your average computer at home or perhaps servers. Not anything super obscure that mad scientists have in their labs (sorry to exaggerate).

I have had many people tell me that I have to pick a specific architecture for a specific CPU from many reputable sources, but I am then shown code examples that work on several different CPUs... conflicting information!

Helppppppp I am going crazy :p and thank you!

EDIT: This is a CPU question not an operating system question, although I have an OCD (obsessive compulsive disorder) problem where I ensure backwards compatibility with Windows 95 sometimes haha.
« Last Edit: June 19, 2018, 12:50:23 AM by securityaudit »

jj2007

  • Member
  • *****
  • Posts: 8507
  • Assembler is fun ;-)
    • MasmBasic
Re: Beginner question - would this work on any CPU?
« Reply #1 on: June 18, 2018, 10:47:38 PM »
I want to learn assembly, to make programs for Windows only. I believe I should learn MASM32?

Yes. Practically all Windows computers understand x86. Programs written in Masm32 ten years ago run just fine on the latest Windows 10 version.

Welcome to the Forum :icon14:

zedd151

  • Member
  • ****
  • Posts: 706
Re: Beginner question - would this work on any CPU?
« Reply #2 on: June 19, 2018, 12:15:57 AM »
Welcome to the forum,   :biggrin:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5484
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Beginner question - would this work on any CPU?
« Reply #3 on: June 19, 2018, 12:29:20 AM »
When you speak of a language that will work on all CPU's I guess you are talking about x86-64, portable device and many other hardware types and a dedicated assembler for x86-64 is not the tool you are after, You need a language like JAVA, some versions of C/C++ or perhaps some other language that is what is called "portable". Sad to say in your case x86-64 assembler will only work on one type of CPU and while they are the most used in PCs, it won't work at all on non x86-64 processors.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

securityaudit

  • Regular Member
  • *
  • Posts: 5
Re: Beginner question - would this work on any CPU?
« Reply #4 on: June 19, 2018, 12:48:26 AM »
@hutch--

I think you looked a little too deep into my question, my question is a noob question, but your reply was helpful.

Pretend I write a basic program in C, using Visual Studio 2010. It displays a message box saying hello world, deletes a file and gets the user's username.

If I write the above program using MASM instead will it work on the same CPUs as the C program would?

Lastly, if the above is true what other asm "languages" should I learn, NASM or one called x86?

Essentially, the reason I am confused is I always thought simple C programs would just work on any computer's CPU, but it appears as if Asm is picky and is compatible with less CPUs? I might be completely wrong and confused... I am just trying to make a simple Windows 32 program :p.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5484
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Beginner question - would this work on any CPU?
« Reply #5 on: June 19, 2018, 01:16:51 AM »
No, sad to say I told you the truth, C is a portable language that can run on many different families of processors, this you cannot do with any assembler. From memory NASM can be built on other than x86-64 hardware but I am not up to date on the details.  For example if you wanted to run an application on ARM hardware, x86 is different and just won't work and of course vice versa. You need a portable language that can be built on different systems with different hardware, this cannot be done with an assembler.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

daydreamer

  • Member
  • ***
  • Posts: 467
Re: Beginner question - would this work on any CPU?
« Reply #6 on: June 19, 2018, 01:29:50 AM »
Welcome to forum :t
Quote from Flashdance
Nick  :  When you give up your dream, you die.
*wears a flameproof asbestos suit*

jj2007

  • Member
  • *****
  • Posts: 8507
  • Assembler is fun ;-)
    • MasmBasic
Re: Beginner question - would this work on any CPU?
« Reply #7 on: June 19, 2018, 01:38:35 AM »
As Hutch wrote, a C program would run on other cpus, too. But that is not what you are after: you want a program that runs on a Windows computer, period. Masm32 programs will run on any Windows computer (ok, show me one that doesn't have an x86 or x64 cpu...).

You have the choice, though, between:
- the Masm32 SDK (copyright Hutch, it is his baby): mature, runs on both x86 and x64 cpus, and practically all Windows versions
- one of the Masm64 SDKs (the most advanced one is from Hutch again, but that is a long story): in constant development, runs on Windows 64-bit versions only.

For a beginner, Masm32 is much easier, and it offers more functions. Perhaps you should explain a little bit more why you want to write Windows programs: for your own hobbyist use, or in the hope of selling something later, ...?

securityaudit

  • Regular Member
  • *
  • Posts: 5
Re: Beginner question - would this work on any CPU?
« Reply #8 on: June 19, 2018, 01:59:20 AM »
@jj2007

Butt kissing: I love you - not to give you wrong idea!

More butt kissing: I have searched for years and spent all day today hammering everything to get this answer. People kept talking about ARM and all of this stuff when I indeed only cared about Windows! Thank you, I seriously love you right now!

Question: I think 99.999% of Windows computers will have a x86 or x64 CPU, so my program will work fine just like if it were coded in C, correct?

Just to confirm: Aside from MASM32 or MASM64, there is no other asm I could learn that works on Windows, because I heard of NASM? I also believe one is called x86 but that might be something else?

Off topic: What is the lowest version of Windows MASM32 can make a program for? No need to go lower than Windows 95.

Answering your question: I am an auditor but I do Red Team, Blue Team and Penetration Tests. I already have a good background in C, I adore the Windows API too. Essentially, I want to improve my malware creation skills (for engagements only), I know it's like using a tiny paintbrush but I enjoy having backwards compatible programs with tiny file sizes. Lastly, I would like to learn some reverse engineering for when I go into Threat Hunting or similar fields. I think rootkit development also requires asm...

Edit: This looks like a very good book for beginners, it also seems to suggest that NASM, FASM etc... can create Windows programs https://www-s.acm.illinois.edu/sigwin/old/workshops/winasmtut.pdf

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5484
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Beginner question - would this work on any CPU?
« Reply #9 on: June 19, 2018, 02:49:35 AM »
> Essentially, I want to improve my malware creation skills

This will get you booted out of here, we have an absolute no malware policy and it is not negotiable.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

felipe

  • Member
  • ****
  • Posts: 867
  • Eagles are just great!
Re: Beginner question - would this work on any CPU?
« Reply #10 on: June 19, 2018, 04:55:24 AM »
 :biggrin: What a funny new member, really don't know if is a joke or is real... :idea:
Felipe.

securityaudit

  • Regular Member
  • *
  • Posts: 5
Re: Beginner question - would this work on any CPU?
« Reply #11 on: June 19, 2018, 05:31:35 AM »
> Essentially, I want to improve my malware creation skills

This will get you booted out of here, we have an absolute no malware policy and it is not negotiable.

Don't worry I will not post on here asking for help related to it, if you have any doubts I invite you to contact me privately and you can look at my LinkedIn (I work for a multinational that does security audit).

At the moment I will use what you have given me for programming related things.


:biggrin: What a funny new member, really don't know if is a joke or is real... :idea:

They were genuine emotions earlier as I wanted to know for YEARS which instruction set I should learn, I always got bored when I searched for help. It took me a whole day to get that simple piece of information that jj2007 posted!

Anyway probably getting banned now as hutch-- thinks I am some big hacker LOL.

Raistlin

  • Member
  • ***
  • Posts: 353
Re: Beginner question - would this work on any CPU?
« Reply #12 on: June 19, 2018, 05:42:49 AM »
I luv the way all of this starts of ALL benign...and then escalates
to hacking the world. What a dip-pseudo-frack idea. Anything
made by man can be destroyed by man (NAN). Can you create it in the first place ? Can you make perfection ? And if you could & understood what it was, could you destroy it ?

IF only they knew the power of the FORCE.  :t

Dear supreme new generation hacker, I can do exactly what you want.  BUT would I ?

NO because building knowledge is more important, ALWAYS, versus crapping about. If you really were set
on security, then be secure yourself  first. You now know what I mean.
« Last Edit: June 19, 2018, 03:49:34 PM by Raistlin »
Are you pondering what I'm pondering? It's time to take over the world ! - let's use ASSEMBLY...

felipe

  • Member
  • ****
  • Posts: 867
  • Eagles are just great!
Re: Beginner question - would this work on any CPU?
« Reply #13 on: June 19, 2018, 05:48:19 AM »
Nice words? Raistlin  :biggrin:

security audit, sorry, but it seemed very strange to me what you have said about your job and your current knowledge. Maybe is normal there? Don't know... :idea:
Felipe.

Siekmanski

  • Member
  • *****
  • Posts: 1550
Re: Beginner question - would this work on any CPU?
« Reply #14 on: June 19, 2018, 07:04:24 AM »
-> I work for a multinational that does security audit.

Camera Security?
Creative coders use backward thinking techniques as their strategy.