Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. [20 Points] Write a subroutine that multiplies the top nibble and the bottom nibble of a number in W and returns the result in

image text in transcribed

4. [20 Points] Write a subroutine that multiplies the top nibble and the bottom nibble of a number in W and returns the result in W. The setup and call of the subroutine are below. Fill in the details between the label Mult_nybbles and the RETURN instruction. Keep your routine less than about 20 instructions, but use any algorithm you like. Hint 1: Split the nybbles into two different registers using ANDWF with a bit mask. Hint 2: keep it simple - remember what you did in grade school. Hint 3: there are more than on solution, if it gets the job done within the about 20 instructions... (feel free to use back of page, but please mark clearly that you have) ; Variable declarations VarA VarB VarC Index ; Constants (for testing) NybbleA NybbleB : Start of code Load W ; Use these as you wish! EQU H'20 EQU H'21 EQU H' 22 EQU H'23 EQU H'3 EQU H'7' MOVLW MOVWF SWAPF ADDLW CALL MOVWF NybbleA VarA VarA, W NybbleB Mult nybbles VarC ; Put 0x3 into VarA ; Now W is 8x30 ; Now W is 0x37 ; Should be NybbleA*NybbleB (0x15) Mult_nybbles; Write your code below 4. [20 Points] Write a subroutine that multiplies the top nibble and the bottom nibble of a number in W and returns the result in W. The setup and call of the subroutine are below. Fill in the details between the label Mult_nybbles and the RETURN instruction. Keep your routine less than about 20 instructions, but use any algorithm you like. Hint 1: Split the nybbles into two different registers using ANDWF with a bit mask. Hint 2: keep it simple - remember what you did in grade school. Hint 3: there are more than on solution, if it gets the job done within the about 20 instructions... (feel free to use back of page, but please mark clearly that you have) ; Variable declarations VarA VarB VarC Index ; Constants (for testing) NybbleA NybbleB : Start of code Load W ; Use these as you wish! EQU H'20 EQU H'21 EQU H' 22 EQU H'23 EQU H'3 EQU H'7' MOVLW MOVWF SWAPF ADDLW CALL MOVWF NybbleA VarA VarA, W NybbleB Mult nybbles VarC ; Put 0x3 into VarA ; Now W is 8x30 ; Now W is 0x37 ; Should be NybbleA*NybbleB (0x15) Mult_nybbles; Write your code below

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions

Question

When you say weve doubled our profit level, you are (wrong).

Answered: 1 week ago