Midterm_sol - the result in rlf PRODUCT_H, f ; product rlf...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
;-------------------------- ; EE 331 ; Midterm Question 4 ; Fall 2010 ;-------------------------- LIST p=16F84 ; PIC16F844 is the target processor #include "P16F84.INC" ; Include header file MULTIPLICAND equ h'30' PRODUCT_L equ h'31' PRODUCT_H equ h'32' TEMP_L equ h'33' TEMP_H equ h'34' ORG 0 entrypoint goto initialise initialise movlw d'200' movwf MULTIPLICAND ; set multiplicand to 200 for testing call MUL_12 ; call subroutine to multiply by 12 goto endfunc ; go to end of program ; subroutine to multiply by 12 MUL_12 movf MULTIPLICAND, w ; move multiplicand to W movwf PRODUCT_L ; move multiplicand to lower byte of result clrf PRODUCT_H ; clear upper byte movwf TEMP_L ; move multiplicand to lower byte of temporary clrf TEMP_H ; clear upper byte bcf STATUS, C rlf PRODUCT_L, f ; multiply multiplicand by 8 and keep
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: the result in rlf PRODUCT_H, f ; product rlf PRODUCT_L, f rlf PRODUCT_H, f rlf PRODUCT_L, f rlf PRODUCT_H, f bcf STATUS, C rlf TEMP_L, f ; multiply multiplicand by 4 and keep the result in rlf TEMP_H, f ; temp rlf TEMP_L, f rlf TEMP_H, f ; add product to temp to get multiply by 12 movf TEMP_L, w ; move the lower byte of temp to W addwf PRODUCT_L, f ; add the lower byte of temp to lower byte of product btfsc STATUS, C ; if there was a carry incf PRODUCT_H,f; increment upper byte of product movf TEMP_H, w ; move upper byte of temp to W addwf PRODUCT_H, f ; add the upper byte of temp to upper byte of product return ; the result is now in product ; end of subroutine to multiply by 12 endfunc END...
View Full Document

Page1 / 6

Midterm_sol - the result in rlf PRODUCT_H, f ; product rlf...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online