This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/35788] New: MIPS stack overflow caused by addui instruction


Hello 

   I am using the latest version of cygwin to compile c++ programs into to
mips-elfs, and I have several serious problems.  One in particular is that fact
that the allocation and deallocation of memory on the stack for function and
procedure calls is not done correctly.  For some reason the compiler allocates
memory on the stack by issuing a Addui sp,sp with some negative number, however
the negative number is only sixteen bits and therefore because the instruction
is an add unsigned immediate this negative number gets treated like a positve
number.  Now once the statements in the function have been executed, you get to
the code which attempts to deallocate the space on the stack which was
allocated at the beginning, well the compiler does this by issuing another
addui but this time using the positve version of the number which was used
before, well this part would work just fine if the prior allocation had been
done with an add immediate instruction but because it doesn't what happens is
the stack grows a little more now you can imagine this can become a problem
very quickly, causing stack overflow.  I have pasted in some dissasembly code
below for you guys to take a look just look at any one of the function at the
allocation and deallocation of memory on the stack and you'll see it.


senchk.bin:     file format elf32-tradbigmips

Disassembly of section .text:

00000000 <start>:
start():
   0:   201c2fa8        addi    gp,zero,12200
   4:   0c00010f        jal     43c <main>
   8:   00000000        nop

0000000c <_exit>:
   c:   1000ffff 00000000                       ........

00000014 <_Z10delay_funcii>:
_Z10delay_funcii():
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/DELAY_FUNC.H:5
#ifndef _DELAY_FUNC_H_
#define _DELAY_FUNC_H_

