Question

Q1) Multiply R16, and R17 and send output on port A and Port B. Write code...


Q1) Multiply R16, and R17 and send output on port A and Port B. Write code in Assembly

Q2) Write assembly code to devide R17 value with R18 value.

Homework Answers

Answer #1

solution:

values of base and high in two registers (R16 and R18). These are 8 bit values

.include "./m2560def.inc"  
;
; Constants
;
.def base = r16
.def high = r17

.equ base_value = 10
.equ high_value = 20

.cseg
.org 0x0000
rjmp reset ; reset intr
reset:
LDI R16, HIGH(RAMEND)
OUT SPH, R16
LDI R16, LOW(RAMEND)
OUT SPL, R16

RCALL configure_ports

start:
LDI base, base_value
LDI high, high_value
MUL base, high
MOVW R18, R0
LSR R18 ;divide by 2
MOV R19, R18
OUT PORTB, R19 ;Output result in PORTB
OUT PORTD, R19 ;Output result in PORTD
RJMP start

configure_ports:
;Configurare B and C ports as outputs
LDI R16, 0XFF
OUT DDRB, R16
OUT DDRC, R16
ret

please give me thumb up

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
FROM The HCS12 / 9S12 (2nd Edition) E4.19 please use C language to write the code...
FROM The HCS12 / 9S12 (2nd Edition) E4.19 please use C language to write the code and submit the code and pictures of the running circuit on the board. (1) Write an instruction sequence to configure Port A and Port B for input and output, respectively; read the value of Port A and output the value to Port B.
Write an assembly language instruction to program the 82C55 to get data from port A and...
Write an assembly language instruction to program the 82C55 to get data from port A and send it to port B, if PA=IN, PB=OUT, PC0-PC3=IN, and PC4- PC7=OUT and operating in Mode 0. Use port addresses of 300H-303H for the 82C55 chip.
Explain the portions of code that write to the serial port. What do these portions of...
Explain the portions of code that write to the serial port. What do these portions of the code do? Why is the display of the month treated differently? Serial.print((minutes & 0x70)>>4); Serial.print(minutes & 0x0F); lcd.print(now.month());
write a MIPS assembly program to get an integer input from the user and multiply it...
write a MIPS assembly program to get an integer input from the user and multiply it by 2 and print output to the console
Q1: Re-write following if-else-if statements as Switch statement. Your final code should result in the same...
Q1: Re-write following if-else-if statements as Switch statement. Your final code should result in the same output as the original code below. if (selection == 10) System.out.println("You selected 10."); else if (selection == 20) System.out.println("You selected 20."); else if (selection == 30) System.out.println("You selected 30."); else if (selection == 40) System.out.println("You selected 40."); else System.out.println("Not good with numbers, eh?"); Q2: Re-write following while loop into Java statements that use a Do-while loop. Your final code should result in the same...
Q1. Write a delay routine for 8051 to create a delay of approximately 1 ms. Q2....
Q1. Write a delay routine for 8051 to create a delay of approximately 1 ms. Q2. Write a routine for 8051 to create a rectangular wave (on port 2, bit 1) of 66% duty cycle using the above delay routine.
For Java programming code: Write methods to add and multiply 1) Two integers 2) Two decimals...
For Java programming code: Write methods to add and multiply 1) Two integers 2) Two decimals 3) One integer and one decimal
Analyze the following Verilog code and write down its output as pictured in the code. module...
Analyze the following Verilog code and write down its output as pictured in the code. module blocking; reg [0:7] A, B; initial begin: init1 A = 3; #1 A = A + 1; // blocking procedural assignment B = A + 1; $display("Output 1: A= %b B= %b", A, B ); A = 1; #1 A <= A + 1; B <= A + 1; #1 $display ("Output 2: A= %b B= %b", A, B ); end endmodul
Write a short MARIE program. Answer ASAP. Will upvote. This program will let the user input...
Write a short MARIE program. Answer ASAP. Will upvote. This program will let the user input two decimal values a and b. Then this program will calculate c = a + b and output the result. Q1) Write down the code which let the user input two valuesa and b. The code need to store the input values. Q2) Write down the code which calculates c = a + b. The code need to store the result into variable c....
Write in pseudo-code how to find the average grade for a class given: quiz grades q1,q2,q3,q4...
Write in pseudo-code how to find the average grade for a class given: quiz grades q1,q2,q3,q4 homework grades h1,h2,h3,h4 Where the final grade is weighted 30% for homework and 70% for quizzes, but with the rule that the lowest homework grade will be excluded if it helps the grade.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT