分页: 1 / 1

初学AT&T汇编,刚学会如何编译

发表于 : 2007-11-21 21:26
liuweni
[liuweni@Liuweni asm]$ cat hw
#This is my first assembly language
.section .data
output:
.ascii "The processor Vendor ID is ‘xxxxxxxxxxxx’\n"
.section .text
.globl _start
_start:
movl $0, %eax
cpuid
movl $output, %edi
movl %ebx, 28(%edi)
movl %edx, 32(%edi)
movl %ecx, 36(%edi)
movl $4, %eax
movl $1, %ebx
movl $output, %ecx
movl $42, %edx
int $0x80
movl $1, %eax
movl $0, %ebx
int $0x80


[liuweni@Liuweni asm]$ as hw
[liuweni@Liuweni asm]$ ls
a.out hw hw.bak hw.o
[liuweni@Liuweni asm]$ ./a.out
bash: ./a.out: 权限不够
[liuweni@Liuweni asm]$ su
口令:
[root@Liuweni asm]# ./a.out
bash: ./a.out: 权限不够
[root@Liuweni asm]#

发表于 : 2007-11-21 21:31
liuweni
[root@Liuweni asm]# as -o hw.o hw.s
[root@Liuweni asm]# ld -o hw hw.o
[root@Liuweni asm]# ls
hw hw.bak hw.o hw.s
[root@Liuweni asm]# .hw
bash: .hw: command not found
[root@Liuweni asm]# ./hw
The processor Vendor ID is �AuthenticAMDxx[root@Liuweni asm]#


搞定,忘记了连接

发表于 : 2007-12-17 15:34
ioriliao
yes yes....
so am i

发表于 : 2008-02-18 17:18
roamer
楼上的牛人你们好,我最近也在学gcc下的汇编,但是一直没有找到好的资料,请问你们可以把你们的资料发出来大家共享一下吗?
谢谢了
我的邮箱:roamer.roamer@gmail.com

Re: 初学AT&T汇编,刚学会如何编译

发表于 : 2009-02-05 16:58
foxhlchen
我有一本richard blum写的汇编语言程序设计中文版(马朝晖 译),感觉挺全面的,你可以去书店找找,当当和卓越都有卖35块,是讲linux下汇编的,全书用的都是at&t风格。不过时效性毕竟是翻译的原作者写的时候是05年……,奔腾4时代,里面没有介绍酷睿2的新功能!

Re: 初学AT&T汇编,刚学会如何编译

发表于 : 2009-02-05 17:05
myewmyew
一窍不通。。。

Re: 初学AT&T汇编,刚学会如何编译

发表于 : 2012-01-11 22:28
word_world
foxhlchen 写了:我有一本richard blum写的汇编语言程序设计中文版(马朝晖 译),感觉挺全面的,你可以去书店找找,当当和卓越都有卖35块,是讲linux下汇编的,全书用的都是at&t风格。不过时效性毕竟是翻译的原作者写的时候是05年……,奔腾4时代,里面没有介绍酷睿2的新功能!

我想做一个类似编译开关的语句应该怎么做呢?
比如说
.section .text
.def USE_GCC #这个是开关,如果定义了USE_GCC就用gcc来编译

.ifdef USE_GCC
.globl main
main:
.else
.globl _start
_start:
.endif
下面就是我的代码
...