this is my code which copies 1st string into 2nd String.

AREA	StrCopy1, CODE
	SWI_WriteC	EQU	&2
 
	ENTRY		; mark the first instruction
main	
	ADR	r1, srcstr	; pointer to first string	
	ADR	r0, dststr	; pointer to second string
	BL		strcopy	; copy the first into second
	SWI	0x11		; and exit

srcstr	DCB " This is my first (source) string",&0a,&0d,0
dststr	DCB " This is my second (destination) string",&0a,&0d,0

	ALIGN		; realign address to word boundary

strcopy
	LDRB	r2, [r1], #1	; load byte, then update address
	STRB	r2, [r0], #1	; store byte, then update address
	CMP	r2, #0		; check for zero terminator
	BNE	printout		; branch if not equal, to Printout
	

printOut
	SWINE	SWI_WriteC	; Print the content
	B			strcopy	; branch to strcopy
	MOV		pc, lr	; return
	END

*******
Now i want to modify the above code so that it encrypts the dststr using Caesar cipher method and which of course will be printed out on the screen aswell.

Thanks for ur reply and i hope it makes the point clear if not feel free to ask me.

Br.

Now i want to modify the above code so that it encrypts the dststr using Caesar cipher method and which of course will be printed out on the screen aswell.

Thanks for ur reply and i hope it makes the point clear if not feel free to ask me.

Br.

A caesar encryption is just a replacement encryption.
Couple of ways to go about this but I only have time to explain two
One is the simpliest you have two strings
ABCDEFGHI
WLPQSRNXZ
You take each char from the source string and find it's equiv in the top string and use that index to find it's equiv in the encryption key there at the bottom.

An faster way would be to setup your encryption key as the previous one for the first 9 characters...
WLPQSRNXZ

Now I find a character in my source string the first character happens to be an 'A' I check a mask to see if it's upper case or lower case and then depending on that outcome I subtract 'A' from it for upper case characters and 'a' from it for lower case characters.
What's this give me? An offset sir 'A' - 'A' is 0 and a 0 offset into our above string is 'W'
'B' - 'A' is 1 so a 1 offset.

thankx for ur reply sir !
whatever i've got so far is in the code if u can pls have a look and correct me:

AREA    text, CODE      

SWI_WriteC	EQU	&0

                ENTRY                   

                ADR	r4, hello       
		ADR	r3, alpha
		ADR	r2, key
loop            
               
                LDRB    r0, [r4], #1    
		CMP     r0, #0          
		BNE	check

check           
		LDRB	r1, [r3], #1
		CMP	r0, r1
		BEQ	encrypt
       		B	loop         
encrypt
                LDRB	r5, [r2], #1
		SUB	r0,r0,r5
		ADD	r5,r5,#1
		STRB	r0,[r5]
		SWINE	SWI_WriteC		
		B	loop	

endP

	MOV	pc, lr			; return
	END

hello	DCB     "Hello World ",0
alpha	DCB	"ABCDEFGHIJKLMNOPQRSTUVWXYZ",0
key	DCB	"XZYCJBTEKMGH",0
This article has been dead for over six months. Start a new discussion instead.