(Solved) : Write Subroutine Divide Two Unsigned 16 Bit Numbers Given Code Change 8 Bit 16 Bit Q42709520 . . .

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

Given code to change from 8-bit to 16-bit:

; Define registers DIVIDND EQU DIVISOR EQU REMAINDR EQU COUNT EQU 0x10 0x11 Ox12 0x13 MAIN: ; Number to be divided MOVLW MOVW

; Define registers DIVIDND EQU DIVISOR EQU REMAINDR EQU COUNT EQU 0x10 0x11 Ox12 0x13 MAIN: ; Number to be divided MOVLW MOVWF MOVLW MOVWF RCALL BRA OxFF DIVIDND OxOA DIVISOR DIVIDE HERE ; Divisor ;Call divide routine HERE: DIVIDE: LOOP: MOVLW MOVWF CLRF BCF RLCF RLCF MOVF SUBWF BTFSS BRA 0x08 ;Set up counter for 8 rotations COUNT REMAINDR ;Clear remainder register STATUS, C,0 ;Clear carry flag DIVIDND ; Take seventh bit in Carry flag REMAINDR ;Place carry flag in remainder DIVISOR, W ;Get divisor in WREG REMAINDR, O ;Subtract divisor from remainder ;- save in WREG STATUS, C,0 ;Test carry flag RESETO ;If dividend <divisor, go to ;reset carry flag SETO: DIVIDND, 0,0 ;If dividend > divisor, set ;carry flag REMAINDR, 0 ; Save remainder for next ; operation NEXT DIVIDND, 0,0;No quotient – reset carry flag COUNT, 1,0 ; One operation complete – ; decrement count LOOP ;Are eight rotations complete? ;If not go back BSF MOVWF RESETO: NEXT: BRA BCF DECF BNZ RETURN END Show transcribed image text ; Define registers DIVIDND EQU DIVISOR EQU REMAINDR EQU COUNT EQU 0x10 0x11 Ox12 0x13 MAIN: ; Number to be divided MOVLW MOVWF MOVLW MOVWF RCALL BRA OxFF DIVIDND OxOA DIVISOR DIVIDE HERE ; Divisor ;Call divide routine HERE: DIVIDE: LOOP: MOVLW MOVWF CLRF BCF RLCF RLCF MOVF SUBWF BTFSS BRA 0x08 ;Set up counter for 8 rotations COUNT REMAINDR ;Clear remainder register STATUS, C,0 ;Clear carry flag DIVIDND ; Take seventh bit in Carry flag REMAINDR ;Place carry flag in remainder DIVISOR, W ;Get divisor in WREG REMAINDR, O ;Subtract divisor from remainder ;- save in WREG STATUS, C,0 ;Test carry flag RESETO ;If dividend divisor, set ;carry flag REMAINDR, 0 ; Save remainder for next ; operation NEXT DIVIDND, 0,0;No quotient – reset carry flag COUNT, 1,0 ; One operation complete – ; decrement count LOOP ;Are eight rotations complete? ;If not go back BSF MOVWF RESETO: NEXT: BRA BCF DECF BNZ RETURN END

Expert Answer


Answer to Write a subroutine to divide two unsigned 16-bit numbers. Given code to change from 8-bit to 16-bit:…

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?