function

Assembly x86-64 get function parameters from stack

99封情书 提交于 2021-01-19 08:38:12
问题 Lately I've been learning x86 Assembly from the book Programming from the Ground Up, but I have an x86-64 computer, so things start to go wrong at one point (pretty early in the book). I got to the part where I'm dealing with functions, specifically the power example. In this example he pushes the parameters onto the stack and then copies them into registers later in the function. Here's what his code looks like: pushl $3 # second argument pushl $2 # first argument call power # call function

Assembly x86-64 get function parameters from stack

主宰稳场 提交于 2021-01-19 08:38:07
问题 Lately I've been learning x86 Assembly from the book Programming from the Ground Up, but I have an x86-64 computer, so things start to go wrong at one point (pretty early in the book). I got to the part where I'm dealing with functions, specifically the power example. In this example he pushes the parameters onto the stack and then copies them into registers later in the function. Here's what his code looks like: pushl $3 # second argument pushl $2 # first argument call power # call function

Is C++ Array passed by reference or by pointer?

ぐ巨炮叔叔 提交于 2021-01-18 06:00:13
问题 In school, our lecturer taught us that the entire array was passed by reference when we pass it to a function,. However, recently I read a book. It says that arrays are passed by pointer by default when passing the entire array to a function. The book further mention that " passing by pointer is very similar to passing by reference ", which means that passing by pointer and passing by reference are actually different. It appears that different source stated differently. So my question is: In

Is C++ Array passed by reference or by pointer?

寵の児 提交于 2021-01-18 05:57:36
问题 In school, our lecturer taught us that the entire array was passed by reference when we pass it to a function,. However, recently I read a book. It says that arrays are passed by pointer by default when passing the entire array to a function. The book further mention that " passing by pointer is very similar to passing by reference ", which means that passing by pointer and passing by reference are actually different. It appears that different source stated differently. So my question is: In

How can I simulate a CALL instruction by using JMP?

拜拜、爱过 提交于 2021-01-13 11:01:08
问题 Like this but without the CALL instruction. I suppose that I should use JMP and probably other instructions. PUSH 5 PUSH 4 CALL Function 回答1: This is fairly easy to do. Push the return address onto the stack and then jump to the subroutine. The final code looks like this: PUSH 5 PUSH 4 PUSH offset label1 jmp Function label1: ; returns here leas esp, 8[esp] Function: ... ret While this works, you really don't want to do this. On most modern processors, an on-chip call stack return address

Using fgets after scanf [duplicate]

寵の児 提交于 2021-01-10 03:35:23
问题 This question already has answers here : fgets doesn't work after scanf [duplicate] (9 answers) Closed 18 days ago . I want to get rid of buffer overflow and I am using fgets instead of scanf to limit the characters. But whenever I enter something with scanf before fgets , it doesn't work correctly anymore. This code works correctly #include <stdio.h> int main() { char name[10]; printf("Who are you? \n"); fgets(name,10,stdin); printf("Good to meet you, %s.\n",name); return(0); } This code

Using fgets after scanf [duplicate]

别等时光非礼了梦想. 提交于 2021-01-10 03:30:18
问题 This question already has answers here : fgets doesn't work after scanf [duplicate] (9 answers) Closed 18 days ago . I want to get rid of buffer overflow and I am using fgets instead of scanf to limit the characters. But whenever I enter something with scanf before fgets , it doesn't work correctly anymore. This code works correctly #include <stdio.h> int main() { char name[10]; printf("Who are you? \n"); fgets(name,10,stdin); printf("Good to meet you, %s.\n",name); return(0); } This code

Using fgets after scanf [duplicate]

*爱你&永不变心* 提交于 2021-01-10 03:29:25
问题 This question already has answers here : fgets doesn't work after scanf [duplicate] (9 answers) Closed 18 days ago . I want to get rid of buffer overflow and I am using fgets instead of scanf to limit the characters. But whenever I enter something with scanf before fgets , it doesn't work correctly anymore. This code works correctly #include <stdio.h> int main() { char name[10]; printf("Who are you? \n"); fgets(name,10,stdin); printf("Good to meet you, %s.\n",name); return(0); } This code

How can I make it where it will print the longest name/string that was inputed by the user

拥有回忆 提交于 2021-01-07 02:55:11
问题 def myNames(): names = [] while True: a = input("Enter Name: ") if a != "done": names.append(a) elif a == "done": return names def all_lengths(myNames): num_of_strings = len(myNames) total_size = 0 for item in myNames: total_size += len(item) ave_size = float(total_size) / float(num_of_strings) print(ave_size) all_lengths(myNames()) def longestWord(myNames): count = 0 for i in myNames: if len(i) > count: count = len(i) word = I print ("the longest string is ", word) how can I make it print

How can I make it where it will print the longest name/string that was inputed by the user

邮差的信 提交于 2021-01-07 02:54:58
问题 def myNames(): names = [] while True: a = input("Enter Name: ") if a != "done": names.append(a) elif a == "done": return names def all_lengths(myNames): num_of_strings = len(myNames) total_size = 0 for item in myNames: total_size += len(item) ave_size = float(total_size) / float(num_of_strings) print(ave_size) all_lengths(myNames()) def longestWord(myNames): count = 0 for i in myNames: if len(i) > count: count = len(i) word = I print ("the longest string is ", word) how can I make it print