.title right .ident /831205/ ;Takes a substring from the right ; ;Register usage: ; R0 span of right substring ; R1 destination of substring ; R2 source string ; right:: mov sp,r0 cmp (r0)+,(r0)+ mov (r0),r1 ;destination mov r2,(r0)+ mov (r0),r2 ;source mov (sp)+,(r0) ; mov #-1,r0 ;find length of source 1$: inc r0 tstb (r2)+ bne 1$ ; clrb (r1) ;mark end just in case tst (sp) ;determine length desired ble 4$ cmp r0,(sp) ble 2$ mov (sp),r0 ; 2$: sub r0,r2 ;copy substring across dec r2 ; 3$: movb (r2)+,(r1)+ bne 3$ ; 4$: tst (sp)+ mov (sp)+,r2 rts pc .end