Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assembly Language Question In other words, the advantage of using ROT13 rather t

ID: 3855347 • Letter: A

Question

Assembly Language Question

In other words, the advantage of using ROT13 rather than ROTn where n 13 is that since there are 26 letters in the alphabet, n = 13 is the only value that can use the same algorithm for encoding and decoding.

Uppercaser code:

Your code should use STDIN and STDOUT for input and output. (This is the default.) Use redirection on the command line to read from a file and write to a file. Your code should open a file, read it character by character and output each character in ROT 13 encoding. Assume that the input file contains just ASCII text Don't worry about what happens with non-text files. section .bss Buff resb 1 section .data section .text global _start _start: nop; This no-op keeps the debugger happy Read: mov eax, 3; Specify sys_read call mov ebx, 0; Specify File Descriptor 0: Standard Input mov ecx, Buff; Pass offset of the buffer to read to mov edx, 1; Tell sys_read to read one char from stdin int 80h; Call sys_read cmp eax, 0; Look at sys_read's return value in EAX je Exit; Dump If Equal to 0 (0 means EOF) to Exit; or fall through to test for lowercase cmp byte [Buff], 61h; Test input char against lowercase 'a' jb Write; If below 'a' in ASCII chart, not lowercase cmp byte [Buff], 7Ah; Test input char against lowercase 'z' ja Write; If above 'z' in ASCII chart, not lowercase; At this point, we have a lowercase character sub byte [Buff], 20h; Subtract 20h from lowercase to; give uppercase...; ...and then write out the char to stdout Write: mov eax, 4; Specify sys_write call mov ebx, 1; Specify File Descriptor 1: Standard output mov ecx, Buff; Pass address of the character to write mov edx, 1; Pass number of chars to write int 80h; Call sys_write... jmp Read; then go to the beginning to get another char Exit: mov eax, 1; Code for Exit Syscall mov ebx, 0; Return a code of zero to Linux int 80H; Make kernel call to exit program

Explanation / Answer

Code Encoding:

section .bss
Buff resb 1

section .data

section .text
global _start

_start:
   nop

Read:
   mov eax,3
   mov ebx,STDIN
   moc ecx,Buff
   move edx,1
   int 80h

   cmp eax,0
   je Exit
   cmp byte [Buff],61h
   jb upper
   cmp byte [Buff],7Ah
   jb upper
   jmp encode

upper:
   cmp byte [Buff],41h
   jb write
   cmp byte [Buff],5Ah
   ja write
   jmp encode

encode:
   add byte [Buff],0Dh

write:
   mov eax,4
   mov ebx,1
   mov ecx,Buff
   mov edx,1
   int 80h
   jmp Read

Exit:
   mov eax,1
   mov ebx,0
   int 80H

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote