user98188
user98188

Reputation:

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).

Upvotes: 1

Views: 2215

Answers (4)

Isaac Vinícius
Isaac Vinícius

Reputation: 21

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

Upvotes: 1

Louis Davis
Louis Davis

Reputation: 784

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.

Upvotes: 0

Daniel Wedlund
Daniel Wedlund

Reputation: 814

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.

Upvotes: 1

William Leara
William Leara

Reputation: 10687

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.

Upvotes: 2

Related Questions