Nasm-64_hello.asm

Source: Internet
Author: User
Tags win32

Nasm-64_hello.asm

32-bit download: http://www.nasm.us/pub/nasm/releasebuilds/2.09.08/win32/nasm-2.09.08-win32.zip string HEX Command linker gcc Linux

[CPP] View plain copy print?; HELLO.ASM A FIRST PROGRAM FOR NASM FOR LINUX,INTEL,GCC   ;  ; assemble:  nasm -f elf64 -l hello.lst hello.asm   ;link:      gcc -o hello hello.o  ; Run:        hello  ;output is: hello world       SECTION .data   ;d ata section   msg:         db  "Hello world", 10 ;the string to print,10= cr   len:        equ $-msg        ; " $ " means " here "                        ;len is a value, not an address       SECTION .text   ;code section           global main     ;make label  available to linker   main:       mov edx,len  ;arg3,length of string to print       mov ecx,msg ; arg2,pointer to string       mov ebx,1   ;arg1,wher  to write,screen       mov eax,4   ;write  sysout command to int 80 hex       int 0x80     ;interrupt 80 hex,call kernel  

Hello.asm a first program for NASM for LINUX,INTEL,GCC
;
; Assemble:	nasm-f elf64-l hello.lst hello.asm
; Link:		gcc-o hello hello.o
; run:		hello
; output is:	Hello World sections
	. Data	;d ATA
section msg:		db ' Hello World ', the	string to print, 10=CR
len:		equ $-msg		; " $ ' means ' here '
					; Len is a value, not an address section
	. text	; Code section
		Global main		; Make lab El available to linker
main:
	mov edx,len	; arg3,length of string to print
	mov ecx,msg	; arg2, Pointer to string
	mov ebx,1	, arg1,wher to Write,screen
	mov eax,4	, write sysout command to int hex
  int 0x80	, interrupt Hex,call kernel


Nasm-f elf64-l Hello.lst hello.asm

Gcc-o Hello hello.o

Run

./hello

Hello.lst's Content

[CPP] View Plain copy print?  1                                   ; hello.asm a first program for nasm for linux,intel,gcc    2                                    ;    3                                   ; assemble:  nasm -f elf -l hello.lst hello.asm    4                                    ;link:       gcc -o hello hello.o    5                                    ;run:       hello     6                                    ;output is: Hello World    7                                        SECTION .data    ;d ATA SECTION&NBsp;   8 00000000 48656C6C6F20576F72-     msg:         db  "Hello world", 10 ;THE STRING TO PRINT,10=CR     9 00000009 6C640A                 10                                    len:        equ $-msg        ; " $ " means " here "   11                                                         ;len is a value, not an address   12                                         SECTION .text   ;code section   13                                             global main     ;make label available to linker    14                                   main:    15 00000000 ba0c000000                   mov edx,len ;arg3,length of string to print   16 00000005 b9[00000000]                 mov ecx,msg ;arg2,pointer to string   17 0000000a  BB01000000                   mov ebx,1   ;arg1,wher to write,screen   18  0000000f b804000000                   mov eax,4   ;write sysout command to int  80 hex   19 00000014 cd80                          int 0x80    ;interrupt 80  hex,call kernel   20                                      

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.