; School of Computer Engineering
; K.N. Toosi University of Technology

%include "asm_io.inc"

segment .data

prime_msg:      db "Prime!", 10, 0
notprime_msg:   db "Not prime!", 10, 0


segment .text

global asm_main

asm_main:
        enter 0,0
        pusha
        ;; ==========================
        call read_int
        mov ebx, eax
        
        mov ecx, 2
startloop:
        call print_int 
        
        cmp ecx, ebx
        jge endloop
        
        mov eax, ebx
        mov edx, 0

        div ecx

        cmp edx, 0
        je  notprime_lbl


        inc ecx
        
        jmp  startloop

endloop:        
        mov     eax, prime_msg
        call    print_string

        jmp     endl
        
notprime_lbl:
        mov eax, notprime_msg
        call print_string
        
endl:   
        
                
        ;; ==========================
        popa
        leave
        ret