Advertisement
Guest User

Untitled

a guest
Feb 16th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.52 KB | None | 0 0
  1.         .section        .rodata
  2. scn_fmt:
  3.         .string "%d%d%d%d"
  4. pnt_fmt:
  5.         .string "%d\n"
  6.  
  7.         .data
  8. sum:    .int    0
  9.  
  10.         .text
  11.         .global process
  12. process:
  13.         pushl   %ebp
  14.         movl    %esp, %ebp
  15.  
  16. loop_start_:
  17.         leal    -4(%esp), %eax
  18.         pushl   %eax
  19.         leal    -4(%esp), %eax
  20.         pushl   %eax
  21.         leal    -4(%esp), %eax
  22.         pushl   %eax
  23.         leal    -4(%esp), %eax
  24.         pushl   %eax
  25.         pushl   $scn_fmt
  26.         call    scanf
  27.         addl    $20, %esp
  28.         cmpl    $4, %eax
  29.         jnz     finish_
  30.  
  31.         movl    $0, %eax
  32.         addl    -12(%esp), %eax /* b1 */
  33.         subl    -16(%esp), %eax /* a1 */
  34.  
  35.         addl    -4(%esp), %eax /* b2 */
  36.         subl    -8(%esp), %eax /* a2 */
  37.  
  38.         /* addl    %eax, sum */
  39.  
  40.         movl    -12(%esp), %ecx
  41.         cmpl    -4(%esp), %ecx /* b1 - b2 */
  42.         jl      take_b2_
  43. cnt1_:
  44.         subl    %ecx, %eax
  45.  
  46.         movl    -16(%esp), %ecx
  47.         cmpl    -8(%esp), %ecx /* a1 - a2 */
  48.         jg      take_a2_
  49. cnt2_:
  50.  
  51.         addl    %ecx, %eax
  52.  
  53.         cmpl    $0, %eax
  54.         jg      add_sum_
  55.         jmp     loop_start_
  56.  
  57. finish_:
  58.         pushl   sum
  59.         pushl   $pnt_fmt
  60.         call    printf
  61.         addl    $8, %esp
  62.  
  63.         popl    %ebp
  64.         ret
  65.  
  66. take_b2_:
  67.         movl    -4(%esp), %ecx
  68.         jmp     cnt1_
  69.  
  70. take_a2_:
  71.         movl    -8(%esp), %ecx
  72.         jmp     cnt2_
  73.  
  74. add_sum_:
  75.         addl    %eax, sum
  76.         jmp     loop_start_
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement