PDA

View Full Version : learning assembly language on fedora 10


User101
6th August 2009, 06:53 AM
hi...

I m trying to learn assembly language. i have intel processor . please suggest e some good books of intel instruction set and also want to know that how to run assemble prog from terminal..

thanks in advance.

mmix
6th August 2009, 12:25 PM
http://software.intel.com/en-us/articles/intel-software-development-emulator/

HTH

Gödel
6th August 2009, 12:40 PM

You can also run assembler code directly from C, here's an a post which uses an example from Linus Torvalds demonstrating the performance of the cmov instruction (bad on out-of-order processors (most modern ones are), good on in-order processors like the intel atom)

http://forums.fedoraforum.org/showpost.php?p=1181529&postcount=6

User101
6th August 2009, 02:05 PM
thank you for your time and advice..but i m still not satisified with the ans..

Gödel
6th August 2009, 03:51 PM
Use 'as' and 'ld' from the binutils package

# hello.s

.section .data
hello:
.ascii "Hello, world!\n"
hello_len:
.long . - hello

.section .text
.globl _start

_start:
## display string using write () system call
xorl %ebx, %ebx # %ebx = 0
movl $4, %eax # write () system call
xorl %ebx, %ebx # %ebx = 0
incl %ebx # %ebx = 1, fd = stdout
leal hello, %ecx # %ecx ---> hello
movl hello_len, %edx # %edx = count
int $0x80 # execute write () system call

## terminate program via _exit () system call
xorl %eax, %eax # %eax = 0
incl %eax # %eax = 1 system call _exit ()
xorl %ebx, %ebx # %ebx = 0 normal program return code
int $0x80 # execute system call _exit ()


$ as -o hello.o hello.s
$ ld -o hello -O0 hello.o


$ ./hello
Hello, world!


(use 'objdump -d hello' to check the assembly code is correct)

http://database.sarang.net/study/linux/asm/linux-asm.txt

This link should satisfy you http://tinyurl.com/n4sop5

trekkie690
7th August 2009, 08:48 PM
Use 'as' and 'ld' from the binutils package

# hello.s

.section .data
hello:
.ascii "Hello, world!\n"
hello_len:
.long . - hello

.section .text
.globl _start

_start:
## display string using write () system call
xorl %ebx, %ebx # %ebx = 0
movl $4, %eax # write () system call
xorl %ebx, %ebx # %ebx = 0
incl %ebx # %ebx = 1, fd = stdout
leal hello, %ecx # %ecx ---> hello
movl hello_len, %edx # %edx = count
int $0x80 # execute write () system call

## terminate program via _exit () system call
xorl %eax, %eax # %eax = 0
incl %eax # %eax = 1 system call _exit ()
xorl %ebx, %ebx # %ebx = 0 normal program return code
int $0x80 # execute system call _exit ()


$ as -o hello.o hello.s
$ ld -o hello -O0 hello.o


$ ./hello
Hello, world!


(use 'objdump -d hello' to check the assembly code is correct)

http://database.sarang.net/study/linux/asm/linux-asm.txt

This link should satisfy you http://tinyurl.com/n4sop5

use this....for doing it in a C program. usually ya need to add some commands to the makefile, which depends on what you do in the assembly. Otherwise just make it a <name>.S. which is the usual way assembly programs are labeled in linux. though some times you get funcy names form windows