Help writing a program in assembly language in pep 8 assembler Create a program
ID: 3567036 • Letter: H
Question
Help writing a program in assembly language in pep 8 assembler
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).
please help I am stuck heres what I got:
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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.