当前位置:网站首页>99乘法表
99乘法表
2022-06-29 02:31:00 【咦哟斯哈】
用 gedit 或 vim 编辑代码:
$ vim table99.c
格式化代码:
$ indent -kr table99.c
用 cat 查看代码:
$ cat table99.c
#include <stdio.h>
void table99()
{
int i, j;
for (i = 1; i <= 9; i++) {
for (j = 1; j <= i; j++) {
printf("%d*%d=%-4d", i, j, i * j);
}
printf("\n");
}
}
int main(int argc, char *argv[])
{
table99();
return 0;
}
用 make 自动触发编译:
$ make table99
cc table99.c -o table99
也可以先从 C 语言得到汇编代码:
$ gcc -S -o table99.s table99.c
$ cat table99.s
.file "table99.c"
.text
.section .rodata
.LC0:
.string "%d*%d=%-4d"
.text
.globl table99
.type table99, @function
table99:
.LFB0:
.cfi_startproc
endbr64
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movl $1, -8(%rbp)
jmp .L2
.L5:
movl $1, -4(%rbp)
jmp .L3
.L4:
movl -8(%rbp), %eax
imull -4(%rbp), %eax
movl %eax, %ecx
movl -4(%rbp), %edx
movl -8(%rbp), %eax
movl %eax, %esi
leaq .LC0(%rip), %rdi
movl $0, %eax
call printf@PLT
addl $1, -4(%rbp)
.L3:
movl -4(%rbp), %eax
cmpl -8(%rbp), %eax
jle .L4
movl $10, %edi
call [email protected]
addl $1, -8(%rbp)
.L2:
cmpl $9, -8(%rbp)
jle .L5
nop
nop
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size table99, .-table99
.globl main
.type main, @function
main:
.LFB1:
.cfi_startproc
endbr64
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movl %edi, -4(%rbp)
movq %rsi, -16(%rbp)
movl $0, %eax
call table99
movl $0, %eax
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE1:
.size main, .-main
.ident "GCC: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0"
.section .note.GNU-stack,"",@progbits
.section .note.gnu.property,"a"
.align 8
.long 1f - 0f
.long 4f - 1f
.long 5
0:
.string "GNU"
1:
.align 8
.long 0xc0000002
.long 3f - 2f
2:
.long 0x3
3:
.align 8
4:
从汇编语言编译成二进制程序:
$ gcc -o table99 table99.s
执行二进制程序:
$ ./table99
1*1=1
2*1=2 2*2=4
3*1=3 3*2=6 3*3=9
4*1=4 4*2=8 4*3=12 4*4=16
5*1=5 5*2=10 5*3=15 5*4=20 5*5=25
6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36
7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49
8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64
9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81
$ PATH=./ table99
1*1=1
2*1=2 2*2=4
3*1=3 3*2=6 3*3=9
4*1=4 4*2=8 4*3=12 4*4=16
5*1=5 5*2=10 5*3=15 5*4=20 5*5=25
6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36
7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49
8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64
9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81
反汇编,从可执行程序获得汇编代码:
$ objdump -d table99
边栏推荐
- Kubernetes: container resource requirements and constraints (constraints)
- 【无标题】
- Table implements alternative adaptation through pseudo classes
- 月薪没到30K的程序员必须要背的面试八股,我先啃为敬
- Wechat applet custom component
- MySQL queries the data of today, yesterday, this week, last week, this month, last month, this quarter, last quarter, this year, last year
- [untitled]
- mark
- Tuples of combined data types
- 18. `bs对象.节点名.next_sibling` 获取兄弟节点
猜你喜欢

chrome浏览器关闭更新弹窗

Boost the digital economy and face the future office | the launch of the new version of spreadjsv15.0 is about to begin

They all talk about interviews with big factories. When I interview with small factories, I invite people to drink tea?

How does sound amplify weak sounds

pvcreate asm disk导致asm磁盘组异常恢复---惜分飞
![[untitled]](/img/36/2f9319e05157ab6a8dd5aa3bef4505.png)
[untitled]

Relationship between EMC, EMI and EMS

兰宝传感科技冲刺科创板:年营收3.5亿 许永童家族色彩浓厚

What is the dry goods microservice architecture? What are the advantages and disadvantages?

對補wasm環境的一些測試
随机推荐
String segment combination
短视频平台常见SQL面试题,你学会了吗?
Boost the digital economy and face the future office | the launch of the new version of spreadjsv15.0 is about to begin
Talk about the copyonwritearraylist of JUC
CTFHub-Web-密码口令-默认口令
MySQL queries the data of today, yesterday, this week, last week, this month, last month, this quarter, last quarter, this year, last year
LabVIEW jump to web page
PMP项目管理概述
干货丨微服务架构是什么?有哪些优点和不足?
如何用项目甘特图,做好项目汇报
18. `bs object Node name next_ Sibling` get sibling nodes
Koa quick start
【一起上水硕系列】最简单的字幕配置
矩阵特征值和特征向量求解——特征值分解(EVD)
Ctfhub web password default password
Tuples of combined data types
线程池是什么老鸡?
字符串方法练习
leetcode 统计放置房子的方式数
字符串输出