Oh, my gosh! I never realized how horrible it is not to be able to talk. I mean, I love talking so much, and when I couldn't talk anymore, my tongue was all 'ehhhh'! It was the worst! Don't you agree, Fluttershy?
This commit is contained in:
@@ -4,52 +4,52 @@
|
|||||||
* Date : 12.05.2015
|
* Date : 12.05.2015
|
||||||
* Description: This program encrypts a string using ROT3
|
* Description: This program encrypts a string using ROT3
|
||||||
*-----------------------------------------------------------
|
*-----------------------------------------------------------
|
||||||
ORG $3000
|
ORG $3000 ; Start at address 3000
|
||||||
START: ; This is where the program starts - obviously
|
START: ; This is where the program starts - obviously
|
||||||
|
|
||||||
* Put program code here
|
* Put program code here
|
||||||
|
|
||||||
; Load string address
|
; Load string address
|
||||||
move.l #input, A0
|
move.l #input, A0 ; Store the address of the varialbe input into address register A0
|
||||||
move.l #output, A1
|
move.l #output, A1 ; Store the address of the varialbe output into address register A1
|
||||||
|
|
||||||
LOOP:
|
LOOP:
|
||||||
; Load char to register
|
; Load char to register
|
||||||
move.b (A0), D0
|
move.b (A0), D0 ; Store the value at the address stored in address register A0 into data register D0
|
||||||
|
|
||||||
; If end of string is reached end loop
|
; If end of string is reached end loop
|
||||||
cmp.b #0, D0
|
cmp.b #0, D0 ; Compare the constant 0 and the value in the register D0
|
||||||
beq LOOP_END
|
beq LOOP_END ; Jump to label LOOP_END if the value in the register D0 == the constant 0
|
||||||
|
|
||||||
; Apply the encryption key
|
; Apply the encryption key
|
||||||
add.b #key, D0
|
add.b #key, D0 ; Add the constant key and the value in the register D0 and store the result into data register D0
|
||||||
|
|
||||||
; Make the char lower case
|
; Make the char lower case
|
||||||
move.b D0, D1
|
move.b D0, D1 ; Store the value in the register D0 into data register D1
|
||||||
or.b #casebit, D1
|
or.b #casebit, D1 ; Bitwise or the constant casebit and the value in the register D1 and store the result into data register D1
|
||||||
|
|
||||||
; Check if char is greater than 'z'
|
; Check if char is greater than 'z'
|
||||||
cmp.b #z, D1
|
cmp.b #z, D1 ; Compare the constant z and the value in the register D1
|
||||||
ble WRITE_CHAR
|
ble WRITE_CHAR ; Jump to label WRITE_CHAR if the value in the register D1 <= the constant z
|
||||||
|
|
||||||
; Cycle to A after Z
|
; Cycle to A after Z
|
||||||
sub.b #alphabetLength, D0
|
sub.b #alphabetLength, D0 ; Subtract the constant alphabetLength from the value in the register D0 and store the result into data register D0
|
||||||
|
|
||||||
WRITE_CHAR:
|
WRITE_CHAR:
|
||||||
; Write the encrypted char to the output string
|
; Write the encrypted char to the output string
|
||||||
move.b D0, (A1)
|
move.b D0, (A1) ; Store the value in the register D0 into the memory at the address stored in address register A1
|
||||||
|
|
||||||
; Move pointers to next char
|
; Move pointers to next char
|
||||||
add.l #1, A0
|
add.l #1, A0 ; Increase the address in the register A0 by 1
|
||||||
add.l #1, A1
|
add.l #1, A1 ; Increase the address in the register A1 by 1
|
||||||
bra LOOP
|
bra LOOP ; Jump to label LOOP
|
||||||
|
|
||||||
LOOP_END:
|
LOOP_END:
|
||||||
|
|
||||||
; Add '\0' at output string end
|
; Add '\0' at output string end
|
||||||
move.b #0, (A1)
|
move.b #0, (A1) ; Store the constant 0 into the memory at the address stored in address register A1
|
||||||
|
|
||||||
SIMHALT ; halt simulator
|
SIMHALT ; halt simulator
|
||||||
|
|
||||||
* Put variables and constants here
|
* Put variables and constants here
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ casebit EQU $20
|
|||||||
alphabetLength EQU 26
|
alphabetLength EQU 26
|
||||||
|
|
||||||
|
|
||||||
END START ; last line of source
|
END START ; last line of source
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -72,3 +72,4 @@ alphabetLength EQU 26
|
|||||||
*~Font size~10~
|
*~Font size~10~
|
||||||
*~Tab type~1~
|
*~Tab type~1~
|
||||||
*~Tab size~4~
|
*~Tab size~4~
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user