void delay_func (int delay_count, int time_scale)
{
  14:   27bdfff0        addiu   sp,sp,-16
  18:   afbe0008        sw      s8,8(sp)
  1c:   03a0f021        move    s8,sp
  20:   afc40010        sw      a0,16(s8)
  24:   afc50014        sw      a1,20(s8)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/DELAY_FUNC.H:8
        int delay_counter;

        if ( time_scale == 1 ) {
  28:   8fc30014        lw      v1,20(s8)
  2c:   24020001        li      v0,1
  30:   14620018        bne     v1,v0,94 <_Z10delay_funcii+0x80>
  34:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/DELAY_FUNC.H:11


                delay_counter = 0;
  38:   afc00000        sw      zero,0(s8)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/DELAY_FUNC.H:12
                while ( delay_counter != delay_count * 5000000 ) {   // changed
from 50000000 to 5000000 because the time was too long, it exceed a second by
about 6 times
  3c:   8fc40010        lw      a0,16(s8)
  40:   00000000        nop
  44:   00801021        move    v0,a0
  48:   00021940        sll     v1,v0,0x5
  4c:   00641823        subu    v1,v1,a0
  50:   00031180        sll     v0,v1,0x6
  54:   00431023        subu    v0,v0,v1
  58:   000210c0        sll     v0,v0,0x3
  5c:   00441021        addu    v0,v0,a0
  60:   00021880        sll     v1,v0,0x2
  64:   00431021        addu    v0,v0,v1
  68:   00021980        sll     v1,v0,0x6
  6c:   8fc20000        lw      v0,0(s8)
  70:   00000000        nop
  74:   10620052        beq     v1,v0,1c0 <_Z10delay_funcii+0x1ac>
  78:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/DELAY_FUNC.H:14

                        delay_counter ++;
  7c:   8fc20000        lw      v0,0(s8)
  80:   00000000        nop
  84:   24420001        addiu   v0,v0,1
  88:   afc20000        sw      v0,0(s8)
  8c:   1000ffeb        b       3c <_Z10delay_funcii+0x28>
  90:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/DELAY_FUNC.H:18

                        }

                } else if ( time_scale == 2 ) {
  94:   8fc30014        lw      v1,20(s8)
  98:   24020002        li      v0,2
  9c:   14620016        bne     v1,v0,f8 <_Z10delay_funcii+0xe4>
  a0:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/DELAY_FUNC.H:21


                        delay_counter = 0;
  a4:   afc00000        sw      zero,0(s8)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/DELAY_FUNC.H:22
                        while ( delay_counter != delay_count * 5000 ) {
  a8:   8fc30010        lw      v1,16(s8)
  ac:   00000000        nop
  b0:   00601021        move    v0,v1
  b4:   00021080        sll     v0,v0,0x2
  b8:   00431021        addu    v0,v0,v1
  bc:   000210c0        sll     v0,v0,0x3
  c0:   00431023        subu    v0,v0,v1
  c4:   00021100        sll     v0,v0,0x4
  c8:   00431021        addu    v0,v0,v1
  cc:   000218c0        sll     v1,v0,0x3
  d0:   8fc20000        lw      v0,0(s8)
  d4:   00000000        nop
  d8:   10620039        beq     v1,v0,1c0 <_Z10delay_funcii+0x1ac>
  dc:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/DELAY_FUNC.H:24

                                delay_counter ++;
  e0:   8fc20000        lw      v0,0(s8)
  e4:   00000000        nop
  e8:   24420001        addiu   v0,v0,1
  ec:   afc20000        sw      v0,0(s8)
  f0:   1000ffed        b       a8 <_Z10delay_funcii+0x94>
  f4:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/DELAY_FUNC.H:27
                                } 

                        } else if ( time_scale == 3 ) {
  f8:   8fc30014        lw      v1,20(s8)
  fc:   24020003        li      v0,3
 100:   14620014        bne     v1,v0,154 <_Z10delay_funcii+0x140>
 104:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/DELAY_FUNC.H:29

                                delay_counter = 0;
 108:   afc00000        sw      zero,0(s8)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/DELAY_FUNC.H:30
                                while ( delay_counter != delay_count * 50 ) {
 10c:   8fc30010        lw      v1,16(s8)
 110:   00000000        nop
 114:   00601021        move    v0,v1
 118:   00021040        sll     v0,v0,0x1
 11c:   00431021        addu    v0,v0,v1
 120:   000210c0        sll     v0,v0,0x3
 124:   00431021        addu    v0,v0,v1
 128:   00021840        sll     v1,v0,0x1
 12c:   8fc20000        lw      v0,0(s8)
 130:   00000000        nop
 134:   10620022        beq     v1,v0,1c0 <_Z10delay_funcii+0x1ac>
 138:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/DELAY_FUNC.H:32

                                        delay_counter ++;
 13c:   8fc20000        lw      v0,0(s8)
 140:   00000000        nop
 144:   24420001        addiu   v0,v0,1
 148:   afc20000        sw      v0,0(s8)
 14c:   1000ffef        b       10c <_Z10delay_funcii+0xf8>
 150:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/DELAY_FUNC.H:35
                                }

                        } else if ( time_scale == 4 ) {
 154:   8fc30014        lw      v1,20(s8)
 158:   24020004        li      v0,4
 15c:   14620018        bne     v1,v0,1c0 <_Z10delay_funcii+0x1ac>
 160:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/DELAY_FUNC.H:37

                                delay_counter = 0;
 164:   afc00000        sw      zero,0(s8)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/DELAY_FUNC.H:39

                                if ( delay_count >= 20 ) {
 168:   8fc20010        lw      v0,16(s8)
 16c:   00000000        nop
 170:   28420014        slti    v0,v0,20
 174:   14400012        bnez    v0,1c0 <_Z10delay_funcii+0x1ac>
 178:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/DELAY_FUNC.H:41

                                while ( delay_counter != delay_count / 20 ) {
 17c:   8fc30010        lw      v1,16(s8)
 180:   24020014        li      v0,20
 184:   0062001a        div     zero,v1,v0
 188:   14400002        bnez    v0,194 <_Z10delay_funcii+0x180>
 18c:   00000000        nop
 190:   0007000d        break   0x7
 194:   00001812        mflo    v1
 198:   8fc20000        lw      v0,0(s8)
 19c:   00000000        nop
 1a0:   10620007        beq     v1,v0,1c0 <_Z10delay_funcii+0x1ac>
 1a4:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/DELAY_FUNC.H:43

                                        delay_counter ++;
 1a8:   8fc20000        lw      v0,0(s8)
 1ac:   00000000        nop
 1b0:   24420001        addiu   v0,v0,1
 1b4:   afc20000        sw      v0,0(s8)
 1b8:   1000fff0        b       17c <_Z10delay_funcii+0x168>
 1bc:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/DELAY_FUNC.H:50
                                }
                        }
                } else {

                        return;
                }
        }
 1c0:   03c0e821        move    sp,s8
 1c4:   8fbe0008        lw      s8,8(sp)
 1c8:   27bd0010        addiu   sp,sp,16
 1cc:   03e00008        jr      ra
 1d0:   00000000        nop

