Your assignment is to write an assembly program that takes a series of characters from the keyboard until a '$' character is entered. These characters must be saved in a stack. Then the program is to print all these characters backwards.

9 Years
Discussion Span
Last Post by qrius

I would like to know ,How to push the charachters which you entered in the stack and pop it from the stack


this is a code that shows how to push somethin on a stack, and then pop it out reversed, hope it helps u... enjoy...

; This program reverses a string.
INCLUDE Irvine32.inc
aName BYTE "Abraham Lincoln",0
nameSize = ($ - aName) - 1
main PROC
; Push the name on the stack.
 mov ecx,nameSize
 mov esi,0
L1: movzx eax,aName[esi] ; get character
 push eax ; push on stack
 inc esi
 Loop L1
; Pop the name from the stack, in reverse,
; and store in the aName array.
 mov ecx,nameSize
 mov esi,0
L2: pop eax ; get character
 mov aName[esi],al ; store in string
 inc esi
 Loop L2
; Display the name.
 mov edx,OFFSET aName
 call Writestring
 call Crlf
main ENDP
END main
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.