flat assembler
Message board for the users of flat assembler.
Index
> Windows > Hello World my first program |
Author |
|
Overflowz 15 Dec 2012, 18:09
It's DOS related problem.
You have to press any key to close the window. if you want EXE, here it is, but will confuse you I guess. Code: format PE CONSOLE 4.0 ;4.0 = WinNT+ include 'win32ax.inc' ;standard include. .data message db "Hello, World!",0 sizeof.message = $ - message wbytes dd ? .code start: invoke WriteFile, STD_OUTPUT_HANDLE, "Hello World!", 12, 0, wbytes ret .end start |
|||
15 Dec 2012, 18:09 |
|
ManOfSteel 15 Dec 2012, 18:10
I see in the YouTube video description a link to DOSBOX. That's where you should run the resulting .com file because your code is DOS code that won't run under any modern Windows system (AFAIK).
You may have downloaded the DOS version of FASM. If you want to code Windows applications you should get the Windows version. You'll find a working "Hello World" code in the "Examples" directory. Or you can use the console under Windows. There are many examples around here such as in this recent thread. |
|||
15 Dec 2012, 18:10 |
|
_Rob_ 15 Dec 2012, 18:33
Should have included this info in my post, sorry for that. I am using the "fasmw17003" for windows and I am on an older XP operating system 2002 x32.
|
|||
15 Dec 2012, 18:33 |
|
_Rob_ 15 Dec 2012, 18:50
Overflowz wrote: It's DOS related problem. Thanks for the help on how to close the window on the original code. So one example uses DOS, and your version uses C type language?? Can you explain the basic concepts on how this works? I mean I am thinking ASM is for very low level stuff so If I was doing low level would I be using C type syntax? I am just curious that's all, I am not a very good programmer I just find this stuff very interesting. Thanks. |
|||
15 Dec 2012, 18:50 |
|
ManOfSteel 15 Dec 2012, 19:06
You can always use the more Windows-specific WriteConsole API.
I haven't tested it, but there's an example in the link I posted last time. You can also check this page. |
|||
15 Dec 2012, 19:06 |
|
Overflowz 15 Dec 2012, 19:14
_Rob_
Sure. now take a look this code with nice comments. Code: format PE CONSOLE 4.0 ;4.0 = we wanna console app and above WinNT systems should run this. include 'win32ax.inc' ;include file, which includes some additional stuff like macros, equotes, etc.. .data ;this is just macro for "section '.data' data readable writeable message db "Hello, World!",0 ;this is our message, including null-terminator (but we actually don't need it.) sizeof.message = $ - message ;$ means current location, whenever we subtract previous value to current location, we get size of string, easy though. wbytes dd ? ;define DWORD value for WriteFile API. http://msdn.microsoft.com/en-us/library/windows/desktop/aa365747(v=vs.85).aspx .code ;another macro for "section '.text' code readable executable start: ;execution will start from here. invoke WriteFile, STD_OUTPUT_HANDLE, message, sizeof.message, 0, wbytes ;invoke macro which is included in win32a/x.inc it's similar as push wbytes, push 0, push sizeof.message, push message, push STD_OUTPUT_HANDLE, call [WriteFile] ret ;exit our procedure .end start ;macro for entry label (at this point, it will be start. tells compiler where execution should begin first, it's an AddressOfEntryPoint.) I'm not good teacher, but I can suggest you if this is your first language, start with C and then move to asm. P.S It's WinAPI, not C. C API is in msvcrt.dll. |
|||
15 Dec 2012, 19:14 |
|
_Rob_ 15 Dec 2012, 20:15
Well lets see I have taken C for UNIX and VS C++ both intro classes. But since I took these classes just for fun, and I am only a windows user not a programmer by trade; In the end I picked up VB.NET and Its all I use now.
But I am interested in low level stuff and why I joined this forum. I am also interested in the MenuetOS operating system. I think my long range goal is developing some low level stuff. How well that goes well it could end up like my C++ class TOUGH! Thanks again for the comments and the links! |
|||
15 Dec 2012, 20:15 |
|
typedef 15 Dec 2012, 20:42
Assembly teaches you more in terms of computer programming.
The most fundamental thing to learn is data structuring, addressing and access. These have to do with some of the most vital parts of a program's execution, like the STACK and or calling conventions. One you get a grasp of that, you're good to go. Last edited by typedef on 16 Dec 2012, 13:21; edited 1 time in total |
|||
15 Dec 2012, 20:42 |
|
_Rob_ 16 Dec 2012, 01:40
typedef wrote: Assembly teaches you more in terms of computer programming. If you have any links regarding this stuff I would be interested. But I would agree with your point. |
|||
16 Dec 2012, 01:40 |
|
ManOfSteel 16 Dec 2012, 08:29
The documentation has pretty much everything you need.
Start with these: http://flatassembler.net/docs.php?article=manual http://flatassembler.net/docs.php?article=win32 |
|||
16 Dec 2012, 08:29 |
|
_Rob_ 16 Dec 2012, 15:19
ManOfSteel wrote: The documentation has pretty much everything you need. Nice, thanks for the links now I know where to start. |
|||
16 Dec 2012, 15:19 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.