Netwide Assembler - Examples of Programs For Various Operating Systems

Examples of Programs For Various Operating Systems

This is a Hello world program for the DOS operating system.

section .text org 0x100 mov ah, 0x9 mov dx, hello int 0x21 mov ax, 0x4c00 int 0x21 section .data hello: db 'Hello, world!', 13, 10, '$'

An example of a similar program for Microsoft Windows:

global _start extern _MessageBoxA@16 extern _ExitProcess@4 section code use32 class=code _start: push dword 0 ; UINT uType = MB_OK push dword title ; LPCSTR lpCaption push dword banner ; LPCSTR lpText push dword 0 ; HWND hWnd = NULL call _MessageBoxA@16 push dword 0 ; UINT uExitCode call _ExitProcess@4 section data use32 class=data banner: db 'Hello, world!', 0 title: db 'Hello', 0

An equivalent program for Linux:

section .data msg: db "Hello, world!", 10 .len: equ $ - msg section .text global _start _start: mov eax, 4 ; write mov ebx, 1 ; stdout mov ecx, msg mov edx, msg.len int 0x80 mov eax, 1 ; exit mov ebx, 0 int 0x80

Read more about this topic:  Netwide Assembler

Famous quotes containing the words examples of, examples, programs, operating and/or systems:

    It is hardly to be believed how spiritual reflections when mixed with a little physics can hold people’s attention and give them a livelier idea of God than do the often ill-applied examples of his wrath.
    —G.C. (Georg Christoph)

    It is hardly to be believed how spiritual reflections when mixed with a little physics can hold people’s attention and give them a livelier idea of God than do the often ill-applied examples of his wrath.
    —G.C. (Georg Christoph)

    [The Republicans] offer ... a detailed agenda for national renewal.... [On] reducing illegitimacy ... the state will use ... funds for programs to reduce out-of-wedlock pregnancies, to promote adoption, to establish and operate children’s group homes, to establish and operate residential group homes for unwed mothers, or for any purpose the state deems appropriate. None of the taxpayer funds may be used for abortion services or abortion counseling.
    Newt Gingrich (b. 1943)

    I think there are innumerable gods. What we on earth call God is a little tribal God who has made an awful mess. Certainly forces operating through human consciousness control events.
    William Burroughs (b. 1914)

    What is most original in a man’s nature is often that which is most desperate. Thus new systems are forced on the world by men who simply cannot bear the pain of living with what is. Creators care nothing for their systems except that they be unique. If Hitler had been born in Nazi Germany he wouldn’t have been content to enjoy the atmosphere.
    Leonard Cohen (b. 1934)