当前位置:网站首页>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
边栏推荐
- Table implements alternative adaptation through pseudo classes
- Informatics Olympiad 1361: Produce
- Kubernetes: container resource requirements and constraints (constraints)
- SystemVerilog structure (I)
- fsockopen函数的应用
- OpenResty 使用介绍
- Exec function of PHP
- LabVIEW jump to web page
- What is the dry goods microservice architecture? What are the advantages and disadvantages?
- Three methods of time series prediction: statistical model, machine learning and recurrent neural network
猜你喜欢
随机推荐
Download and installation of MySQL
Pytoch Learning Series: Introduction
Regular expression (?: pattern)
table通过伪类实现 另类自适应
Chrome browser close update Popup
e. Difference between target and e.currenttarget
"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
对补wasm环境的一些测试
leetcode 统计无向图中无法互相到达点对数
月薪没到30K的程序员必须要背的面试八股,我先啃为敬
thinkphp5.1 runtime文件改成777权限了, 还是无法写入
Mipi d-phy -- contents of HS and LP agreements
Boost the digital economy and face the future office | the launch of the new version of spreadjsv15.0 is about to begin
Today's sleep quality record 82 points
Handling method of occasional error reporting on overseas equipment
Talk about the copyonwritearraylist of JUC
Application of fsockopen function
PHP的exec函数
Set set
[sans titre]









