LOGIN   :::   RECOVER PASS   :::   GET ACCOUNT    
Browse
  • Projects
  • Code (CVS)
  • Forums
  • News
  • Articles
  • Polls
  •  
    OpenCores
  • FAQ
  • CVS HowTo
  • Mission
  • Media
  • Tools
  • Advertise
  • Mirrors
  • Logos
  • Contact us
  • Find Resources
  • Job Opportunity
  •  
    Tools
  • Search
      
  • Download Cores (CVSGet)
  •  
    More
  • Wishbone
  • Perlilog
  • EDA tools
  • OpenTech CD
  •  
    Navigation: All forums > Openrisc > Message List > Message Post

    Message

    Reply | Reply all
    Date Prev | Date Next | Thread Prev | Thread Next Date Index | Thread Index

    From: Matjaz Breskvar<phoenix@o...>
    Date: Wed May 4 01:30:07 CEST 2005
    Subject: [openrisc] Starting Stack Value and arguments passing
    Top
    * Balaji V. Iyer (bviyer@n...) wrote:
    > Hello Everyone,
    > I have a couple questions about stack and register values
    > initialization. I am also "cut and pasting" a copy of the _start from
    > the object dump of a simple file. My question is, what is the stack
    > register (r1) initialized as? Also, when we have a main function like
    > this:

    well this would depend on the OS. if you were running on uclinux userspace
    stack would be somewhere in the uniform memory. On linux though userspace
    stack is at the top of the user addressable space, just below 0x80000000 in
    or32 case.

    > int main(int argc, char *argv[]), How are the argc and argv passed into
    > the function. In the below code, r3 is used, so what value does it
    > originally contain?

    argv and argc are put on the userspace stack of program by kernel. (all the
    nasty details are in fs/binfmt_elf.c...)

    best regards,
    p.

    > Here is the objdump:
    >
    > 0100016c <_start>:
    > 100016c: 9c 21 ff f8 l.addi r1,r1,0xfffffff8
    > 1000170: d4 01 48 00 l.sw 0x0(r1),r9
    > 1000174: d4 01 10 04 l.sw 0x4(r1),r2
    > 1000178: 9c 41 00 08 l.addi r2,r1,0x8
    > 100017c: a8 a3 00 00 l.ori r5,r3,0x0
    > 1000180: 84 63 ff fc l.lwz r3,0xfffffffc(r3)
    > 1000184: a8 85 00 00 l.ori r4,r5,0x0
    > 1000188: b9 83 00 02 l.slli r12,r3,0x2
    > 100018c: e0 a5 60 00 l.add r5,r5,r12
    > 1000190: 04 00 00 15 l.jal 10001e4 <___uClibc_main>
    > 1000194: 9c a5 00 04 l.addi r5,r5,0x4
    > 1000198: 84 41 00 04 l.lwz r2,0x4(r1)
    > 100019c: 85 21 00 00 l.lwz r9,0x0(r1)
    > 10001a0: 44 00 48 00 l.jr r9
    > 10001a4: 9c 21 00 08 l.addi r1,r1,0x8

    ReferenceAuthor
    [openrisc] Starting Stack Value and arguments passingBalaji V Iyer

    Follow upAuthor
    [openrisc] Starting Stack Value and arguments passingBalaji V Iyer

     
    Copyright (c) 1999 OPENCORES.ORG. All rights reserved.