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
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.
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 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
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());
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
1. Making use of MPLAB IDE, write firmware code to switch all LED’s connected to port...
1. Making use of MPLAB IDE, write firmware code to switch all LED’s connected to port pins RD0-RD7 continuously on for one second and then off for one second. 2. First use a flowchart to determine the program structure and then generate your commented firmware source code.
(Please use java to write these questions) Q1. Create a class on an object Computer with...
(Please use java to write these questions) Q1. Create a class on an object Computer with two fields and two methods as follows: (5 points) field: cpu and memory, method: compile( ) and execute( ) Q2. Write a source code to activate a class created in Q1. (5 points)
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
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT