I develop the code with x86 gcc.
The C code:
#include <stdio.h>
void test() {
int i;
int array[3] = {0};
for (i = 0; i < 3; i++)
printf("array[%d] = %d\n", i, array[i]);
}
int main(int argc, const char *argv[]) {
test();
return 0;
}
The assembly code:
.file "init.c"
.section .rodata
.LC0:
.string "array[%d] = %d\n"
.text
.globl test
.type test, @function
test:
pushl %ebp
movl %esp, %ebp
subl $40, %esp
# Code for array initialization
movl $0, -24(%ebp)
movl $0, -20(%ebp)
movl $0, -16(%ebp)
movl $0, -12(%ebp)
jmp .L2
.L3:
movl -12(%ebp), %eax
movl -24(%ebp,%eax,4), %edx
movl $.LC0, %eax
movl %edx, 8(%esp)
movl -12(%ebp), %edx
movl %edx, 4(%esp)
movl %eax, (%esp)
call printf
addl $1, -12(%ebp)
.L2:
cmpl $2, -12(%ebp)
jle .L3
leave
ret
.size test, .-test
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
call test
movl $0, %eax
movl %ebp, %esp
popl %ebp
ret
.size main, .-main
.ident "GCC: (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3"
.section .note.GNU-stack,"",@progbits
分享到:
相关推荐
Some Final Comments on the MOV Instructions <br>4.9 Laboratory Exercises 4.9.1 The UCR Standard Library for 80x86 Assembly Language Programmers 4.9.2 Editing Your Source Files 4.9.3 The ...
10.2 Software Initialization for Real-Address Mode 10.3 Switching to Protected Mode 10.4 Software Initialization for Protected Mode 10.5 Initialization Example 10.6 TLB Testing Chapter 11 Coprocessing...
Code has no effect -----------------代码不可述不可能执行到 Compound statement missing{ --------------------分程序漏掉"{" Conflicting type modifiers ------------------不明确的类型说明符 Constant ...
#### 数组指针与指向数组的指针(Array of pointers and pointer to arrays) 数组指针是指向一组指针的数组,而指向数组的指针则是指向数组的首地址。 #### 数组复制(Copying arrays) 复制数组时需要注意内存...
python学习资源
jfinal-undertow 用于开发、部署由 jfinal 开发的 web 项目
基于Andorid的音乐播放器项目设计(国外开源)实现源码,主要针对计算机相关专业的正在做毕设的学生和需要项目实战练习的学习者,也可作为课程设计、期末大作业。
python学习资源
python学习资源
python学习一些项目和资源
【毕业设计】java-springboot+vue家具销售平台实现源码(完整前后端+mysql+说明文档+LunW).zip
HTML+CSS+JavaScarip开发的前端网页源代码
python学习资源
【毕业设计】java-springboot-vue健身房信息管理系统源码(完整前后端+mysql+说明文档+LunW).zip
成绩管理系统C/Go。大学生期末小作业,指针实现,C语言版本(ANSI C)和Go语言版本
1_基于大数据的智能菜品个性化推荐与点餐系统的设计与实现.docx
【毕业设计】java-springboot-vue交流互动平台实现源码(完整前后端+mysql+说明文档+LunW).zip
内容概要:本文主要探讨了在高并发情况下如何设计并优化火车票秒杀系统,确保系统的高性能与稳定性。通过对比分析三种库存管理模式(下单减库存、支付减库存、预扣库存),强调了预扣库存结合本地缓存及远程Redis统一库存的优势,同时介绍了如何利用Nginx的加权轮询策略、MQ消息队列异步处理等方式降低系统压力,保障交易完整性和数据一致性,防止超卖现象。 适用人群:具有一定互联网应用开发经验的研发人员和技术管理人员。 使用场景及目标:适用于电商、票务等行业需要处理大量瞬时并发请求的业务场景。其目标在于通过合理的架构规划,实现在高峰期保持平台的稳定运行,保证用户体验的同时最大化销售额。 其他说明:文中提及的技术细节如Epoll I/O多路复用模型以及分布式系统中的容错措施等内容,对于深入理解大规模并发系统的构建有着重要指导意义。
基于 OpenCV 和 PyTorch 的深度车牌识别
【毕业设计-java】springboot-vue教学资料管理系统实现源码(完整前后端+mysql+说明文档+LunW).zip