#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void myFunctiontrue1()
{
}
void myFunctionfalse1()
{
}
void myFunctiontrue2()
{
}
void myFunctionfalse2()
{
}
void myFunctiontrue3()
{
}
void myFunctionfalse3()
{
}
void myFunctiontrue4()
{
}
void myFunctionfalse4()
{
}
void myFunctiontrue5()
{
}
void myFunctionfalse5()
{
}
int myfunc6True()
{
int random = rand() % time(0);
if (random > 10)
{
return 20;
}
return 1;
}
int main()
{
int random = rand() % time(0);
printf("hello random %d\n", random);
int a = random;
int b = 2;
int c = 5;
a:
if (a - 2 > 2)
{
myFunctiontrue1();
}
else
{
myFunctionfalse1();
}
int jumpBool = a - 2 > 2;
if (jumpBool)
{
myFunctiontrue2();
}
else
{
myFunctionfalse2();
}
jumpBool = a - 2 > 2;
if (jumpBool > 5)
{
myFunctiontrue3();
}
else
{
myFunctionfalse3();
}
jumpBool = a - 2 > 2;
if (jumpBool < 5)
{
myFunctiontrue4();
}
else
{
myFunctionfalse4();
}
if (jumpBool > 5 || jumpBool < 2)
{
myFunctiontrue5();
}
int bb=myfunc6True();
myb:
c++;
if (c < 10)
{
printf("%d<10, gotb ++\n", c);
goto myb;
}
else
{
if (c < 15)
{
printf("%d<15, gotb ++ \n", c);
goto myb;
}
}
printf(" end %d" ,bb);
return 0;
}
.file "arm.c"
.text
.globl myFunctiontrue1
.type myFunctiontrue1, @function
myFunctiontrue1:
.LFB2:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
nop
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2:
.size myFunctiontrue1, .-myFunctiontrue1
.globl myFunctionfalse1
.type myFunctionfalse1, @function
myFunctionfalse1:
.LFB3:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
nop
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE3:
.size myFunctionfalse1, .-myFunctionfalse1
.globl myFunctiontrue2
.type myFunctiontrue2, @function
myFunctiontrue2:
.LFB4:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
nop
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE4:
.size myFunctiontrue2, .-myFunctiontrue2
.globl myFunctionfalse2
.type myFunctionfalse2, @function
myFunctionfalse2:
.LFB5:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
nop
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE5:
.size myFunctionfalse2, .-myFunctionfalse2
.globl myFunctiontrue3
.type myFunctiontrue3, @function
myFunctiontrue3:
.LFB6:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
nop
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE6:
.size myFunctiontrue3, .-myFunctiontrue3
.globl myFunctionfalse3
.type myFunctionfalse3, @function
myFunctionfalse3:
.LFB7:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
nop
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE7:
.size myFunctionfalse3, .-myFunctionfalse3
.globl myFunctiontrue4
.type myFunctiontrue4, @function
myFunctiontrue4:
.LFB8:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
nop
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE8:
.size myFunctiontrue4, .-myFunctiontrue4
.globl myFunctionfalse4
.type myFunctionfalse4, @function
myFunctionfalse4:
.LFB9:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
nop
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE9:
.size myFunctionfalse4, .-myFunctionfalse4
.globl myFunctiontrue5
.type myFunctiontrue5, @function
myFunctiontrue5:
.LFB10:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
nop
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE10:
.size myFunctiontrue5, .-myFunctiontrue5
.globl myFunctionfalse5
.type myFunctionfalse5, @function
myFunctionfalse5:
.LFB11:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
nop
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE11:
.size myFunctionfalse5, .-myFunctionfalse5
.globl myfunc6True
.type myfunc6True, @function
myfunc6True:
.LFB12:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
pushq %rbx
subq $24, %rsp
.cfi_offset 3, -24
call rand
movslq %eax, %rbx
movl $0, %edi
call time
movq %rax, %rcx
movq %rbx, %rax
cqto
idivq %rcx
movq %rdx, %rax
movl %eax, -20(%rbp)
cmpl $10, -20(%rbp)
jle .L12
movl $20, %eax
jmp .L13
.L12:
movl $1, %eax
.L13:
addq $24, %rsp
popq %rbx
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE12:
.size myfunc6True, .-myfunc6True
.section .rodata
.LC0:
.string "hello random %d\n"
.LC1:
.string "%d<10, gotb ++\n"
.LC2:
.string "%d<15, gotb ++ \n"
.LC3:
.string " end %d"
.text
.globl main
.type main, @function
main:
.LFB13:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
pushq %rbx
subq $40, %rsp
.cfi_offset 3, -24
call rand
movslq %eax, %rbx
movl $0, %edi
call time
movq %rax, %rcx
movq %rbx, %rax
cqto
idivq %rcx
movq %rdx, %rax
movl %eax, -36(%rbp)
movl -36(%rbp), %eax
movl %eax, %esi
movl $.LC0, %edi
movl $0, %eax
call printf
movl -36(%rbp), %eax
movl %eax, -32(%rbp)
movl $2, -28(%rbp)
movl $5, -40(%rbp)
.L15:
movl -32(%rbp), %eax
subl $2, %eax
cmpl $2, %eax
jle .L16
movl $0, %eax
call myFunctiontrue1
jmp .L17 //直接执行.L17 .L17是主程序的部分代码
.L16:
movl $0, %eax
call myFunctionfalse1 //s顺序执行
.L17:
movl -32(%rbp), %eax
subl $2, %eax
cmpl $2, %eax
setg %al
movzbl %al, %eax
movl %eax, -24(%rbp)
cmpl $0, -24(%rbp)
je .L18 //成立就跳转到 L18 下面 不会走
movl $0, %eax
call myFunctiontrue2
jmp .L19
.L18:
movl $0, %eax
call myFunctionfalse2
.L19:
movl -32(%rbp), %eax
subl $2, %eax
cmpl $2, %eax
setg %al
movzbl %al, %eax
movl %eax, -24(%rbp)
cmpl $5, -24(%rbp)
jle .L20
movl $0, %eax
call myFunctiontrue3
jmp .L21
.L20:
movl $0, %eax
call myFunctionfalse3
.L21:
movl -32(%rbp), %eax
subl $2, %eax
cmpl $2, %eax
setg %al
movzbl %al, %eax
movl %eax, -24(%rbp)
cmpl $4, -24(%rbp)
jg .L22
movl $0, %eax
call myFunctiontrue4
jmp .L23
.L22:
movl $0, %eax
call myFunctionfalse4
.L23:
cmpl $5, -24(%rbp)
jg .L24
cmpl $1, -24(%rbp)
jg .L25
.L24:
movl $0, %eax
call myFunctiontrue5
.L25:
movl $0, %eax
call myfunc6True
movl %eax, -20(%rbp) //取返回值
.L26:
addl $1, -40(%rbp)
cmpl $9, -40(%rbp)
jg .L27
movl -40(%rbp), %eax
movl %eax, %esi
movl $.LC1, %edi
movl $0, %eax
call printf
jmp .L26
.L27:
cmpl $14, -40(%rbp)
jg .L28
movl -40(%rbp), %eax
movl %eax, %esi
movl $.LC2, %edi
movl $0, %eax
call printf
jmp .L26
.L28:
movl -20(%rbp), %eax
movl %eax, %esi
movl $.LC3, %edi
movl $0, %eax
call printf
movl $0, %eax
addq $40, %rsp
popq %rbx
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE13:
.size main, .-main
.ident "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609"
.section .note.GNU-stack,"",@progbits
jg
大于跳jge
大于等于跳jmp
无条件跳call
调用方法bne
不等于跳转jle
小于等于跳JNB al, bl
;al里的内容不等于bl时跳转JBE al, bl
;al里的内容小于或等于bl时跳转
;A(above)大于,B(below)小于,E(equal)等于,用于比较无符号数
;G(great)大于,L(less than)小于, E(equal)等于,用于比较带符号数
cmp 比较
jnz 不等于
jz 等于
有符号
jg 大于 great
jl 小于 less
无符号
ja 大于
jb 小于
n 夹在中间 表示否定
e 跟到后面 表示肯定
jge jg 是大于 jge大于等于 great equal
jle 小于等于 less equal
jnb 不小于 //大于等于 无符号
jbe 小于等于 无符号
--debug
汇编语言里 eax, ebx, ecx, edx, esi, edi, ebp, esp这些都是什么意思啊?
赋值操作常用 ,而 edi 通常是字符串赋值。如本程序的move edi,offset aD15Gotb;
就是把地址偏移这里的内容赋值给edi
https://blog.csdn.net/gettogetto/article/details/76793553
c代码演示
main(){
int a,b,c;
int i;
int ib;
int ic;
int k=0;
scanf("%d %d %d",&a,&b,&c);//取了地址则代表从内存中申请内存而不是从cpu,寄存器用si之类的。
for(i=0;i<3;i++){
ib=(i+1)%3;//确保不会超过index 2
b=(i+2)%3;//确定不会超过2
if(*(&a+1)>=*(&a+ib)+*($a+ic)){
k=1;
break;
//没有用到 b ,c这里是用地址操作获取到b和 c,然后for循环 先a bc 然后 b c a 然后 c a b ???
}
}
if(k){
printf(" 三角形成立");// 任意一边大于等于其他两边之和就是三角形。
}else{
printf("warn");
//
}