162k views
4 votes
Write an assembly language program that will accept a single character from the keyboard, and then output the next character in the ASCII sequence. For example, if the character 'A' is entered, the character 'B' will be typed out.

1 Answer

2 votes

Answer:

Step-by-step explanation:

.LC0:

.string "Enter a alphabet "

.LC1:

.string "%c"

.LC2:

.string "The next alphabet is %c"

main:

push rbp

mov rbp, rsp

sub rsp, 16

mov edi, OFFSET FLAT:.LC0

mov eax, 0

call printf

lea rax, [rbp-5]

mov rsi, rax

mov edi, OFFSET FLAT:.LC1

mov eax, 0

call scanf

movzx eax, BYTE PTR [rbp-5]

movsx eax, al

add eax, 1

mov DWORD PTR [rbp-4], eax

mov eax, DWORD PTR [rbp-4]

mov esi, eax

mov edi, OFFSET FLAT:.LC2

mov eax, 0

call printf

mov eax, 0

leave

ret

OUTPUT

Enter a alphabet C

The next alphabet is D

Explanation

Here the logic used is first we converted the input character to its corresponding ASCII value and we added one to it and again it is converted back to corresponding alphabet and displayed

User Marz
by
4.6k points