• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

Xeee

About assembly , stacks

5 posts in this topic

kindly, would you tell me what is the use of stacks in assembly (it is created using .STACK , right??!!), i know just the two instructions pop , push , so what is its use?? thanks for care ...Xeee
0

Share this post


Link to post
Share on other sites
I''ll try to be general here (since I''ve only done MIPS assembly, and everything here is basically Intel based), but a stack is just a place in memory where local variables and such are stored. There is usually a specific register which is called the stack pointer (henceforth called SP), and it points to the top of the stack. For example, when a function call is made, the local variables in the calling function must be stored so they aren''t overwritten by local variables in the callee function. They are stored by ''pushing'' them on the stack (ie, saved at the pointer where SP points to, then SP is decremented so the next variable can be saved). When the callee function returns to the previous function, each variable is the ''popped'' off the stack (ie, the SP is incremented, and then the variabled saved at where SP is located is taken off the stack).

That is how a stack is used in assmebly, but stacks can be used for anything else, and often are. They are basically a FILO queue (First In Last Out).

Hope that helps (/me is not much of a teacher)
Nutts
0

Share this post


Link to post
Share on other sites
The stack is also used to store return addresses for procedures. When you use the CALL instruction, the IP address of the next instruction is pushed on the stack. When the RET address is executed, the last number is popped from the stack and put in the IP. You can also hijack the stack for local variable storage, as long as you have enough space allocated. When someone talks about a stack frame, they''re basically saying that there is a region of memory that holds arguments to a function/procedure, the return address, and some extra space set aside for local variables. I believe the BP register is used to give a base for looking into the stack. The ENTER and LEAVE instructions can take care of maintaining the stack frame for you.
The .STACK assembler directive simply sets aside a fixed amount of memory for use by the system stack instructions. Depending on the memory model, the stack can be placed just past your data segment(s), your code segment(s), or some arbitrary location in memory.
0

Share this post


Link to post
Share on other sites
Also I would like to say that the stack is used to pass arguments to functions, all the arguments are PUSHed into the stack in inverse order, and the return value gets stored in AX or EAX so a call to function like:

int function(int n1,int n2);

will be translated to ASM as:

PUSH n2
PUSH n1
CALL Function
TEST EAX,EAX ; see if returned Value is NOT Zero after the function returns.

this is important to know if you are makin an ASM module with functions you want to call from C,
inside the ASM function, the SP is a delimiter where, to one side of the Address pointed by SP there are the arguments to the function, and to the other the local variables (sorry dont remember which way is which)
so if you want to access that data you use offsets from the SP like

MOV EBX,[SP + 4]; will get the integer value in the 2 (if I am not mistaken) variable inside EBX
0

Share this post


Link to post
Share on other sites
Well, depending on the processor, sometimes the Return address and parameters are stored in registers, and not on the stack
Example: MIPS processors, the return address is stored in the ra register, and parameters (up to 4) are stored in registers a0 to a3 (granted, the ra must be stored on the stack when another function is called).

Just an FYI
0

Share this post


Link to post
Share on other sites
Yup, the MIPS Processor has 32 registers, having registers even for function arguments and variables as well (v0 to v3?), it also executes 2 instructions per cicle (if I am not mistaken) I have fidled with my PSX I am sure you know more than me about this Processor BeerNutts, Greets!.
0

Share this post


Link to post
Share on other sites