'A simple assembly program?

I've recently learned how to use MASM from MSVC++ IDE, and to test whether it works, I would like to run a short program.

However, I don't know any assembly yet (that which I do is useless: ie: even though I know what i+=1; is in C++, I can't do anything without int main()).

So where can I find a simple assembly program akin to the helloworld program used with C++? (It doesn't actually have to display "Hello, World!", it just has to do something so that I can make sure the set-up I have works).



Solution 1:[1]

Here is the MASM documentation online: http://web.sau.edu/LillisKevinM/csci240/masmdocs/

Here is the difinitive tutorial on assembly: http://webster.cs.ucr.edu/

I think that between the two of those you should be able to get up to speed and start writing programs.

Solution 2:[2]

To get you into a quick start I would suggest the following sites: RADasm and WinASM.

From these sites you can find some examples, some prepackaged downloads with IDE and compiler. This way it is actually pretty easy to do some GUI-software early on but be warned, take care to read about x86 assembly. Check out wikibooks - x86 assembler.

Solution 3:[3]

Try this

global _main

_main:
mov ax, 0x01
mov bx, 0x02

inc ax
inc bx

jmp _main

Explanation:

1°_ you're saying to nasm to search for a _main label: global _main

2°_ you're declaring the _main label

3°_ you're changing the value of two cpu registers: ax and bx to 0x01 and 0x02 respectively

4°_ you're incrementing the values of ax and bx

5°_ lastly, you're jumping to _main, this mean you are in a infinite loop

Solution 4:[4]

You may find this site interesting: Authoring Windows Applications In Assembly Language. You can download The Small Is Beautiful Starter Kit which contains a sample application to write a Windows program in assembly.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 William Leara
Solution 2 Daniel Wedlund
Solution 3 Peter Cordes
Solution 4 Louis Davis