Assembly language is one of the oldest low-level programming language for computers , micro-processors etc etc...It implements a symbolic representation of the Machine Opcodes needed to program a given CPU Architecture...Its a language based on mnemonics , labels , instructions , memory addresses and Registers... A major disadvantage of programming in assembly is that it is not at all platform independent and thus , cannot be ported to other architectures... The Code In this article we'll be learning about a simple Hello World Program in x86 Unix Assembly and Will be using basic syscall table to accomplish our tasks... We'll be using write() function to write 'Hello World' to STDIN Syntax Code: write(int fd, char *Buff, int NumBytes); In a Assembly program the arguments can be passed on to the function via a simple call stack or via registers.. We'll be using registers to pass the arguments... Points to remember eax should contain the syscall number ebx should point to the first ecx should point to the second edx should point to the third esx should point to the fourth edi should point to the fifth Syscall(system call) table can be looked up in /usr/include/asm/unistd_32.h helloworld.asm Code: segment .data helloWorldString db "Hello World",0xA ; 0xA is ascii code for line feed helloWorldStringlen equ $ - helloWorldString ; it contains the length of string segment .text global _start _start : mov eax,4 ;syscall of write is 4 mov ebx,1 ;int fd = STDIN is 1 mov ecx,helloWorldString ;char * mov edx,helloWorldStringlen ;int len int 0x80 ;shift to kernel mode ; exit call mov eax,1 ;syscall of exit mov ebx,0 ; exit(0) int 0x80 ; shift to kernel mode segment .data The first 2 lines simply define a db string containing 'Hello World' and the length of string segment .text First we delare a global declaration of _start lable so as to provide a entry point to the program.. The main code have been commented above for explanation , so as to provide a better understanding. Lets now Assemble and link the program Code: aneesh@aneesh-laptop:~/Programming/ASM$ nasm -f elf32 helloworld.asm -o helloworld.o aneesh@aneesh-laptop:~/Programming/ASM$ ld helloworld.o -o helloworld Now lets run the program Code: aneesh@aneesh-laptop:~/Programming/ASM$ ./helloworld Hello World That's enough for this Article … Stay tuned for more...
This is a wonderful opinion. The things mentioned are unanimous and needs to be appreciated by everyone. The initiative taken for the concern is very serious and need an attention of every one. This