000001d4 <_Z15i2c_range_rd_wrii>:
_Z15i2c_range_rd_wrii():
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:4
#ifndef _I2C_RANGE_RD_WR_H_
#define _I2C_RANGE_RD_WR_H_

void i2c_range_rd_wr (int sensor_sel, int op_sel) {
 1d4:   27bdfff0        addiu   sp,sp,-16
 1d8:   afbe0008        sw      s8,8(sp)
 1dc:   03a0f021        move    s8,sp
 1e0:   afc40010        sw      a0,16(s8)
 1e4:   afc50014        sw      a1,20(s8)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:8

                                                                               
          // I2C address format
                                                                               
         // 7   6       5       4       3       2       1       0               
        switch (sensor_sel) {                   // <-------Address---------->
Read/Write Bit
 1e8:   8fc20010        lw      v0,16(s8)
 1ec:   00000000        nop
 1f0:   afc20000        sw      v0,0(s8)
 1f4:   24020002        li      v0,2
 1f8:   8fc30000        lw      v1,0(s8)
 1fc:   00000000        nop
 200:   10620028        beq     v1,v0,2a4 <_Z15i2c_range_rd_wrii+0xd0>
 204:   00000000        nop
 208:   8fc30000        lw      v1,0(s8)
 20c:   00000000        nop
 210:   28620003        slti    v0,v1,3
 214:   10400008        beqz    v0,238 <_Z15i2c_range_rd_wrii+0x64>
 218:   00000000        nop
 21c:   24020001        li      v0,1
 220:   8fc30000        lw      v1,0(s8)
 224:   00000000        nop
 228:   1062000a        beq     v1,v0,254 <_Z15i2c_range_rd_wrii+0x80>
 22c:   00000000        nop
 230:   10000042        b       33c <_Z15i2c_range_rd_wrii+0x168>
 234:   00000000        nop
 238:   24020003        li      v0,3
 23c:   8fc30000        lw      v1,0(s8)
 240:   00000000        nop
 244:   1062002b        beq     v1,v0,2f4 <_Z15i2c_range_rd_wrii+0x120>
 248:   00000000        nop
 24c:   1000003b        b       33c <_Z15i2c_range_rd_wrii+0x168>
 250:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:12

                case 1: //Right Sensor

                        if ( op_sel == 2 ) {
 254:   8fc30014        lw      v1,20(s8)
 258:   24020002        li      v0,2
 25c:   14620007        bne     v1,v0,27c <_Z15i2c_range_rd_wrii+0xa8>
 260:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:14

                          *i2c_interface  = 0xE603E700;    // READ
 264:   8f82ff48        lw      v0,-184(gp)
 268:   3c03e603        lui     v1,0xe603
 26c:   3463e700        ori     v1,v1,0xe700
 270:   ac430000        sw      v1,0(v0)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:15
                           break;
 274:   10000031        b       33c <_Z15i2c_range_rd_wrii+0x168>
 278:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:17

                           } else if ( op_sel == 1 ) {
 27c:   8fc30014        lw      v1,20(s8)
 280:   24020001        li      v0,1
 284:   1462002d        bne     v1,v0,33c <_Z15i2c_range_rd_wrii+0x168>
 288:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:19

                          *i2c_interface  = 0xE6005100;    // WRITE
 28c:   8f82ff48        lw      v0,-184(gp)
 290:   3c03e600        lui     v1,0xe600
 294:   34635100        ori     v1,v1,0x5100
 298:   ac430000        sw      v1,0(v0)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:20
                           break;
 29c:   10000027        b       33c <_Z15i2c_range_rd_wrii+0x168>
 2a0:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:30

                           } else {

                                break;

                                }

                case 2: //Middle Sensor

                        if ( op_sel == 2 ) {
 2a4:   8fc30014        lw      v1,20(s8)
 2a8:   24020002        li      v0,2
 2ac:   14620007        bne     v1,v0,2cc <_Z15i2c_range_rd_wrii+0xf8>
 2b0:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:32

                          *i2c_interface  = 0xE803E900;
 2b4:   8f82ff48        lw      v0,-184(gp)
 2b8:   3c03e803        lui     v1,0xe803
 2bc:   3463e900        ori     v1,v1,0xe900
 2c0:   ac430000        sw      v1,0(v0)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:33
                           break;
 2c4:   1000001d        b       33c <_Z15i2c_range_rd_wrii+0x168>
 2c8:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:34
                  } else if ( op_sel == 1 ) {
 2cc:   8fc30014        lw      v1,20(s8)
 2d0:   24020001        li      v0,1
 2d4:   14620019        bne     v1,v0,33c <_Z15i2c_range_rd_wrii+0x168>
 2d8:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:36

                          *i2c_interface  = 0xE8005100;
 2dc:   8f82ff48        lw      v0,-184(gp)
 2e0:   3c03e800        lui     v1,0xe800
 2e4:   34635100        ori     v1,v1,0x5100
 2e8:   ac430000        sw      v1,0(v0)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:37
                           break;
 2ec:   10000013        b       33c <_Z15i2c_range_rd_wrii+0x168>
 2f0:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:45
                  } else {

                                break;
                  }

                case 3: //Left Sensor

                        if ( op_sel == 2 ) {
 2f4:   8fc30014        lw      v1,20(s8)
 2f8:   24020002        li      v0,2
 2fc:   14620007        bne     v1,v0,31c <_Z15i2c_range_rd_wrii+0x148>
 300:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:47

                          *i2c_interface  = 0xEA03EB00;
 304:   8f82ff48        lw      v0,-184(gp)
 308:   3c03ea03        lui     v1,0xea03
 30c:   3463eb00        ori     v1,v1,0xeb00
 310:   ac430000        sw      v1,0(v0)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:48
                           break;
 314:   10000009        b       33c <_Z15i2c_range_rd_wrii+0x168>
 318:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:49
                  } else if ( op_sel == 1 ) {
 31c:   8fc30014        lw      v1,20(s8)
 320:   24020001        li      v0,1
 324:   14620005        bne     v1,v0,33c <_Z15i2c_range_rd_wrii+0x168>
 328:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:51

                          *i2c_interface  = 0xEA051000;
 32c:   8f82ff48        lw      v0,-184(gp)
 330:   3c03ea05        lui     v1,0xea05
 334:   34631000        ori     v1,v1,0x1000
 338:   ac430000        sw      v1,0(v0)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/I2C_RANGE_RD_WR.H:63
                           break;
                  } else {

                                break;
                  }

                default:

                        break;

                          }
}       
 33c:   03c0e821        move    sp,s8
 340:   8fbe0008        lw      s8,8(sp)
 344:   27bd0010        addiu   sp,sp,16
 348:   03e00008        jr      ra
 34c:   00000000        nop

