Question: Need help with string reverse function ; ; string_reverse.asm .include m2560def.inc ;SPH, SPL, RAMEND, etc. are defined in m2560def.inc .cseg ; initialize the stack pointer
Need help with string reverse function ; ; string_reverse.asm .include "m2560def.inc" ;SPH, SPL, RAMEND, etc. are defined in "m2560def.inc" .cseg ; initialize the stack pointer ldi r16, low(RAMEND) out SPL, r16 ldi r16, high(RAMEND) out SPH, r16 ; prepare the parameters X and Z ldi ZH, high(src<<1) ldi ZL, low(src<<1) ldi XH, high(dest) ldi XL, low(dest) ;call subroutine void strcpy(src, dest) call strcpy ;call subroutine: str_reverse(dest, mesg) ;write your code here ; program ends here done: jmp done ; This subroutine (function) copies a null-terminated string ; starting at some (source) program memory address to a location starting ; at some (destination) memory address. ; The memory addresses are passed to the subroutine via the X and Z pointers strcpy: ; copy the string from source (Z) to destination (X) next_char: lpm r23, Z+ st X+, r23 tst r23 brne next_char strcpy_done: ret ; Write your str_reverse subroutine and comments here. ; Using push and pop, reverse the c-string and store at a different memory ; location. The memory addresses are passed to the subroutine via pointers. str_reverse: ; write your code here src: .db "Hello, world!", 0 ; c-string format .dseg .org 0x200 dest: .byte 14 reversed: .byte 14
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
