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

ASSEMBLY LANGUAGE (NASM) PROBLEM 1. Your code will look very similar to Dunteman

ID: 3594681 • Letter: A

Question

ASSEMBLY LANGUAGE (NASM) PROBLEM

1. Your code will look very similar to Dunteman's uppercaser code that we went
through in class.
2. 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.
3. Your code should open a file, read it character by character and output each
character in ROT13 encoding.
4. Assume that the input file contains just ASCII text Don't worry about what
happens with non-text files.
Hints
1. There are really two different parts to this problem. One is how to do I/O, the
second is how to do ROT13 encoding. Solve one problem at a time.
2. Start with how to do I/O. That will be very similar to the uppercaser code.
3. Once you've got that figured out, you can do the ROT13 encoding part.
4. Note that ROT13 only changes the values 'a' through 'z' and 'A' through 'Z'. All
other characters remain unchanged.

Dunteman's uppercase code to begin:

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 ; Jump 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:

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