当前位置:网站首页>99 multiplication table
99 multiplication table
2022-06-29 02:44:00 【Eh, oh, SiHa】
use gedit or vim Edit code :
$ vim table99.c
formatting code :
$ indent -kr table99.c
use cat Look at the code :
$ 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;
}
use make Auto trigger compilation :
$ make table99
cc table99.c -o table99
You can also start with C Language get assembly code :
$ 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:
Compile from assembly language into binary program :
$ gcc -o table99 table99.s
Execute binary :
$ ./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
Disassembly , Obtaining assembly code from an executable program :
$ objdump -d table99
边栏推荐
- EMC、EMI、EMS的关系
- Centos7 installation php7.2
- STM32L4系列单片机ADC通过内部参考电压精确计算输入电压
- MySQL的下载和安装
- 字符串属性练习
- HashSet storing objects and how to not store the same objects
- [Algèbre linéaire] 1.1 déterminant du deuxième et du troisième ordre
- 哪个证券公司最大最安全 哪家券商服务好
- Regular expression (?: pattern)
- 深入解析 Apache BookKeeper 系列:第三篇——读取原理
猜你喜欢

短视频平台常见SQL面试题,你学会了吗?

矩阵特征值和特征向量求解——特征值分解(EVD)

Have you learned the common SQL interview questions on the short video platform?

Target detection - ADAS practice

對補wasm環境的一些測試
![[Algèbre linéaire] 1.1 déterminant du deuxième et du troisième ordre](/img/ea/70b59c64d3287a887e371a9181fe45.png)
[Algèbre linéaire] 1.1 déterminant du deuxième et du troisième ordre
![[线性代数] 1.1 二阶与三阶行列式](/img/ea/70b59c64d3287a887e371a9181fe45.png)
[线性代数] 1.1 二阶与三阶行列式

LinkedList learning

Relationship between EMC, EMI and EMS

"The first share of endoscope" broke into IPO two times. Last year, it lost 500million yuan. The commercialization of core products is still in doubt | IPO Express
随机推荐
There is a time delay for the click event on the mobile terminal. What is the delay time? How to solve it?
短视频平台常见SQL面试题,你学会了吗?
信息学奥赛一本通 1361:产生数(Produce)
Trigonometric function calculation
On the fact that lambda expressions cannot handle recursion
PWN attack and defense world guess_ num
pvcreate asm disk导致asm磁盘组异常恢复---惜分飞
What is Mipi
Pvcreate ASM disk causes abnormal recovery of ASM disk group - sparing separation
18. `bs對象.節點名.next_sibling` 獲取兄弟節點
The 10 most commonly used gadgets for waterfall project management can be built and used freely
Oracle recovery tools actual batch bad block repair
Leetcode counts the number of ways to place houses
Install mysql5.7 and change the password
Troubleshooting of pyinstaller failed to pack pikepdf
Relationship between EMC, EMI and EMS
线程池是什么老鸡?
2022年启牛学堂证券开户安全的嘛?
Have you learned the common SQL interview questions on the short video platform?
计算矩形面积