Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %include "asm_io.inc"
- CPU 386
- segment .data
- msg db "Trova i numeri primi da 2 ad N. Inserisci N: ",0
- segment .bss
- n resq 1
- temp resq 1
- segment .text
- global _asm_main
- _asm_main:
- enter 0,0
- pusha
- mov eax,msg
- call print_string
- call read_int
- mov [n],eax
- jmp test_primalita
- test_primalita:
- mov eax,2
- call print_int
- call print_nl
- mov eax,3
- while_primo:
- cmp eax,[n]
- jnle end_primo
- mov ebx,3
- while_secondo:
- cmp ebx,eax
- jnl end_secondo
- mov [temp],ebx
- mov ecx,eax
- mov edx,0
- idiv ebx
- cmp edx,0
- mov eax,ecx
- je end_secondo
- mov ebx,[temp]
- add ebx,2
- jmp while_secondo
- end_secondo:
- cmp edx,0
- jne stampa
- jmp continua
- stampa:
- call print_int
- call print_nl
- jmp continua
- continua:
- add eax,2
- jmp while_primo
- end_primo:
- popa
- mov eax,0
- leave
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement