From 9b9163082f8b2b33126d85f458a80d4fc2332c90 Mon Sep 17 00:00:00 2001 From: aumym Date: Sun, 31 Aug 2014 22:18:58 +0200 Subject: [PATCH 01/18] answers so much i dont understand, really not knowing anything and this is just the first week very frustrating not knowing a thing, sorri i dont know anything anymore ill just submit what i have in a seperate file --- myAnswers.txt | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 myAnswers.txt diff --git a/myAnswers.txt b/myAnswers.txt new file mode 100644 index 0000000..20f63c5 --- /dev/null +++ b/myAnswers.txt @@ -0,0 +1,81 @@ +1. What option with the command "rm" is required to remove a directory? + it has to be empty + +2. What is the command used to display the manual pages for any command? + man command + +3. What command will show the first 5 lines of an input file? + head -5 filename + +4. What command can be used to rename a file? + mv currentfilename newfilename + +5. What option can we given to "ls" to show the hidden files? + ls -a + +6. What will the command "cat -n file" do? + displays content inside the -n file (??) + +7. What will the command "echo -n hello" do? + it adds "hello" to the start of your username, so when you write next time it says HelloUsername@computername: + +8. What command will display list of the users who currently logged in in the system? + who + +9. How do you change password on your account? + passwd enter oldpassword enter newpassword enter newpassword enter (enter = enterbutton) + +10. How can you list a file in reverse order? + ls -r + +11. What does the "less" command do? + writes out content of a file one page at a time + +12. With "less" how do you navigate? + space bar for another page and q for quit + +13. What command will display the running processes of the current user? + ps + +14. What command can be used to end the process(es) consuming the most CPU? + sleep 100 + C (control c), kill PID_number +-------------------------------------------------------------------------------------------- +1. How do we save a file in vi and continue working? + :w filename +2. What command/key is used to start entering text? + "i"for insert, escape for going back to command + +3. What are the different modes the editor can be in? + insert and command + +4. What command can be used to place the cursor at the beginning of line 4? + :# 4 # + +5. What will dd command do (in command-mode)? + deletes the line that the cursor is on + +6. How do you undo the most recent changes? + "u" for undo + +7. How do you move back one word? + "b" +-------------------------------------------------------------------------------------------- + +1. a) How do you use gcc to only produce the .o file? + using -c flag like -c hello.c (??) +1. b) What is the difference between generating only the .o file, and building the hello executable done in the previous compilation above? + When you do it like in the lab, you get two files one named hello.c and another named hello*(??) +2. + +I cant seem to find answers on the rest of the lab and i have struggled with the tasks above, and i wont get to finish this here and now +I cant seem to find what to do in the labs, telling me what to do but not knowing what and where i can find out how to do it, is very hard. + + + + + + + + + + \ No newline at end of file From 5f5971bfff325eaf3ac10125fe2775d8ff1a8668 Mon Sep 17 00:00:00 2001 From: aumym Date: Sun, 31 Aug 2014 23:47:31 +0200 Subject: [PATCH 02/18] Revert "answers" This reverts commit 9b9163082f8b2b33126d85f458a80d4fc2332c90. --- myAnswers.txt | 81 --------------------------------------------------- 1 file changed, 81 deletions(-) delete mode 100644 myAnswers.txt diff --git a/myAnswers.txt b/myAnswers.txt deleted file mode 100644 index 20f63c5..0000000 --- a/myAnswers.txt +++ /dev/null @@ -1,81 +0,0 @@ -1. What option with the command "rm" is required to remove a directory? - it has to be empty - -2. What is the command used to display the manual pages for any command? - man command - -3. What command will show the first 5 lines of an input file? - head -5 filename - -4. What command can be used to rename a file? - mv currentfilename newfilename - -5. What option can we given to "ls" to show the hidden files? - ls -a - -6. What will the command "cat -n file" do? - displays content inside the -n file (??) - -7. What will the command "echo -n hello" do? - it adds "hello" to the start of your username, so when you write next time it says HelloUsername@computername: - -8. What command will display list of the users who currently logged in in the system? - who - -9. How do you change password on your account? - passwd enter oldpassword enter newpassword enter newpassword enter (enter = enterbutton) - -10. How can you list a file in reverse order? - ls -r - -11. What does the "less" command do? - writes out content of a file one page at a time - -12. With "less" how do you navigate? - space bar for another page and q for quit - -13. What command will display the running processes of the current user? - ps - -14. What command can be used to end the process(es) consuming the most CPU? - sleep 100 + C (control c), kill PID_number --------------------------------------------------------------------------------------------- -1. How do we save a file in vi and continue working? - :w filename -2. What command/key is used to start entering text? - "i"for insert, escape for going back to command - -3. What are the different modes the editor can be in? - insert and command - -4. What command can be used to place the cursor at the beginning of line 4? - :# 4 # - -5. What will dd command do (in command-mode)? - deletes the line that the cursor is on - -6. How do you undo the most recent changes? - "u" for undo - -7. How do you move back one word? - "b" --------------------------------------------------------------------------------------------- - -1. a) How do you use gcc to only produce the .o file? - using -c flag like -c hello.c (??) -1. b) What is the difference between generating only the .o file, and building the hello executable done in the previous compilation above? - When you do it like in the lab, you get two files one named hello.c and another named hello*(??) -2. - -I cant seem to find answers on the rest of the lab and i have struggled with the tasks above, and i wont get to finish this here and now -I cant seem to find what to do in the labs, telling me what to do but not knowing what and where i can find out how to do it, is very hard. - - - - - - - - - - \ No newline at end of file From 66422c4c260ff6003f8272816c583f99940e32f0 Mon Sep 17 00:00:00 2001 From: aumym Date: Mon, 1 Sep 2014 21:45:32 +0200 Subject: [PATCH 03/18] 01.09 answered some of the questions --- ANSWERS.md | 56 +++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/ANSWERS.md b/ANSWERS.md index 9e5261a..f90df93 100644 --- a/ANSWERS.md +++ b/ANSWERS.md @@ -19,7 +19,7 @@ Please use [markdown](https://help.github.com/articles/markdown-basics) formatin Make another directory inside the `unixstuff` directory called `backups` -**Answer:** *YOUR ANSWER HERE* +cd unixstuff, mdir backups, (, indicates return press) ###Exercise 1b @@ -27,31 +27,31 @@ Use the commands `cd`, `ls` and `pwd` to explore the file system. (Remember, if you get lost, type `cd` by itself to return to your home-directory) -**Answer:** *YOUR ANSWER HERE* +cd NAME gets you to directory NAME, ls lists all files and directory in the current working directory, pwd shows me where i am working ###Exercise 2a Create a backup of your `science.txt` file by copying it to a file called `science.bak` -**Answer:** *YOUR ANSWER HERE* +cp science.txt science.bak ###Exercise 2b Create a directory called `tempstuff` using `mkdir`, then remove it using the `rmdir` command. -**Answer:** *YOUR ANSWER HERE* +mkdir tempstuff, rmdir tempstuff ###Exercise 3a Using the above method, create another file called `list2` containing the following fruit: orange, plum, mango, grapefruit. Read the contents of `list2`. -**Answer:** *YOUR ANSWER HERE* +cat > list2, orange, plum, mango, grapefruit, (ctrl+d) cat list2 ###Exercise 3b Using pipes, display all lines of `list1` and `list2` containing the letter 'p', and sort the result. -**Answer:** *YOUR ANSWER HERE* +cat list1 list2 | grep p | sort ###Exercise 5a @@ -59,54 +59,54 @@ Try changing access permissions on the file `science.txt` and on the directory ` Use `ls -l` to check that the permissions have changed. -**Answer:** *YOUR ANSWER HERE* +chmod go-rwx backups, chmod a+rw science.txt ##Shell questions 1. What option with the command `rm` is required to remove a directory? - - **Answer:** *YOUR ANSWER HERE* + - it has to be empty 1. What is the command used to display the manual pages for any command? - - **Answer:** *YOUR ANSWER HERE* + man command 1. What command will show the first 5 lines of an input file? - - **Answer:** *YOUR ANSWER HERE* + - head -5 filename 1. What command can be used to rename a file? - - **Answer:** *YOUR ANSWER HERE* + - mv currentfilename newfilename 1. What option can we given to `ls` to show the hidden files? - - **Answer:** *YOUR ANSWER HERE* + - ls -a 1. What will the command `cat -n file` do? - - **Answer:** *YOUR ANSWER HERE* + - displays content inside the file file and with line numbers 1. What will the command `echo -n hello` do? - - **Answer:** *YOUR ANSWER HERE* + - it adds "hello" to the start of your username, so when you write next time it says helloUsername@computername: 1. What command will display s list of the users who currently logged in in the system? - - **Answer:** *YOUR ANSWER HERE* + - who 1. How do you change password on your account? - - **Answer:** *YOUR ANSWER HERE* + - passwd enter oldpassword enter newpassword enter newpassword enter (enter = enterbutton) 1. How can you list a file in reverse order? - - **Answer:** *YOUR ANSWER HERE* + - ls -r 1. What does the `less` command do? - - **Answer:** *YOUR ANSWER HERE* + - writes out content of a file one page at a time 1. With `less` how do you navigate? - - **Answer:** *YOUR ANSWER HERE* + - space bar for another page and q for quit 1. What command will display the running processes of the current user? - - **Answer:** *YOUR ANSWER HERE* + - ps 1. What command can be used to find the process(es) consuming the most CPU? - - **Answer:** *YOUR ANSWER HERE* + - sleep 100 + C (control c), kill PID_number ##vi questions 1. How do we save a file in `vi` and continue working? - - **Answer:** *YOUR ANSWER HERE* + - :w filename 1. What command/key is used to start entering text? - - **Answer:** *YOUR ANSWER HERE* + - "i"for insert, escape for going back to command 1. What are the different modes the editor can be in? - - **Answer:** *YOUR ANSWER HERE* + - insert and command 1. What command can be used to place the cursor at the beginning of line 4? - - **Answer:** *YOUR ANSWER HERE* + - :# 4 # 1. What will `dd` command do (in command-mode)? - - **Answer:** *YOUR ANSWER HERE* + - deletes the line that the cursor is on 1. How do you undo the most recent changes? - - **Answer:** *YOUR ANSWER HERE* + - "u" for undo 1. How do you move back one word? - - **Answer:** *YOUR ANSWER HERE* + - "b" ##The C Language and Make tool Questions From 473e6a940f69f3529af52735e0f5807638538038 Mon Sep 17 00:00:00 2001 From: aumym Date: Mon, 1 Sep 2014 21:45:35 +0200 Subject: [PATCH 04/18] Revert "Revert "answers"" This reverts commit 5f5971bfff325eaf3ac10125fe2775d8ff1a8668. --- myAnswers.txt | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 myAnswers.txt diff --git a/myAnswers.txt b/myAnswers.txt new file mode 100644 index 0000000..20f63c5 --- /dev/null +++ b/myAnswers.txt @@ -0,0 +1,81 @@ +1. What option with the command "rm" is required to remove a directory? + it has to be empty + +2. What is the command used to display the manual pages for any command? + man command + +3. What command will show the first 5 lines of an input file? + head -5 filename + +4. What command can be used to rename a file? + mv currentfilename newfilename + +5. What option can we given to "ls" to show the hidden files? + ls -a + +6. What will the command "cat -n file" do? + displays content inside the -n file (??) + +7. What will the command "echo -n hello" do? + it adds "hello" to the start of your username, so when you write next time it says HelloUsername@computername: + +8. What command will display list of the users who currently logged in in the system? + who + +9. How do you change password on your account? + passwd enter oldpassword enter newpassword enter newpassword enter (enter = enterbutton) + +10. How can you list a file in reverse order? + ls -r + +11. What does the "less" command do? + writes out content of a file one page at a time + +12. With "less" how do you navigate? + space bar for another page and q for quit + +13. What command will display the running processes of the current user? + ps + +14. What command can be used to end the process(es) consuming the most CPU? + sleep 100 + C (control c), kill PID_number +-------------------------------------------------------------------------------------------- +1. How do we save a file in vi and continue working? + :w filename +2. What command/key is used to start entering text? + "i"for insert, escape for going back to command + +3. What are the different modes the editor can be in? + insert and command + +4. What command can be used to place the cursor at the beginning of line 4? + :# 4 # + +5. What will dd command do (in command-mode)? + deletes the line that the cursor is on + +6. How do you undo the most recent changes? + "u" for undo + +7. How do you move back one word? + "b" +-------------------------------------------------------------------------------------------- + +1. a) How do you use gcc to only produce the .o file? + using -c flag like -c hello.c (??) +1. b) What is the difference between generating only the .o file, and building the hello executable done in the previous compilation above? + When you do it like in the lab, you get two files one named hello.c and another named hello*(??) +2. + +I cant seem to find answers on the rest of the lab and i have struggled with the tasks above, and i wont get to finish this here and now +I cant seem to find what to do in the labs, telling me what to do but not knowing what and where i can find out how to do it, is very hard. + + + + + + + + + + \ No newline at end of file From d3fc62d9ea3b5ef1183a98c7aea34d054e2e0496 Mon Sep 17 00:00:00 2001 From: aumym Date: Mon, 1 Sep 2014 21:49:37 +0200 Subject: [PATCH 05/18] Revert "Revert "Revert "answers""" This reverts commit 473e6a940f69f3529af52735e0f5807638538038. --- myAnswers.txt | 81 --------------------------------------------------- 1 file changed, 81 deletions(-) delete mode 100644 myAnswers.txt diff --git a/myAnswers.txt b/myAnswers.txt deleted file mode 100644 index 20f63c5..0000000 --- a/myAnswers.txt +++ /dev/null @@ -1,81 +0,0 @@ -1. What option with the command "rm" is required to remove a directory? - it has to be empty - -2. What is the command used to display the manual pages for any command? - man command - -3. What command will show the first 5 lines of an input file? - head -5 filename - -4. What command can be used to rename a file? - mv currentfilename newfilename - -5. What option can we given to "ls" to show the hidden files? - ls -a - -6. What will the command "cat -n file" do? - displays content inside the -n file (??) - -7. What will the command "echo -n hello" do? - it adds "hello" to the start of your username, so when you write next time it says HelloUsername@computername: - -8. What command will display list of the users who currently logged in in the system? - who - -9. How do you change password on your account? - passwd enter oldpassword enter newpassword enter newpassword enter (enter = enterbutton) - -10. How can you list a file in reverse order? - ls -r - -11. What does the "less" command do? - writes out content of a file one page at a time - -12. With "less" how do you navigate? - space bar for another page and q for quit - -13. What command will display the running processes of the current user? - ps - -14. What command can be used to end the process(es) consuming the most CPU? - sleep 100 + C (control c), kill PID_number --------------------------------------------------------------------------------------------- -1. How do we save a file in vi and continue working? - :w filename -2. What command/key is used to start entering text? - "i"for insert, escape for going back to command - -3. What are the different modes the editor can be in? - insert and command - -4. What command can be used to place the cursor at the beginning of line 4? - :# 4 # - -5. What will dd command do (in command-mode)? - deletes the line that the cursor is on - -6. How do you undo the most recent changes? - "u" for undo - -7. How do you move back one word? - "b" --------------------------------------------------------------------------------------------- - -1. a) How do you use gcc to only produce the .o file? - using -c flag like -c hello.c (??) -1. b) What is the difference between generating only the .o file, and building the hello executable done in the previous compilation above? - When you do it like in the lab, you get two files one named hello.c and another named hello*(??) -2. - -I cant seem to find answers on the rest of the lab and i have struggled with the tasks above, and i wont get to finish this here and now -I cant seem to find what to do in the labs, telling me what to do but not knowing what and where i can find out how to do it, is very hard. - - - - - - - - - - \ No newline at end of file From 4e92affea2061f7e54eaf6fb290f2364fb325902 Mon Sep 17 00:00:00 2001 From: aumym Date: Mon, 1 Sep 2014 21:51:21 +0200 Subject: [PATCH 06/18] Revert "Revert "Revert "Revert "answers"""" This reverts commit d3fc62d9ea3b5ef1183a98c7aea34d054e2e0496. --- myAnswers.txt | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 myAnswers.txt diff --git a/myAnswers.txt b/myAnswers.txt new file mode 100644 index 0000000..20f63c5 --- /dev/null +++ b/myAnswers.txt @@ -0,0 +1,81 @@ +1. What option with the command "rm" is required to remove a directory? + it has to be empty + +2. What is the command used to display the manual pages for any command? + man command + +3. What command will show the first 5 lines of an input file? + head -5 filename + +4. What command can be used to rename a file? + mv currentfilename newfilename + +5. What option can we given to "ls" to show the hidden files? + ls -a + +6. What will the command "cat -n file" do? + displays content inside the -n file (??) + +7. What will the command "echo -n hello" do? + it adds "hello" to the start of your username, so when you write next time it says HelloUsername@computername: + +8. What command will display list of the users who currently logged in in the system? + who + +9. How do you change password on your account? + passwd enter oldpassword enter newpassword enter newpassword enter (enter = enterbutton) + +10. How can you list a file in reverse order? + ls -r + +11. What does the "less" command do? + writes out content of a file one page at a time + +12. With "less" how do you navigate? + space bar for another page and q for quit + +13. What command will display the running processes of the current user? + ps + +14. What command can be used to end the process(es) consuming the most CPU? + sleep 100 + C (control c), kill PID_number +-------------------------------------------------------------------------------------------- +1. How do we save a file in vi and continue working? + :w filename +2. What command/key is used to start entering text? + "i"for insert, escape for going back to command + +3. What are the different modes the editor can be in? + insert and command + +4. What command can be used to place the cursor at the beginning of line 4? + :# 4 # + +5. What will dd command do (in command-mode)? + deletes the line that the cursor is on + +6. How do you undo the most recent changes? + "u" for undo + +7. How do you move back one word? + "b" +-------------------------------------------------------------------------------------------- + +1. a) How do you use gcc to only produce the .o file? + using -c flag like -c hello.c (??) +1. b) What is the difference between generating only the .o file, and building the hello executable done in the previous compilation above? + When you do it like in the lab, you get two files one named hello.c and another named hello*(??) +2. + +I cant seem to find answers on the rest of the lab and i have struggled with the tasks above, and i wont get to finish this here and now +I cant seem to find what to do in the labs, telling me what to do but not knowing what and where i can find out how to do it, is very hard. + + + + + + + + + + \ No newline at end of file From 0237b99ba26c9e053e5c5875cf5accaabbedde25 Mon Sep 17 00:00:00 2001 From: aumym Date: Mon, 1 Sep 2014 22:01:36 +0200 Subject: [PATCH 07/18] Delete myAnswers.txt --- myAnswers.txt | 81 --------------------------------------------------- 1 file changed, 81 deletions(-) delete mode 100644 myAnswers.txt diff --git a/myAnswers.txt b/myAnswers.txt deleted file mode 100644 index 20f63c5..0000000 --- a/myAnswers.txt +++ /dev/null @@ -1,81 +0,0 @@ -1. What option with the command "rm" is required to remove a directory? - it has to be empty - -2. What is the command used to display the manual pages for any command? - man command - -3. What command will show the first 5 lines of an input file? - head -5 filename - -4. What command can be used to rename a file? - mv currentfilename newfilename - -5. What option can we given to "ls" to show the hidden files? - ls -a - -6. What will the command "cat -n file" do? - displays content inside the -n file (??) - -7. What will the command "echo -n hello" do? - it adds "hello" to the start of your username, so when you write next time it says HelloUsername@computername: - -8. What command will display list of the users who currently logged in in the system? - who - -9. How do you change password on your account? - passwd enter oldpassword enter newpassword enter newpassword enter (enter = enterbutton) - -10. How can you list a file in reverse order? - ls -r - -11. What does the "less" command do? - writes out content of a file one page at a time - -12. With "less" how do you navigate? - space bar for another page and q for quit - -13. What command will display the running processes of the current user? - ps - -14. What command can be used to end the process(es) consuming the most CPU? - sleep 100 + C (control c), kill PID_number --------------------------------------------------------------------------------------------- -1. How do we save a file in vi and continue working? - :w filename -2. What command/key is used to start entering text? - "i"for insert, escape for going back to command - -3. What are the different modes the editor can be in? - insert and command - -4. What command can be used to place the cursor at the beginning of line 4? - :# 4 # - -5. What will dd command do (in command-mode)? - deletes the line that the cursor is on - -6. How do you undo the most recent changes? - "u" for undo - -7. How do you move back one word? - "b" --------------------------------------------------------------------------------------------- - -1. a) How do you use gcc to only produce the .o file? - using -c flag like -c hello.c (??) -1. b) What is the difference between generating only the .o file, and building the hello executable done in the previous compilation above? - When you do it like in the lab, you get two files one named hello.c and another named hello*(??) -2. - -I cant seem to find answers on the rest of the lab and i have struggled with the tasks above, and i wont get to finish this here and now -I cant seem to find what to do in the labs, telling me what to do but not knowing what and where i can find out how to do it, is very hard. - - - - - - - - - - \ No newline at end of file From 941974c75d22635824856e58734d904c471d838f Mon Sep 17 00:00:00 2001 From: aumym Date: Tue, 2 Sep 2014 10:33:32 +0200 Subject: [PATCH 08/18] more --- ANSWERS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ANSWERS.md b/ANSWERS.md index f90df93..c6e211f 100644 --- a/ANSWERS.md +++ b/ANSWERS.md @@ -111,7 +111,7 @@ chmod go-rwx backups, chmod a+rw science.txt ##The C Language and Make tool Questions 1. How do you use `gcc` to only produce the `.o` file? What is the difference between generating only the `.o` file, and building the `hello` executable done in the previous compilation above? - - **Answer:** *YOUR ANSWER HERE* + - gcc -c hello.c 1. Give the command for compiling with `debug` enabled instead of normal compilation for the two examples shown in Listing 2 and Listing 3. Explain how to turn debugging on/off for the two cases. - **Answer:** *YOUR ANSWER HERE* 1. Give a brief pros and cons discussion for the two methods to add debug code shown in Listing 2 and Listing 3. From 9cc01cd0fdd8a9b95281ba8493d92c5adce3b030 Mon Sep 17 00:00:00 2001 From: aumym Date: Tue, 2 Sep 2014 10:37:44 +0200 Subject: [PATCH 09/18] 1a --- ANSWERS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ANSWERS.md b/ANSWERS.md index c6e211f..471f172 100644 --- a/ANSWERS.md +++ b/ANSWERS.md @@ -111,7 +111,7 @@ chmod go-rwx backups, chmod a+rw science.txt ##The C Language and Make tool Questions 1. How do you use `gcc` to only produce the `.o` file? What is the difference between generating only the `.o` file, and building the `hello` executable done in the previous compilation above? - - gcc -c hello.c + - gcc -c hello.c, you dont specify the exe filename and hello.o isnt runnable 1. Give the command for compiling with `debug` enabled instead of normal compilation for the two examples shown in Listing 2 and Listing 3. Explain how to turn debugging on/off for the two cases. - **Answer:** *YOUR ANSWER HERE* 1. Give a brief pros and cons discussion for the two methods to add debug code shown in Listing 2 and Listing 3. From 4a6b348a940ce57092bfe25ab314cb5081588da3 Mon Sep 17 00:00:00 2001 From: aumym Date: Tue, 2 Sep 2014 11:17:03 +0200 Subject: [PATCH 10/18] more --- ANSWERS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ANSWERS.md b/ANSWERS.md index 471f172..4ddfe40 100644 --- a/ANSWERS.md +++ b/ANSWERS.md @@ -111,9 +111,9 @@ chmod go-rwx backups, chmod a+rw science.txt ##The C Language and Make tool Questions 1. How do you use `gcc` to only produce the `.o` file? What is the difference between generating only the `.o` file, and building the `hello` executable done in the previous compilation above? - - gcc -c hello.c, you dont specify the exe filename and hello.o isnt runnable + - gcc -c hello.c -o hello.o, you dont specify the exe filename and hello.o isnt runnable 1. Give the command for compiling with `debug` enabled instead of normal compilation for the two examples shown in Listing 2 and Listing 3. Explain how to turn debugging on/off for the two cases. - - **Answer:** *YOUR ANSWER HERE* + - gcc hello.c -D DEBUG hello -o 1. Give a brief pros and cons discussion for the two methods to add debug code shown in Listing 2 and Listing 3. - **Answer:** *YOUR ANSWER HERE* 1. Provide the command for generating the *map* file. Which of the `gcc` tools is responsible for producing a *map* file? From 9723d55a88c2224b06c1f7fb3671c18e3856740a Mon Sep 17 00:00:00 2001 From: aumym Date: Tue, 2 Sep 2014 11:20:20 +0200 Subject: [PATCH 11/18] m --- ANSWERS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ANSWERS.md b/ANSWERS.md index 4ddfe40..ba55723 100644 --- a/ANSWERS.md +++ b/ANSWERS.md @@ -113,7 +113,7 @@ chmod go-rwx backups, chmod a+rw science.txt 1. How do you use `gcc` to only produce the `.o` file? What is the difference between generating only the `.o` file, and building the `hello` executable done in the previous compilation above? - gcc -c hello.c -o hello.o, you dont specify the exe filename and hello.o isnt runnable 1. Give the command for compiling with `debug` enabled instead of normal compilation for the two examples shown in Listing 2 and Listing 3. Explain how to turn debugging on/off for the two cases. - - gcc hello.c -D DEBUG hello -o + - gcc hello.c -D DEBUG hello -o (debug on) gcc hello.c hello -o (debug off). 1. Give a brief pros and cons discussion for the two methods to add debug code shown in Listing 2 and Listing 3. - **Answer:** *YOUR ANSWER HERE* 1. Provide the command for generating the *map* file. Which of the `gcc` tools is responsible for producing a *map* file? From 914d4b90fc14dcde2d056a7131269118402f3378 Mon Sep 17 00:00:00 2001 From: aumym Date: Tue, 2 Sep 2014 11:31:49 +0200 Subject: [PATCH 12/18] m --- ANSWERS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ANSWERS.md b/ANSWERS.md index ba55723..b075c99 100644 --- a/ANSWERS.md +++ b/ANSWERS.md @@ -113,7 +113,7 @@ chmod go-rwx backups, chmod a+rw science.txt 1. How do you use `gcc` to only produce the `.o` file? What is the difference between generating only the `.o` file, and building the `hello` executable done in the previous compilation above? - gcc -c hello.c -o hello.o, you dont specify the exe filename and hello.o isnt runnable 1. Give the command for compiling with `debug` enabled instead of normal compilation for the two examples shown in Listing 2 and Listing 3. Explain how to turn debugging on/off for the two cases. - - gcc hello.c -D DEBUG hello -o (debug on) gcc hello.c hello -o (debug off). + - gcc hello.c -D DEBUG hello -o (debug on) gcc hello.c hello -o (debug off). For the other one we can change it off by setting int debug = 0; and take debug on by typing in 1 instead of 0 and compile and runt the program. 1. Give a brief pros and cons discussion for the two methods to add debug code shown in Listing 2 and Listing 3. - **Answer:** *YOUR ANSWER HERE* 1. Provide the command for generating the *map* file. Which of the `gcc` tools is responsible for producing a *map* file? From a7caca1aaeba1e2252390bd039beb86d93ba14fc Mon Sep 17 00:00:00 2001 From: aumym Date: Tue, 2 Sep 2014 11:46:23 +0200 Subject: [PATCH 13/18] m --- ANSWERS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ANSWERS.md b/ANSWERS.md index b075c99..f911443 100644 --- a/ANSWERS.md +++ b/ANSWERS.md @@ -115,7 +115,7 @@ chmod go-rwx backups, chmod a+rw science.txt 1. Give the command for compiling with `debug` enabled instead of normal compilation for the two examples shown in Listing 2 and Listing 3. Explain how to turn debugging on/off for the two cases. - gcc hello.c -D DEBUG hello -o (debug on) gcc hello.c hello -o (debug off). For the other one we can change it off by setting int debug = 0; and take debug on by typing in 1 instead of 0 and compile and runt the program. 1. Give a brief pros and cons discussion for the two methods to add debug code shown in Listing 2 and Listing 3. - - **Answer:** *YOUR ANSWER HERE* + - the first one you can run just by taking in the -D DEBUG false or true when you compile, the other one is a little more work since you need to change int debug which is inside the c file. 1. Provide the command for generating the *map* file. Which of the `gcc` tools is responsible for producing a *map* file? - **Answer:** *YOUR ANSWER HERE* 1. What is the content of each of the sections in a *map* file. Explain briefly. From 340f23b7f25c3de047a62240bf7a49327b4e1671 Mon Sep 17 00:00:00 2001 From: aumym Date: Tue, 2 Sep 2014 12:15:19 +0200 Subject: [PATCH 14/18] m --- ANSWERS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ANSWERS.md b/ANSWERS.md index f911443..fb7f563 100644 --- a/ANSWERS.md +++ b/ANSWERS.md @@ -117,7 +117,7 @@ chmod go-rwx backups, chmod a+rw science.txt 1. Give a brief pros and cons discussion for the two methods to add debug code shown in Listing 2 and Listing 3. - the first one you can run just by taking in the -D DEBUG false or true when you compile, the other one is a little more work since you need to change int debug which is inside the c file. 1. Provide the command for generating the *map* file. Which of the `gcc` tools is responsible for producing a *map* file? - - **Answer:** *YOUR ANSWER HERE* + - gcc hello.c -o hello -Wl,-Map=output.map, linkeren 1. What is the content of each of the sections in a *map* file. Explain briefly. - **Answer:** *YOUR ANSWER HERE* 1. Rewrite `hello.c` to produce entries in the *map* file for `.data`, `.bss`, and `.rodata`. Hint: This can be done by adding one variable for each type to the file. From 44b871f8f7bed898b99935062e46df4a0b3e32cc Mon Sep 17 00:00:00 2001 From: aumym Date: Tue, 2 Sep 2014 13:23:34 +0200 Subject: [PATCH 15/18] m --- ANSWERS.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ANSWERS.md b/ANSWERS.md index fb7f563..0399df6 100644 --- a/ANSWERS.md +++ b/ANSWERS.md @@ -119,11 +119,13 @@ chmod go-rwx backups, chmod a+rw science.txt 1. Provide the command for generating the *map* file. Which of the `gcc` tools is responsible for producing a *map* file? - gcc hello.c -o hello -Wl,-Map=output.map, linkeren 1. What is the content of each of the sections in a *map* file. Explain briefly. - - **Answer:** *YOUR ANSWER HERE* + - initialized (int somthing set to somthing that is not 0) plomme + - uninitialized (int somthing set to 0) eple + - read only (int const) appelsin 1. Rewrite `hello.c` to produce entries in the *map* file for `.data`, `.bss`, and `.rodata`. Hint: This can be done by adding one variable for each type to the file. - - **Answer:** *YOUR ANSWER HERE* + - int eple =0;(.bss) int plomme = 1;(.data) const int appelsin = 2;(.rodata) 1. Add the following function to `hello.c`: `double multiply(double x1, double x2)`, which returns `x1*x2`. Use `gcc` to generate an assembly code listing for the program, and examine the assembly code. What assembly instructions are used to do this? Repeat this task, but now replace `double` with `float`. Explain! - - **Answer:** *YOUR ANSWER HERE* + - (gcc hello.c -S -o hello.assembly) 1. How does `make` know if a file must be recompiled? - **Answer:** *YOUR ANSWER HERE* 1. Provide a `make` command to use a file named `mymakefile` instead of the default `makefile`. From 60b8d27f597ed0dfdb44fbe6bbe6c8f457f40d31 Mon Sep 17 00:00:00 2001 From: aumym Date: Tue, 2 Sep 2014 13:34:18 +0200 Subject: [PATCH 16/18] m --- ANSWERS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ANSWERS.md b/ANSWERS.md index 0399df6..ac1859f 100644 --- a/ANSWERS.md +++ b/ANSWERS.md @@ -126,6 +126,7 @@ chmod go-rwx backups, chmod a+rw science.txt - int eple =0;(.bss) int plomme = 1;(.data) const int appelsin = 2;(.rodata) 1. Add the following function to `hello.c`: `double multiply(double x1, double x2)`, which returns `x1*x2`. Use `gcc` to generate an assembly code listing for the program, and examine the assembly code. What assembly instructions are used to do this? Repeat this task, but now replace `double` with `float`. Explain! - (gcc hello.c -S -o hello.assembly) + - assembly for float: movss and mulss, for double movsd and mulsd 1. How does `make` know if a file must be recompiled? - **Answer:** *YOUR ANSWER HERE* 1. Provide a `make` command to use a file named `mymakefile` instead of the default `makefile`. From eb633ac35cab9b8d007221f8bfd8360c86c58200 Mon Sep 17 00:00:00 2001 From: aumym Date: Tue, 2 Sep 2014 13:37:52 +0200 Subject: [PATCH 17/18] m --- ANSWERS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ANSWERS.md b/ANSWERS.md index ac1859f..0f5f5a1 100644 --- a/ANSWERS.md +++ b/ANSWERS.md @@ -126,7 +126,7 @@ chmod go-rwx backups, chmod a+rw science.txt - int eple =0;(.bss) int plomme = 1;(.data) const int appelsin = 2;(.rodata) 1. Add the following function to `hello.c`: `double multiply(double x1, double x2)`, which returns `x1*x2`. Use `gcc` to generate an assembly code listing for the program, and examine the assembly code. What assembly instructions are used to do this? Repeat this task, but now replace `double` with `float`. Explain! - (gcc hello.c -S -o hello.assembly) - - assembly for float: movss and mulss, for double movsd and mulsd + - assembly for float: movss and mulss, for double movsd and mulsd, they have different type of ssembly but the start of the assembly are thesame (mov x3 and mul x1) 1. How does `make` know if a file must be recompiled? - **Answer:** *YOUR ANSWER HERE* 1. Provide a `make` command to use a file named `mymakefile` instead of the default `makefile`. From dd72e700c418dd343548c56ccd502c876edde06d Mon Sep 17 00:00:00 2001 From: "Victoria G. Kaddour" Date: Tue, 2 Sep 2014 13:59:16 +0200 Subject: [PATCH 18/18] trete --- hello.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 hello.c diff --git a/hello.c b/hello.c new file mode 100644 index 0000000..09ea4c7 --- /dev/null +++ b/hello.c @@ -0,0 +1,30 @@ + +#include +int debug = 1; +int eple =0; +int plomme = 1; +const int appelsin = 2; + +int main(void) + +{ + if ( debug ) + { + printf("Debugging\n"); + } + printf("Hello, world!\n"); + return 0; + +} + +float fmultiply(float a, float b){ + return a*b;} + + +double dmultiply(double a, double b){ + return a*b; + +} + + +