Logo 
Search:

Assembly Language Articles

Submit Article
Home » Articles » Assembly Language » Homework HelpRSS Feeds

To find the Prime Numbers between 1 to 50

Posted By: Ludvig Fischer     Category: Assembly Language     Views: 16977

Program to find the Prime Numbers between 1 to 50.

Code for To find the Prime Numbers between 1 to 50 in Assembly Language

Data Segment
    arrprime db 20 dup (?)
    i db 02h
Data Ends

Code Segment
    Assume cs:code, ds:data
Begin:   
    mov ax, data
    mov ds, ax
    mov es, ax

    mov dl, 01h
    mov cx, 10h
    lea di, arrprime
    
    L1:
       mov bl, 02
       add dl, 01h

       cmp dl, 02h
       je Insert
       cmp dl, 03h
       je Insert
       cmp dl, 04h
       jge Logic

    Logic:
          mov ah, 00
          mov al, dl
          div bl
          cmp ah, 00
      je L1
          add bl, 01h
          cmp bl, al  
          jle Logic
      jmp insert

    Insert:
       mov [di], dl
       inc di
       loop L1

    Exit:
       mov ax, 4c00h
       int 21h
Code Ends
End Begin
    
  
Share: 


Didn't find what you were looking for? Find more on To find the Prime Numbers between 1 to 50 Or get search suggestion and latest updates.

Ludvig Fischer
Ludvig Fischer author of To find the Prime Numbers between 1 to 50 is from Frankfurt, Germany.
 
View All Articles

 

Other Interesting Articles in Assembly Language:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!