20145237 《信息安全系统设计基础》第八周学习总结

2017-2018-1 20145237 《信息安全系统设计基础》第八周学习总结

课堂测试

课堂测试
在Linux下完成“求命令行传入整数参数的和”

测试代码传入自己的8位学号

课堂测试3

4·47

取指:icode:ifun = D:0
valP<-PC+1
译码:valB<-R[%ebp]
执行:valE<-valB+4
访存:valM<-M4[valB]
写回:R[%esp]<-valE R[%ebp]<-valM

y86-64汇编代码

bubble_b:  
.LFB22:  
.cfi_startproc  
pushl   %edi  
.cfi_def_cfa_offset 8  
.cfi_offset 7, -8  
pushl   %esi  
.cfi_def_cfa_offset 12  
.cfi_offset 6, -12  
pushl   %ebx  
.cfi_def_cfa_offset 16  
.cfi_offset 3, -16  
mrmovl   16(%esp), %edx  
mrmovl   20(%esp), %edi  
irmovl   $1, %eax  
subl     %eax, %edi  
jle      .L1  
subl     $1, %edi  
irmovl   $0, %esi  
.L6:  
rrmovl   %esi, %eax  
irmovl   $0 , ebx   
subl     %ebx, %esi  
jl       .L3  
.L7:  
rrmovl   %eax, %ecx  
addl     %ecx, %ecx  
addl     %ecx, %ecx  
addl     %edx, %ecx  
mrmovl   4(%ecx), %ecx  
rrmovl   %eax, %ebx  
addl     %ecx, %ebx  
addl     %ecx, %ebx  
addl     %edx, %ebx  
mrmovl   (%ebx), %ebx  
subl     %ebx, %ecx  
jge     .L4  
addl     %eax, %eax  
addl     %eax, %eax  
addl     %edx, %eax  
rmmovl   %ebx, 4(%eax)  
addl     %eax, %eax  
addl     %eax, %eax  
addl     %edx, %eax  
rmmovl   %ecx, 4(%eax)  
.L4:  
subl    $1, %eax  
irmovl  $-1, %edx  
subl    %edx, %eax  
jne .L7  
.L3:  
addl    $1, %esi  
subl    %edi, %esi  
jne .L6  
.L1:  
popl    %ebx  
.cfi_def_cfa_offset 12  
.cfi_restore 3  
popl    %esi  
.cfi_def_cfa_offset 8  
.cfi_restore 6  
popl    %edi  

.cfi_def_cfa_offset 4  
.cfi_restore 7  
ret  
.cfi_endproc  
.LFE22:  
.size   bubble_b, .-bubble_b  
.section    .rodata.str1.1,"aMS",@progbits,1

4·48

取指:icode:ifun = M1[PC] = C:0
rA:rB<-M1[PC+1]
valC<-M4[PC+2]
valP<-PC+6
译码:valB<-R[rB]
执行:valE<-valB+valC
SetCC
访存:-
写回:R[rB]<-valE

y86-64汇编代码

bubble_b:  
.LFB22:  
    .cfi_startproc  
    pushl   %edi  
    .cfi_def_cfa_offset 8  
    .cfi_offset 7, -8  
    pushl   %esi  
    .cfi_def_cfa_offset 12  
    .cfi_offset 6, -12  
    pushl   %ebx  
    .cfi_def_cfa_offset 16  
    .cfi_offset 3, -16  
    mrmovl   16(%esp), %edx  
    mrmovl   20(%esp), %edi  
    irmovl   $1, %eax  
    subl     %eax, %edi  
    jle      .L1  
    subl     $1, %edi  
    irmovl   $0, %esi  
.L6:  
    movl    (%ebx,%eax,4), %edx  
    movl    4(%ebx,%eax,4), %ecx  
    cmpl    %edx, %ecx  
    movl    %edx, %ebp  
    cmovle  %ecx, %ebp  
    movl    %ebp, (%ebx,%eax,4)  
    cmovge  %ecx, %edx  
    movl    %edx, 4(%ebx,%eax,4)  
    subl    $1, %eax  
    cmpl    $-1, %eax  
    jne .L6  
.L7:  
    rrmovl   %eax, %ecx  
    addl     %ecx, %ecx  
    addl     %ecx, %ecx  
    addl     %edx, %ecx  
    mrmovl   4(%ecx), %ecx  
    rrmovl   %eax, %ebx  
    addl     %ecx, %ebx  
    addl     %ecx, %ebx  
    addl     %edx, %ebx  
    mrmovl   (%ebx), %ebx  
    subl     %ebx, %ecx  
    jge     .L4  
    addl     %eax, %eax  
    addl     %eax, %eax  
    addl     %edx, %eax  
    rmmovl   %ebx, 4(%eax)  
    addl     %eax, %eax  
    addl     %eax, %eax  
    addl     %edx, %eax  
    rmmovl   %ecx, 4(%eax)  
.L4:  
    subl    $1, %eax  
    irmovl  $-1, %edx  
    subl    %edx, %eax  
    jne .L7  
.L3:  
    addl    $1, %esi  
    subl    %edi, %esi  
    jne .L6  
.L1:  
    popl    %ebx  
    .cfi_def_cfa_offset 12  
    .cfi_restore 3  
    popl    %esi  
    .cfi_def_cfa_offset 8  
    .cfi_restore 6  
    popl    %edi  
  
    .cfi_def_cfa_offset 4  
    .cfi_restore 7  
    ret  
    .cfi_endproc  
.LFE22:  
    .size   bubble_b, .-bubble_b  
    .section    .rodata.str1.1,"aMS",@progbits,1 

课下测试二

posted on 2017-11-12 21:33  20145237  阅读(118)  评论(0编辑  收藏  举报