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:

    There are many examples of women that have excelled in learning, and even in war, but this is no reason we should bring ‘em all up to Latin and Greek or else military discipline, instead of needle-work and housewifry.
    Bernard Mandeville (1670–1733)

    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)

    Go on then in doing with your pen what in other times was done with the sword; shew that reformation is more practicable by operating on the mind than on the body of man.
    Thomas Jefferson (1743–1826)

    The skylines lit up at dead of night, the air- conditioning systems cooling empty hotels in the desert and artificial light in the middle of the day all have something both demented and admirable about them. The mindless luxury of a rich civilization, and yet of a civilization perhaps as scared to see the lights go out as was the hunter in his primitive night.
    Jean Baudrillard (b. 1929)