Transcript for:
COMP1521 Week 1 Lecture 1 Course Overview and Content

[Music] all right everyone let's make a start first of all I'd like to know if everyone can hear me hear myself echoing and how about the chat do we have anyone in the chat no one in the chat sorry no that's okay but we have uh participation as well right oh okay could I ask someone in chat to post a question please a discussion in Moodle in Echo in echo is accessed here we go is that a Oh yeah excellent everyone can hear me everyone is here we are ready to start all right find a seat quickly please all right you can catch up later so welcome to your first comp lecture my name is Alex Crow and I will be your lecturer today um if you're not meant to be in comp 1521 now is a good chance for you to sneak out quietly and go to your correct room okay all right could I ask for quiet please we're starting this class we're five minutes in already guys thank you all right so in today's lecture we will be doing welcomes and introductions i'll be telling you how um the course will work i'll be telling you how to get help as well and um in terms of the content we are going to be looking at how does a program run and we're going to be looking at we're going to be taking a first look at MIPS assembler sorry I just hear myself getting a bit of feedback is that better okay so all the course information is on our course website there's the link there for you and um a QR code that you can snap right now if you like who has already had a look at the course website i see hands couple of people excellent so the the course um so please bookmark the course website so there's a lot of resources on there that you will be using frequently read the course outline thoroughly and this this term we will be using Moodle only for the online lectures the live streaming and for later on we'll publish the recorded lectures uh we'll also be using it for blackboard collaborate who has used that before the mic is a bit quiet I think it's a bit quiet back up here um [Music] How's that oh no feedback excellent um okay so who's used Blackboard Collaborate excellent one person oh not so many we'll be using it this term this is all accessed through Moodle so we'll be using that for um online help sessions and online tutorials okay course staff who are we so I'm the lecturer as I mentioned Alex Crow so Angela Finlathan will be the convenor so she's going to be responsible for ticking off on things that anything that I'm not able to tick off on we have a number of admins because we have a very large class so we have Aberam um Alex Anna and JJ and Jimmy um and our lecturer moderators so thanks for coming today okay so we have Tess and um and Ashley so so they're both here for introductions today but um Tess will be taking the Monday lectures and Ashley will be taking the Wednesday lectures and of course we have an amazing team of tutors we have about 30 of them this year over 30 and all the details of the team are linked on the course website just like everything else okay and you guys who are you so most students in this course have completed 1511 or 911 and that covers the the fundamentals of C programming so this week this week's cheats and labs so we're going to review and strengthen some of um assumed C knowledge we're going to cover some non assume non-assumed C knowledge as well so mostly recursion and for anyone who needs more practice with C fundamentals um re we're going to hold revision sessions in week two and they'll help you um to revise some important concepts um strrus pointers malik recursion oh hands up if you have done recursion before quite a number so we'll just be more of a refresher um so in terms of assume C knowledge uh we assume that you know how to design an algorithmic solution so at this point I'm not talking about actually implementing that solution but you know how to design it and then you can describe your solution in CC code using variable assignments tests the um if um inputs and outputs like scan f and print f um functions returns prototypes and being able to split your um your design your solution into multiple files um so we also assume that you know the arrays strrus pointers uh malik and free not assume knowledge um we don't assume that you know recursion but it's great to see that a lot of you already do and we don't assume that you know for loops so these are going to be covered in the week one tutorials um bit operations and file operations these are actually quite a core part of this course so you'll be definitely learning these in the Course you still do not need to know what link lists are so maybe those will come do next in your course schedule no one got the pun all right thank you guys that makes me feel better um okay so 1511 911 so that got you thinking like a programmer how do you write a program solving problems by developing programs and expressing your solutions in the C language um in 1521 so we're going to start getting you to think more like a systems program how do we create systems that can run a program so um and at the very least we want you we we would like you to be able to reason better about what your C programs are doing of course expectations um so we expect you to further develop Linux command line skills um so it often baffles me when I when I meet someone they don't know how to use the command line they're clicking these gooies everywhere i'm like just type this thing in it's really easy um so that's I'm definitely really glad that I learned those skills early on um because it's very very powerful to just get in there and and type what you want okay we also expect you to further your um development of coding and debugging skills of course um but we would like you to become less reliant on auto tests and think more about your own test cases because when you're out there in your career as a software engineer um you won't just be writing the software half the job will also be writing the test cases so one of the one of the skills that you'll need to develop is like what makes a good test case have we test every branch of execution in our program what happens if the program is given some unusual input does it report an appropriate error or does it segment and crash or does it do something even worse like maybe take all the money out of some person's bank account okay and we expect you to get used to reading manuals and documentations um I will get into those a bit more later though so 1511 so on the left um so that's what what um 1 911511 would have been like to you so 1521 is a bit more like the image on the right where you have a a cliffhanger you might feel like that sometimes just hanging there um very important to reach out for help if you need it i want you all to succeed in this course i want you all to pass so reach out reach out early and keep in mind that every cliffhanger was once jumping in a jumping castle so we all started somewhere right so this course in context so there is a wide variety of courses that you can take at CSSE um and this is the relationship between them i some of these courses I'm not very familiar with but I know um if you just go up a little bit of 1511 oh so there we are 1521 just up from there so from here on the left is um believe it's circuits and systems um so we'll be talking about a little bit we'll be touching on CPU architecture in this course and in that course you actually design um a CPU and on the right operating systems um so that takes the the lessons that you'll be learning in this course even further and one thing I wanted to point out is some of these so you know the the first number in the course codes that's the level of the course right so you have one that's typically level one course two level two three level three four level four how do you get to level six there's no five here right so these sixes so we we only go up to level four everything above level four they're considered level four courses so later on if you'd like to take some of these for example um courses that start with a six just be aware they can be substituted as a level four course right um okay so major themes for this this course so we'd like you to be able to understand the execution of software in detail so software components of a modern computing system how C programs execute at the machine level um how to write MYIPS assembly language has anyone heard of MIPS oh wow could I sorry could I ask you where have you heard of MIPS um well I guess prior to the course I actually just like went on a bit deep into all the different types of assembly language so So just out of your own interest you had a look at um all the assembly languages out there very briefly right okay that's all right fantastic great thank you so just pure curiosity um great so we're going to be So we want you to be able to understand how computers represent data including integers floats emojis okay and how operating systems are structured um so Unix Unix Linux um system level programming so we're going to be looking at file systems in particular here and u we'll give you an introduction to processes threads and concurrency because that's always fun there's no prescribed textbook for this course um so there is a recommended reference though if you're a real keen reader so it's called computer systems a programmer's perspective by Bryant and her halerinum um so it covers most topics um uses different machine code though so I mentioned that um in this course we'll be looking at MIT assembly um so it uses a different kind of assembly language so this one is available at the UNL bookshop um so in terms of the systems and tools that you will have available to you um so they'll be avail tools that you need will be in the cse labs um and has anyone used vlab yet has anyone heard of vlab all right I think I need to give a quick demonstration so elab gateway stop you're inside UNSW to use VNC um so use VNC instead okay the problem is this machine that I'm using doesn't have VNC so I'm just going to use the web interface just to give you a little um look at what is like when you sign in oops okay that's how you would get VNC uh which resolution so you just punch in your ID so maybe this is why it's not recommended i just had a bit of lag there and I missed the character all right does anyone recognize this setup i chose a resolution that was too big i think everyone recognizes that excellent so from home you can easily log in um to this system um again use a V use Tiger VNC that's the recommended one um and then you'll have access to the the lab environment all right that's all I wanted to show you there oh sorry so does it use the same sort of browser as we had for 151 does all that stuff like is it the same like if I sign inc Right so the um vlab is going to be a mirror of what you see on the cse machine so on every CSC machine all of your bookmarks all of your files and everything carries over from one system to another and it also carries over into VLAB as well um okay ssh has anyone used SSH excellent so I'm an SSH kind of guy i mentioned that I love the command line so I won't be using VLAB very much in the lectures when I need to use when I need to log into the systems i'll just be using SSH directly let's make that bigger um compilers we have dcc or you can use clang or dcc um so dcc has some um added catches in there so when you run dcc help it will give you a bit more information about any compile errors that you might have had and what caused them um so I miss we'll be we'll be working with assembly languages um so we have I'm going to talk about this more later so I won't go into that now so you can use your favorite editor VS Code Ed Vim Emacs Nano Gedit who likes Vim no one oh one excellent my best friend two best friends who uses VS Code all right excellent it's I think VS Code is pretty good but I'm so used to using BIM and I know all the shortcuts so I stick with it um other tools as well on the CSC machines we have make we have man that's going to be a big one in today's lecture bc-ql that's great for maths on the command line and of course Python so so learn to love the shell on command line it is very useful so the Linux manual so I mentioned manuals so the Linux manual in um is how we would get information about common commands C libraries it's got a number of sections so the first section is the executable programs and shells so anything you can write on the command line you can um look up the man page for that just by typing man and then um one for the section and then the command so we have another one for system calls section two and section three are your um library calls so as an example I didn't log in i was hoping it would carry over my settings just like Vlab would all right so we have man one CP so from u from this we can double check the arguments that we're providing to CP but that's a little boring because I'm sure you use CP all the time um but there are some interesting flags in here that you might know about like -v verbose that's nice to get a little um indication of what you're copying and the other one I like to use when I'm a little bit nervous dash I interactive if I'm over overwriting a file it's going to prompt me before doing that um so it is possible to uh get the manual pages to these commands by typing man and just the the command print s that's not a command that's a c function so actually you can see this has opened up um the section one print f in section one so this is actually a bash command as well okay so if I want to be specific about which section so now I've told it that I specifically want section three and it will open the the man page for um C functions q to quit and if we forget all that there's always the man page for man and to get more information about all the different sections so man section number intro we can get some more information there but you're going to find man very useful for this course and it will be available to you in um in exams oh I can just mouse wheel no I can't properties oh that's looks like exactly what I was doing before so we have some line wrap now but I think it is big enough for the people watching okay all right excellent okay so I've just been through over how to use MAM so I'm not going to go through these slides and for everyone um online or offline they'll be able to go through this later as well um yes but key thing down the bottom here man will be available for the exam if you've become used to using that then it'll be very easy in your exam to use that you'll be very familiar with it okay so the course format it's a brief overview I will go through detail um so we've got weekly lectures 2 by two hours um so of course on Monday from uh 2 to 4 and on Wednesday from 11 till 1 um now these lectures are are both in person they're livereamed and they're recorded so they're available offline and I don't think the people online can see right now but there are plenty of empty seats here if the people online would like to come in and see me in person um and also if if you guys are struggling the people who are in here today are struggling um to meet deadlines that you can you know work from home um and just join the class remotely i do recommend coming in in person though it's a much better experience um so we have two tutorials and labs so they're threehour blocks one hour for the tute and two for the um two for the labs um I said this was going to be an overview so let's run through this real quick so weekly tests done in your own time starting in week three two major assignments and one final exam in person so the lectures just gone through there is so there's usually space in the lecture hall come in um okay so in the lectures we'll be presenting a brief overview in theory we'll focus on practical demonstrations of coding some problem solving some testing testing and some debugging so hopefully I won't have to stand up here lecturing you guys the whole time I can show you some some programming techniques um so if you have a question during the lecture please put up your hand and ask and we have the live chat which people are already using which is fantastic um but please be respectful of others yes go ahead can you explain what the weekly uh yes I will go over that in just a minute um so please be respectful of others everyone is here to learn don't be noisy because it'll disturb the people around you they won't be able to hear and they might miss something important and more importantly you'll um might miss something important as well so be kind to one another in the chat and of course in person too so resources all of the lectures are recorded lecture slides are available um okay so here so the slides I'll usually release the day before the the lecture so that you can follow along on your machines um the lectures will usually come with live codes but they will usually be released later on and down here so today's lecture is on MIP's basics once we get through the introduction um so there's also some um some additional notes that you might want to look at if you if you um would like to read up on what I've been telling you about so Chute Labs so three-hour cheats Chute Labs so they start in week one this week has anyone had a CH lab already all right so each class is a 1-hour tutorial followed by by a 2hour lab so most of the Toot Labs are face-to-face classes but we do have some that are online over Blackboard Collaborate so the online tabs Yips and Blackboard Collaborate of course via Moodle so the tutorials um to get the best out of you your tutorials so these are not marked there's no submission there's no participation mark um but you will learn more if you come to these tutorials having tried these the problems in of the tutorials yourself beforehand so by doing these problems first you'll be able to find where your knowledge gaps are and you'll be able to know what questions to ask and it also provides a better discussion with everyone else as well who might have solved your problem in a different way so um it includes extra questions that you can use for revision um that won't get covered in class so you'll have some fresh content there where you um can go back when you're revising for the exam or you can do it um already just to make sure that you you have a firm understanding uh so do not keep quiet during the the tutorials it's the tutorials there are mostly to um promote a discussion you'll learn a lot more from discussing from discussing the questions in the tutorial than you will from the tutor just telling you how to do all the work just telling you the answers so labs each tutorial is followed by a two-hour lab class um se several exercises they're mainly small coding tasks so these will build build the skills that you need for the assignments and for the exam these are to be done individually submitted by give um before Monday midday um the following week but lab one is the exception because we assume that people are still finding like there's still new enrollments coming in and people are still um getting adjusted to the next term so all the labs um will be due the following week except for lab one which will be week three um so labs are automarked worth a total of 15% of your final mark um there will be seen auto tests and unseen auto tests so I mentioned that that now we're going to be um expecting you to be able to write and test um be able to test your code yourselves so um for that reason we do hide some of the tests now so you'll have to think about is there anything that I missed and make sure that you've your uh program is working perfectly before you submit it question yes what happens if we miss a lab or tutorial to a public holiday or something that is a very good question because next week we have a public holiday um so okay so so next week there will be no lecture on Monday because it's a public holiday and I'll be recording a lecture and releasing it online so no one gets to no one has to miss out um in terms of cheats and labs so I recommend discussing with your your tutor about which lab you would um switch to for that term for that week sorry um but we really don't want 250 students from the Monday classes rocking up at one um class later on in the week so please discuss with your tutors so that they can balance the the um the like balance the movement of the Monday classes to the other classes um okay sorry back to the the auto test so the auto tests that we provide you with they're generally just sanity checks so it'll test that your program compiles it'll do some um so initial no simple tests just to make sure that you haven't submitted the wrong file or accidentally made a change before submitting and also it will keep a record of I think it's the last five submissions that you make so please do submit early um submit often if there is a problem with your final submission we may be able to accept your previous submission with um without you incurring the late penalty okay so labs may include challenge exercises they might be silly confusing impossibly difficult but they will be fun so but you can almost get full marks um without completing any of these challenge exercises so don't be too worried if you're struggling with one um flexi week and public holidays um so we flexi week is usual week six there'll be no lectures no tutorials no labs and um there will be optional revision activities and help sessions for you to attend to catch up on these things public holidays I've already mentioned skip over that tests so from week three every week um every week after including week six so these tests will be released on Thursday at 3 p.m due exactly one week later submitted via GIF just like everything else and it gives you an immediate reality check on your progress so if you find that you're struggling with these tests please reach out for help from tutors help sessions so that you can stay on top of the coursework um because if you reach out at the end of the semester you're going to realize there's a lot to catch up on okay so the conditions these are so we're expecting self um yes they will be and thank you so much for pointing out the people with their hands up it's a sea of people and sometimes I have trouble especially on the sides um so self- enforced exam conditions for these tests um so that means uh so in the in the test you won't have access to it you'll be a very restricted lab environment right so we want you to be getting prepared for this final exam um so do these tests in self enforced exam conditions where you don't have access to um the outside world you only have access to the man and the uh resources on the course website not the lecture notes um so time limit of 1 hour for the tests and you can keep working on it after the 50 minute um sorry you can keep working on it after the hour but you will receive a 50% cap um right so we automark with partial marks so the best six out of the eight tests will contribute to 10% of your final mark so 10% isn't really that much right so um so just use a so the this 10% is just to encourage you to do these tests so that you can gauge your performance how you're going in the course and whether you need to start reaching out for um these help sessions okay okay and if if we do detect any violation of these self- enforced exam conditions we will be giving you a zero for the whole component assignments assignment one so assignment one there'll be two assignments assignment one is going to be on the on assembly programming so I'll be touching on that at the end of this lecture um so the assignment will be released in week three and due in week five worth 15% the second assignment is on C systems programming so this will generally be uh like file system operations and things like that so that will be due in week seven uh sorry released in week seven due in week nine again worth 15% um so the assignment is going to give you experience with larger um programming problems than the lab exercises right lab exercises are generally very short simple exercises to make sure you understand the theory these assignments are going to make sure you know how to be a good software engineer yes and the assignments are to be carried out individually no group work on those assignments um so there is a rule and an an unwritten rule for um estimating how long something in computer science is going to take you estimate how long it will take and you multiply that by 10 right so you might look at the assignment and say "Hey I can hack this up in an hour no worries." And then as you're going through it you work out "Ah this I didn't actually anticipate that this part of the assignment was going to be more challenging." So okay maybe it takes you two hours but you get it done in two hours and you submit it and the auto test value oh you've misunderstood something in the assignment spec so now you have to go back through and and do a little bit of rework and uh test your submission and then you submit it again but now you're thinking "Oh well it didn't work the first time maybe there's other um other conditions that I haven't tested yet that would cause one of the unseen auto tests to fail maybe I should take a better look at it and make sure that my code is perfect." So then you can see how this 1hour estimate of hacking it up can um end up taking a lot longer than you expected so please don't leave it till the last minute uh so um so yeah so and with the with everything in this course we have the help sessions we have the forums we have tutors in your lab so they're all going to be a um a big help for um any problems that you might have with the assignment okay don't copy or use generative AI so in later courses I believe you will be able to use AI in some way but in this course you're learning you're still learning the the fundamentals so there's no use of generative AI here and for the assessments we follow the standard UNSW late p late late policy which is 5% per day for 5 days computed hourly so the penalty is the maximum of the possible marks it's not the max it's not 5% of the marks that you that you were awarded it's 5% of the maximum okay the final exam is what you've all been waiting for this will be an in-person 3-hour practical exam at CSSE on CSSE lab computers and um you must be in Sydney to sit this exam so no VLAB for you and it will be a limited environment so you get the tools and software of the lab computer not your own computer you don't have access to your normal CSSE account um so do not so no custom configuration files and no course website available and there was a a mention about um about vlab and whether that carries over your bookmarks and all of that so with this restricted environment you won't get the your bookmarks you won't get any of your tricky bash aliases for when you're using the command line vs Code extensions you won't have any of those so when you're practicing for this test make sure that you're not using any of those um so you'll have the man pages i mentioned mentioned that we're going to be looking at MIP's assembly so you will have documentation on what the assembly instructions are and all of that but that's all you'll be given and can I ask everyone to be quiet please thank you very much oh what else so you won't have dcc help or auto test help either you must you must score um at least 18 out of 45 so that's 40% on the final exam to pass the course um so a breakdown of the assessments in terms of marks you have 45% for the final exam and 15 each for the assessments 15 for the labs 10% for the tests so again I want to highlight that 10% for the tests that's only a small part of these marks yes you do them at home yeah so self- enforced exam conditions so we put a lot of faith in you to do the right thing um that's a good question do you recall do we have auto tests for the exam i believe there are right yes for some so it's just like the the lab submissions so some of the tests are going to be available to you and um some won't be okay so to pass you must score greater than 50% the Yes um for assignment one they'll be released in week three okay so to pass overall you need 50% in the um an overall mark of 50 out of 100 um but the exam is a hurdle you need to get um 18 out of 85 for the final exam so if you get 55 in the overall coursework and 17 out of 45 for the final exam you will get a grade that looks like it's passing but it will say UF on the end of it to say unsatisfactory fail so you will not get a grade of 55 PS for pass so just be aware of that so um so yes code of conduct um CSC offers um an inclusive learning environment for all students um what did I do to these slides if anything connected to UNSW including social media the following sorry anything connected to UNSW including social media the following following are considered to be student misconduct and won't be tolerated racist sexist offensive languages or images i'm sorry that I had to bring that up sexually inappropriate behavior bullying harassing or aggressive behavior invasion of privacy but I'm sure none of you will be doing any of that you'll all be respecting your fellow students and course staff plagiarism um cheating of any kind constitutes academic misconduct and carries a range of penalties so examples include the group work on individual assignments so discussions are okay i really encourage you to discuss the assessment the assignments but you don't need to do that by sharing code in the process right if you do happen to look at someone else's code um I recommend not doing any coding straight after that maybe go home go to sleep um let the specific details of that code that you saw drift out of your mind and all the key concepts come and settle in and then get started the next day um to finish off that assignment with this new knowledge that you've gained um so allowing another student to copy your work is also considered academic misconduct so don't think that just because you weren't copying someone's work you won't be um you won't uh face academic misconduct it's if you're also helping someone do that then that is academic misconduct as well and of course the favorite getting a hacker cousin to code for you don't do that and purchasing a solution to the assignment is also academic misconduct um the labs test and assignments must be entirely your own work so there's no group work in this um course you cannot work on labs tests or assignments as a pair or in a group so plagiarism will be checked and it will be penalized so it might result in suspension from USW um scholarship students might lose their scholarship international students might lose their visas and um again supplying your work to another person is also considered plagiarism please don't post any of your work online on GitHub so more information on this can be found in the course outline if I haven't spent enough time on this already generative AI so um I think we can all see the So I think we can all see the the subtle issues with these images from AI okay so if you're using generative AI will you be able to see all the issues um in your AI generated MIPS or C code will AI generate the same code for other students okay so be mindful of that and what will you do in the final exam because you won't have access to the internet um chat GPT will go away copilot will go away and you'll be forced to rely on your own knowledge and understanding on everything that we have been trying to teach to you and um and in that case we can end up with some very interesting uh final marks so you can score very high for the overall coursework because you've been using generative AI and then in the final exam which again is a hurdle you don't make that hurdle and so we we can see very large coursework marks but still that still have the unsatisfactory fail attached to it u okay so more on on generative AI tools so they do show great promise um but the code they generate sub um generally has subtle errors and security vulnerabilities and what I've actually seen people do is they they um they're using AI because they don't know how to program in the programming language Um so then when the AI generates the code and there's there's a subtle problem with that code they also don't know how to change that code to fix any problems with it so what they do is they just use AI to generate another layer of AI generated code to try and mask those problems but now you end up with this um this stack of of code when where each layer has its own little problem and there can be subtle subtle problems within that code so the expert coders should be able to look at it immediately and say something doesn't look right about this and be able to adjust the generated code that they've they've been given to match what they really wanted that code to do and um the use of tools such as chat um copilot chat GBT uh won't help you understand like the underlying design decisions that have been made um the alternate approaches that you could have taken or how the code works so it's doesn't become a very good um learning aid and it's incapable of solving larger problems seen later in courses so if you're using chat GBT now then later on in courses when you're asked for example to design an operating system you can't have AI generate a whole operating system for you so the use of just to just to reiterate use of the generative AI tools in um is not permitted for comp 1521 so later courses will likely allow you to though um so the dcc compiler does make use of AI but only to help you understand the the problems that you have in the code that you wrote yourself okay so coding is a skill that improves with practice the more more you practice the easier you'll find the assignments and the exams so do the lab exercise yourself do the weekly tests yourself do the assignments yourself practice programs outside classes as well be curious and experiment with alternate solutions that you may think of do revision lab exercises and um do extravision tutorial questions like the samply exam that we put on the course website and please if you're struggling get help from the course staff okay so course content related help i think we're almost through all the admin stuff um so ask questions and lectures number of you already doing that and that's fantastic to see and thank you again for the moderators for highlighting the the hands in the sea of people here and also for monitoring the forum the uh discussion in the live chat okay so when when you're asking questions in these forums try and be as general as you can don't post your code from for the assignments okay so um just try and reduce your problem to u a minimal example you can post that in there or just put it in words okay the help sessions they're a good place to get one-on-one help outside of normal lab tutorial times um so there is optional dropin sessions for those revision sessions so these will be scheduled for not so much look at the um so this will be used to revi revise the related topics they don't have to be for that week's um specific um uh content so bookings are required for these to make just to make sure that we don't have you know everyone turning up to one at the same time and the first one in week two will be C revision so we'll be looking at 2D arrays pointers strrus malik and recursion schedule for this will be coming out soon admin related help cool um so yeah for the for issues with the course go to CS well email into CS1521 this will hit all of our admins and myself um we have Nucleus for enrollment issues um for course account issues we have the CSC help de desk um if you require special consideration if you were sick for an assignment then um this is where you would go for the special consideration and equitable learning plans as well um okay so I'd like to make an acknowledgement about where I'm drawing information from this course so it's it's come from the introduction to computing systems from bits and gates to see and beyond um elements of computing systems building a modern computer system from first principles um from the comp 2121 course website is that course still available I I did that one when I was at university here and that was a really good course and it's actually a lot like this course um right and from past 1521 lecturers admins and tutors all right I think that is a fantastic um place to take a break um let's take five minutes and when we come back we'll be getting started with myths sir I really like that but I have a tutorial to go to so I'm leaving i'll be good all right not a problem i hope you can catch the the recording later yes thank you so much how's everything going so you think that was just the camera you're seeing a live feed now i saw the myths instruction set and it looked pretty large are we expected to memorize all of the myths instructions um so so the the document with the instructions is going to be your best friend for the course right you can print it out have it next to you the whole time and you'll have it in the exam as well for the exam yes i think as you begin to use it you'll find that it's not really that complicated there's a lot of instructions but most of them do the same thing just in slightly different ways but you said the course website wasn't allowed on the exam um but the myth instruction set will be Oh okay just Yeah definitely we would not expect you to to go without that all right thank you is that the lag that we're seeing that's still pretty horrible it is is that wrapping it's not wrapping and see also toilet okay good question really that's the first one it's always been All right can I look I'm kidding i think we should start up again [Music] i mean all right is everyone ready to have fun again we get to get to the juicy bits of this lecture now you hearing me through the mic all right everyone all right so what is a program how do they execute so in 1511 and 911 um we we run a compiler so in that case it was dcc and we run our program so what's going on here spoiler there so if we have our program here hello so if we have our program here hello so what's what's going on here why can't we just run this program straight away as it is that's interesting oh I know why well that didn't work but I thought that was going to crash in magical ways but um yeah so why can't we run this um as it is yes compiled it's not compiled what does that mean mhm great so the CPU on which this program is going to run does not understand does not understand these sequence of characters they're very nice for us to read but the machine isn't designed to read this it would need a program to to read this um instead and that program is a compiler will convert this code into machine code okay so where is the hello program stored i need the hello program where is this program stored in the current directory yes so on disk and if we say not mount but mount where are we what's the current directory import glass so mount Too many things um okay so this is the current working directory right right where the the um the hello file is stored so you might notice that if we ran the mount command we can see that One of the parent folders here is mounted from NFS so we're actually accessing a disk over in a remote machine and that's where our file is stored um so so the program is going to so we've compiled it to a a sequence of ones and zeros so it's stored in a file on the hard disk um so this is nonvolatile storage so if we turn off the machine that program my assignment is thankfully still going to be there when I come back so how do we execute this program so the program needs to be loaded into memory first before it can execute memory is like a massive 2D array so it has addresses which are like indexes into that array and RAM is much faster than the um the hard drive be it SSD or HDD but it is more expensive and if we flip the power switch then uh we lose power to that RAM and the RAM forgets where our programming is yes that's right yes yes they're just different technologies so for the HDD we we're storing um ones and zeros on a platter using magnetism and um for the SSD we're charging it on we're storing it on a gate i believe it's been a while since I looked into how an SSD works okay so when we load our program into memory so the program contains information that needs to be loaded into the appropriate appropriate segments of memory so the program can execute so those segments include the text or the code segments so that stores the instructions the machine code it's typically read only and has a fixed size because why would our program program grow over time and it's typically read only because otherwise our program would be able to modify our program while it's running that's called selfmodifying code and typically only found in viruses um so then we also have the the data segment so this is a readonly section for string literal and for constants um a writable section for global variables and this is usually a fixed size as well um okay and right so we have two two other segments of um of the program as well which is the heap so this is dynamically allocated memory so at runtime this can grow and it can sometimes it can shrink um so and we have the stack as well so these are um these store your local parameters local variables parameters um that automatically manages those and it grows when functions are called shrinks when functions return so this is an overall layout of what that memory address space would look like we've got the text and the code section we don't typically So this typically starts at a low address but we don't typically use zero can anyone think why up the back yes reserved for null yes if we have a null pointer in our program then we want then that's usually a bug and if we have a bug we want our program to crash so we don't want to continue with this bug um so when if something tries to access the memory at address zero then our program will seg fault and crash rather than picking up whatever instruction was stored at address zero of our text section and start using that for whatever this program was supposed to do um right and then we have our data section next the heap tends to grow straight after that data section we just extend that data section with the heap and the stack at the end will grow the opposite way okay so this is a um little demonstration of how the stack would work so we have our main function which is usually our ent entry point and when we enter into that main function we will have a stack frame created for main and on that stack frame we'll have in this case we have two local variables and so they'll be contain they will be present on that stack frame there and main calls into fo um so when the when we call into f we create another stack frame and that will contain the parameter here x and then x calls into g so we pop push another parameter onto the stack y local variable there as well r so you see they're both here on the stack this one calls h we have a few here we have zed as the parameter i and p as local variables but we go no further from here so when when H returns the result P then this stack frame for H will disappear from the stack and it can be repurposed for for other things later on for the next function call and then when G returns the stack frame for G pops off the stack again can be reused but we're not doing that in this example so back to f that returns and eventually that stack falls back to zero again so a good way to use up all your stack does that look all right on the chat it's just very laggy i wonder if the audio is laggy as well all right so a good way to use up all your stack space is to use Yes were you asking like what's wrong with um No no sorry i was I was asking so we seem to be having a bit of trouble with uh lag in the the audio recording that's I'm sorry the video recording that's all yes gcc so GCC is a traditional compiler right dcc is something I believe CC introduce um to provide feedback when um the when a compiler fails it can um sorry when the compiler fails to compile your code it can give very cryptic error messages that um people who have just started out coding um can find difficult to interpret my favorite is if you have a really long file and you have a missing curly bracket in there somewhere the compiler can say you have a missing curly bracket at the very end of your file but it could actually be earlier in the file it could be right up the top of the file so when you use dcc help it puts some little cookies in the system so when sorry when you use G dcc instead of GCC it puts some cookies in the system so that when you um run dcc help it can try and help you interpret better what that um compile error means and how to fix it um but GCC and and claim um are the more traditional compilers so I'm more used to using those so if you prefer to use dcc then please go ahead ddc dcc dcc um but yeah otherwise don't don't think that there's any difference between them yes um right so p man pwd so pw prints the name of the current working directory so when I go pwd it just tells Um so I like to use it because we have this tilda here and that tilda is like a um an a notation for your home directory so when I type pwd I can get away from that annotation for my home directory and see what that real path looks like and mount mounts the file system but as I was using it there I was using it to show which file systems had been mounted and unfortunately that trick backfired for me because there was a lot of file systems mounted so it was tricky for me to to highlight just one of them but um but yeah this this is bonus material think of this as bonus material for the course right i think pwd is actually in the course later on so maybe that one will be useful math not so much okay back to the lecture infinite recursion so this is a great way of um so guys guys in the middle on the left can you keep it down please thank you so this is this is a great way to use up all your stacks so in this program here we have our main function which calls f with zero and f it calls f So it comes back around recurses calls itself and most importantly there is no termination condition here okay normally if you're using recursion the first thing you do is look for that exit clause and and tell yourself yes it looks saying that this recursive program is going to terminate at some stage but at this stage we don't have anything like that so when we infinite did I not compile it i thought I um I should compile it properly if recursion this actually counted a lot higher than I thought it would that's a lot of recursive calls before we segmentation fault so who knows what a segmentation fault is who can explain it yes doesn't it just mean it's looking for something but nothing is there looking for something yes so I think more importantly it's looking for a segment of the program that you just loaded right so you have your data section and you have your your heap which grows that's a controlled growth by the way you need to ask the operating system to grow that and you have the stack as well um so if you access anything out of that it's faulting on the segment because the segment doesn't exist in the program okay so recursion can be really good for some algorithms they can be applied very nicely yes uh so that number oops that demo wasn't delayed okay so that number is printed by the function f every time we call it so that number is just counting the number of times we're executing that function yes go ahead so that number Okay let's give something a go i really wish I'd given this program a shorter name how about we print Oops let's print the address of depth remember we said that depth was going to be on the stack going off script here so all right um the powers of the command line let's pass that to head so if we man head output the first parts of the files okay and I've used the pipe there so the output of this program that I'm running is going to the input of this program head and so the head is going to just print the first parts of of what this program is out outputting um maybe I'll use Okay so let's give that a miss i'm using less here so this just lets us view all of the output um we can scroll it search it okay so the first number here that's printed is F-C6E49C who knows hex few people all right so um for hex instead of using the numbers 0 to 9 we go beyond that and we start using letters to represent numbers a b cde e f so this gives us a base 16 representation and that can be really convenient when you are looking at binary numbers so here um just one there so this hexodimal digit here this is going to represent four bits right the next digit here um represents the next four bits so it becomes really easy to look at which bits in this number are set and which ones aren't um Um yes true is it 64 bit yeah good point though i wonder why it didn't print out a 32 a 64-bit number 64 bit i'll have a look into that might just be that our stack isn't put at such a high address i will have a look at that um okay so yes x so I've added the L on front which if I recall correctly um extends this to be a long integer instead of just an integer yeah that looks much better thanks for that so um so as we expected we've got the so this is printing out the address of these local this parameter for this function every time it's executed so you can gauge the stack size here right so we have um so we're adding two to this second um column each time so that will be now my my math is going to fail so 32 so it should be a stack size of 32 if this hexodimal digit is going up by two each time does that make sense 32 oh we haven't gone into So uh so we do have one 32-bit value on the stack um but I haven't gone over what else would be stored on there so we got 32 bytes and four bytes um would be for the depth but there are some other things that will be on the stack i don't really want to go into those just yet because we will cover them later um all right so and also by printing the address of this depth variable we could also gauge how big our how how big the stack is that the operating system has given us okay but I digress let's get back on topic that was fun though thank you all right so this is this is what a CPU looks like on the inside if you take its cover off grind it away this is the die of a R4600 yes I think so um it's be in those lecture notes anyway exactly what it is um so can anyone have a guess of what the different parts of this CPU are fair enough all right yes sorry yes exactly but certain Yes i'm not 100% but are the two corners with the big rectangles that the cache perfect yes because this is a very big slab and it's very very unison then I imagine this to be the cache of the CPU so the cache is that the question sorry uh so the the big slabs up in the top corners so I'm they're not labeled but I imagine them to be the CPU cache cache um so so the cache is a memory that sits inside the CPU and it's going to mirror your RAM so every time you access memory the hardware will actually not just bring in the memory you're trying to access but it will bring in a range of of memory and it will store it in that cache so that when you access it again it'll be much faster than having to go all the way back to um to the RAM the offchip RAM question um so the reason I believe this is to be the cache is because memory is very simple and there'll be a lot of it so you can see this these areas are very uniform and um and consistent in their layout was there a question yes the cores sorry the CPU course is that what you're asking so the CPU cores um am I getting ahead of myself uh so the CPU cores will be implementing implementing a wide range of circuits inside depending on what the machine code is telling it what to do so I would imagine the CPUs to be more like these sections here which look very disorganized right because there's no value in repeating a circuit in a CPU um be um yeah because it it'll only use one of those circuits at a time i'll I'll get to this later on but the the CPU I would imagine to be a very um chaotic part of the the system here like over here all righty so we have our instructions in memory and guys at the back can I get you to be quiet please i know this the room tends to everything I said just kind of echoes everywhere so I can't hear you um so we have our instructions in memory the CPU can fetch an instruction from memory decode that instruction and then execute that instruction it's a very simple machine so this is what it would look like if it was a C program so we have a program counter that tells us what which instruction in memory um it tells us the address of the instruction in memory so then first thing we need to do is we need to fetch that instruction from memory oh sorry first thing we need to do is set that program counter to to point to our first instruction something has to tell us where to start then we load the instruction at that address right read that from RAM increment this program counter so we're already going to start moving on to the next instruction or prepare for the next instruction and then we execute that instruction okay and so you'll notice here the program counter as a second parameter here we're passing the address of that parameter so this means that this execute step could in fact modify that program counter as well because a linear program that can just single step through code is very boring so what can the instructions do so they're very simple instructions they can provide they can um produce very simple computations add subtract multiply divide bitwise which we'll cover a little bit later on and some of these instructions can load data from RAM as well or store data back into RAM because these the CPUs tend to yeah the CPUs tend to operate on um little registers little bits of memory inside them rather than uh accessing RAM so we also have branch instructions so that we can jump to different parts of the code rather than having that sequential execution and um and we have system in some CPUs at least we have uh system calls so this is how we ask the the operating system to do us a favor so machine code versus assembly code so machine code instructions are really just zeros and ones cool machine code instructions are are really just uh zeros and ones so it's binary data so this would be a real pain to read and write these literal instructions right these ones and zeros or better yet hexadimal numbers right what does this number mean what does it do what does it take in be a real pain to read and write this and the instructions might change depending on your code layout as well so if you have a an instruction and you say "Okay I want to jump four instructions into the future then if you ever add an instruction in the middle you're going to need to change this um original instruction to now jump five instructions in the future but this instruction is encoded in machine code not C not assembly so we need to decode that in that um machine code into its different sections um update it and then put it back into the program and we would have to do that for every single um uh instruction that has anything in it like that that depends on the structure of the code so instead we use an assembly language and this provides a human readable um representation of each instruction it generally maps one to one with the the machine code um but that's not always the case okay and then the assembler translates um the assembly code to the binary machine code so this would be an example of an assembly code and this is for the MIPS architecture as well so this will be useful this will be in the exam that's probably what you're all here to learn what's in the exam um for example what might what we might write in assembly is this is the instruction here add I very simple instruction um who can guess what this instruction does yes add integer looks like to a register in a different register great can you identify the input and the output registers the output's going to be T1 probably all right why do you say that it just looks It looks vaguely like T1= T + 12 excellent perfect answer yes so it was kind of a guess but yes intuitively yes t1 = T0 + T1 because the the up code here is an ad and what do you think the I at the end here means integer not quite not quite not quite it's tricky one actually up the very back yes do you know what that hardcoded value is called i think I heard it over this side can I go over to this side right i think someone called out something immediate immediate yes immediate because the integer is immediately in the instruction right okay and then the assembly sorry the the assembler might generate the following machine code instruction so 00100 0 might be the op code for addi or the machine op code for add um the blue here will map to the blue register 01 triple 0 so these so when this instruction is decoded so these bits are going to be routed off to some circuit that chooses the input register for this operation and the green ones here so these map to the the target register T1 so this again will these bits will be routed to the the circuit that um enables the appropriate register to take in that value and the rest here is of course the immediate um literal that that's baked into this instruction so key CPUs just like see they can't run the assembly code directly they can only execute the machine code so we still need the assembler to take um the C the assembly code and turn it into a binary for the CPU yes yes well we call it assembling sorry I think um formally it's called assembly it's just because normally when we compile something we're going from like a higher level language i've come to just call everything compiling but it's technique called assembling okay um so we usually just compile our code in one step to create our executable program um so when we compile our code the compiler um first generates assembly code but it has its own internal representation of that but for simplicity let's just call that let's call it assembly code um and then from this intermediate to sorry to see this intermediate step we have a compiler directive which program we use um hello is best oh it didn't like printing that maybe while I'm here so I cuted hello dot yeah so you might want to use something like I don't know hex dump dash c if you really want to see what's contained in that that binary file because it doesn't li the terminal doesn't like to print non-printable characters right so hex dump will um will give you the raw binary data in that file and on the right if there are printable characters you'll be able to see that easily as well but I'm very sorry to the term for putting all that garbage on there so hello s I think I've done something wrong that's probably why so main's okay and that's going crazy i probably got my arguments around the wrong way silly me oh oh something is going on here let's get rid of this we just need the dash s and we cut hello what am I missing i know what I can do man GC no man entry entry for GCC what is going on all right we have Mantha Clang i'll need to update my slides all right and the moment you've all been waiting for sorry about that seem to have the the case of this seems to have um switched around on me so it's capital S not little S um so just to demo that again so if we do GCC- capital S hello C um it will create our hello s for us i'm going to open that in Vim no I'm not okay so we can see um what the assembly code for this program looks like um is anyone able to read this all right well this looks familiar hello world string well we'll um touch on this later but this cover this so will this generate the same assembly code on a different machine what do you think um yes yeah go ahead and why is that exactly different architectures so you'll be happy to know that this assembly code has been written for the x86 architecture and even that go ahead x86 x86 so that's like the the architecture for normally used for Intel believe 64bit sorry what's an architecture what's an architecture so all right I will come to that in just a minute okay Um but I find I find this assembly code very difficult to read but that's okay because we're not targeting Intel chips we're targeting uh MIP's chips in this course all right right so I will go into that now so the instructions said architectures um so these these machine codes right the person who was designing these CPUs decide how these codes look so who decided that this up code for the add eye instruction would be six bits long and that this particular number would map to add eye and who decided that this next five bits of of the machine code would map to a register for the the source register the designer of the CPU the designer of the CPU yes and all those with all those things we call that the architecture of the CPU and when we're specifically referring to how the instructions are um executed and represented we call that the instruction set architecture so um so this instruction here um it's for a MIP's CPU and if we were compiling for say an ARM CPU it would look a little bit different um but I find from from MIP I've found it very easy to switch to ARM and to risk five they're all different architectures but I've never understood x86 i've always I've always had trouble understanding that one okay so just to recap on everything that we've covered so we have a program in some language maybe C um we compile the program into assembly and is assembly assembled into a binary the binary is stored to a file and then to execute it that program is loaded into memory and the CPU program counter is set to the first instruction in that um in where that the CPU should start executing in memory and that CPU is off okay so writing assembly code so I think we're we're falling a bit behind schedule so I need to speed up a little bit um so usually we tend to write in a high level compiled language like C plus C C++ Go Rust Java Swift many many more um so a compiler takes those languages and and will output the corresponding assembly instructions each of these different languages has a different advantage by the way so C is most closely related to the assembly that you'll that you program c++ has some um um has some extensions to it um that sorry I won't won't go into that so in this course we write assembly code ourselves so the main reason in um in this course is to understand how a compiler program executes so this can be helpful when debugging so also handy to identify security um vulnerabilities in the compiled um program and to exploit those as well and there is a course in there if you would like to explore that further so other reasons to write assembly code so to optimize code performance so um the C compiler will will not necessarily always generate the the most the fastest um machine code so if you go in there you can hand code the that part of your code using assembly to get some extra picos seconds after it out of it and you have to remember the 9010 rule here so 90% of the time is going to be spent in no sorry 90% of the time spent executing the program is going to be spent in 10% of the code of that program so to get these performance boosts you only need to optimize 10% of that code and one option would be to optimize that code by writing it directly in in assembler so sometimes it's also necessary to write in in assembly code so some CPUs have special instructions for doing IO with device drivers so then you there's no C equivalent of of performing these operations so at the very least you need a C wrapper around the assembly code that will perform these IO operations and sometimes someone has to so um someone had to write the machine code that would program the first assembler someone had to write the first assembler to program the first C interpreter and etc so instruction set architectures I've already mentioned this was there anything that I miss so they define a finite set of instructions the like different languages of the different CPUs okay MIPS why MITips so in 1521 we learned the MIPS instruction set architecture so it was once used for gaming consoles and to to supercomputers has anyone heard of the Nintendo 64 sorry there's emulating it uh I'll take that yes has it ended up in the museum yet oh no that was my favorite console well there was like a game changer back then but um there was there was a game i believe it was Super Mario and um in there there appeared this character this character was a little rabbit and its name was Mips so a little Easter egg because Nintendo 64 was designed with a Mips CPU in it so it's still used in some in routers and TVs i need to age check that that bullet point because it is quickly being out competed by ARM and risk 5 CPUs um but there is still a considerate considerable number of learning resources around the MIPS architecture not yet so much with the risk fire um but the MIPS did inspire many other instruction set architectures um so you from MIPS as I mentioned you can um being familiar with MIPS is makes it very easy to be familiar with ARM and Risk 5 and I was actually born and raised with the ARM assembly language so if I accidentally punch in um for um the wrong assembly instruction then that would be why but they look very similar that's why I get confused because MIP looks so much like ARM i'm like right I'm writing ARM oh no I'm not this is MIP so MIP is simple and powerful it's a good foundation for for building your knowledge on assembly but you don't have a myip CPU and I've I heard this mentioned so um we can emulate um a CPU using a program that we've um that we've provided so it was actually written by a past course admin called Zach um he's now graduated though um but this emulator will take the MYIPS instructions and it will decode that and it will apply that to a data structure that represents a M.Y.I.P cpu okay so it doesn't execute the instructions directly but it knows how to interpret those instructions and it emulates it on a a pretend uh MIP CPU okay okay so we have a number of ways of of using MIPY the MIPS emulator that we that we use in this course um we can do it from the command line this might be the only time where I I'm avoid using the command line and probably for the better because the command line seems to be a bit fuzzy for the online people but we have a we have Mipy web so we can run this emulator in a web browser and um we have a VS code extension for the VS code extend uh the VS code programmers out there to help you write your MIP and I'm surprised I haven't mentioned it there's a Vim one as well yes so in order to emulate we either download it from the program or just download the VS Code extension so the VS Code ex Oh the My apologies i actually I'm not so familiar with VS Code i think the VS Code extension does a lot more than just help you write it i think it can emulate it for you as well yes so um if you'd like more information about that I'm afraid I have to hand that over to um your tutors to to show you um but I will be focusing on the the web version can we write some no not yet soon though um okay so what's in the myip CPU so we've already had a look at some of the registers so we have a set of data registers um they have aliases so this is more of a general diagram here with R0 R R1 R2 so we have a set of control registers as well of course the program counter to tell us where in the program we are control unit arith arithmetic logic unit so that alou is um that's where all of our different instructions are encapsulated yes what is a register what is a register is a it's a um it's a little bit of storage inside the actual CPU so it's typically the memory that the CPU can operate on and if it wants to operate on RAM it has to execute an instruction to load data from RAM into that register and then it can um operate on that register so we have a floatingoint unit but that won't be covered in this course caches and um connection to memory and RAM of course we need that connection to RAM if we want to be able to load and store from memory so most CPU architectures perform these operations over registers so they're part of the processor itself not memory i've just mentioned that so the speed advantages is here because it's um it's the close you are to the closer the memory is to the CPU the faster you are so there are only a small number of registers as well so MIP has 32 general purpose registers um program counter sorry I need to skip a few all right so for now we'll mainly use registers labeled as t0 to t9 um for general purpose calculations so we'll also need v 0 and a z for certain things too but let's focus on t 0 to t9 now uh register zero is very special so every time we read this register it'll always read as zero and if we write to it um it won't change the value of that register ra also has a very special purpose can anyone have a guess of what RA might be for yes return yes return address so that tells us what address we would return to if we have made a function call but I'll cover that more later on okay so mix computations with registers so almost all computations happen between registers so let's say we want to multiply two and three and store the result so we want to load two and load three into registers and then we we um issue the multiply um instruction to multiply these together so I'll give a quick demo of that and it would be wonderful if you guys could um open up myipsy web get rid of that so if you go to the course website MIP web is here under MIPY then you can follow along with what I am doing yeah this is what our interface looks like so first thing we need is a entry point so the program knows where to start we wanted to what did we want to do li for load so these instructions we have MIP's documentation believe it is this one so these are the this is the MIPS instruction set documentation that you will have available to you during the exam so here is a identification of all the registers that will be available but what we care about right now are the instruction um the instructions that we can use all right l I Okay so L I T02 we need commas in there li T13 next we have ML for multiply um so in T3 we are going to put T2 times T1 and just to help us understand let's say T3 in a comment equals T3 = T2 times T1 and let's indent a bit better okay so a little comment to remind us of what this crazy instruction does and to run this first we save and then we can step through it sorry um well this is an assembly so we get full control we don't need to return zero just because we can do something doesn't mean that we should right