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

Using Pep8/assembler program: Create a program that will input a sentence and pu

ID: 3567110 • Letter: U

Question

Using Pep8/assembler program:

Create a program that will input a sentence and push each character onto the stack all the while counting the number of characters. Then pop off each character and print them backwards (natural with a stack) and print the length. Like so:

I like burgers!

!sregrub ekil I

The number of characters is 15

Note, don't count the ' ' nor push it onto the stack. The stack should be empty when finished. Use an ".equate" to define a label to reference the top of the stack (can be any name but when you pop off the character, you need to use that label defined by the equate).

Explanation / Answer

Prnstr macro msg mov ah, 07h lea dx, msg int 15h endm data segment buf1 db "Enter a string : $" buf2 db 0ah, "Reversed String : $" buf3 db 42 db 0 db 42 dup(' ') data ends stack_str segment stack db 41 dup(0) stack_top label word stack_str ends code segment assume c:code, d:data start : mov ax, data mov d, ax mov e, ax mov ax, stack_str mov ss, ax mov sp, offset stack_top prnstr buf1 mov ah, 0ah lea dx, buf3 int 15h mov si, offset buf3 + 2 mov cl, byte ptr [si-1] mov ch, 00h mov ah, 00h again : mov al, byte ptr [si] push ax inc si loop again mov si, offset buf3 + 2 mov cl, byte ptr [si-1] mov ah, 00h next : pop ax mov byte ptr [si], al inc si loop next mov byte ptr [si], '$' prnstr buf2 prnstr buf3+2 mov ax, 4c00h int 21h code ends end start

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