00000350 <_Z9init_funcv>:
_Z9init_funcv():
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/INIT_FUNC.H:4
#ifndef _INIT_FUNC_H_
#define _INIT_FUNC_H_

void init_func (void) {
 350:   27bdffd8        addiu   sp,sp,-40
 354:   afbf0024        sw      ra,36(sp)
 358:   afbe0020        sw      s8,32(sp)
 35c:   03a0f021        move    s8,sp
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/INIT_FUNC.H:6

 int five_seconds = 2500000;
 360:   3c020026        lui     v0,0x26
 364:   344225a0        ori     v0,v0,0x25a0
 368:   afc20010        sw      v0,16(s8)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/INIT_FUNC.H:8

 int idle  = 1500;
 36c:   240205dc        li      v0,1500
 370:   afc20014        sw      v0,20(s8)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/INIT_FUNC.H:9
 int right = 1000;
 374:   240203e8        li      v0,1000
 378:   afc20018        sw      v0,24(s8)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/INIT_FUNC.H:10
 int left  = 2000;      
 37c:   240207d0        li      v0,2000
 380:   afc2001c        sw      v0,28(s8)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/INIT_FUNC.H:12

    *i2c_clk_gen          = I2C_SPI_100Kbps;
 384:   8f83ff3c        lw      v1,-196(gp)
 388:   24020001        li      v0,1
 38c:   ac620000        sw      v0,0(v1)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/INIT_FUNC.H:13
    *spi_clk_gen          = I2C_SPI_3Mbps;
 390:   8f83ff40        lw      v1,-192(gp)
 394:   24020003        li      v0,3
 398:   ac620000        sw      v0,0(v1)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/INIT_FUNC.H:14
    *baud_rate_gen    = Baud9600;
 39c:   8f83ff44        lw      v1,-188(gp)
 3a0:   24020005        li      v0,5
 3a4:   ac620000        sw      v0,0(v1)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/INIT_FUNC.H:16

        *throttle_pwm = idle;
 3a8:   8f83ff58        lw      v1,-168(gp)
 3ac:   8fc20014        lw      v0,20(s8)
 3b0:   00000000        nop
 3b4:   ac620000        sw      v0,0(v1)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/INIT_FUNC.H:18

        *seven_segment_display = 0;
 3b8:   8f82ff6c        lw      v0,-148(gp)
 3bc:   00000000        nop
 3c0:   ac400000        sw      zero,0(v0)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/INIT_FUNC.H:20

        *steering_pwm = left;
 3c4:   8f83ff54        lw      v1,-172(gp)
 3c8:   8fc2001c        lw      v0,28(s8)
 3cc:   00000000        nop
 3d0:   ac620000        sw      v0,0(v1)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/INIT_FUNC.H:21
         delay_func(40,nanoseconds);
 3d4:   24040028        li      a0,40
 3d8:   24050004        li      a1,4
 3dc:   0c000005        jal     14 <_Z10delay_funcii>
 3e0:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/INIT_FUNC.H:23

        *steering_pwm = right;
 3e4:   8f83ff54        lw      v1,-172(gp)
 3e8:   8fc20018        lw      v0,24(s8)
 3ec:   00000000        nop
 3f0:   ac620000        sw      v0,0(v1)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/INIT_FUNC.H:24
        delay_func(40,nanoseconds);
 3f4:   24040028        li      a0,40
 3f8:   24050004        li      a1,4
 3fc:   0c000005        jal     14 <_Z10delay_funcii>
 400:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/INIT_FUNC.H:27


        *steering_pwm = idle;
 404:   8f83ff54        lw      v1,-172(gp)
 408:   8fc20014        lw      v0,20(s8)
 40c:   00000000        nop
 410:   ac620000        sw      v0,0(v1)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/INIT_FUNC.H:28
        delay_func(40,nanoseconds);
 414:   24040028        li      a0,40
 418:   24050004        li      a1,4
 41c:   0c000005        jal     14 <_Z10delay_funcii>
 420:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/INIT_FUNC.H:32

        //*seven_segment_display = temp_sensor; 

}
 424:   03c0e821        move    sp,s8
 428:   8fbf0024        lw      ra,36(sp)
 42c:   8fbe0020        lw      s8,32(sp)
 430:   27bd0028        addiu   sp,sp,40
 434:   03e00008        jr      ra
 438:   00000000        nop

