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.

Recommended Answers

All 4 Replies

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

An easy implementation of a stack is simply an array which you only access at one end.

How to push the value in 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
.data
aName BYTE "Abraham Lincoln",0
nameSize = ($ - aName) - 1
.code
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
 exit
main ENDP
END main
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.