All pastes #435717 Raw Edit

Untitled

public text v1 · immutable
·published 2007-04-12 02:50 UTC
rendered paste body

;Christina Hill
;email: chill5
;ECE 267  Spring '07
;Project 3- Prime Factorization
;DUE: 4/11/07 11:55 pm
;Professor Goncharoff




INCLUDE Irvine32.inc

.data
String1 BYTE "Enter N: ", 0
String2 BYTE "N = ", 0
String3 BYTE " x "
N DWORD ?
M DWORD ?
Count SDWORD 2
Q DWORD ?
R DWORD ?
	 
.code
main PROC
     mov edx, OFFSET String1
     call WriteString
     call ReadInt
     mov edx, OFFSET String2
     call WriteString
     call WriteInt
     call crlf
     
     mov N, eax
        
	call Find_Factors
        
     exit
 main ENDP
 
 Find_Factors PROC
	mov edx, OFFSET String2
	call WriteString
	mov eax, N
	call WriteInt
	call crlf
	
	mov edx, 0
	mov eax, N
	div Count
	mov M, eax
	call WriteInt
	call crlf
	
	mov M, eax

A0:	.IF (Count <= eax)
		mov eax, N
		div Count
		mov Q, eax
		mov R, edx
		.IF (R == 0)
			mov edx, R
			call WriteInt
			mov edx, OFFSET String3
			call Writestring
			call crlf
			mov eax, Q
			mov N, eax
			jmp A0
		.ELSE
			mov ebx, Count
			shr ebx, 1
			mov Count, ebx
			jmp A0
		.ENDIF
	.ELSE
		mov eax, N
		call WriteString
		call crlf
	.ENDIF
 
	exit
Find_Factors ENDP

END main