0000043c <main>:
main():
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/sensor_display_check_program.cpp:8
#include "INIT_FUNC.H"


int main()
{
 43c:   27bdffe8        addiu   sp,sp,-24
 440:   afbf0014        sw      ra,20(sp)
 444:   afbe0010        sw      s8,16(sp)
 448:   03a0f021        move    s8,sp
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/sensor_display_check_program.cpp:10

 init_func();
 44c:   0c0000d4        jal     350 <_Z9init_funcv>
 450:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/sensor_display_check_program.cpp:11
 *power_register = 0;
 454:   8f82ff74        lw      v0,-140(gp)
 458:   00000000        nop
 45c:   ac400000        sw      zero,0(v0)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/sensor_display_check_program.cpp:13

while ( *usr_cntrl_reg != 255 ) {
 460:   8f82ff38        lw      v0,-200(gp)
 464:   00000000        nop
 468:   8c430000        lw      v1,0(v0)
 46c:   240200ff        li      v0,255
 470:   10620037        beq     v1,v0,550 <main+0x114>
 474:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/sensor_display_check_program.cpp:15

 if (  *usr_cntrl_reg != 0 ) {
 478:   8f82ff38        lw      v0,-200(gp)
 47c:   00000000        nop
 480:   8c420000        lw      v0,0(v0)
 484:   00000000        nop
 488:   1040fff5        beqz    v0,460 <main+0x24>
 48c:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/sensor_display_check_program.cpp:17

         *led_register = *usr_cntrl_reg;
 490:   8f82ff70        lw      v0,-144(gp)
 494:   8f83ff38        lw      v1,-200(gp)
 498:   00000000        nop
 49c:   8c630000        lw      v1,0(v1)
 4a0:   00000000        nop
 4a4:   ac430000        sw      v1,0(v0)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/sensor_display_check_program.cpp:19

         while ( *power_register != 11 ) {
 4a8:   8f82ff74        lw      v0,-140(gp)
 4ac:   00000000        nop
 4b0:   8c430000        lw      v1,0(v0)
 4b4:   2402000b        li      v0,11
 4b8:   1062000e        beq     v1,v0,4f4 <main+0xb8>
 4bc:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/sensor_display_check_program.cpp:21

                 delay_func(1,microseconds);
 4c0:   24040001        li      a0,1
 4c4:   24050003        li      a1,3
 4c8:   0c000005        jal     14 <_Z10delay_funcii>
 4cc:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/sensor_display_check_program.cpp:22
                 *power_register = *power_register + 1;
 4d0:   8f83ff74        lw      v1,-140(gp)
 4d4:   8f82ff74        lw      v0,-140(gp)
 4d8:   00000000        nop
 4dc:   8c420000        lw      v0,0(v0)
 4e0:   00000000        nop
 4e4:   24420001        addiu   v0,v0,1
 4e8:   ac620000        sw      v0,0(v1)
 4ec:   1000ffee        b       4a8 <main+0x6c>
 4f0:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/sensor_display_check_program.cpp:25
         }

         *seven_segment_display = 3;
 4f4:   8f83ff6c        lw      v1,-148(gp)
 4f8:   24020003        li      v0,3
 4fc:   ac620000        sw      v0,0(v1)
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/sensor_display_check_program.cpp:27

         while ( *usr_cntrl_reg != 255 ) {
 500:   8f82ff38        lw      v0,-200(gp)
 504:   00000000        nop
 508:   8c430000        lw      v1,0(v0)
 50c:   240200ff        li      v0,255
 510:   1062ffd3        beq     v1,v0,460 <main+0x24>
 514:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/sensor_display_check_program.cpp:29

                 i2c_range_rd_wr(1, 1);          
 518:   24040001        li      a0,1
 51c:   24050001        li      a1,1
 520:   0c000075        jal     1d4 <_Z15i2c_range_rd_wrii>
 524:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/sensor_display_check_program.cpp:30
                 delay_func(70,microseconds);
 528:   24040046        li      a0,70
 52c:   24050003        li      a1,3
 530:   0c000005        jal     14 <_Z10delay_funcii>
 534:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/sensor_display_check_program.cpp:31
                 i2c_range_rd_wr(1, 2);
 538:   24040001        li      a0,1
 53c:   24050002        li      a1,2
 540:   0c000075        jal     1d4 <_Z15i2c_range_rd_wrii>
 544:   00000000        nop
 548:   1000ffed        b       500 <main+0xc4>
 54c:   00000000        nop
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/sensor_display_check_program.cpp:40

         }
 }

}                 

 // visually inspect the new addresses you should see the numbers 0 1 2 3 4 5 6
appear in binary little endian

 return (0);             
 550:   00001021        move    v0,zero
/cygdrive/c/users/TheOne1/sde-6.06/sde/examples/Init_Program/sensor_display_check_program.cpp:41
}                                                                              
                 554:   03c0e821        move    sp,s8
 558:   8fbf0014        lw      ra,20(sp)
 55c:   8fbe0010        lw      s8,16(sp)
 560:   27bd0018        addiu   sp,sp,24
 564:   03e00008        jr      ra
 568:   00000000        nop


-- 
           Summary: MIPS stack overflow caused by addui instruction
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: derrick_chi at msn dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35788


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]