Logo 
Search:

Assembly Language Articles

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

Program to determine the HCF of N 1 byte numbers

Posted By: Meryl Schmidt     Category: Assembly Language     Views: 3513

Write an assembly program to determine the HCF of N 1 byte numbers.

Code for Program to determine the HCF of N 1 byte numbers in Assembly Language

.model small

.data
        arr db 9,18,27
        cnt db 0
        min db 50
        ans db ?

.code
        mov ax,@data
        mov ds,ax

        LEA DI,cnt
        LEA SI,arr
        mov cx,3

        FinMin:
                mov ah,BYTE PTR[SI]
                cmp ah,min
                jg IncSI
                mov min,ah
                inc SI
                Loop FinMin
                jmp FindHcf
        IncSi:
                inc SI
                Loop FinMin

        FindHcf:
                mov ch,min
                mov cnt,0
                mov ax,00

                Chk1:
                        mov ah,00
                        add cnt,1
                        cmp cnt,ch
                        jg ext
                        LEA SI,arr
                        mov al,BYTE PTR [SI]
                        div cnt
                        cmp ah,00
                        jne Chk1

                        Chk2:
                                Inc SI
                                mov ah,00
                                mov al,BYTE PTR [SI]
                                div cnt
                                cmp ah,00
                                jne Chk1

                                Chk3:
                                        Inc SI
                                        mov ah,00
                                        mov al,BYTE PTR [SI]
                                        div cnt
                                        cmp ah,00
                                        jne Chk1

                                        mov ax,0000                                                        
                                        mov al,cnt
                                        mov ans,al
                                        cmp cnt,ch
                                        jle Chk1
             ext:
                mov ax,0
                mov ah,ans

                add ans,30h
                mov ah,02h
                mov dh,00
                mov Dl,ans
                int 21h



                mov ax,4C00h
                int 21h
end
  
Share: 


Didn't find what you were looking for? Find more on Program to determine the HCF of N 1 byte numbers Or get search suggestion and latest updates.

Meryl Schmidt
Meryl Schmidt author of Program to determine the HCF of N 1 byte numbers 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!