Last active
February 20, 2016 01:17
-
-
Save boarnoah/746277581ab6f7ed02a1 to your computer and use it in GitHub Desktop.
String reversal assembly pic24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.include "xc.inc" | |
.bss | |
sz_1: .space 16 | |
sz_2: .space 16 | |
mplab_x_bug: .space 2 | |
.section .const, psv | |
sz_1_const: .asciz "Upper/LOWER." | |
sz_2_const: .asciz "mIXeD CaSe.." | |
.text | |
.global __reset | |
__reset: | |
mov #__SP_init, W15 | |
mov #__SPLIM_init, W0 | |
mov W0, SPLIM | |
call init_variables | |
rcall main | |
;reset ;not sure if we need this for now(?) | |
main: | |
;load addr for s1, s2 | |
mov #sz_1, W1 | |
mov #sz_2, W2 | |
;start dostr | |
rcall dostr | |
;dostr(*s1, *s2) | |
;DEFINITIONS: | |
;*sz_1 w1 | |
;*sz_2 w2 | |
;w3 -> tmp | |
;w4 -> c | |
dostr: | |
;(i.e *psz_1 - 0, then check if the result is not zero, | |
; if result was 0 then *psz_1 must have been 0 | |
mov[W1], W5 | |
cp.b W5, #0 | |
bra Z END_PROGRAM | |
mov.b [W1], W3 | |
mov.b [W2], W4 | |
cp.b W4, #0X2F; c - 0X2F | |
bra leu, LOOP1_ELSE ; if(c <= 0x2f go to the else{} | |
xor.b W4, #0X20, [W1];psz_1 = c ^ 0x20 | |
rcall LOOP1_END | |
LOOP1_ELSE: | |
mov.b W4, [W1];*sz_1 = c | |
rcall LOOP1_END | |
LOOP1_END: | |
mov.b W3, [W3] | |
inc [W1], [W1] | |
inc [W2], [W2] | |
rcall dostr | |
END_DOSTR: | |
;do w/e the f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment