flat assembler
Message board for the users of flat assembler.

Index > Windows > Hello world console program

Author
Thread Post new topic Reply to topic
Lucy Berie



Joined: 08 Dec 2012
Posts: 13
Lucy Berie
Hello, I'm Lucy Berie and I would like to write a "Hello World" console program by assembly language. I'm using C++ but also I very like assembly. Smile

I want to translate :

Code:

#include <iostream>

int main()
{
printf ("Hello World !");
}
    



To Assembly code...

If you tell me how and the code, it would be very helpful Wink
Post 08 Dec 2012, 11:43
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17450
Location: In your JS exploiting you and your system
revolution
Lucy: Answers are given in the other thread.

Look in the "examples" folder in the fasm download.
Post 08 Dec 2012, 11:51
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
A lady ? Very Happy

Anyways, @Rev be kind. And IIRC there are no console examples in the download folder.

@Lucy
Here's how.

Code:

format pe console


include 'win32ax.inc'

entry main

section '.data!!!' data readable writeable

strHello db 'Hello World !',13,10,0
strPause db 'pause',0

section '.txt' code executable readable

main:
       ; you can use crt functions or windows API.
       cinvoke printf,strHello
       cinvoke system,strPause; or import getc()
       ; or
       ; invoke printf,srtHello
       ; add esp, 4

       ; or use WriteFile and GetStdHandle APIs
       push 0
       call [ExitProcess]
      
section '.blah' import data readable

library kernel32,'kernel32.dll',\
    msvcrt,'msvcrt.dll'    ;; C-Run time from MS. This is always on every windows machine

import kernel32,\
          ExitProcess,'ExitProcess'
import msvcrt,\
          printf,'printf',\
          system,'system'


    
Post 09 Dec 2012, 17:12
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Lucy Berie,

printf() is prototyped in stdio.h, iostream gives you (object-oriented-&-overloaded) operator << for cout.

Heh, you can even use puts() for a free CR/LF. Wink
Post 12 Dec 2012, 08:16
View user's profile Send private message Reply with quote
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek
The flower of blooming prairies,
Lucy "asm" Berie.

sorry, couldn't constrain myself.
Post 14 Dec 2012, 15:05
View user's profile Send private message Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler
Code:
format PE console
include 'win32ax.inc'
.code
start:
        invoke  WriteConsole,<invoke GetStdHandle,STD_OUTPUT_HANDLE>,"Hello World !",13,0
        invoke  Sleep,-1
.end start    

_________________
This is a block of text that can be added to posts you make.
Post 14 Dec 2012, 15:36
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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 YouTube, Twitter.

Website powered by rwasa.