Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
X86 assembly language
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==="Hello world!" program for Windows in MASM and NASM style assembly=== {|class=wikitable |- !! MASM !! NASM !! Description |- | <syntaxhighlight lang="nasm"> ; requires /coff switch on 6.15 and earlier versions .386 .model small,c .stack 1000h </syntaxhighlight> | <syntaxhighlight lang="nasm"> ; Image base = 0x00400000 %define RVA(x) (x-0x00400000) </syntaxhighlight> |Permeable. MASM requires defining the address model and stack size. |- |<syntaxhighlight lang="nasm"> .data msg db "Hello world!",0 </syntaxhighlight> |<syntaxhighlight lang="nasm"> section .data msg db "Hello world!" </syntaxhighlight> | Data section. We use the db (define byte) pseudo-op to define a string. |- |<syntaxhighlight lang="nasm"> .code includelib libcmt.lib includelib libvcruntime.lib includelib libucrt.lib includelib legacy_stdio_definitions.lib extrn printf:near extrn exit:near public main main proc push offset msg call printf push 0 call exit main endp end </syntaxhighlight> | <syntaxhighlight lang="nasm"> section .text push dword msg call dword [printf] push byte +0 call dword [exit] ret section .idata dd RVA(msvcrt_LookupTable) dd -1 dd 0 dd RVA(msvcrt_string) dd RVA(msvcrt_imports) times 5 dd 0 ; ends the descriptor table msvcrt_string dd "msvcrt.dll", 0 msvcrt_LookupTable: dd RVA(msvcrt_printf) dd RVA(msvcrt_exit) dd 0 msvcrt_imports: printf dd RVA(msvcrt_printf) exit dd RVA(msvcrt_exit) dd 0 msvcrt_printf: dw 1 dw "printf", 0 msvcrt_exit: dw 2 dw "exit", 0 dd 0 </syntaxhighlight> |The code (.text section) and the import table. In NASM the import table is manually constructed, while in the MASM example directives are used to simplify the process. |}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)