Linux下的汇编语言编程
来源:互联网 发布:中国的政治体系 知乎 编辑:程序博客网 时间:2024/05/28 22:11
/* linux version of AVTEMP.ASM CS 200, fall 1998 */
.data /* beginning of data segment */
/* hi_temp data item */
.type hi_temp,@object /* declare as data object */
.size hi_temp,1 /* declare size in bytes */
hi_temp:
.byte 0x92 /* set value */
/* lo_temp data item */
.type lo_temp,@object
.size lo_temp,1
lo_temp:
.byte 0x52
/* av_temp data item */
.type av_temp,@object
.size av_temp,1
av_temp:
.byte 0
/* segment registers set up by linked code */
/* beginning of text(code) segment */
.text
.align 4 /* set 4 double-word alignment */
.globl main /* make main global for linker */
.type main,@function /* declare main as a function */
main:
pushl %ebp/* function requirement */
movl %esp,%ebp /* function requirement */
movb hi_temp,%al
addb lo_temp,%al
movb $0,%ah
adcb $0,%ah
movb $2,%bl
idivb %bl
movb %al,av_temp
leave/* function requirement */
ret/* function requirement */
This code may be assembled with the following command:
as -a --gstabs -o average.o average.s
The link command is the following:
"-m elf_i386" instructs the linker to use the ELF file format. "-static"cause static rather than dynamic linking to occur. And "-lc" links in the standard c libraries (libc.a). It might be necessary to include "-I/libdirectory" in the invocation for ld to find the c library.
The object file (average.o) can then be linked to the Linux wrapper codein order to create an executable. These files are crt1.o, crti.o andcrtn.o. crt1.o and crti.o provide initialization code and crtn.o does cleanup.These should all be located in "/usr/lib" be may be elsewere on some systems.They, and their source, might be located by executing the following find command:
- Linux下的汇编语言编程
- 学习Linux下的汇编语言
- Linux下的汇编语言之系统调用
- Linux下汇编语言------计算n的阶乘
- Linux 环境下汇编语言
- Linux 环境下汇编语言
- linux下使用汇编语言
- linux开发---2.汇编语言arm-linux下的打印
- 汇编语言的硬盘编程
- 在linux下使用汇编语言
- linux下汇编语言编译执行
- linux下汇编语言编译执行
- linux下汇编语言编译执行
- linux下汇编语言开发总结
- 学习linux环境下汇编的好书《汇编语言程序设计》
- linux下的C语言开发(AT&T 汇编语言)
- linux下的C语言开发(AT&T 汇编语言)
- linux下的C语言开发(AT&T 汇编语言)
- 用PHOTOSHOP处理图片的一些技巧
- 不常用但是很实用的CSS整理
- test
- Photoshop应用超小技巧十则
- 网站的目录结构
- Linux下的汇编语言编程
- 中文乱码问题的一些解决方案和经验
- web开发中的中文问题
- JSP彩色验证码
- 常用表单格式的五点技巧
- 对于调用约定的一些总结
- 不同分辨率显示不同的连接
- QQ在线服务
- 限制TextArea区的文字输入数量