Content
- Introduction
- Code
- Assembly and launch
- Miscellaneous
- Question
1. Introduction
This is not a question in itself (although there is one below), but the HelloWorld application for people on whom StackOverflow is experimenting.
When I first tried to program in MASM, I tried to find a working HelloWorld application that used WIN32 API calls (so without contacting the C libraries), but could not find it (in the MASM syntax). So, now that I have some experience, I wrote one for others who want to learn the assembly in order to play with it.
2. Code
.386 ; 386 Processor Instruction Set .model flat,stdcall ; Flat memory model and stdcall method option casemap:none ; Case Sensitive ;Libaries and Include files used in this project ; Windows.inc defines alias (such as NULL and STD_OUTPUT_HANDLE in this code include \masm32\include\windows.inc ; Functions that we use (GetStdHandle, WriteConsole, and ExitProcess) ; Listing of all available functions in kernel32.lib include \masm32\include\kernel32.inc ; Actuall byte code available of the functions includelib \masm32\lib\kernel32.lib .data ; Labels that with the allocated data (in this case Hello World!...) that are aliases to memory. output db "Hello World!", 0ah, 0h; This String Hello World! and then a the newline character \n (0ah) and then the null character 0h .code start: ;
3. Assembly and launch
I assume that you have MASM32 installed in the C: \ MASM32 directory.
If you do not have MASM installed, go to http://masm32.com/install.htm and follow the instructions.
If MASM32 is installed in a different directory, please change accordingly.
Open the MASM32 editor (QEditor) by clicking on the desktop shortcut or if there is no shortcut, go to C: \ MASM32 \ and double-click qeditor.exe
Copy the code in the code section (only text with a gray background) and paste it into the MASM32 editor (QEditor) and save it.
After saving the code, click the Project menu and select “Assembly and Connection Console” ( NOT “Assemble and Link” (see the “Miscellaneous” section))
Scroll to START and click Run, then type cmd and press Enter. A black box appears with gray text.
Go, using Explorer, to the place where you saved the code in step 3. Now there should be a file with the same name as the source file (step 3), but be exe. Drag the exe file from the Explorer window into the cmd field (step 4 - black box)
Select the black box and press ENTER, the text "Hello World!". should appear.
4. Miscellaneous
Why do I need to click the Build and Run console and not the Build and Run console in the Project menu?
The reason you should click Build and Run Console is because there are two types of applications: graphical interfaces, and then there are text-based applications (DOS). The Hello application will be text-based, and therefore the console-based applications should be configured during the build, not the graphical interface.
For a more detailed explanation, see the third paragraph in the Notes section of this link .
5. Question
Ok, now the question is, does anyone here see any problems, errors or general problems with this code or any suggestions
source share