pragma solidity ^0.4.21;
contract Test1 {
function add(int a, int b) returns(string){ //Simply add the two arguments and return
return "Qmrwokdkeoiudkeooiskelpdislpeosj;sd[opek;s[pkfe,;soeipsoekf;sodfpsoe,mfoskfesktgfetg";
}
}
contract Test2 {
Test1 test1;
function Test2(){ //Constructor function
test1 = new Test1(); //Create new "Test1" function
}
function test(string a, string b) constant returns (string c){
address addr = address(test1); //Place the test1 address on the stack
bytes4 sig = bytes4(sha3("add(int256,int256)")); //Function signature
assembly {
let x := mload(0x40) //Find empty storage location using "free memory pointer"
mstore(x,sig) //Place signature at begining of empty storage
mstore(add(x,0x04),a) //Place first argument directly next to signature
mstore(add(x,0x24),b) //Place second argument next to first, padded to 32 bytes
let success := call( //This is the critical change (Pop the top stack value)
5000, //5k gas
addr, //To addr
0, //No value
x, //Inputs are stored at location x
0x44, //Inputs are 68 bytes long
x, //Store output over input (saves space)
0x20) //Outputs are 32 bytes long
c := mload(x) //Assign output value to c
mstore(0x40,add(x,0x44)) // Set storage pointer to empty space
}
}
}
but c
is empty string