Question

Write a subroutine to divide two unsigned 16-bit numbers.

EXPERT ANSWER

Subroutine to divide two unsigned 16-bit numbers:

;Declares Quotient

clrf Quotient

;Increment the Quotient

clrf Quotient +1

;Moves the value to Q

movlw 1

;Intitialize the Count

movwf Count

;Increment Count +1

clrf Count +1

;Starting Loop

StartLoop

;Finding How Large the Divisor Can be Divisor as &

btfsc Divisor +1, 7

;If at the Top, Then Do

goto Loop

;Then Division Getting the BCF status

bcf STATUS, C

;Shift Count and Divisor up

rlf Count +1

;Divisor Up

rlf Divisor

;Increment the Divisor +1

rlf Divisor +1

goto StartLoop

Loop

;Now,