stack

Assembly Language Question: Display Characters to screen LIFO (Last In First Out) in assembly language

Given a stack that displays characters to the screen First in First Out(FIFO), how do you switch it to display them Last in First Out(LIFO). Theoretically speaking... is it simply just sending the characters to print in reverse order? ...

How is the bottom of stack determined?

A stack is a contiguous block of memory containing data. A register called the stack pointer (SP) points to the top of the stack. The bottom of the stack is at a fixed address. How is the stack bottom fixed by the kernel? ...

Memory assignment of local variables

void function(int a, int b, int c) { char buffer1[5]; char buffer2[10]; } We must remember that memory can only be addressed in multiples of the word size. A word in our case is 4 bytes, or 32 bits. So our 5 byte buffer is really going to take 8 bytes (2 words) of memory, and our 10 byte buffer is going to take 1...

Why does it NOT give a segmentation violation?

The code below is said to give a segmentation violation: #include <stdio.h> #include <string.h> void function(char *str) { char buffer[16]; strcpy(buffer,str); } int main() { char large_string[256]; int i; for( i = 0; i < 255; i++) large_string[i] = 'A'; function(large_string); return 1; } It's compiled and ...

How is return address specified in stack?

This is what I see by disassemble for the statement function(1,2,3);: movl $0x3,0x8(%esp) movl $0x2,0x4(%esp) movl $0x1,(%esp) call 0x4012d0 <_Z8functioniii> It seems the ret address is not pushed into stack at all,then how does ret work? ...

How to write a buffer-overflow exploit in GCC,windows XP,x86?

void function(int a, int b, int c) { char buffer1[5]; char buffer2[10]; int *ret; ret = buffer1 + 12; (*ret) += 8;//why is it 8?? } void main() { int x; x = 0; function(1,2,3); x = 1; printf("%d\n",x); } The above demo is from here: http://insecure.org/stf/smashstack.html But it's not working here: D:\tes...

How to change stack size for a .NET program?

I have a program that does recursive calls for 2 billion times and the stack overflow. I make changes, and then it still need 40K resursive calls. So I need probably serveral MB stack memory. I heard the stack size is default to 1MB. I tried search online. Some one said to go properties ->linker .........in visual studio, but I cannot fi...

Adding "this" to the parents stack for "each" in jQuery

This question is a bit of a two-parter. First, the title question. Here's what I've got: // Report all of the parents $(this).parents().each(function(i){ // Collect the parts in a var var $crumb = ''; // Get the tag name of the parent $crumb += "<span class='tagName'>"+this.tagName+"</span>"; // And finally, repor...

Stack & heap understanding question

Hi, I would really appreciate if someone could tell me whether I understand it well: class X { A a1=new A(); // reference on the stack, object value on the heap a1.VarA=5; // on the stack - value type A a2=a1; // reference on the stack, object value on the heap a2.VarA=10; // on the stack - value type } ...

Fields of class, are they stored in the stack or heap?

I saw a question yesterday which raised (for me) another question. Please look at the following code: public class Class1 { int A; //as I uderstand, int is value type and therefore lives in the stack } class Class2 { Run() { Class1 instance1 = new Class1(); instance1.A = 10; //it points to value type, but isnt ...

IA-32: Pushing a byte onto a stack isn't possible on Pentium, why?

Hi, I've come to learn that you cannot push a byte directly onto the Intel Pentium's stack, can anyone explain this to me please? The reason that I've been given is because the esp register is word-addressable (or, that is the assumption in our model) and it must be an "even address". I would have assumed decrementing the value of some...

C String literals: Where do they go?

I have read a lot of posts about "string literals" on SO, most of which have been about best-practices, or where the literal is NOT located in memory. I am interested in where the string DOES get allocated/stored, etc. I did find one intriguing answer here, saying: Defining a string inline actually embeds the data in the program it...

Android - Can I force BACK button to go 2 steps back in the Acitivty stack?

Android - Can I force BACK button to go 2 steps back in the Acitivty stack with some kind of code? I know I can override the onKeyDown method but I want BACK to do it's thing, just twice! ...

Passing parameters on the stack

When you pass parameters to a function on the cpu stack, You put the parameters on then JSR puts the return address on the stack. So that means in your function you must take the top item of the stack (the return address) before you can take the others off) eg is the following the correct way to go about it: ... |Let’s do some additio...

Problems with this stack implementation

where is the mistake? My code here: typedef struct _box { char *dados; struct _box * proximo; } Box; typedef struct _pilha { Box * topo; }Stack; void Push(Stack *p, char * algo) { Box *caixa; if (!p) { exit(1); } caixa = (Box *) calloc(1, sizeof(Box)); caix...

Using stack defined in C++ stl

#include <stack> using namespace std; int main() { stack<int> s; int i; for (i = 0; i <= 10; i++) { s.push(i); } for (i = 0; i <= 10; i++) { printf("%d", s.pop()); } } Whats wrong with the code above? Error: In function int main(): aggregate value used where an integer was expected ...

Allocated memory address clash

Hi, i don't understand how this happen. This is portion of my code.. int isGoal(Node *node, int startNode){ int i; . . } When i debug this using gdb i found out that 'i' was allocated at the memory address that have been previously allocated. (gdb)print &node->path->next $26 = (struct intNode **) 0xffbff2f0 (gdb)...

stack.ToList() in .NET - order of elements?

When using the .ToList() extension method on a Stack<T>, is the result the same as popping each element and adding to a new list (reverse of what was pushed)? If so, is this because it really is iterating over each element, or does it store the elements in reverse internally and slip the array into a new List<T>? ...

Weird call stack when application has frozen

I apparently have an dead lock problem in one of my applications and started investigating EurekaLog stack traces. Here's one recent: Call Stack Information: -------------------------------------------------------------------------------------------------------------------------------------- |Address |Module |Unit ...

C++ stack memory still valid?

Hi all, If I create an object on the stack and push it into a list, then the object loses scope (outside of the for loop in the example below) will the object still exist in the list? If the list still holds the object, is that data now invalid/possibly corrupt? Please let me know, and please explain the reasoning.. Thanks, jbu cl...