How to access to the top of the stack in xv6? - stack

I'm trying to access to the top of the stack for the main process in xv6. How i must do it?
Thanks.

Related

How to move sram to top hierarchy in Chisel3/Firrtl

I make a RISCV core with chisel3. However, when I want to tapeout the core, the SRAMs make a big problem. I should synthesize the logic first, and synthesize the top hierarchy with SRAM as blackbox.
So how can I move all SRAMs to the Top? I have tried the topWiring. But I find it can only wire the output port or the wires to the top, instead of the module.
Can anyone provide me with an example?

How to check if the stack is empty in MIPS?

So I need to check if the stack is empty before returning a value that is being calculated.
if its not empty, then I will raise an error.
How can I check if the stack is empty or not?
Compare $sp with null, how?
or if starting address of $sp is always the same, should I hard code it? (if address of $sp equal to 270346..3, then empty) (this feels very wrong)
Any help would be appreciated
Thanks
You should never check if the call stack is "empty" — this concept doesn't really make sense — the call stack is supposed to always be there.
However, if you are pushing a dynamic number of things onto the stack, and later popping them all of them off, you can either:
Capture the value of stack pointer before any of the dynamic pushing, and then as part of dynamic popping compare the current stack pointer with that previously captured stack pointer — when they are equal, there's nothing to pop.
Alternately, start a count at zero before any dynamic pushing, and add to that count as items are pushed, decrement the count as they are popped — whenever the count is zero, then there's nothing to pop.
On the other hand, if you are writing a program that takes control directly from the simulator or from the operating system, these are special in that there is no one to return to.  Because of this, usually we use custom startup code for that, and such startup code is not a classic function.
Any code that is written as a function can assume that it was called, and thus can return to its caller.

Moving items up in the stack

How does one move items up in the stack?
(Pseudocode, because the code inside and the registers to push will vary.)
push registers to stack
alter the registers
get return value on top of the stack
keep the top of the stack but restore the registers
So the stack looks like this:
(Top)
(Return value)
(Register)
(Register)
...
(Register)
And I want to make it look like this:
(Top)
(Return value)
And then have the registers get their values from the stack. Is this at all possible? I am trying to do it in gas. Can this be done? Thank you in advance.
If I understand correctly, you want to put a return value (which you get from...?) before the registers on the stack, then pop the registers, but keep the return value?
One suggestion I could give is to make room for your return value on the stack first (like subl $4, %esp, in case your return value is 4 bytes) and then put your return value there, instead of on top of the stack.
Another suggestion (which may be easier to implement), is to make some room in the .datasection with .skip, move the return value there, and then after restoring the registers move it back to the stack.
It's hard to give you a concrete example, since I don't know much about the scenario.

How to replace content ViewController inside other View controller

I am working on an application which allows users to work with a couple of workmodes. Main view of the app contains information common to all workmodes. I want to create a "subview" with ability to change its ViewController. This subview will be used to display information connected with specified workmode. It is important that app goes to MainViewController from WorkmodesViewController in which user chooses workmode to work with.
My question is:
Which tehnique should I use to acheave changeable WorkmodeViewController inside MainViewVontroller
I have found example git project with functionality I need:
https://github.com/mluton/EmbeddedSwapping

How to show UIImageView Quick Look by address?

In Xcode 5, we can now hover over a UIImageView variable to get a Quick Look of the image. If I want to see the image of an image view whose variable I don't have direct access to, but I have the hex address, is there a way to show it? i.e., If I know there's a UIImageView at 0x12193fb0, doing po 0x12193fb0 in the debugger will print out the info about the object. Is there a similar way to Quick Look by address? Using the Variables View next to the debugger isn't an option, since I'm breaking the program manually, so it's not in the context of the object that owns the image view.
You can add a watch for your variable (Debug area, variables view). You just have to cast it if you only have the pointer address. Eg.
(NSString*)0x1234567
The watch can be added from the context menu.
Quick update:
Just to clarify myself, you can get to the following just by knowing the address. In this instance I just typed (BNMap*)0xb4b5dd0 as the expression.

Resources