Commit 6c5c46ede86a61370552b02d330f0ff7dc548229

Authored by Pierre Cwik
1 parent f9b47477

fin exo 4 avec premier assembleur manuel

Showing 2 changed files with 69 additions and 1 deletions   Show diff stats
answerstoquestions
... ... @@ -174,7 +174,7 @@ main:
174 174  
175 175 rip (8 octets)
176 176 rpb (8 octets)
177   -eax/1 (4 octets)
  177 +eax/2 (4 octets)
178 178 .. (4 octets)
179 179 .. (4 octets)
180 180 .. (4 octets)
... ... @@ -230,6 +230,21 @@ main:
230 230 .section .note.GNU-stack,"",@progbits
231 231  
232 232  
  233 +1 (4 octets)
  234 +1 (4 octets)
  235 +eip (4 octets)
  236 +ebp (4 octets)
  237 +-- (4 octets)
  238 +-- (4 octets)
  239 +eax/2 (4 octets)
  240 +-- (4 octets)
  241 +-- (4 octets)
  242 +-- (4 octets)
  243 +-- (4 octets)
  244 +-- (4 octets)
  245 +edx/2 (4 octets)
  246 +eax/LCO (4 octets)
  247 +
233 248  
234 249  
235 250  
... ...
premierass_embleur.s 0 → 100644
... ... @@ -0,0 +1,53 @@
  1 +.section .rodata
  2 +.LC0:
  3 + .string "%d\n"
  4 + .text
  5 + .globl multiplier
  6 + .type multiplier, @function
  7 +multiplier:
  8 +
  9 +pushq %rbp
  10 +movq %rsp, %rbp
  11 +subq $48, %rsp
  12 +movq %rdi, -32(%rbp)
  13 +movq %rsi, -40(%rbp)
  14 +cmpq $0, -32(%rbp)
  15 +jne .L1
  16 +movq $0, %rax
  17 +jmp .L10
  18 +.L1:
  19 +cmpq $1, -32(%rbp)
  20 +jne .L2
  21 +movq -40(%rbp), %rax
  22 +jmp .L10
  23 +.L2:
  24 +movq -40(%rbp), %rax
  25 +subq $1, -32(%rbp)
  26 +.L7:
  27 +add -40(%rbp), %rax
  28 +subq $1, -32(%rbp)
  29 +cmpq $0, -32(%rbp)
  30 +jne .L7
  31 +.L10:
  32 +leave
  33 +ret
  34 +
  35 + .globl main
  36 + .type main, @function
  37 +main:
  38 +pushq %rbp
  39 +movq %rsp, %rbp
  40 +subq $24, %rsp
  41 +movq $10, -16(%rbp)
  42 +movq $20, -24(%rbp)
  43 +movq -16(%rbp), %rdi
  44 +movq -24(%rbp), %rsi
  45 +call multiplier
  46 +movq %rax, -8(%rbp)
  47 +movq -8(%rbp),%rsi
  48 +movq $.LC0,%rdi
  49 +movq $0, %rax
  50 +call printf
  51 +leave
  52 +ret
  53 +
... ...