czwartek, 4 grudnia 2008

Hello ASM World

> cat /etc/release
Solaris Express Community Edition snv_103 X86
Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
Use is subject to license terms.
Assembled 17 November 2008


> cat my01.s
.data
str:
.string "Hello OpenSolaris!!! :)\n"
.text
.globl main
main:
# WRITE
movl $4, %eax
pushl $24
pushl $str
pushl $1
pushl $1
int $0x91

# EXIT
movl $1, %eax
pushl %eax
int $0x91



> as my01.s -o my01.o && ld my01.o -o my01 && strip my01

> file my01
my01: ELF 32-bit LSB executable 80386 Version 1, dynamically linked, stripped
> ldd my01
> dis my01
disassembly for my01


section .text
0x8050408: b8 04 00 00 00 movl $0x4,%eax
0x805040d: 6a 18 pushl $0x18
0x805040f: 68 04 05 06 08 pushl $0x8060504
0x8050414: 6a 01 pushl $0x1
0x8050416: 6a 01 pushl $0x1
0x8050418: cd 91 int $0x91
0x805041a: b8 01 00 00 00 movl $0x1,%eax
0x805041f: 50 pushl %eax
0x8050420: cd 91 int $0x91



> ./my01
Hello OpenSolaris!!! :)

2 komentarze:

Trochej pisze...

Ale osso chozi?

estibi pisze...

No co? Jeszcze nie uzywalem Asemblera pod Solarisem :)