Advertisement
auriza

posneg.asm

Mar 1st, 2021
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Positif/Negatif
  2.  
  3. global main
  4. extern scanf,printf
  5.  
  6. section .data
  7.     fmtin   db      "%d",0
  8.     pos     db      "positif",10,0
  9.     nol     db      "nol",10,0
  10.     nega    db      "negatif",10,0
  11.  
  12. section .bss
  13.     x       resd    1
  14.  
  15. section .text
  16.  
  17.     main:   ; scanf("%d", &x);
  18.             push    x
  19.             push    fmtin
  20.             call    scanf
  21.             add     esp, 8
  22.  
  23.             ; if      (x  > 0) printf("positif");
  24.             ; else if (x == 0) printf("nol");
  25.             ; else             printf("negatif");
  26.             cmp     dword [x], 0
  27.             jg      print_pos
  28.             je      print_nol
  29.             jl      print_neg
  30.  
  31.     print_pos:
  32.             push    pos
  33.             jmp     print
  34.     print_nol:
  35.             push    nol
  36.             jmp     print
  37.     print_neg:
  38.             push    nega
  39.  
  40.     print:  call    printf
  41.             add     esp, 4
  42.  
  43.             mov     eax, 0
  44.             ret
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement