<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.itcollege.ee/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Lvosandi</id>
	<title>ICO wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.itcollege.ee/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Lvosandi"/>
	<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php/Special:Contributions/Lvosandi"/>
	<updated>2026-05-11T02:02:31Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=File:Half-adder.png&amp;diff=127874</id>
		<title>File:Half-adder.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=File:Half-adder.png&amp;diff=127874"/>
		<updated>2017-12-12T10:19:30Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: Lvosandi uploaded a new version of File:Half-adder.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=File:Full-adder.png&amp;diff=127872</id>
		<title>File:Full-adder.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=File:Full-adder.png&amp;diff=127872"/>
		<updated>2017-12-12T10:18:54Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: Lvosandi uploaded a new version of File:Full-adder.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=File:Full-adder.png&amp;diff=127870</id>
		<title>File:Full-adder.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=File:Full-adder.png&amp;diff=127870"/>
		<updated>2017-12-12T10:17:46Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: Lvosandi uploaded a new version of File:Full-adder.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=File:Full-adder.png&amp;diff=127869</id>
		<title>File:Full-adder.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=File:Full-adder.png&amp;diff=127869"/>
		<updated>2017-12-12T10:17:15Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: Lvosandi uploaded a new version of File:Full-adder.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=File:Full-adder.png&amp;diff=127836</id>
		<title>File:Full-adder.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=File:Full-adder.png&amp;diff=127836"/>
		<updated>2017-12-12T08:55:49Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: Lvosandi uploaded a new version of File:Full-adder.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=File:Full-adder.png&amp;diff=127835</id>
		<title>File:Full-adder.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=File:Full-adder.png&amp;diff=127835"/>
		<updated>2017-12-12T08:55:46Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127834</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127834"/>
		<updated>2017-12-12T08:55:30Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Full adder */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP (5p)=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario (5p)=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git (5p)=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers (15p)=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (3p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (3p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (9p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (3p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (3p)&lt;br /&gt;
# Optional/extra: Rewrite the function in assembly with NEON instructions. How much speed boost did you gain? (+10p)&lt;br /&gt;
# Optional/extra: What is the space complexity of the algorithm? What is the time complexity of the algorithm? Explain! (+4p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design (5p)=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
Assignment steps&lt;br /&gt;
&lt;br /&gt;
* Fork the repo on GitHub, clone your repo, fix mistakes, commit and push changes, send link to your GitHub repo where you have fixed the issues (5p)&lt;br /&gt;
* Optional/extra: Expand ALU to 8 bits (2p)&lt;br /&gt;
* Optional/extra: Add another opcode bit and implement multiplication so opcode(2) high means we&#039;re doing multiplication, opcode(1) in case of multiplication selects between higher and lower bits of the result and opcode(0) is used to negate the second operand of multiplication. (+5p)&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates (5p)=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each CD74HC00E chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 CD74HC00E] contains 4 CMOS NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+5p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=File:Half-adder.png&amp;diff=127833</id>
		<title>File:Half-adder.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=File:Half-adder.png&amp;diff=127833"/>
		<updated>2017-12-12T08:54:42Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127831</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127831"/>
		<updated>2017-12-12T08:53:17Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Half adder */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP (5p)=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario (5p)=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git (5p)=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers (15p)=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (3p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (3p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (9p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (3p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (3p)&lt;br /&gt;
# Optional/extra: Rewrite the function in assembly with NEON instructions. How much speed boost did you gain? (+10p)&lt;br /&gt;
# Optional/extra: What is the space complexity of the algorithm? What is the time complexity of the algorithm? Explain! (+4p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design (5p)=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
Assignment steps&lt;br /&gt;
&lt;br /&gt;
* Fork the repo on GitHub, clone your repo, fix mistakes, commit and push changes, send link to your GitHub repo where you have fixed the issues (5p)&lt;br /&gt;
* Optional/extra: Expand ALU to 8 bits (2p)&lt;br /&gt;
* Optional/extra: Add another opcode bit and implement multiplication so opcode(2) high means we&#039;re doing multiplication, opcode(1) in case of multiplication selects between higher and lower bits of the result and opcode(0) is used to negate the second operand of multiplication. (+5p)&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates (5p)=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each CD74HC00E chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 CD74HC00E] contains 4 CMOS NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127826</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127826"/>
		<updated>2017-12-12T08:50:05Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Assignment: Adders with NAND gates (5p) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP (5p)=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario (5p)=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git (5p)=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers (15p)=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (3p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (3p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (9p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (3p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (3p)&lt;br /&gt;
# Optional/extra: Rewrite the function in assembly with NEON instructions. How much speed boost did you gain? (+10p)&lt;br /&gt;
# Optional/extra: What is the space complexity of the algorithm? What is the time complexity of the algorithm? Explain! (+4p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design (5p)=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
Assignment steps&lt;br /&gt;
&lt;br /&gt;
* Fork the repo on GitHub, clone your repo, fix mistakes, commit and push changes, send link to your GitHub repo where you have fixed the issues (5p)&lt;br /&gt;
* Optional/extra: Expand ALU to 8 bits (2p)&lt;br /&gt;
* Optional/extra: Add another opcode bit and implement multiplication so opcode(2) high means we&#039;re doing multiplication, opcode(1) in case of multiplication selects between higher and lower bits of the result and opcode(0) is used to negate the second operand of multiplication. (+5p)&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates (5p)=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each CD74HC00E chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 CD74HC00E] contains 4 CMOS NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=127814</id>
		<title>Category:I802 Firewalls and VPN IPSec (2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=127814"/>
		<updated>2017-12-11T15:11:06Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Hardware */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Firewalls and VPN/IPSec=&lt;br /&gt;
&lt;br /&gt;
==General information==&lt;br /&gt;
&lt;br /&gt;
ECTS: 4&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
To register to this course send your SSH public key to Lauri and state which service you want to configure.&lt;br /&gt;
&lt;br /&gt;
Grading bot is at http://193.40.244.178/static/bot.html&lt;br /&gt;
&lt;br /&gt;
==Scenario==&lt;br /&gt;
&lt;br /&gt;
In this course we will attempt to set up a network similar to a corporate network with multiple offices, eg http://docplayer.it/docs-images/20/596222/images/25-0.png&lt;br /&gt;
&lt;br /&gt;
Our virtual company&#039;s story is based on [http://futurama.wikia.com/wiki/MomCorp Mom&#039;s Friendly Robot Company].&lt;br /&gt;
&lt;br /&gt;
We will use VPN software to connect subnets to each other and we will use VPN software to connect our personal computers to the intranet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Hardware==&lt;br /&gt;
&lt;br /&gt;
School&#039;s infra provides with public subnet for 62 hosts:&lt;br /&gt;
&lt;br /&gt;
* IPv4 address: 193.40.244.129-188&lt;br /&gt;
* Subnet: /26&lt;br /&gt;
* Gateway: 193.40.244.189&lt;br /&gt;
* DNS: 8.8.8.8&lt;br /&gt;
&lt;br /&gt;
That network is physically routed to 413-6-16 port in room 413.&lt;br /&gt;
&lt;br /&gt;
We have total of about 264GB of RAM and couple of terabytes of SSD storage:&lt;br /&gt;
&lt;br /&gt;
* Marek&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s (hosts 130-139)&lt;br /&gt;
* Madis&#039; box HP Proliant G5, 4x quadcore Opteron, 64GB RAM, 2 NIC-s (hosts 140-149)&lt;br /&gt;
* Erik&#039;s box Sun 32GB, 2x 256GB SSD (hosts 155-159)&lt;br /&gt;
* Lauri&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s, 4x 250G SSD (hosts 160-179)&lt;br /&gt;
* Frank&#039;s box DELL 16GB, 2x 256GB SSD, 6 NIC (hosts 180-185)&lt;br /&gt;
* Another Sun box with 24G of RAM, dying harddisks&lt;br /&gt;
* Reserved addresses 186-188&lt;br /&gt;
&lt;br /&gt;
NB! Replace BIOS batteries; replace thermal paste&lt;br /&gt;
&lt;br /&gt;
==Grading==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to do pick a topic from the services list below.&lt;br /&gt;
Send your SSH public key to Lauri and state which service you want to take care of.&lt;br /&gt;
&lt;br /&gt;
Collect 100p in total to pass the course, note that there are opportunities to collect much more points in total:&lt;br /&gt;
&lt;br /&gt;
* Get the service up and running (15p)&lt;br /&gt;
* Configure Let&#039;s Encrypt certificates for your service if applicable (15p)&lt;br /&gt;
* Add your service to monitoring at mon.momcorp.eu (15p)&lt;br /&gt;
* Enable log forwarding to log.momcorp.eu, if applicable configure auditing for your service (15p)&lt;br /&gt;
* Configure your service to send e-mails (mail.momcorp.eu) if applicable (15p)&lt;br /&gt;
* Keep the service up and running through the semester (up to -20p)&lt;br /&gt;
* Keep the bad guys out from your servers (up to -30p)&lt;br /&gt;
* Have a disaster recovery plan (up to -20p)&lt;br /&gt;
* Configure layer3 firewall (15p)&lt;br /&gt;
* Configure application firewall(s) if applicable&lt;br /&gt;
* Configure your laptop to connect to intranet using OpenVPN and IPSec (15p)&lt;br /&gt;
* Configure your mobile device to connect to intranet using OpenVPN or IPSec (15p)&lt;br /&gt;
* Configure your service to use authentication from AD (20p)&lt;br /&gt;
&lt;br /&gt;
We will start with services facing the public internet, see what&#039;s the worst that can happen in that case and later migrate some services to intranet only. Some services will retain connectivity to public internet due to their nature (eg OwnCloud, mailserver) and some services will be available only in the intranet (eg fileserver)&lt;br /&gt;
&lt;br /&gt;
==Services==&lt;br /&gt;
&lt;br /&gt;
To support our virtual company in everyday business we need to provide them with a variety of services:&lt;br /&gt;
&lt;br /&gt;
* www.momcorp.eu - Install webserver/load balancer and create a homepage for the company and link to remaining sites. Olusiji&lt;br /&gt;
* shop.momcorp.eu - Install Magento and add some fictive products like dark matter and neutron star. Sander&lt;br /&gt;
* wiki.momcorp.eu - Install MediaWiki, later integrate with AD. Peep&lt;br /&gt;
* blog.momcorp.eu - Install WordPress, later integrate with AD. Steven&lt;br /&gt;
* chat.momcorp.eu - Install IRC server, provide  multiple channels for developers. Install some web based software for customer helldesk. Ardi&lt;br /&gt;
* ns1.momcorp.eu - Primary Bind9 installation, later also add DNSSEC. Erik J&lt;br /&gt;
* ns2.momcorp.eu - Secondary Bind9 installation in another physical host. ???&lt;br /&gt;
* git.momcorp.eu - Gogs installation. Farhan&lt;br /&gt;
* mon.momcorp.eu - Nagios monitoring. Nika&lt;br /&gt;
* mail.momcorp.eu - Mailserver with Postfix (postfw, greylisting, dkim, spf, setup secondary mx), later with AD integration if exchange won&#039;t be used. Andris&lt;br /&gt;
* ca.momcorp.eu - Java servlet container, EJBCA installation for certificate management. Masaki&lt;br /&gt;
* nas.momcorp.eu - Samba fileserver. Hindrek&lt;br /&gt;
* log.momcorp.eu - Graylog or similar for central logging. Kaspar, Sten-Erik&lt;br /&gt;
* vpn.momcorp.eu - OpenVPN gateway. Moira&lt;br /&gt;
* cs.momcorp.eu - Teamspeak and/or gaming server for entertainment. Christopher&lt;br /&gt;
&lt;br /&gt;
Additionally for each physical box listed under Hardware we could set up:&lt;br /&gt;
&lt;br /&gt;
* Person responsible for the hypervisor on that box&lt;br /&gt;
* Virtual machine with router OS - Mikrotik RouterOS, Vyatta, pfsense or just vanilla Debian with shell scripts&lt;br /&gt;
&lt;br /&gt;
Other topics:&lt;br /&gt;
&lt;br /&gt;
* Mikus - Remote management: Puppet master, DSC, postfix with kerberos (and AD?)&lt;br /&gt;
* Strongswan gateway&lt;br /&gt;
* OpenVPN gateway, later AD integration&lt;br /&gt;
* Exchange&lt;br /&gt;
* failover/high availability (heartbeat)&lt;br /&gt;
* db clusters/shards/replication (mysql/mariadb)&lt;br /&gt;
* clustered filesystems/servers (clvm, corosync, fenced, gfs)&lt;br /&gt;
* web caches (varnish, squid, nginx)&lt;br /&gt;
* load balancing (haproxy, nginx, simple roundrobin)&lt;br /&gt;
&lt;br /&gt;
==Lectures==&lt;br /&gt;
&lt;br /&gt;
Following lectures are planned:&lt;br /&gt;
&lt;br /&gt;
* 7. sept - Intro, virtualization, containers etc. Relevant story [https://lauri.xn--vsandi-pxa.com/lan/virtualization.html here]&lt;br /&gt;
* 14. sept - Network topology, bridges, tagging, trunking, subnetting, LAN, WAN&lt;br /&gt;
* 21. sept - iptables, ebtables, packet forwarding, DNAT, SNAT, routing tables, empheral ports, listening ports, slides [https://docs.google.com/presentation/d/1XMISOg88BJ0Dy8o3r8ZL9cxFT0oZZKDqPZ2EaWJRqFQ/edit?usp=sharing here]&lt;br /&gt;
* 28. sept - X.509 certificates, certificate authority, TLS, symmetric, asymmetric, keyexchange, Let&#039;s Encrypt, relevant slides [https://docs.google.com/presentation/d/1kqTyhhUu5CfwODmOTIC7odhlYfeEeJALTd4RX7XhPLE/edit?usp=sharing here]&lt;br /&gt;
* 30. nov - [https://docs.google.com/presentation/d/1aXtreUS2YD9vlsngVUSr_ZaXdrQv37zCRtc51TSGjPI/edit?usp=sharing AD auth]&lt;br /&gt;
&lt;br /&gt;
Order to be determined:&lt;br /&gt;
&lt;br /&gt;
* OpenVPN&lt;br /&gt;
* IPSec&lt;br /&gt;
* TBD, there are a lot of topics to discuss&lt;br /&gt;
&lt;br /&gt;
==Firewall rules==&lt;br /&gt;
&lt;br /&gt;
You can load these rules by running iptables-restore command, pasting the rules to the terminal and pressing Ctrl-D.&lt;br /&gt;
&lt;br /&gt;
To make rules persistent on your box install netfilter-persistent package, the rules will be stored at /etc/iptables/rules.v4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;iptables&amp;quot;&amp;gt;&lt;br /&gt;
*raw&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*mangle&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:INPUT ACCEPT [0:0]&lt;br /&gt;
:FORWARD ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
:POSTROUTING ACCEPT [0:0]&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*nat&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:INPUT ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
:POSTROUTING ACCEPT [0:0]&lt;br /&gt;
-A POSTROUTING -o eth1 -m comment --comment &amp;quot;Hide VPN addresses from LAN&amp;quot; -j MASQUERADE&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*filter&lt;br /&gt;
:INPUT DROP [0:0]&lt;br /&gt;
:FORWARD DROP [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment &amp;quot;Allow returning packets&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -i eth1 -m comment --comment &amp;quot;Allow traffic from LAN&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -s 127.0.0.0/8 -i lo -m comment --comment &amp;quot;Allow loopback&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p icmp -m icmp --icmp-type 8 -m comment --comment &amp;quot;Allow ping&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p tcp -m tcp --dport 22 -m comment --comment &amp;quot;Allow SSH&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p tcp -m tcp --dport 5666 -m comment --comment &amp;quot;Allow Nika\&#039;s Monitoring&amp;quot; -j ACCEPT&lt;br /&gt;
-A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment &amp;quot;Allow returning packets&amp;quot; -j ACCEPT&lt;br /&gt;
-A FORWARD -i tun0 -o eth1 -m comment --comment &amp;quot;Allow from VPN to LAN&amp;quot; -j ACCEPT&lt;br /&gt;
COMMIT&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=127489</id>
		<title>Category:I802 Firewalls and VPN IPSec (2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=127489"/>
		<updated>2017-12-07T14:42:04Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Lectures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Firewalls and VPN/IPSec=&lt;br /&gt;
&lt;br /&gt;
==General information==&lt;br /&gt;
&lt;br /&gt;
ECTS: 4&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
To register to this course send your SSH public key to Lauri and state which service you want to configure.&lt;br /&gt;
&lt;br /&gt;
Grading bot is at http://193.40.244.178/static/bot.html&lt;br /&gt;
&lt;br /&gt;
==Scenario==&lt;br /&gt;
&lt;br /&gt;
In this course we will attempt to set up a network similar to a corporate network with multiple offices, eg http://docplayer.it/docs-images/20/596222/images/25-0.png&lt;br /&gt;
&lt;br /&gt;
Our virtual company&#039;s story is based on [http://futurama.wikia.com/wiki/MomCorp Mom&#039;s Friendly Robot Company].&lt;br /&gt;
&lt;br /&gt;
We will use VPN software to connect subnets to each other and we will use VPN software to connect our personal computers to the intranet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Hardware==&lt;br /&gt;
&lt;br /&gt;
School&#039;s infra provides with public subnet for 62 hosts:&lt;br /&gt;
&lt;br /&gt;
* IPv4 address: 193.40.244.129-188&lt;br /&gt;
* Subnet: /26&lt;br /&gt;
* Gateway: 193.40.244.188&lt;br /&gt;
* DNS: 8.8.8.8&lt;br /&gt;
&lt;br /&gt;
That network is physically routed to 413-6-16 port in room 413.&lt;br /&gt;
&lt;br /&gt;
We have total of about 264GB of RAM and couple of terabytes of SSD storage:&lt;br /&gt;
&lt;br /&gt;
* Marek&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s (hosts 130-139)&lt;br /&gt;
* Madis&#039; box HP Proliant G5, 4x quadcore Opteron, 64GB RAM, 2 NIC-s (hosts 140-149)&lt;br /&gt;
* Erik&#039;s box Sun 32GB, 2x 256GB SSD (hosts 155-159)&lt;br /&gt;
* Lauri&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s, 4x 250G SSD (hosts 160-179)&lt;br /&gt;
* Frank&#039;s box DELL 16GB, 2x 256GB SSD, 6 NIC (hosts 180-185)&lt;br /&gt;
* Another Sun box with 24G of RAM, dying harddisks&lt;br /&gt;
* Reserved addresses 186-188&lt;br /&gt;
&lt;br /&gt;
NB! Replace BIOS batteries; replace thermal paste&lt;br /&gt;
&lt;br /&gt;
==Grading==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to do pick a topic from the services list below.&lt;br /&gt;
Send your SSH public key to Lauri and state which service you want to take care of.&lt;br /&gt;
&lt;br /&gt;
Collect 100p in total to pass the course, note that there are opportunities to collect much more points in total:&lt;br /&gt;
&lt;br /&gt;
* Get the service up and running (15p)&lt;br /&gt;
* Configure Let&#039;s Encrypt certificates for your service if applicable (15p)&lt;br /&gt;
* Add your service to monitoring at mon.momcorp.eu (15p)&lt;br /&gt;
* Enable log forwarding to log.momcorp.eu, if applicable configure auditing for your service (15p)&lt;br /&gt;
* Configure your service to send e-mails (mail.momcorp.eu) if applicable (15p)&lt;br /&gt;
* Keep the service up and running through the semester (up to -20p)&lt;br /&gt;
* Keep the bad guys out from your servers (up to -30p)&lt;br /&gt;
* Have a disaster recovery plan (up to -20p)&lt;br /&gt;
* Configure layer3 firewall (15p)&lt;br /&gt;
* Configure application firewall(s) if applicable&lt;br /&gt;
* Configure your laptop to connect to intranet using OpenVPN and IPSec (15p)&lt;br /&gt;
* Configure your mobile device to connect to intranet using OpenVPN or IPSec (15p)&lt;br /&gt;
* Configure your service to use authentication from AD (20p)&lt;br /&gt;
&lt;br /&gt;
We will start with services facing the public internet, see what&#039;s the worst that can happen in that case and later migrate some services to intranet only. Some services will retain connectivity to public internet due to their nature (eg OwnCloud, mailserver) and some services will be available only in the intranet (eg fileserver)&lt;br /&gt;
&lt;br /&gt;
==Services==&lt;br /&gt;
&lt;br /&gt;
To support our virtual company in everyday business we need to provide them with a variety of services:&lt;br /&gt;
&lt;br /&gt;
* www.momcorp.eu - Install webserver/load balancer and create a homepage for the company and link to remaining sites. Olusiji&lt;br /&gt;
* shop.momcorp.eu - Install Magento and add some fictive products like dark matter and neutron star. Sander&lt;br /&gt;
* wiki.momcorp.eu - Install MediaWiki, later integrate with AD. Peep&lt;br /&gt;
* blog.momcorp.eu - Install WordPress, later integrate with AD. Steven&lt;br /&gt;
* chat.momcorp.eu - Install IRC server, provide  multiple channels for developers. Install some web based software for customer helldesk. Ardi&lt;br /&gt;
* ns1.momcorp.eu - Primary Bind9 installation, later also add DNSSEC. Erik J&lt;br /&gt;
* ns2.momcorp.eu - Secondary Bind9 installation in another physical host. ???&lt;br /&gt;
* git.momcorp.eu - Gogs installation. Farhan&lt;br /&gt;
* mon.momcorp.eu - Nagios monitoring. Nika&lt;br /&gt;
* mail.momcorp.eu - Mailserver with Postfix (postfw, greylisting, dkim, spf, setup secondary mx), later with AD integration if exchange won&#039;t be used. Andris&lt;br /&gt;
* ca.momcorp.eu - Java servlet container, EJBCA installation for certificate management. Masaki&lt;br /&gt;
* nas.momcorp.eu - Samba fileserver. Hindrek&lt;br /&gt;
* log.momcorp.eu - Graylog or similar for central logging. Kaspar, Sten-Erik&lt;br /&gt;
* vpn.momcorp.eu - OpenVPN gateway. Moira&lt;br /&gt;
* cs.momcorp.eu - Teamspeak and/or gaming server for entertainment. Christopher&lt;br /&gt;
&lt;br /&gt;
Additionally for each physical box listed under Hardware we could set up:&lt;br /&gt;
&lt;br /&gt;
* Person responsible for the hypervisor on that box&lt;br /&gt;
* Virtual machine with router OS - Mikrotik RouterOS, Vyatta, pfsense or just vanilla Debian with shell scripts&lt;br /&gt;
&lt;br /&gt;
Other topics:&lt;br /&gt;
&lt;br /&gt;
* Mikus - Remote management: Puppet master, DSC, postfix with kerberos (and AD?)&lt;br /&gt;
* Strongswan gateway&lt;br /&gt;
* OpenVPN gateway, later AD integration&lt;br /&gt;
* Exchange&lt;br /&gt;
* failover/high availability (heartbeat)&lt;br /&gt;
* db clusters/shards/replication (mysql/mariadb)&lt;br /&gt;
* clustered filesystems/servers (clvm, corosync, fenced, gfs)&lt;br /&gt;
* web caches (varnish, squid, nginx)&lt;br /&gt;
* load balancing (haproxy, nginx, simple roundrobin)&lt;br /&gt;
&lt;br /&gt;
==Lectures==&lt;br /&gt;
&lt;br /&gt;
Following lectures are planned:&lt;br /&gt;
&lt;br /&gt;
* 7. sept - Intro, virtualization, containers etc. Relevant story [https://lauri.xn--vsandi-pxa.com/lan/virtualization.html here]&lt;br /&gt;
* 14. sept - Network topology, bridges, tagging, trunking, subnetting, LAN, WAN&lt;br /&gt;
* 21. sept - iptables, ebtables, packet forwarding, DNAT, SNAT, routing tables, empheral ports, listening ports, slides [https://docs.google.com/presentation/d/1XMISOg88BJ0Dy8o3r8ZL9cxFT0oZZKDqPZ2EaWJRqFQ/edit?usp=sharing here]&lt;br /&gt;
* 28. sept - X.509 certificates, certificate authority, TLS, symmetric, asymmetric, keyexchange, Let&#039;s Encrypt, relevant slides [https://docs.google.com/presentation/d/1kqTyhhUu5CfwODmOTIC7odhlYfeEeJALTd4RX7XhPLE/edit?usp=sharing here]&lt;br /&gt;
* 30. nov - [https://docs.google.com/presentation/d/1aXtreUS2YD9vlsngVUSr_ZaXdrQv37zCRtc51TSGjPI/edit?usp=sharing AD auth]&lt;br /&gt;
&lt;br /&gt;
Order to be determined:&lt;br /&gt;
&lt;br /&gt;
* OpenVPN&lt;br /&gt;
* IPSec&lt;br /&gt;
* TBD, there are a lot of topics to discuss&lt;br /&gt;
&lt;br /&gt;
==Firewall rules==&lt;br /&gt;
&lt;br /&gt;
You can load these rules by running iptables-restore command, pasting the rules to the terminal and pressing Ctrl-D.&lt;br /&gt;
&lt;br /&gt;
To make rules persistent on your box install netfilter-persistent package, the rules will be stored at /etc/iptables/rules.v4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;iptables&amp;quot;&amp;gt;&lt;br /&gt;
*raw&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*mangle&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:INPUT ACCEPT [0:0]&lt;br /&gt;
:FORWARD ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
:POSTROUTING ACCEPT [0:0]&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*nat&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:INPUT ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
:POSTROUTING ACCEPT [0:0]&lt;br /&gt;
-A POSTROUTING -o eth1 -m comment --comment &amp;quot;Hide VPN addresses from LAN&amp;quot; -j MASQUERADE&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*filter&lt;br /&gt;
:INPUT DROP [0:0]&lt;br /&gt;
:FORWARD DROP [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment &amp;quot;Allow returning packets&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -i eth1 -m comment --comment &amp;quot;Allow traffic from LAN&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -s 127.0.0.0/8 -i lo -m comment --comment &amp;quot;Allow loopback&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p icmp -m icmp --icmp-type 8 -m comment --comment &amp;quot;Allow ping&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p tcp -m tcp --dport 22 -m comment --comment &amp;quot;Allow SSH&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p tcp -m tcp --dport 5666 -m comment --comment &amp;quot;Allow Nika\&#039;s Monitoring&amp;quot; -j ACCEPT&lt;br /&gt;
-A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment &amp;quot;Allow returning packets&amp;quot; -j ACCEPT&lt;br /&gt;
-A FORWARD -i tun0 -o eth1 -m comment --comment &amp;quot;Allow from VPN to LAN&amp;quot; -j ACCEPT&lt;br /&gt;
COMMIT&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127288</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127288"/>
		<updated>2017-11-28T16:21:43Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Assignment: Debugging ALU design (5p) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP (5p)=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario (5p)=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git (5p)=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers (15p)=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (3p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (3p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (9p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (3p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (3p)&lt;br /&gt;
# Optional/extra: Rewrite the function in assembly with NEON instructions. How much speed boost did you gain? (+10p)&lt;br /&gt;
# Optional/extra: What is the space complexity of the algorithm? What is the time complexity of the algorithm? Explain! (+4p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design (5p)=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
Assignment steps&lt;br /&gt;
&lt;br /&gt;
* Fork the repo on GitHub, clone your repo, fix mistakes, commit and push changes, send link to your GitHub repo where you have fixed the issues (5p)&lt;br /&gt;
* Optional/extra: Expand ALU to 8 bits (2p)&lt;br /&gt;
* Optional/extra: Add another opcode bit and implement multiplication so opcode(2) high means we&#039;re doing multiplication, opcode(1) in case of multiplication selects between higher and lower bits of the result and opcode(0) is used to negate the second operand of multiplication. (+5p)&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates (5p)=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127287</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127287"/>
		<updated>2017-11-28T16:21:29Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Assignment: Debugging ALU design (5p) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP (5p)=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario (5p)=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git (5p)=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers (15p)=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (3p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (3p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (9p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (3p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (3p)&lt;br /&gt;
# Optional/extra: Rewrite the function in assembly with NEON instructions. How much speed boost did you gain? (+10p)&lt;br /&gt;
# Optional/extra: What is the space complexity of the algorithm? What is the time complexity of the algorithm? Explain! (+4p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design (5p)=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
Assignment steps&lt;br /&gt;
&lt;br /&gt;
* For the repo on GitHub, clone your repo, fix mistakes, commit and push changes, send link to your GitHub repo where you have fixed the issues (5p)&lt;br /&gt;
* Optional/extra: Expand ALU to 8 bits (2p)&lt;br /&gt;
* Optional/extra: Add another opcode bit and implement multiplication so opcode(2) high means we&#039;re doing multiplication, opcode(1) in case of multiplication selects between higher and lower bits of the result and opcode(0) is used to negate the second operand of multiplication. (+5p)&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates (5p)=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127286</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127286"/>
		<updated>2017-11-28T16:19:22Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Assignment: Debugging ALU design (5p) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP (5p)=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario (5p)=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git (5p)=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers (15p)=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (3p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (3p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (9p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (3p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (3p)&lt;br /&gt;
# Optional/extra: Rewrite the function in assembly with NEON instructions. How much speed boost did you gain? (+10p)&lt;br /&gt;
# Optional/extra: What is the space complexity of the algorithm? What is the time complexity of the algorithm? Explain! (+4p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design (5p)=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
Optional/extra: Expand ALU to 8 bits (3p)&lt;br /&gt;
Optional/extra: Add another opcode bit and implement multiplication so opcode(2) high means we&#039;re doing multiplication, opcode(1) in case of multiplication selects between higher and lower bits of the result and opcode(0) is used to negate the second operand of multiplication. (+5p)&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates (5p)=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127283</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127283"/>
		<updated>2017-11-28T07:49:31Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Assignment: Adders with NAND gates (5p) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP (5p)=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario (5p)=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git (5p)=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers (15p)=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (3p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (3p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (9p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (3p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (3p)&lt;br /&gt;
# Optional/extra: Rewrite the function in assembly with NEON instructions. How much speed boost did you gain? (+10p)&lt;br /&gt;
# Optional/extra: What is the space complexity of the algorithm? What is the time complexity of the algorithm? Explain! (+4p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design (5p)=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates (5p)=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127115</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127115"/>
		<updated>2017-11-21T13:26:16Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP (5p)=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario (5p)=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git (5p)=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers (15p)=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (3p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (3p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (9p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (3p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (3p)&lt;br /&gt;
# Optional/extra: Rewrite the function in assembly with NEON instructions. How much speed boost did you gain? (+10p)&lt;br /&gt;
# Optional/extra: What is the space complexity of the algorithm? What is the time complexity of the algorithm? Explain! (+4p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates (5p)=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design (5p)&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127113</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127113"/>
		<updated>2017-11-21T10:03:24Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Assignment: Debugging ALU design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP (5p)=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario (5p)=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git (5p)=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers (15p)=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (3p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (3p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (9p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (3p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (3p)&lt;br /&gt;
# Optional/extra: Rewrite the function in assembly with NEON instructions. How much speed boost did you gain? (+10p)&lt;br /&gt;
# Optional/extra: What is the space complexity of the algorithm? What is the time complexity of the algorithm? Explain! (+4p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates (5p)=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design (5p)&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127112</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127112"/>
		<updated>2017-11-21T10:03:13Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Assignment: Adders with NAND gates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP (5p)=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario (5p)=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git (5p)=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers (15p)=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (3p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (3p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (9p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (3p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (3p)&lt;br /&gt;
# Optional/extra: Rewrite the function in assembly with NEON instructions. How much speed boost did you gain? (+10p)&lt;br /&gt;
# Optional/extra: What is the space complexity of the algorithm? What is the time complexity of the algorithm? Explain! (+4p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates (5p)=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127111</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127111"/>
		<updated>2017-11-21T10:03:00Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Assignment: Investigating compilers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP (5p)=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario (5p)=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git (5p)=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers (15p)=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (3p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (3p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (9p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (3p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (3p)&lt;br /&gt;
# Optional/extra: Rewrite the function in assembly with NEON instructions. How much speed boost did you gain? (+10p)&lt;br /&gt;
# Optional/extra: What is the space complexity of the algorithm? What is the time complexity of the algorithm? Explain! (+4p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127110</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127110"/>
		<updated>2017-11-21T10:02:52Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Assignment: Collaborating using Git */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP (5p)=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario (5p)=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git (5p)=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (3p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (3p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (9p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (3p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (3p)&lt;br /&gt;
# Optional/extra: Rewrite the function in assembly with NEON instructions. How much speed boost did you gain? (+10p)&lt;br /&gt;
# Optional/extra: What is the space complexity of the algorithm? What is the time complexity of the algorithm? Explain! (+4p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127109</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127109"/>
		<updated>2017-11-21T07:41:34Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Assignment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP (5p)=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario (5p)=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (3p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (3p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (9p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (3p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (3p)&lt;br /&gt;
# Optional/extra: Rewrite the function in assembly with NEON instructions. How much speed boost did you gain? (+10p)&lt;br /&gt;
# Optional/extra: What is the space complexity of the algorithm? What is the time complexity of the algorithm? Explain! (+4p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127108</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127108"/>
		<updated>2017-11-21T07:30:29Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Assignment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP (5p)=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario (5p)=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (1p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (1p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (3p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (1p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (1p)&lt;br /&gt;
# Optional/extra: Rewrite the function in assembly with NEON instructions. How much speed boost did you gain? (+10p)&lt;br /&gt;
# Optional/extra: What is the space complexity of the algorithm? What is the time complexity of the algorithm? Explain! (+4p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127107</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127107"/>
		<updated>2017-11-21T07:29:39Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Assignment: Investigating compilers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP (5p)=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario (5p)=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (1p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (1p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (3p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (1p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (1p)&lt;br /&gt;
# Optional/extra: Rewrite the function in assembly with NEON instructions. How much speed boost did you gain? (+10p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127106</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127106"/>
		<updated>2017-11-21T07:10:58Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Assignment: Set up basic IoT scenario */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP (5p)=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario (5p)=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (1p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (1p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (3p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (1p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (1p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127105</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127105"/>
		<updated>2017-11-21T07:09:48Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Assignment: Investigating LAMP */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP (5p)=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (1p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (1p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (3p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (1p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (1p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127104</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127104"/>
		<updated>2017-11-21T07:09:36Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Assignment: Investigating embedded hardware */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (1p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (1p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (3p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (1p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (1p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127103</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127103"/>
		<updated>2017-11-21T07:09:27Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Assignment: Investigating PC hardware */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware (5p)=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (1p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (1p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (3p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (1p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (1p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127102</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127102"/>
		<updated>2017-11-21T07:09:11Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (1p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (1p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (3p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (1p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (1p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
In the Git assignment most of the following was already required&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127101</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=127101"/>
		<updated>2017-11-21T07:08:14Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (1p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (1p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (3p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (1p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (1p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Deprecated assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In the IoT assignment we already played around with ESP32 microcontroller, most microcontroller concepts are the same for Arduino (interrupts, PWM, etc).&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=125398</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=125398"/>
		<updated>2017-10-31T13:49:28Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Feedback form: https://goo.gl/forms/evqt69NeRkf5IPKx1&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (1p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (1p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (3p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (1p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (1p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=125155</id>
		<title>Category:I802 Firewalls and VPN IPSec (2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=125155"/>
		<updated>2017-10-26T14:24:40Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Firewall rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Firewalls and VPN/IPSec=&lt;br /&gt;
&lt;br /&gt;
==General information==&lt;br /&gt;
&lt;br /&gt;
ECTS: 4&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
To register to this course send your SSH public key to Lauri and state which service you want to configure.&lt;br /&gt;
&lt;br /&gt;
Grading bot is at http://193.40.244.178/static/bot.html&lt;br /&gt;
&lt;br /&gt;
==Scenario==&lt;br /&gt;
&lt;br /&gt;
In this course we will attempt to set up a network similar to a corporate network with multiple offices, eg http://docplayer.it/docs-images/20/596222/images/25-0.png&lt;br /&gt;
&lt;br /&gt;
Our virtual company&#039;s story is based on [http://futurama.wikia.com/wiki/MomCorp Mom&#039;s Friendly Robot Company].&lt;br /&gt;
&lt;br /&gt;
We will use VPN software to connect subnets to each other and we will use VPN software to connect our personal computers to the intranet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Hardware==&lt;br /&gt;
&lt;br /&gt;
School&#039;s infra provides with public subnet for 62 hosts:&lt;br /&gt;
&lt;br /&gt;
* IPv4 address: 193.40.244.129-188&lt;br /&gt;
* Subnet: /26&lt;br /&gt;
* Gateway: 193.40.244.188&lt;br /&gt;
* DNS: 8.8.8.8&lt;br /&gt;
&lt;br /&gt;
That network is physically routed to 413-6-16 port in room 413.&lt;br /&gt;
&lt;br /&gt;
We have total of about 264GB of RAM and couple of terabytes of SSD storage:&lt;br /&gt;
&lt;br /&gt;
* Marek&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s (hosts 130-139)&lt;br /&gt;
* Madis&#039; box HP Proliant G5, 4x quadcore Opteron, 64GB RAM, 2 NIC-s (hosts 140-149)&lt;br /&gt;
* Erik&#039;s box Sun 32GB, 2x 256GB SSD (hosts 155-159)&lt;br /&gt;
* Lauri&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s, 4x 250G SSD (hosts 160-179)&lt;br /&gt;
* Frank&#039;s box DELL 16GB, 2x 256GB SSD, 6 NIC (hosts 180-185)&lt;br /&gt;
* Another Sun box with 24G of RAM, dying harddisks&lt;br /&gt;
* Reserved addresses 186-188&lt;br /&gt;
&lt;br /&gt;
NB! Replace BIOS batteries; replace thermal paste&lt;br /&gt;
&lt;br /&gt;
==Grading==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to do pick a topic from the services list below.&lt;br /&gt;
Send your SSH public key to Lauri and state which service you want to take care of.&lt;br /&gt;
&lt;br /&gt;
Collect 100p in total to pass the course, note that there are opportunities to collect much more points in total:&lt;br /&gt;
&lt;br /&gt;
* Get the service up and running (15p)&lt;br /&gt;
* Configure Let&#039;s Encrypt certificates for your service if applicable (15p)&lt;br /&gt;
* Add your service to monitoring at mon.momcorp.eu (15p)&lt;br /&gt;
* Enable log forwarding to log.momcorp.eu, if applicable configure auditing for your service (15p)&lt;br /&gt;
* Configure your service to send e-mails (mail.momcorp.eu) if applicable (15p)&lt;br /&gt;
* Keep the service up and running through the semester (up to -20p)&lt;br /&gt;
* Keep the bad guys out from your servers (up to -30p)&lt;br /&gt;
* Have a disaster recovery plan (up to -20p)&lt;br /&gt;
* Configure layer3 firewall (15p)&lt;br /&gt;
* Configure application firewall(s) if applicable&lt;br /&gt;
* Configure your laptop to connect to intranet using OpenVPN and IPSec (15p)&lt;br /&gt;
* Configure your mobile device to connect to intranet using OpenVPN or IPSec (15p)&lt;br /&gt;
* Configure your service to use authentication from AD (20p)&lt;br /&gt;
&lt;br /&gt;
We will start with services facing the public internet, see what&#039;s the worst that can happen in that case and later migrate some services to intranet only. Some services will retain connectivity to public internet due to their nature (eg OwnCloud, mailserver) and some services will be available only in the intranet (eg fileserver)&lt;br /&gt;
&lt;br /&gt;
==Services==&lt;br /&gt;
&lt;br /&gt;
To support our virtual company in everyday business we need to provide them with a variety of services:&lt;br /&gt;
&lt;br /&gt;
* www.momcorp.eu - Install webserver/load balancer and create a homepage for the company and link to remaining sites. Olusiji&lt;br /&gt;
* shop.momcorp.eu - Install Magento and add some fictive products like dark matter and neutron star. Sander&lt;br /&gt;
* wiki.momcorp.eu - Install MediaWiki, later integrate with AD. Peep&lt;br /&gt;
* blog.momcorp.eu - Install WordPress, later integrate with AD. Steven&lt;br /&gt;
* chat.momcorp.eu - Install IRC server, provide  multiple channels for developers. Install some web based software for customer helldesk. Ardi&lt;br /&gt;
* ns1.momcorp.eu - Primary Bind9 installation, later also add DNSSEC. Erik J&lt;br /&gt;
* ns2.momcorp.eu - Secondary Bind9 installation in another physical host. ???&lt;br /&gt;
* git.momcorp.eu - Gogs installation. Farhan&lt;br /&gt;
* mon.momcorp.eu - Nagios monitoring. Nika&lt;br /&gt;
* mail.momcorp.eu - Mailserver with Postfix (postfw, greylisting, dkim, spf, setup secondary mx), later with AD integration if exchange won&#039;t be used. Andris&lt;br /&gt;
* ca.momcorp.eu - Java servlet container, EJBCA installation for certificate management. Masaki&lt;br /&gt;
* nas.momcorp.eu - Samba fileserver. Hindrek&lt;br /&gt;
* log.momcorp.eu - Graylog or similar for central logging. Kaspar, Sten-Erik&lt;br /&gt;
* vpn.momcorp.eu - OpenVPN gateway. Moira&lt;br /&gt;
* cs.momcorp.eu - Teamspeak and/or gaming server for entertainment. Christopher&lt;br /&gt;
&lt;br /&gt;
Additionally for each physical box listed under Hardware we could set up:&lt;br /&gt;
&lt;br /&gt;
* Person responsible for the hypervisor on that box&lt;br /&gt;
* Virtual machine with router OS - Mikrotik RouterOS, Vyatta, pfsense or just vanilla Debian with shell scripts&lt;br /&gt;
&lt;br /&gt;
Other topics:&lt;br /&gt;
&lt;br /&gt;
* Mikus - Remote management: Puppet master, DSC, postfix with kerberos (and AD?)&lt;br /&gt;
* Strongswan gateway&lt;br /&gt;
* OpenVPN gateway, later AD integration&lt;br /&gt;
* Exchange&lt;br /&gt;
* failover/high availability (heartbeat)&lt;br /&gt;
* db clusters/shards/replication (mysql/mariadb)&lt;br /&gt;
* clustered filesystems/servers (clvm, corosync, fenced, gfs)&lt;br /&gt;
* web caches (varnish, squid, nginx)&lt;br /&gt;
* load balancing (haproxy, nginx, simple roundrobin)&lt;br /&gt;
&lt;br /&gt;
==Lectures==&lt;br /&gt;
&lt;br /&gt;
Following lectures are planned:&lt;br /&gt;
&lt;br /&gt;
* 7. sept - Intro, virtualization, containers etc. Relevant story [https://lauri.xn--vsandi-pxa.com/lan/virtualization.html here]&lt;br /&gt;
* 14. sept - Network topology, bridges, tagging, trunking, subnetting, LAN, WAN&lt;br /&gt;
* 21. sept - iptables, ebtables, packet forwarding, DNAT, SNAT, routing tables, empheral ports, listening ports, slides [https://docs.google.com/presentation/d/1XMISOg88BJ0Dy8o3r8ZL9cxFT0oZZKDqPZ2EaWJRqFQ/edit?usp=sharing here]&lt;br /&gt;
* 28. sept - X.509 certificates, certificate authority, TLS, symmetric, asymmetric, keyexchange, Let&#039;s Encrypt, relevant slides [https://docs.google.com/presentation/d/1kqTyhhUu5CfwODmOTIC7odhlYfeEeJALTd4RX7XhPLE/edit?usp=sharing here]&lt;br /&gt;
&lt;br /&gt;
Order to be determined:&lt;br /&gt;
&lt;br /&gt;
* OpenVPN&lt;br /&gt;
* IPSec&lt;br /&gt;
* TBD, there are a lot of topics to discuss&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Firewall rules==&lt;br /&gt;
&lt;br /&gt;
You can load these rules by running iptables-restore command, pasting the rules to the terminal and pressing Ctrl-D.&lt;br /&gt;
&lt;br /&gt;
To make rules persistent on your box install netfilter-persistent package, the rules will be stored at /etc/iptables/rules.v4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;iptables&amp;quot;&amp;gt;&lt;br /&gt;
*raw&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*mangle&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:INPUT ACCEPT [0:0]&lt;br /&gt;
:FORWARD ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
:POSTROUTING ACCEPT [0:0]&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*nat&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:INPUT ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
:POSTROUTING ACCEPT [0:0]&lt;br /&gt;
-A POSTROUTING -o eth1 -m comment --comment &amp;quot;Hide VPN addresses from LAN&amp;quot; -j MASQUERADE&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*filter&lt;br /&gt;
:INPUT DROP [0:0]&lt;br /&gt;
:FORWARD DROP [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment &amp;quot;Allow returning packets&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -i eth1 -m comment --comment &amp;quot;Allow traffic from LAN&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -s 127.0.0.0/8 -i lo -m comment --comment &amp;quot;Allow loopback&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p icmp -m icmp --icmp-type 8 -m comment --comment &amp;quot;Allow ping&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p tcp -m tcp --dport 22 -m comment --comment &amp;quot;Allow SSH&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p tcp -m tcp --dport 5666 -m comment --comment &amp;quot;Allow Nika\&#039;s Monitoring&amp;quot; -j ACCEPT&lt;br /&gt;
-A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment &amp;quot;Allow returning packets&amp;quot; -j ACCEPT&lt;br /&gt;
-A FORWARD -i tun0 -o eth1 -m comment --comment &amp;quot;Allow from VPN to LAN&amp;quot; -j ACCEPT&lt;br /&gt;
COMMIT&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=124776</id>
		<title>Category:I802 Firewalls and VPN IPSec (2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=124776"/>
		<updated>2017-10-19T14:33:40Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Firewall rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Firewalls and VPN/IPSec=&lt;br /&gt;
&lt;br /&gt;
==General information==&lt;br /&gt;
&lt;br /&gt;
ECTS: 4&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
To register to this course send your SSH public key to Lauri and state which service you want to configure.&lt;br /&gt;
&lt;br /&gt;
Grading bot is at http://193.40.244.178/static/bot.html&lt;br /&gt;
&lt;br /&gt;
==Scenario==&lt;br /&gt;
&lt;br /&gt;
In this course we will attempt to set up a network similar to a corporate network with multiple offices, eg http://docplayer.it/docs-images/20/596222/images/25-0.png&lt;br /&gt;
&lt;br /&gt;
Our virtual company&#039;s story is based on [http://futurama.wikia.com/wiki/MomCorp Mom&#039;s Friendly Robot Company].&lt;br /&gt;
&lt;br /&gt;
We will use VPN software to connect subnets to each other and we will use VPN software to connect our personal computers to the intranet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Hardware==&lt;br /&gt;
&lt;br /&gt;
School&#039;s infra provides with public subnet for 62 hosts:&lt;br /&gt;
&lt;br /&gt;
* IPv4 address: 193.40.244.129-188&lt;br /&gt;
* Subnet: /26&lt;br /&gt;
* Gateway: 193.40.244.188&lt;br /&gt;
* DNS: 8.8.8.8&lt;br /&gt;
&lt;br /&gt;
That network is physically routed to 413-6-16 port in room 413.&lt;br /&gt;
&lt;br /&gt;
We have total of about 264GB of RAM and couple of terabytes of SSD storage:&lt;br /&gt;
&lt;br /&gt;
* Marek&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s (hosts 130-139)&lt;br /&gt;
* Madis&#039; box HP Proliant G5, 4x quadcore Opteron, 64GB RAM, 2 NIC-s (hosts 140-149)&lt;br /&gt;
* Erik&#039;s box Sun 32GB, 2x 256GB SSD (hosts 155-159)&lt;br /&gt;
* Lauri&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s, 4x 250G SSD (hosts 160-179)&lt;br /&gt;
* Frank&#039;s box DELL 16GB, 2x 256GB SSD, 6 NIC (hosts 180-185)&lt;br /&gt;
* Another Sun box with 24G of RAM, dying harddisks&lt;br /&gt;
* Reserved addresses 186-188&lt;br /&gt;
&lt;br /&gt;
NB! Replace BIOS batteries; replace thermal paste&lt;br /&gt;
&lt;br /&gt;
==Grading==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to do pick a topic from the services list below.&lt;br /&gt;
Send your SSH public key to Lauri and state which service you want to take care of.&lt;br /&gt;
&lt;br /&gt;
Collect 100p in total to pass the course, note that there are opportunities to collect much more points in total:&lt;br /&gt;
&lt;br /&gt;
* Get the service up and running (15p)&lt;br /&gt;
* Configure Let&#039;s Encrypt certificates for your service if applicable (15p)&lt;br /&gt;
* Add your service to monitoring at mon.momcorp.eu (15p)&lt;br /&gt;
* Enable log forwarding to log.momcorp.eu, if applicable configure auditing for your service (15p)&lt;br /&gt;
* Configure your service to send e-mails (mail.momcorp.eu) if applicable (15p)&lt;br /&gt;
* Keep the service up and running through the semester (up to -20p)&lt;br /&gt;
* Keep the bad guys out from your servers (up to -30p)&lt;br /&gt;
* Have a disaster recovery plan (up to -20p)&lt;br /&gt;
* Configure layer3 firewall (15p)&lt;br /&gt;
* Configure application firewall(s) if applicable&lt;br /&gt;
* Configure your laptop to connect to intranet using OpenVPN and IPSec (15p)&lt;br /&gt;
* Configure your mobile device to connect to intranet using OpenVPN or IPSec (15p)&lt;br /&gt;
* Configure your service to use authentication from AD (20p)&lt;br /&gt;
&lt;br /&gt;
We will start with services facing the public internet, see what&#039;s the worst that can happen in that case and later migrate some services to intranet only. Some services will retain connectivity to public internet due to their nature (eg OwnCloud, mailserver) and some services will be available only in the intranet (eg fileserver)&lt;br /&gt;
&lt;br /&gt;
==Services==&lt;br /&gt;
&lt;br /&gt;
To support our virtual company in everyday business we need to provide them with a variety of services:&lt;br /&gt;
&lt;br /&gt;
* www.momcorp.eu - Install webserver/load balancer and create a homepage for the company and link to remaining sites. Olusiji&lt;br /&gt;
* shop.momcorp.eu - Install Magento and add some fictive products like dark matter and neutron star. Sander&lt;br /&gt;
* wiki.momcorp.eu - Install MediaWiki, later integrate with AD. Peep&lt;br /&gt;
* blog.momcorp.eu - Install WordPress, later integrate with AD. Steven&lt;br /&gt;
* chat.momcorp.eu - Install IRC server, provide  multiple channels for developers. Install some web based software for customer helldesk. Ardi&lt;br /&gt;
* ns1.momcorp.eu - Primary Bind9 installation, later also add DNSSEC. Erik J&lt;br /&gt;
* ns2.momcorp.eu - Secondary Bind9 installation in another physical host. ???&lt;br /&gt;
* git.momcorp.eu - Gogs installation. Farhan&lt;br /&gt;
* mon.momcorp.eu - Nagios monitoring. Nika&lt;br /&gt;
* mail.momcorp.eu - Mailserver with Postfix (postfw, greylisting, dkim, spf, setup secondary mx), later with AD integration if exchange won&#039;t be used. Andris&lt;br /&gt;
* ca.momcorp.eu - Java servlet container, EJBCA installation for certificate management. Masaki&lt;br /&gt;
* nas.momcorp.eu - Samba fileserver. Hindrek&lt;br /&gt;
* log.momcorp.eu - Graylog or similar for central logging. Kaspar, Sten-Erik&lt;br /&gt;
* vpn.momcorp.eu - OpenVPN gateway. Moira&lt;br /&gt;
* cs.momcorp.eu - Teamspeak and/or gaming server for entertainment. Christopher&lt;br /&gt;
&lt;br /&gt;
Additionally for each physical box listed under Hardware we could set up:&lt;br /&gt;
&lt;br /&gt;
* Person responsible for the hypervisor on that box&lt;br /&gt;
* Virtual machine with router OS - Mikrotik RouterOS, Vyatta, pfsense or just vanilla Debian with shell scripts&lt;br /&gt;
&lt;br /&gt;
Other topics:&lt;br /&gt;
&lt;br /&gt;
* Mikus - Remote management: Puppet master, DSC, postfix with kerberos (and AD?)&lt;br /&gt;
* Strongswan gateway&lt;br /&gt;
* OpenVPN gateway, later AD integration&lt;br /&gt;
* Exchange&lt;br /&gt;
* failover/high availability (heartbeat)&lt;br /&gt;
* db clusters/shards/replication (mysql/mariadb)&lt;br /&gt;
* clustered filesystems/servers (clvm, corosync, fenced, gfs)&lt;br /&gt;
* web caches (varnish, squid, nginx)&lt;br /&gt;
* load balancing (haproxy, nginx, simple roundrobin)&lt;br /&gt;
&lt;br /&gt;
==Lectures==&lt;br /&gt;
&lt;br /&gt;
Following lectures are planned:&lt;br /&gt;
&lt;br /&gt;
* 7. sept - Intro, virtualization, containers etc. Relevant story [https://lauri.xn--vsandi-pxa.com/lan/virtualization.html here]&lt;br /&gt;
* 14. sept - Network topology, bridges, tagging, trunking, subnetting, LAN, WAN&lt;br /&gt;
* 21. sept - iptables, ebtables, packet forwarding, DNAT, SNAT, routing tables, empheral ports, listening ports, slides [https://docs.google.com/presentation/d/1XMISOg88BJ0Dy8o3r8ZL9cxFT0oZZKDqPZ2EaWJRqFQ/edit?usp=sharing here]&lt;br /&gt;
* 28. sept - X.509 certificates, certificate authority, TLS, symmetric, asymmetric, keyexchange, Let&#039;s Encrypt, relevant slides [https://docs.google.com/presentation/d/1kqTyhhUu5CfwODmOTIC7odhlYfeEeJALTd4RX7XhPLE/edit?usp=sharing here]&lt;br /&gt;
&lt;br /&gt;
Order to be determined:&lt;br /&gt;
&lt;br /&gt;
* OpenVPN&lt;br /&gt;
* IPSec&lt;br /&gt;
* TBD, there are a lot of topics to discuss&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Firewall rules==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;iptables&amp;quot;&amp;gt;&lt;br /&gt;
*raw&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*mangle&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:INPUT ACCEPT [0:0]&lt;br /&gt;
:FORWARD ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
:POSTROUTING ACCEPT [0:0]&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*nat&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:INPUT ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
:POSTROUTING ACCEPT [0:0]&lt;br /&gt;
-A POSTROUTING -o eth1 -m comment --comment &amp;quot;Hide VPN addresses from LAN&amp;quot; -j MASQUERADE&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*filter&lt;br /&gt;
:INPUT DROP [0:0]&lt;br /&gt;
:FORWARD DROP [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment &amp;quot;Allow returning packets&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -i eth1 -m comment --comment &amp;quot;Allow traffic from LAN&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -s 127.0.0.0/8 -i lo -m comment --comment &amp;quot;Allow loopback&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p icmp -m icmp --icmp-type 8 -m comment --comment &amp;quot;Allow ping&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p tcp -m tcp --dport 22 -m comment --comment &amp;quot;Allow SSH&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p tcp -m tcp --dport 5666 -m comment --comment &amp;quot;Allow Nika\&#039;s Monitoring&amp;quot; -j ACCEPT&lt;br /&gt;
-A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment &amp;quot;Allow returning packets&amp;quot; -j ACCEPT&lt;br /&gt;
-A FORWARD -i tun0 -o eth1 -m comment --comment &amp;quot;Allow from VPN to LAN&amp;quot; -j ACCEPT&lt;br /&gt;
COMMIT&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=124775</id>
		<title>Category:I802 Firewalls and VPN IPSec (2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=124775"/>
		<updated>2017-10-19T14:30:42Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Firewall rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Firewalls and VPN/IPSec=&lt;br /&gt;
&lt;br /&gt;
==General information==&lt;br /&gt;
&lt;br /&gt;
ECTS: 4&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
To register to this course send your SSH public key to Lauri and state which service you want to configure.&lt;br /&gt;
&lt;br /&gt;
Grading bot is at http://193.40.244.178/static/bot.html&lt;br /&gt;
&lt;br /&gt;
==Scenario==&lt;br /&gt;
&lt;br /&gt;
In this course we will attempt to set up a network similar to a corporate network with multiple offices, eg http://docplayer.it/docs-images/20/596222/images/25-0.png&lt;br /&gt;
&lt;br /&gt;
Our virtual company&#039;s story is based on [http://futurama.wikia.com/wiki/MomCorp Mom&#039;s Friendly Robot Company].&lt;br /&gt;
&lt;br /&gt;
We will use VPN software to connect subnets to each other and we will use VPN software to connect our personal computers to the intranet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Hardware==&lt;br /&gt;
&lt;br /&gt;
School&#039;s infra provides with public subnet for 62 hosts:&lt;br /&gt;
&lt;br /&gt;
* IPv4 address: 193.40.244.129-188&lt;br /&gt;
* Subnet: /26&lt;br /&gt;
* Gateway: 193.40.244.188&lt;br /&gt;
* DNS: 8.8.8.8&lt;br /&gt;
&lt;br /&gt;
That network is physically routed to 413-6-16 port in room 413.&lt;br /&gt;
&lt;br /&gt;
We have total of about 264GB of RAM and couple of terabytes of SSD storage:&lt;br /&gt;
&lt;br /&gt;
* Marek&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s (hosts 130-139)&lt;br /&gt;
* Madis&#039; box HP Proliant G5, 4x quadcore Opteron, 64GB RAM, 2 NIC-s (hosts 140-149)&lt;br /&gt;
* Erik&#039;s box Sun 32GB, 2x 256GB SSD (hosts 155-159)&lt;br /&gt;
* Lauri&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s, 4x 250G SSD (hosts 160-179)&lt;br /&gt;
* Frank&#039;s box DELL 16GB, 2x 256GB SSD, 6 NIC (hosts 180-185)&lt;br /&gt;
* Another Sun box with 24G of RAM, dying harddisks&lt;br /&gt;
* Reserved addresses 186-188&lt;br /&gt;
&lt;br /&gt;
NB! Replace BIOS batteries; replace thermal paste&lt;br /&gt;
&lt;br /&gt;
==Grading==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to do pick a topic from the services list below.&lt;br /&gt;
Send your SSH public key to Lauri and state which service you want to take care of.&lt;br /&gt;
&lt;br /&gt;
Collect 100p in total to pass the course, note that there are opportunities to collect much more points in total:&lt;br /&gt;
&lt;br /&gt;
* Get the service up and running (15p)&lt;br /&gt;
* Configure Let&#039;s Encrypt certificates for your service if applicable (15p)&lt;br /&gt;
* Add your service to monitoring at mon.momcorp.eu (15p)&lt;br /&gt;
* Enable log forwarding to log.momcorp.eu, if applicable configure auditing for your service (15p)&lt;br /&gt;
* Configure your service to send e-mails (mail.momcorp.eu) if applicable (15p)&lt;br /&gt;
* Keep the service up and running through the semester (up to -20p)&lt;br /&gt;
* Keep the bad guys out from your servers (up to -30p)&lt;br /&gt;
* Have a disaster recovery plan (up to -20p)&lt;br /&gt;
* Configure layer3 firewall (15p)&lt;br /&gt;
* Configure application firewall(s) if applicable&lt;br /&gt;
* Configure your laptop to connect to intranet using OpenVPN and IPSec (15p)&lt;br /&gt;
* Configure your mobile device to connect to intranet using OpenVPN or IPSec (15p)&lt;br /&gt;
* Configure your service to use authentication from AD (20p)&lt;br /&gt;
&lt;br /&gt;
We will start with services facing the public internet, see what&#039;s the worst that can happen in that case and later migrate some services to intranet only. Some services will retain connectivity to public internet due to their nature (eg OwnCloud, mailserver) and some services will be available only in the intranet (eg fileserver)&lt;br /&gt;
&lt;br /&gt;
==Services==&lt;br /&gt;
&lt;br /&gt;
To support our virtual company in everyday business we need to provide them with a variety of services:&lt;br /&gt;
&lt;br /&gt;
* www.momcorp.eu - Install webserver/load balancer and create a homepage for the company and link to remaining sites. Olusiji&lt;br /&gt;
* shop.momcorp.eu - Install Magento and add some fictive products like dark matter and neutron star. Sander&lt;br /&gt;
* wiki.momcorp.eu - Install MediaWiki, later integrate with AD. Peep&lt;br /&gt;
* blog.momcorp.eu - Install WordPress, later integrate with AD. Steven&lt;br /&gt;
* chat.momcorp.eu - Install IRC server, provide  multiple channels for developers. Install some web based software for customer helldesk. Ardi&lt;br /&gt;
* ns1.momcorp.eu - Primary Bind9 installation, later also add DNSSEC. Erik J&lt;br /&gt;
* ns2.momcorp.eu - Secondary Bind9 installation in another physical host. ???&lt;br /&gt;
* git.momcorp.eu - Gogs installation. Farhan&lt;br /&gt;
* mon.momcorp.eu - Nagios monitoring. Nika&lt;br /&gt;
* mail.momcorp.eu - Mailserver with Postfix (postfw, greylisting, dkim, spf, setup secondary mx), later with AD integration if exchange won&#039;t be used. Andris&lt;br /&gt;
* ca.momcorp.eu - Java servlet container, EJBCA installation for certificate management. Masaki&lt;br /&gt;
* nas.momcorp.eu - Samba fileserver. Hindrek&lt;br /&gt;
* log.momcorp.eu - Graylog or similar for central logging. Kaspar, Sten-Erik&lt;br /&gt;
* vpn.momcorp.eu - OpenVPN gateway. Moira&lt;br /&gt;
* cs.momcorp.eu - Teamspeak and/or gaming server for entertainment. Christopher&lt;br /&gt;
&lt;br /&gt;
Additionally for each physical box listed under Hardware we could set up:&lt;br /&gt;
&lt;br /&gt;
* Person responsible for the hypervisor on that box&lt;br /&gt;
* Virtual machine with router OS - Mikrotik RouterOS, Vyatta, pfsense or just vanilla Debian with shell scripts&lt;br /&gt;
&lt;br /&gt;
Other topics:&lt;br /&gt;
&lt;br /&gt;
* Mikus - Remote management: Puppet master, DSC, postfix with kerberos (and AD?)&lt;br /&gt;
* Strongswan gateway&lt;br /&gt;
* OpenVPN gateway, later AD integration&lt;br /&gt;
* Exchange&lt;br /&gt;
* failover/high availability (heartbeat)&lt;br /&gt;
* db clusters/shards/replication (mysql/mariadb)&lt;br /&gt;
* clustered filesystems/servers (clvm, corosync, fenced, gfs)&lt;br /&gt;
* web caches (varnish, squid, nginx)&lt;br /&gt;
* load balancing (haproxy, nginx, simple roundrobin)&lt;br /&gt;
&lt;br /&gt;
==Lectures==&lt;br /&gt;
&lt;br /&gt;
Following lectures are planned:&lt;br /&gt;
&lt;br /&gt;
* 7. sept - Intro, virtualization, containers etc. Relevant story [https://lauri.xn--vsandi-pxa.com/lan/virtualization.html here]&lt;br /&gt;
* 14. sept - Network topology, bridges, tagging, trunking, subnetting, LAN, WAN&lt;br /&gt;
* 21. sept - iptables, ebtables, packet forwarding, DNAT, SNAT, routing tables, empheral ports, listening ports, slides [https://docs.google.com/presentation/d/1XMISOg88BJ0Dy8o3r8ZL9cxFT0oZZKDqPZ2EaWJRqFQ/edit?usp=sharing here]&lt;br /&gt;
* 28. sept - X.509 certificates, certificate authority, TLS, symmetric, asymmetric, keyexchange, Let&#039;s Encrypt, relevant slides [https://docs.google.com/presentation/d/1kqTyhhUu5CfwODmOTIC7odhlYfeEeJALTd4RX7XhPLE/edit?usp=sharing here]&lt;br /&gt;
&lt;br /&gt;
Order to be determined:&lt;br /&gt;
&lt;br /&gt;
* OpenVPN&lt;br /&gt;
* IPSec&lt;br /&gt;
* TBD, there are a lot of topics to discuss&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Firewall rules==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;iptables&amp;quot;&amp;gt;&lt;br /&gt;
*raw&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*mangle&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:INPUT ACCEPT [0:0]&lt;br /&gt;
:FORWARD ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
:POSTROUTING ACCEPT [0:0]&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*nat&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:INPUT ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
:POSTROUTING ACCEPT [0:0]&lt;br /&gt;
-A POSTROUTING -o eth1  -m comment --comment &amp;quot;Hide VPN addresses from LAN&amp;quot; -j MASQUERADE&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*filter&lt;br /&gt;
:INPUT DROP [0:0]&lt;br /&gt;
:FORWARD DROP [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment &amp;quot;Allow returning packets&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -i eth1 -m comment --comment &amp;quot;Allow traffic from LAN&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -s 127.0.0.0/8 -i lo -m comment --comment &amp;quot;Allow loopback&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p icmp -m icmp --icmp-type 8 -m comment --comment &amp;quot;Allow ping&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p tcp -m tcp --dport 22 -m comment --comment &amp;quot;Allow SSH&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p tcp -m tcp --dport 5666 -m comment --comment &amp;quot;Allow Nika\&#039;s Monitoring&amp;quot; -j ACCEPT&lt;br /&gt;
-A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment &amp;quot;Allow returning packets&amp;quot; -j ACCEPT&lt;br /&gt;
-A FORWARD -i tun0 -eth1 -m comment --comment &amp;quot;Allow from VPN to LAN&amp;quot; -j ACCEPT&lt;br /&gt;
COMMIT&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=124774</id>
		<title>Category:I802 Firewalls and VPN IPSec (2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=124774"/>
		<updated>2017-10-19T14:29:09Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Firewall rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Firewalls and VPN/IPSec=&lt;br /&gt;
&lt;br /&gt;
==General information==&lt;br /&gt;
&lt;br /&gt;
ECTS: 4&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
To register to this course send your SSH public key to Lauri and state which service you want to configure.&lt;br /&gt;
&lt;br /&gt;
Grading bot is at http://193.40.244.178/static/bot.html&lt;br /&gt;
&lt;br /&gt;
==Scenario==&lt;br /&gt;
&lt;br /&gt;
In this course we will attempt to set up a network similar to a corporate network with multiple offices, eg http://docplayer.it/docs-images/20/596222/images/25-0.png&lt;br /&gt;
&lt;br /&gt;
Our virtual company&#039;s story is based on [http://futurama.wikia.com/wiki/MomCorp Mom&#039;s Friendly Robot Company].&lt;br /&gt;
&lt;br /&gt;
We will use VPN software to connect subnets to each other and we will use VPN software to connect our personal computers to the intranet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Hardware==&lt;br /&gt;
&lt;br /&gt;
School&#039;s infra provides with public subnet for 62 hosts:&lt;br /&gt;
&lt;br /&gt;
* IPv4 address: 193.40.244.129-188&lt;br /&gt;
* Subnet: /26&lt;br /&gt;
* Gateway: 193.40.244.188&lt;br /&gt;
* DNS: 8.8.8.8&lt;br /&gt;
&lt;br /&gt;
That network is physically routed to 413-6-16 port in room 413.&lt;br /&gt;
&lt;br /&gt;
We have total of about 264GB of RAM and couple of terabytes of SSD storage:&lt;br /&gt;
&lt;br /&gt;
* Marek&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s (hosts 130-139)&lt;br /&gt;
* Madis&#039; box HP Proliant G5, 4x quadcore Opteron, 64GB RAM, 2 NIC-s (hosts 140-149)&lt;br /&gt;
* Erik&#039;s box Sun 32GB, 2x 256GB SSD (hosts 155-159)&lt;br /&gt;
* Lauri&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s, 4x 250G SSD (hosts 160-179)&lt;br /&gt;
* Frank&#039;s box DELL 16GB, 2x 256GB SSD, 6 NIC (hosts 180-185)&lt;br /&gt;
* Another Sun box with 24G of RAM, dying harddisks&lt;br /&gt;
* Reserved addresses 186-188&lt;br /&gt;
&lt;br /&gt;
NB! Replace BIOS batteries; replace thermal paste&lt;br /&gt;
&lt;br /&gt;
==Grading==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to do pick a topic from the services list below.&lt;br /&gt;
Send your SSH public key to Lauri and state which service you want to take care of.&lt;br /&gt;
&lt;br /&gt;
Collect 100p in total to pass the course, note that there are opportunities to collect much more points in total:&lt;br /&gt;
&lt;br /&gt;
* Get the service up and running (15p)&lt;br /&gt;
* Configure Let&#039;s Encrypt certificates for your service if applicable (15p)&lt;br /&gt;
* Add your service to monitoring at mon.momcorp.eu (15p)&lt;br /&gt;
* Enable log forwarding to log.momcorp.eu, if applicable configure auditing for your service (15p)&lt;br /&gt;
* Configure your service to send e-mails (mail.momcorp.eu) if applicable (15p)&lt;br /&gt;
* Keep the service up and running through the semester (up to -20p)&lt;br /&gt;
* Keep the bad guys out from your servers (up to -30p)&lt;br /&gt;
* Have a disaster recovery plan (up to -20p)&lt;br /&gt;
* Configure layer3 firewall (15p)&lt;br /&gt;
* Configure application firewall(s) if applicable&lt;br /&gt;
* Configure your laptop to connect to intranet using OpenVPN and IPSec (15p)&lt;br /&gt;
* Configure your mobile device to connect to intranet using OpenVPN or IPSec (15p)&lt;br /&gt;
* Configure your service to use authentication from AD (20p)&lt;br /&gt;
&lt;br /&gt;
We will start with services facing the public internet, see what&#039;s the worst that can happen in that case and later migrate some services to intranet only. Some services will retain connectivity to public internet due to their nature (eg OwnCloud, mailserver) and some services will be available only in the intranet (eg fileserver)&lt;br /&gt;
&lt;br /&gt;
==Services==&lt;br /&gt;
&lt;br /&gt;
To support our virtual company in everyday business we need to provide them with a variety of services:&lt;br /&gt;
&lt;br /&gt;
* www.momcorp.eu - Install webserver/load balancer and create a homepage for the company and link to remaining sites. Olusiji&lt;br /&gt;
* shop.momcorp.eu - Install Magento and add some fictive products like dark matter and neutron star. Sander&lt;br /&gt;
* wiki.momcorp.eu - Install MediaWiki, later integrate with AD. Peep&lt;br /&gt;
* blog.momcorp.eu - Install WordPress, later integrate with AD. Steven&lt;br /&gt;
* chat.momcorp.eu - Install IRC server, provide  multiple channels for developers. Install some web based software for customer helldesk. Ardi&lt;br /&gt;
* ns1.momcorp.eu - Primary Bind9 installation, later also add DNSSEC. Erik J&lt;br /&gt;
* ns2.momcorp.eu - Secondary Bind9 installation in another physical host. ???&lt;br /&gt;
* git.momcorp.eu - Gogs installation. Farhan&lt;br /&gt;
* mon.momcorp.eu - Nagios monitoring. Nika&lt;br /&gt;
* mail.momcorp.eu - Mailserver with Postfix (postfw, greylisting, dkim, spf, setup secondary mx), later with AD integration if exchange won&#039;t be used. Andris&lt;br /&gt;
* ca.momcorp.eu - Java servlet container, EJBCA installation for certificate management. Masaki&lt;br /&gt;
* nas.momcorp.eu - Samba fileserver. Hindrek&lt;br /&gt;
* log.momcorp.eu - Graylog or similar for central logging. Kaspar, Sten-Erik&lt;br /&gt;
* vpn.momcorp.eu - OpenVPN gateway. Moira&lt;br /&gt;
* cs.momcorp.eu - Teamspeak and/or gaming server for entertainment. Christopher&lt;br /&gt;
&lt;br /&gt;
Additionally for each physical box listed under Hardware we could set up:&lt;br /&gt;
&lt;br /&gt;
* Person responsible for the hypervisor on that box&lt;br /&gt;
* Virtual machine with router OS - Mikrotik RouterOS, Vyatta, pfsense or just vanilla Debian with shell scripts&lt;br /&gt;
&lt;br /&gt;
Other topics:&lt;br /&gt;
&lt;br /&gt;
* Mikus - Remote management: Puppet master, DSC, postfix with kerberos (and AD?)&lt;br /&gt;
* Strongswan gateway&lt;br /&gt;
* OpenVPN gateway, later AD integration&lt;br /&gt;
* Exchange&lt;br /&gt;
* failover/high availability (heartbeat)&lt;br /&gt;
* db clusters/shards/replication (mysql/mariadb)&lt;br /&gt;
* clustered filesystems/servers (clvm, corosync, fenced, gfs)&lt;br /&gt;
* web caches (varnish, squid, nginx)&lt;br /&gt;
* load balancing (haproxy, nginx, simple roundrobin)&lt;br /&gt;
&lt;br /&gt;
==Lectures==&lt;br /&gt;
&lt;br /&gt;
Following lectures are planned:&lt;br /&gt;
&lt;br /&gt;
* 7. sept - Intro, virtualization, containers etc. Relevant story [https://lauri.xn--vsandi-pxa.com/lan/virtualization.html here]&lt;br /&gt;
* 14. sept - Network topology, bridges, tagging, trunking, subnetting, LAN, WAN&lt;br /&gt;
* 21. sept - iptables, ebtables, packet forwarding, DNAT, SNAT, routing tables, empheral ports, listening ports, slides [https://docs.google.com/presentation/d/1XMISOg88BJ0Dy8o3r8ZL9cxFT0oZZKDqPZ2EaWJRqFQ/edit?usp=sharing here]&lt;br /&gt;
* 28. sept - X.509 certificates, certificate authority, TLS, symmetric, asymmetric, keyexchange, Let&#039;s Encrypt, relevant slides [https://docs.google.com/presentation/d/1kqTyhhUu5CfwODmOTIC7odhlYfeEeJALTd4RX7XhPLE/edit?usp=sharing here]&lt;br /&gt;
&lt;br /&gt;
Order to be determined:&lt;br /&gt;
&lt;br /&gt;
* OpenVPN&lt;br /&gt;
* IPSec&lt;br /&gt;
* TBD, there are a lot of topics to discuss&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Firewall rules==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;iptables&amp;quot;&amp;gt;&lt;br /&gt;
*raw&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*mangle&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:INPUT ACCEPT [0:0]&lt;br /&gt;
:FORWARD ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
:POSTROUTING ACCEPT [0:0]&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*nat&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:INPUT ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
:POSTROUTING ACCEPT [0:0]&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*filter&lt;br /&gt;
:INPUT DROP [0:0]&lt;br /&gt;
:FORWARD DROP [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment &amp;quot;Allow returning packets&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -i eth1 -m comment --comment &amp;quot;Allow traffic from LAN&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -s 127.0.0.0/8 -i lo -m comment --comment &amp;quot;Allow loopback&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p icmp -m icmp --icmp-type 8 -m comment --comment &amp;quot;Allow ping&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p tcp -m tcp --dport 22 -m comment --comment &amp;quot;Allow SSH&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p tcp -m tcp --dport 5666 -m comment --comment &amp;quot;Allow Nika\&#039;s Monitoring&amp;quot; -j ACCEPT&lt;br /&gt;
-A FORWARD -i tun0 -eth1 -m comment --comment &amp;quot;Allow from VPN to LAN&amp;quot; -j ACCEPT&lt;br /&gt;
COMMIT&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=124773</id>
		<title>Category:I802 Firewalls and VPN IPSec (2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=124773"/>
		<updated>2017-10-19T14:25:23Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Firewalls and VPN/IPSec=&lt;br /&gt;
&lt;br /&gt;
==General information==&lt;br /&gt;
&lt;br /&gt;
ECTS: 4&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
To register to this course send your SSH public key to Lauri and state which service you want to configure.&lt;br /&gt;
&lt;br /&gt;
Grading bot is at http://193.40.244.178/static/bot.html&lt;br /&gt;
&lt;br /&gt;
==Scenario==&lt;br /&gt;
&lt;br /&gt;
In this course we will attempt to set up a network similar to a corporate network with multiple offices, eg http://docplayer.it/docs-images/20/596222/images/25-0.png&lt;br /&gt;
&lt;br /&gt;
Our virtual company&#039;s story is based on [http://futurama.wikia.com/wiki/MomCorp Mom&#039;s Friendly Robot Company].&lt;br /&gt;
&lt;br /&gt;
We will use VPN software to connect subnets to each other and we will use VPN software to connect our personal computers to the intranet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Hardware==&lt;br /&gt;
&lt;br /&gt;
School&#039;s infra provides with public subnet for 62 hosts:&lt;br /&gt;
&lt;br /&gt;
* IPv4 address: 193.40.244.129-188&lt;br /&gt;
* Subnet: /26&lt;br /&gt;
* Gateway: 193.40.244.188&lt;br /&gt;
* DNS: 8.8.8.8&lt;br /&gt;
&lt;br /&gt;
That network is physically routed to 413-6-16 port in room 413.&lt;br /&gt;
&lt;br /&gt;
We have total of about 264GB of RAM and couple of terabytes of SSD storage:&lt;br /&gt;
&lt;br /&gt;
* Marek&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s (hosts 130-139)&lt;br /&gt;
* Madis&#039; box HP Proliant G5, 4x quadcore Opteron, 64GB RAM, 2 NIC-s (hosts 140-149)&lt;br /&gt;
* Erik&#039;s box Sun 32GB, 2x 256GB SSD (hosts 155-159)&lt;br /&gt;
* Lauri&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s, 4x 250G SSD (hosts 160-179)&lt;br /&gt;
* Frank&#039;s box DELL 16GB, 2x 256GB SSD, 6 NIC (hosts 180-185)&lt;br /&gt;
* Another Sun box with 24G of RAM, dying harddisks&lt;br /&gt;
* Reserved addresses 186-188&lt;br /&gt;
&lt;br /&gt;
NB! Replace BIOS batteries; replace thermal paste&lt;br /&gt;
&lt;br /&gt;
==Grading==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to do pick a topic from the services list below.&lt;br /&gt;
Send your SSH public key to Lauri and state which service you want to take care of.&lt;br /&gt;
&lt;br /&gt;
Collect 100p in total to pass the course, note that there are opportunities to collect much more points in total:&lt;br /&gt;
&lt;br /&gt;
* Get the service up and running (15p)&lt;br /&gt;
* Configure Let&#039;s Encrypt certificates for your service if applicable (15p)&lt;br /&gt;
* Add your service to monitoring at mon.momcorp.eu (15p)&lt;br /&gt;
* Enable log forwarding to log.momcorp.eu, if applicable configure auditing for your service (15p)&lt;br /&gt;
* Configure your service to send e-mails (mail.momcorp.eu) if applicable (15p)&lt;br /&gt;
* Keep the service up and running through the semester (up to -20p)&lt;br /&gt;
* Keep the bad guys out from your servers (up to -30p)&lt;br /&gt;
* Have a disaster recovery plan (up to -20p)&lt;br /&gt;
* Configure layer3 firewall (15p)&lt;br /&gt;
* Configure application firewall(s) if applicable&lt;br /&gt;
* Configure your laptop to connect to intranet using OpenVPN and IPSec (15p)&lt;br /&gt;
* Configure your mobile device to connect to intranet using OpenVPN or IPSec (15p)&lt;br /&gt;
* Configure your service to use authentication from AD (20p)&lt;br /&gt;
&lt;br /&gt;
We will start with services facing the public internet, see what&#039;s the worst that can happen in that case and later migrate some services to intranet only. Some services will retain connectivity to public internet due to their nature (eg OwnCloud, mailserver) and some services will be available only in the intranet (eg fileserver)&lt;br /&gt;
&lt;br /&gt;
==Services==&lt;br /&gt;
&lt;br /&gt;
To support our virtual company in everyday business we need to provide them with a variety of services:&lt;br /&gt;
&lt;br /&gt;
* www.momcorp.eu - Install webserver/load balancer and create a homepage for the company and link to remaining sites. Olusiji&lt;br /&gt;
* shop.momcorp.eu - Install Magento and add some fictive products like dark matter and neutron star. Sander&lt;br /&gt;
* wiki.momcorp.eu - Install MediaWiki, later integrate with AD. Peep&lt;br /&gt;
* blog.momcorp.eu - Install WordPress, later integrate with AD. Steven&lt;br /&gt;
* chat.momcorp.eu - Install IRC server, provide  multiple channels for developers. Install some web based software for customer helldesk. Ardi&lt;br /&gt;
* ns1.momcorp.eu - Primary Bind9 installation, later also add DNSSEC. Erik J&lt;br /&gt;
* ns2.momcorp.eu - Secondary Bind9 installation in another physical host. ???&lt;br /&gt;
* git.momcorp.eu - Gogs installation. Farhan&lt;br /&gt;
* mon.momcorp.eu - Nagios monitoring. Nika&lt;br /&gt;
* mail.momcorp.eu - Mailserver with Postfix (postfw, greylisting, dkim, spf, setup secondary mx), later with AD integration if exchange won&#039;t be used. Andris&lt;br /&gt;
* ca.momcorp.eu - Java servlet container, EJBCA installation for certificate management. Masaki&lt;br /&gt;
* nas.momcorp.eu - Samba fileserver. Hindrek&lt;br /&gt;
* log.momcorp.eu - Graylog or similar for central logging. Kaspar, Sten-Erik&lt;br /&gt;
* vpn.momcorp.eu - OpenVPN gateway. Moira&lt;br /&gt;
* cs.momcorp.eu - Teamspeak and/or gaming server for entertainment. Christopher&lt;br /&gt;
&lt;br /&gt;
Additionally for each physical box listed under Hardware we could set up:&lt;br /&gt;
&lt;br /&gt;
* Person responsible for the hypervisor on that box&lt;br /&gt;
* Virtual machine with router OS - Mikrotik RouterOS, Vyatta, pfsense or just vanilla Debian with shell scripts&lt;br /&gt;
&lt;br /&gt;
Other topics:&lt;br /&gt;
&lt;br /&gt;
* Mikus - Remote management: Puppet master, DSC, postfix with kerberos (and AD?)&lt;br /&gt;
* Strongswan gateway&lt;br /&gt;
* OpenVPN gateway, later AD integration&lt;br /&gt;
* Exchange&lt;br /&gt;
* failover/high availability (heartbeat)&lt;br /&gt;
* db clusters/shards/replication (mysql/mariadb)&lt;br /&gt;
* clustered filesystems/servers (clvm, corosync, fenced, gfs)&lt;br /&gt;
* web caches (varnish, squid, nginx)&lt;br /&gt;
* load balancing (haproxy, nginx, simple roundrobin)&lt;br /&gt;
&lt;br /&gt;
==Lectures==&lt;br /&gt;
&lt;br /&gt;
Following lectures are planned:&lt;br /&gt;
&lt;br /&gt;
* 7. sept - Intro, virtualization, containers etc. Relevant story [https://lauri.xn--vsandi-pxa.com/lan/virtualization.html here]&lt;br /&gt;
* 14. sept - Network topology, bridges, tagging, trunking, subnetting, LAN, WAN&lt;br /&gt;
* 21. sept - iptables, ebtables, packet forwarding, DNAT, SNAT, routing tables, empheral ports, listening ports, slides [https://docs.google.com/presentation/d/1XMISOg88BJ0Dy8o3r8ZL9cxFT0oZZKDqPZ2EaWJRqFQ/edit?usp=sharing here]&lt;br /&gt;
* 28. sept - X.509 certificates, certificate authority, TLS, symmetric, asymmetric, keyexchange, Let&#039;s Encrypt, relevant slides [https://docs.google.com/presentation/d/1kqTyhhUu5CfwODmOTIC7odhlYfeEeJALTd4RX7XhPLE/edit?usp=sharing here]&lt;br /&gt;
&lt;br /&gt;
Order to be determined:&lt;br /&gt;
&lt;br /&gt;
* OpenVPN&lt;br /&gt;
* IPSec&lt;br /&gt;
* TBD, there are a lot of topics to discuss&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Firewall rules==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;iptables&amp;quot;&amp;gt;&lt;br /&gt;
*raw&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*mangle&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:INPUT ACCEPT [1227947:503510401]&lt;br /&gt;
:FORWARD ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [570735:77510916]&lt;br /&gt;
:POSTROUTING ACCEPT [570741:77511294]&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*nat&lt;br /&gt;
:PREROUTING ACCEPT [0:0]&lt;br /&gt;
:INPUT ACCEPT [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
:POSTROUTING ACCEPT [0:0]&lt;br /&gt;
COMMIT&lt;br /&gt;
&lt;br /&gt;
*filter&lt;br /&gt;
:INPUT DROP [0:0]&lt;br /&gt;
:FORWARD DROP [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment &amp;quot;Allow returning packets&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -i eth1 -m comment --comment &amp;quot;Allow traffic from LAN&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -s 127.0.0.0/8 -i lo -m comment --comment &amp;quot;Allow loopback&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p icmp -m icmp --icmp-type 8 -m comment --comment &amp;quot;Allow ping&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p tcp -m tcp --dport 22 -m comment --comment &amp;quot;Allow SSH&amp;quot; -j ACCEPT&lt;br /&gt;
-A INPUT -p tcp -m tcp --dport 5666 -m comment --comment &amp;quot;Allow Nika\&#039;s Monitoring&amp;quot; -j ACCEPT&lt;br /&gt;
-A FORWARD -i tun0 -eth1 -m comment --comment &amp;quot;Allow from VPN to LAN&amp;quot; -j ACCEPT&lt;br /&gt;
COMMIT&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=124665</id>
		<title>Category:I802 Firewalls and VPN IPSec (2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=124665"/>
		<updated>2017-10-12T12:28:52Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* General information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Firewalls and VPN/IPSec=&lt;br /&gt;
&lt;br /&gt;
==General information==&lt;br /&gt;
&lt;br /&gt;
ECTS: 4&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
To register to this course send your SSH public key to Lauri and state which service you want to configure.&lt;br /&gt;
&lt;br /&gt;
Grading bot is at http://193.40.244.178/static/bot.html&lt;br /&gt;
&lt;br /&gt;
==Scenario==&lt;br /&gt;
&lt;br /&gt;
In this course we will attempt to set up a network similar to a corporate network with multiple offices, eg http://docplayer.it/docs-images/20/596222/images/25-0.png&lt;br /&gt;
&lt;br /&gt;
Our virtual company&#039;s story is based on [http://futurama.wikia.com/wiki/MomCorp Mom&#039;s Friendly Robot Company].&lt;br /&gt;
&lt;br /&gt;
We will use VPN software to connect subnets to each other and we will use VPN software to connect our personal computers to the intranet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Hardware==&lt;br /&gt;
&lt;br /&gt;
School&#039;s infra provides with public subnet for 62 hosts:&lt;br /&gt;
&lt;br /&gt;
* IPv4 address: 193.40.244.129-188&lt;br /&gt;
* Subnet: /26&lt;br /&gt;
* Gateway: 193.40.244.188&lt;br /&gt;
* DNS: 8.8.8.8&lt;br /&gt;
&lt;br /&gt;
That network is physically routed to 413-6-16 port in room 413.&lt;br /&gt;
&lt;br /&gt;
We have total of about 264GB of RAM and couple of terabytes of SSD storage:&lt;br /&gt;
&lt;br /&gt;
* Marek&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s (hosts 130-139)&lt;br /&gt;
* Madis&#039; box HP Proliant G5, 4x quadcore Opteron, 64GB RAM, 2 NIC-s (hosts 140-149)&lt;br /&gt;
* Erik&#039;s box Sun 32GB, 2x 256GB SSD (hosts 155-159)&lt;br /&gt;
* Lauri&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s, 4x 250G SSD (hosts 160-179)&lt;br /&gt;
* Frank&#039;s box DELL 16GB, 2x 256GB SSD, 6 NIC (hosts 180-185)&lt;br /&gt;
* Another Sun box with 24G of RAM, dying harddisks&lt;br /&gt;
* Reserved addresses 186-188&lt;br /&gt;
&lt;br /&gt;
NB! Replace BIOS batteries; replace thermal paste&lt;br /&gt;
&lt;br /&gt;
==Grading==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to do pick a topic from the services list below.&lt;br /&gt;
Send your SSH public key to Lauri and state which service you want to take care of.&lt;br /&gt;
&lt;br /&gt;
Collect 100p in total to pass the course, note that there are opportunities to collect much more points in total:&lt;br /&gt;
&lt;br /&gt;
* Get the service up and running (15p)&lt;br /&gt;
* Configure Let&#039;s Encrypt certificates for your service if applicable (15p)&lt;br /&gt;
* Add your service to monitoring at mon.momcorp.eu (15p)&lt;br /&gt;
* Enable log forwarding to log.momcorp.eu, if applicable configure auditing for your service (15p)&lt;br /&gt;
* Configure your service to send e-mails (mail.momcorp.eu) if applicable (15p)&lt;br /&gt;
* Keep the service up and running through the semester (up to -20p)&lt;br /&gt;
* Keep the bad guys out from your servers (up to -30p)&lt;br /&gt;
* Have a disaster recovery plan (up to -20p)&lt;br /&gt;
* Configure layer3 firewall (15p)&lt;br /&gt;
* Configure application firewall(s) if applicable&lt;br /&gt;
* Configure your laptop to connect to intranet using OpenVPN and IPSec (15p)&lt;br /&gt;
* Configure your mobile device to connect to intranet using OpenVPN or IPSec (15p)&lt;br /&gt;
* Configure your service to use authentication from AD (20p)&lt;br /&gt;
&lt;br /&gt;
We will start with services facing the public internet, see what&#039;s the worst that can happen in that case and later migrate some services to intranet only. Some services will retain connectivity to public internet due to their nature (eg OwnCloud, mailserver) and some services will be available only in the intranet (eg fileserver)&lt;br /&gt;
&lt;br /&gt;
==Services==&lt;br /&gt;
&lt;br /&gt;
To support our virtual company in everyday business we need to provide them with a variety of services:&lt;br /&gt;
&lt;br /&gt;
* www.momcorp.eu - Install webserver/load balancer and create a homepage for the company and link to remaining sites. Olusiji&lt;br /&gt;
* shop.momcorp.eu - Install Magento and add some fictive products like dark matter and neutron star. Sander&lt;br /&gt;
* wiki.momcorp.eu - Install MediaWiki, later integrate with AD. Peep&lt;br /&gt;
* blog.momcorp.eu - Install WordPress, later integrate with AD. Steven&lt;br /&gt;
* chat.momcorp.eu - Install IRC server, provide  multiple channels for developers. Install some web based software for customer helldesk. Ardi&lt;br /&gt;
* ns1.momcorp.eu - Primary Bind9 installation, later also add DNSSEC. Erik J&lt;br /&gt;
* ns2.momcorp.eu - Secondary Bind9 installation in another physical host. ???&lt;br /&gt;
* git.momcorp.eu - Gogs installation. Farhan&lt;br /&gt;
* mon.momcorp.eu - Nagios monitoring. Nika&lt;br /&gt;
* mail.momcorp.eu - Mailserver with Postfix (postfw, greylisting, dkim, spf, setup secondary mx), later with AD integration if exchange won&#039;t be used. Andris&lt;br /&gt;
* ca.momcorp.eu - Java servlet container, EJBCA installation for certificate management. Masaki&lt;br /&gt;
* nas.momcorp.eu - Samba fileserver. Hindrek&lt;br /&gt;
* log.momcorp.eu - Graylog or similar for central logging. Kaspar, Sten-Erik&lt;br /&gt;
* vpn.momcorp.eu - OpenVPN gateway. Moira&lt;br /&gt;
* cs.momcorp.eu - Teamspeak and/or gaming server for entertainment. Christopher&lt;br /&gt;
&lt;br /&gt;
Additionally for each physical box listed under Hardware we could set up:&lt;br /&gt;
&lt;br /&gt;
* Person responsible for the hypervisor on that box&lt;br /&gt;
* Virtual machine with router OS - Mikrotik RouterOS, Vyatta, pfsense or just vanilla Debian with shell scripts&lt;br /&gt;
&lt;br /&gt;
Other topics:&lt;br /&gt;
&lt;br /&gt;
* Mikus - Remote management: Puppet master, DSC, postfix with kerberos (and AD?)&lt;br /&gt;
* Strongswan gateway&lt;br /&gt;
* OpenVPN gateway, later AD integration&lt;br /&gt;
* Exchange&lt;br /&gt;
* failover/high availability (heartbeat)&lt;br /&gt;
* db clusters/shards/replication (mysql/mariadb)&lt;br /&gt;
* clustered filesystems/servers (clvm, corosync, fenced, gfs)&lt;br /&gt;
* web caches (varnish, squid, nginx)&lt;br /&gt;
* load balancing (haproxy, nginx, simple roundrobin)&lt;br /&gt;
&lt;br /&gt;
==Lectures==&lt;br /&gt;
&lt;br /&gt;
Following lectures are planned:&lt;br /&gt;
&lt;br /&gt;
* 7. sept - Intro, virtualization, containers etc. Relevant story [https://lauri.xn--vsandi-pxa.com/lan/virtualization.html here]&lt;br /&gt;
* 14. sept - Network topology, bridges, tagging, trunking, subnetting, LAN, WAN&lt;br /&gt;
* 21. sept - iptables, ebtables, packet forwarding, DNAT, SNAT, routing tables, empheral ports, listening ports, slides [https://docs.google.com/presentation/d/1XMISOg88BJ0Dy8o3r8ZL9cxFT0oZZKDqPZ2EaWJRqFQ/edit?usp=sharing here]&lt;br /&gt;
* 28. sept - X.509 certificates, certificate authority, TLS, symmetric, asymmetric, keyexchange, Let&#039;s Encrypt, relevant slides [https://docs.google.com/presentation/d/1kqTyhhUu5CfwODmOTIC7odhlYfeEeJALTd4RX7XhPLE/edit?usp=sharing here]&lt;br /&gt;
&lt;br /&gt;
Order to be determined:&lt;br /&gt;
&lt;br /&gt;
* OpenVPN&lt;br /&gt;
* IPSec&lt;br /&gt;
* TBD, there are a lot of topics to discuss&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=124575</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=124575"/>
		<updated>2017-10-10T09:01:33Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Assignment: Set up basic IoT scenario */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario=&lt;br /&gt;
&lt;br /&gt;
NB! This year ESP32 instead of Raspberry Pi, see instructions [https://lauri.xn--vsandi-pxa.com/2017/06/espressif.html here]&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (1p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (1p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (3p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (1p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (1p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=124506</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=124506"/>
		<updated>2017-10-03T06:00:07Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (1p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (1p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (3p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (1p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (1p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=124433</id>
		<title>Category:I802 Firewalls and VPN IPSec (2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=124433"/>
		<updated>2017-09-27T08:49:05Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Hardware */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Firewalls and VPN/IPSec=&lt;br /&gt;
&lt;br /&gt;
==General information==&lt;br /&gt;
&lt;br /&gt;
ECTS: 4&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
To register to this course send your SSH public key to Lauri and state which service you want to configure.&lt;br /&gt;
&lt;br /&gt;
==Scenario==&lt;br /&gt;
&lt;br /&gt;
In this course we will attempt to set up a network similar to a corporate network with multiple offices, eg http://docplayer.it/docs-images/20/596222/images/25-0.png&lt;br /&gt;
&lt;br /&gt;
Our virtual company&#039;s story is based on [http://futurama.wikia.com/wiki/MomCorp Mom&#039;s Friendly Robot Company].&lt;br /&gt;
&lt;br /&gt;
We will use VPN software to connect subnets to each other and we will use VPN software to connect our personal computers to the intranet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Hardware==&lt;br /&gt;
&lt;br /&gt;
School&#039;s infra provides with public subnet for 62 hosts:&lt;br /&gt;
&lt;br /&gt;
* IPv4 address: 193.40.244.129-188&lt;br /&gt;
* Subnet: /26&lt;br /&gt;
* Gateway: 193.40.244.188&lt;br /&gt;
* DNS: 8.8.8.8&lt;br /&gt;
&lt;br /&gt;
That network is physically routed to 413-6-16 port in room 413.&lt;br /&gt;
&lt;br /&gt;
We have total of about 264GB of RAM and couple of terabytes of SSD storage:&lt;br /&gt;
&lt;br /&gt;
* Marek&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s (hosts 130-139)&lt;br /&gt;
* Madis&#039; box HP Proliant G5, 4x quadcore Opteron, 64GB RAM, 2 NIC-s (hosts 140-149)&lt;br /&gt;
* Erik&#039;s box Sun 32GB, 2x 256GB SSD (hosts 155-159)&lt;br /&gt;
* Lauri&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s, 4x 250G SSD (hosts 160-179)&lt;br /&gt;
* Frank&#039;s box DELL 16GB, 2x 256GB SSD, 6 NIC (hosts 180-185)&lt;br /&gt;
* Another Sun box with 24G of RAM, dying harddisks&lt;br /&gt;
* Reserved addresses 186-188&lt;br /&gt;
&lt;br /&gt;
NB! Replace BIOS batteries; replace thermal paste&lt;br /&gt;
&lt;br /&gt;
==Grading==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to do pick a topic from the services list below.&lt;br /&gt;
Send your SSH public key to Lauri and state which service you want to take care of.&lt;br /&gt;
&lt;br /&gt;
Collect 100p in total to pass the course, note that there are opportunities to collect much more points in total:&lt;br /&gt;
&lt;br /&gt;
* Get the service up and running (15p)&lt;br /&gt;
* Configure Let&#039;s Encrypt certificates for your service if applicable (15p)&lt;br /&gt;
* Add your service to monitoring at mon.momcorp.eu (15p)&lt;br /&gt;
* Enable log forwarding to log.momcorp.eu, if applicable configure auditing for your service (15p)&lt;br /&gt;
* Configure your service to send e-mails (mail.momcorp.eu) if applicable (15p)&lt;br /&gt;
* Keep the service up and running through the semester (up to -20p)&lt;br /&gt;
* Keep the bad guys out from your servers (up to -30p)&lt;br /&gt;
* Have a disaster recovery plan (up to -20p)&lt;br /&gt;
* Configure layer3 firewall (15p)&lt;br /&gt;
* Configure application firewall(s) if applicable&lt;br /&gt;
* Configure your laptop to connect to intranet using OpenVPN and IPSec (15p)&lt;br /&gt;
* Configure your mobile device to connect to intranet using OpenVPN or IPSec (15p)&lt;br /&gt;
* Configure your service to use authentication from AD (20p)&lt;br /&gt;
&lt;br /&gt;
We will start with services facing the public internet, see what&#039;s the worst that can happen in that case and later migrate some services to intranet only. Some services will retain connectivity to public internet due to their nature (eg OwnCloud, mailserver) and some services will be available only in the intranet (eg fileserver)&lt;br /&gt;
&lt;br /&gt;
==Services==&lt;br /&gt;
&lt;br /&gt;
To support our virtual company in everyday business we need to provide them with a variety of services:&lt;br /&gt;
&lt;br /&gt;
* www.momcorp.eu - Install webserver/load balancer and create a homepage for the company and link to remaining sites. Olusiji&lt;br /&gt;
* shop.momcorp.eu - Install Magento and add some fictive products like dark matter and neutron star. Sander&lt;br /&gt;
* wiki.momcorp.eu - Install MediaWiki, later integrate with AD. Peep&lt;br /&gt;
* blog.momcorp.eu - Install WordPress, later integrate with AD. Steven&lt;br /&gt;
* chat.momcorp.eu - Install IRC server, provide  multiple channels for developers. Install some web based software for customer helldesk. Ardi&lt;br /&gt;
* ns1.momcorp.eu - Primary Bind9 installation, later also add DNSSEC. Erik J&lt;br /&gt;
* ns2.momcorp.eu - Secondary Bind9 installation in another physical host. ???&lt;br /&gt;
* git.momcorp.eu - Gogs installation. ???&lt;br /&gt;
* mon.momcorp.eu - Nagios monitoring. Nika&lt;br /&gt;
* mail.momcorp.eu - Mailserver with Postfix (postfw, greylisting, dkim, spf, setup secondary mx), later with AD integration if exchange won&#039;t be used. Andris&lt;br /&gt;
* ca.momcorp.eu - Java servlet container, EJBCA installation for certificate management. Masaki&lt;br /&gt;
* nas.momcorp.eu - Samba fileserver. Hindrek&lt;br /&gt;
* log.momcorp.eu - Graylog or similar for central logging. Kaspar, Sten-Erik&lt;br /&gt;
* vpn.momcorp.eu - OpenVPN gateway. Moira&lt;br /&gt;
* cs.momcorp.eu - Teamspeak and/or gaming server for entertainment. Christopher&lt;br /&gt;
&lt;br /&gt;
Additionally for each physical box listed under Hardware we could set up:&lt;br /&gt;
&lt;br /&gt;
* Person responsible for the hypervisor on that box&lt;br /&gt;
* Virtual machine with router OS - Mikrotik RouterOS, Vyatta, pfsense or just vanilla Debian with shell scripts&lt;br /&gt;
&lt;br /&gt;
Other topics:&lt;br /&gt;
&lt;br /&gt;
* Mikus - Remote management: Puppet master, DSC, postfix with kerberos (and AD?)&lt;br /&gt;
* Strongswan gateway&lt;br /&gt;
* OpenVPN gateway, later AD integration&lt;br /&gt;
* Exchange&lt;br /&gt;
* failover/high availability (heartbeat)&lt;br /&gt;
* db clusters/shards/replication (mysql/mariadb)&lt;br /&gt;
* clustered filesystems/servers (clvm, corosync, fenced, gfs)&lt;br /&gt;
* web caches (varnish, squid, nginx)&lt;br /&gt;
* load balancing (haproxy, nginx, simple roundrobin)&lt;br /&gt;
&lt;br /&gt;
==Lectures==&lt;br /&gt;
&lt;br /&gt;
Following lectures are planned:&lt;br /&gt;
&lt;br /&gt;
* 7. sept - Intro, virtualization, containers etc. Relevant story [https://lauri.xn--vsandi-pxa.com/lan/virtualization.html here]&lt;br /&gt;
* 14. sept - Network topology, bridges, tagging, trunking, subnetting, LAN, WAN&lt;br /&gt;
* 21. sept - iptables, ebtables, packet forwarding, DNAT, SNAT, routing tables, empheral ports, listening ports, slides [https://docs.google.com/presentation/d/1XMISOg88BJ0Dy8o3r8ZL9cxFT0oZZKDqPZ2EaWJRqFQ/edit?usp=sharing here]&lt;br /&gt;
* 28. sept - X.509 certificates, certificate authority, TLS, symmetric, asymmetric, keyexchange, Let&#039;s Encrypt, relevant slides [https://docs.google.com/presentation/d/1kqTyhhUu5CfwODmOTIC7odhlYfeEeJALTd4RX7XhPLE/edit?usp=sharing here]&lt;br /&gt;
&lt;br /&gt;
Order to be determined:&lt;br /&gt;
&lt;br /&gt;
* OpenVPN&lt;br /&gt;
* IPSec&lt;br /&gt;
* TBD, there are a lot of topics to discuss&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=124424</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=124424"/>
		<updated>2017-09-26T08:50:58Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Assignment: Investigating LAMP */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Credits: 5 points plus extra point for being extra thorough about interpreting what you see.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Points: 4 points&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Points: 4 points&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* Install [http://upload.itcollege.ee/iso/ubuntu-16.04.2-server-amd64.iso Ubuntu 16.04 server] in a virtual machine or use [http://upload.itcollege.ee/ova/lamp.ova prepared virtual appliance]&lt;br /&gt;
* Configure second network interface as Host-only adapter, this is already done in case of OVA&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Install webserver, MySQL server and PHP, this is already done in case of OVA. Usually you&#039;d do something like &amp;lt;code&amp;gt;apt install apache2 mysql-server php7.0 phpmyadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set up any of the web applications referenced above in &amp;lt;code&amp;gt;/var/www/html&amp;lt;/code&amp;gt;. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
Points: 4 points&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Points: 5&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (1p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (1p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (3p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (1p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (1p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=124423</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=124423"/>
		<updated>2017-09-26T06:23:40Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Credits: 5 points plus extra point for being extra thorough about interpreting what you see.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Points: 4 points&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Ubuntu server virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Points: 4 points&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* If you&#039;re using Ubuntu virtual machine approach, see [[Accessing a virtual machine via SSH connection]]&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Set up any of the web applications referenced above. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next lab, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Ubuntu box]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: If you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
Points: 4 points&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Points: 5&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (1p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (1p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (3p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (1p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (1p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=124328</id>
		<title>Category:I802 Firewalls and VPN IPSec (2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=124328"/>
		<updated>2017-09-21T12:59:43Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Lectures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Firewalls and VPN/IPSec=&lt;br /&gt;
&lt;br /&gt;
==General information==&lt;br /&gt;
&lt;br /&gt;
ECTS: 4&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
To register to this course send your SSH public key to Lauri and state which service you want to configure.&lt;br /&gt;
&lt;br /&gt;
==Scenario==&lt;br /&gt;
&lt;br /&gt;
In this course we will attempt to set up a network similar to a corporate network with multiple offices, eg http://docplayer.it/docs-images/20/596222/images/25-0.png&lt;br /&gt;
&lt;br /&gt;
Our virtual company&#039;s story is based on [http://futurama.wikia.com/wiki/MomCorp Mom&#039;s Friendly Robot Company].&lt;br /&gt;
&lt;br /&gt;
We will use VPN software to connect subnets to each other and we will use VPN software to connect our personal computers to the intranet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Hardware==&lt;br /&gt;
&lt;br /&gt;
School&#039;s infra provides with public subnet for 62 hosts:&lt;br /&gt;
&lt;br /&gt;
* IPv4 address: 193.40.244.129-188&lt;br /&gt;
* Subnet: /26&lt;br /&gt;
* Gateway: 193.40.244.188&lt;br /&gt;
* DNS: 8.8.8.8&lt;br /&gt;
&lt;br /&gt;
That network is physically routed to 413-6-16 port in room 413.&lt;br /&gt;
&lt;br /&gt;
We have total of about 264GB of RAM and couple of terabytes of SSD storage:&lt;br /&gt;
&lt;br /&gt;
* Marek&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s (hosts 130-139)&lt;br /&gt;
* Madis&#039; box HP Proliant G5, 4x quadcore Opteron, 64GB RAM, 2 NIC-s (hosts 140-149)&lt;br /&gt;
* Erik&#039;s box Sun 32GB, 2x 256GB SSD (hosts 155-159)&lt;br /&gt;
* Lauri&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s, 4x 250G SSD (hosts 160-179)&lt;br /&gt;
* Frank&#039;s box DELL 16GB, 2x 256GB SSD, 6 NIC (hosts 180-185)&lt;br /&gt;
* Another Sun box with 24G of RAM, dying harddisks&lt;br /&gt;
&lt;br /&gt;
NB! Replace BIOS batteries; replace thermal paste&lt;br /&gt;
&lt;br /&gt;
==Grading==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to do pick a topic from the services list below.&lt;br /&gt;
Send your SSH public key to Lauri and state which service you want to take care of.&lt;br /&gt;
&lt;br /&gt;
Collect 100p in total to pass the course, note that there are opportunities to collect much more points in total:&lt;br /&gt;
&lt;br /&gt;
* Get the service up and running (15p)&lt;br /&gt;
* Configure Let&#039;s Encrypt certificates for your service if applicable (15p)&lt;br /&gt;
* Add your service to monitoring at mon.momcorp.eu (15p)&lt;br /&gt;
* Enable log forwarding to log.momcorp.eu, if applicable configure auditing for your service (15p)&lt;br /&gt;
* Configure your service to send e-mails (mail.momcorp.eu) if applicable (15p)&lt;br /&gt;
* Keep the service up and running through the semester (up to -20p)&lt;br /&gt;
* Keep the bad guys out from your servers (up to -30p)&lt;br /&gt;
* Have a disaster recovery plan (up to -20p)&lt;br /&gt;
* Configure layer3 firewall (15p)&lt;br /&gt;
* Configure application firewall(s) if applicable&lt;br /&gt;
* Configure your laptop to connect to intranet using OpenVPN and IPSec (15p)&lt;br /&gt;
* Configure your mobile device to connect to intranet using OpenVPN or IPSec (15p)&lt;br /&gt;
* Configure your service to use authentication from AD (20p)&lt;br /&gt;
&lt;br /&gt;
We will start with services facing the public internet, see what&#039;s the worst that can happen in that case and later migrate some services to intranet only. Some services will retain connectivity to public internet due to their nature (eg OwnCloud, mailserver) and some services will be available only in the intranet (eg fileserver)&lt;br /&gt;
&lt;br /&gt;
==Services==&lt;br /&gt;
&lt;br /&gt;
To support our virtual company in everyday business we need to provide them with a variety of services:&lt;br /&gt;
&lt;br /&gt;
* www.momcorp.eu - Install webserver/load balancer and create a homepage for the company and link to remaining sites. Olusiji&lt;br /&gt;
* shop.momcorp.eu - Install Magento and add some fictive products like dark matter and neutron star. Sander&lt;br /&gt;
* wiki.momcorp.eu - Install MediaWiki, later integrate with AD. Peep&lt;br /&gt;
* blog.momcorp.eu - Install WordPress, later integrate with AD. Steven&lt;br /&gt;
* chat.momcorp.eu - Install IRC server, provide  multiple channels for developers. Install some web based software for customer helldesk. Ardi&lt;br /&gt;
* ns1.momcorp.eu - Primary Bind9 installation, later also add DNSSEC. Erik J&lt;br /&gt;
* ns2.momcorp.eu - Secondary Bind9 installation in another physical host. ???&lt;br /&gt;
* git.momcorp.eu - Gogs installation. ???&lt;br /&gt;
* mon.momcorp.eu - Nagios monitoring. Nika&lt;br /&gt;
* mail.momcorp.eu - Mailserver with Postfix (postfw, greylisting, dkim, spf, setup secondary mx), later with AD integration if exchange won&#039;t be used. Andris&lt;br /&gt;
* ca.momcorp.eu - Java servlet container, EJBCA installation for certificate management. Masaki&lt;br /&gt;
* nas.momcorp.eu - Samba fileserver. Hindrek&lt;br /&gt;
* log.momcorp.eu - Graylog or similar for central logging. Kaspar, Sten-Erik&lt;br /&gt;
* vpn.momcorp.eu - OpenVPN gateway. Moira&lt;br /&gt;
* cs.momcorp.eu - Teamspeak and/or gaming server for entertainment. Christopher&lt;br /&gt;
&lt;br /&gt;
Additionally for each physical box listed under Hardware we could set up:&lt;br /&gt;
&lt;br /&gt;
* Person responsible for the hypervisor on that box&lt;br /&gt;
* Virtual machine with router OS - Mikrotik RouterOS, Vyatta, pfsense or just vanilla Debian with shell scripts&lt;br /&gt;
&lt;br /&gt;
Other topics:&lt;br /&gt;
&lt;br /&gt;
* Mikus - Remote management: Puppet master, DSC, postfix with kerberos (and AD?)&lt;br /&gt;
* Strongswan gateway&lt;br /&gt;
* OpenVPN gateway, later AD integration&lt;br /&gt;
* Exchange&lt;br /&gt;
* failover/high availability (heartbeat)&lt;br /&gt;
* db clusters/shards/replication (mysql/mariadb)&lt;br /&gt;
* clustered filesystems/servers (clvm, corosync, fenced, gfs)&lt;br /&gt;
* web caches (varnish, squid, nginx)&lt;br /&gt;
* load balancing (haproxy, nginx, simple roundrobin)&lt;br /&gt;
&lt;br /&gt;
==Lectures==&lt;br /&gt;
&lt;br /&gt;
Following lectures are planned:&lt;br /&gt;
&lt;br /&gt;
* 7. sept - Intro, virtualization, containers etc. Relevant story [https://lauri.xn--vsandi-pxa.com/lan/virtualization.html here]&lt;br /&gt;
* 14. sept - Network topology, bridges, tagging, trunking, subnetting, LAN, WAN&lt;br /&gt;
* 21. sept - iptables, ebtables, packet forwarding, DNAT, SNAT, routing tables, empheral ports, listening ports, slides [https://docs.google.com/presentation/d/1XMISOg88BJ0Dy8o3r8ZL9cxFT0oZZKDqPZ2EaWJRqFQ/edit?usp=sharing here]&lt;br /&gt;
* 28. sept - X.509 certificates, certificate authority, TLS, symmetric, asymmetric, keyexchange, Let&#039;s Encrypt, relevant slides [https://docs.google.com/presentation/d/1kqTyhhUu5CfwODmOTIC7odhlYfeEeJALTd4RX7XhPLE/edit?usp=sharing here]&lt;br /&gt;
&lt;br /&gt;
Order to be determined:&lt;br /&gt;
&lt;br /&gt;
* OpenVPN&lt;br /&gt;
* IPSec&lt;br /&gt;
* TBD, there are a lot of topics to discuss&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=124311</id>
		<title>Category:I802 Firewalls and VPN IPSec (2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=124311"/>
		<updated>2017-09-20T07:33:55Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Firewalls and VPN/IPSec=&lt;br /&gt;
&lt;br /&gt;
==General information==&lt;br /&gt;
&lt;br /&gt;
ECTS: 4&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
To register to this course send your SSH public key to Lauri and state which service you want to configure.&lt;br /&gt;
&lt;br /&gt;
==Scenario==&lt;br /&gt;
&lt;br /&gt;
In this course we will attempt to set up a network similar to a corporate network with multiple offices, eg http://docplayer.it/docs-images/20/596222/images/25-0.png&lt;br /&gt;
&lt;br /&gt;
Our virtual company&#039;s story is based on [http://futurama.wikia.com/wiki/MomCorp Mom&#039;s Friendly Robot Company].&lt;br /&gt;
&lt;br /&gt;
We will use VPN software to connect subnets to each other and we will use VPN software to connect our personal computers to the intranet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Hardware==&lt;br /&gt;
&lt;br /&gt;
School&#039;s infra provides with public subnet for 62 hosts:&lt;br /&gt;
&lt;br /&gt;
* IPv4 address: 193.40.244.129-188&lt;br /&gt;
* Subnet: /26&lt;br /&gt;
* Gateway: 193.40.244.188&lt;br /&gt;
* DNS: 8.8.8.8&lt;br /&gt;
&lt;br /&gt;
That network is physically routed to 413-6-16 port in room 413.&lt;br /&gt;
&lt;br /&gt;
We have total of about 264GB of RAM and couple of terabytes of SSD storage:&lt;br /&gt;
&lt;br /&gt;
* Marek&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s (hosts 130-139)&lt;br /&gt;
* Madis&#039; box HP Proliant G5, 4x quadcore Opteron, 64GB RAM, 2 NIC-s (hosts 140-149)&lt;br /&gt;
* Erik&#039;s box Sun 32GB, 2x 256GB SSD (hosts 155-159)&lt;br /&gt;
* Lauri&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s, 4x 250G SSD (hosts 160-179)&lt;br /&gt;
* Frank&#039;s box DELL 16GB, 2x 256GB SSD, 6 NIC (hosts 180-185)&lt;br /&gt;
* Another Sun box with 24G of RAM, dying harddisks&lt;br /&gt;
&lt;br /&gt;
NB! Replace BIOS batteries; replace thermal paste&lt;br /&gt;
&lt;br /&gt;
==Grading==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to do pick a topic from the services list below.&lt;br /&gt;
Send your SSH public key to Lauri and state which service you want to take care of.&lt;br /&gt;
&lt;br /&gt;
Collect 100p in total to pass the course, note that there are opportunities to collect much more points in total:&lt;br /&gt;
&lt;br /&gt;
* Get the service up and running (15p)&lt;br /&gt;
* Configure Let&#039;s Encrypt certificates for your service if applicable (15p)&lt;br /&gt;
* Add your service to monitoring at mon.momcorp.eu (15p)&lt;br /&gt;
* Enable log forwarding to log.momcorp.eu, if applicable configure auditing for your service (15p)&lt;br /&gt;
* Configure your service to send e-mails (mail.momcorp.eu) if applicable (15p)&lt;br /&gt;
* Keep the service up and running through the semester (up to -20p)&lt;br /&gt;
* Keep the bad guys out from your servers (up to -30p)&lt;br /&gt;
* Have a disaster recovery plan (up to -20p)&lt;br /&gt;
* Configure layer3 firewall (15p)&lt;br /&gt;
* Configure application firewall(s) if applicable&lt;br /&gt;
* Configure your laptop to connect to intranet using OpenVPN and IPSec (15p)&lt;br /&gt;
* Configure your mobile device to connect to intranet using OpenVPN or IPSec (15p)&lt;br /&gt;
* Configure your service to use authentication from AD (20p)&lt;br /&gt;
&lt;br /&gt;
We will start with services facing the public internet, see what&#039;s the worst that can happen in that case and later migrate some services to intranet only. Some services will retain connectivity to public internet due to their nature (eg OwnCloud, mailserver) and some services will be available only in the intranet (eg fileserver)&lt;br /&gt;
&lt;br /&gt;
==Services==&lt;br /&gt;
&lt;br /&gt;
To support our virtual company in everyday business we need to provide them with a variety of services:&lt;br /&gt;
&lt;br /&gt;
* www.momcorp.eu - Install webserver/load balancer and create a homepage for the company and link to remaining sites. Olusiji&lt;br /&gt;
* shop.momcorp.eu - Install Magento and add some fictive products like dark matter and neutron star. Sander&lt;br /&gt;
* wiki.momcorp.eu - Install MediaWiki, later integrate with AD. Peep&lt;br /&gt;
* blog.momcorp.eu - Install WordPress, later integrate with AD. Steven&lt;br /&gt;
* chat.momcorp.eu - Install IRC server, provide  multiple channels for developers. Install some web based software for customer helldesk. Ardi&lt;br /&gt;
* ns1.momcorp.eu - Primary Bind9 installation, later also add DNSSEC. Erik J&lt;br /&gt;
* ns2.momcorp.eu - Secondary Bind9 installation in another physical host. ???&lt;br /&gt;
* git.momcorp.eu - Gogs installation. ???&lt;br /&gt;
* mon.momcorp.eu - Nagios monitoring. Nika&lt;br /&gt;
* mail.momcorp.eu - Mailserver with Postfix (postfw, greylisting, dkim, spf, setup secondary mx), later with AD integration if exchange won&#039;t be used. Andris&lt;br /&gt;
* ca.momcorp.eu - Java servlet container, EJBCA installation for certificate management. Masaki&lt;br /&gt;
* nas.momcorp.eu - Samba fileserver. Hindrek&lt;br /&gt;
* log.momcorp.eu - Graylog or similar for central logging. Kaspar, Sten-Erik&lt;br /&gt;
* vpn.momcorp.eu - OpenVPN gateway. Moira&lt;br /&gt;
* cs.momcorp.eu - Teamspeak and/or gaming server for entertainment. Christopher&lt;br /&gt;
&lt;br /&gt;
Additionally for each physical box listed under Hardware we could set up:&lt;br /&gt;
&lt;br /&gt;
* Person responsible for the hypervisor on that box&lt;br /&gt;
* Virtual machine with router OS - Mikrotik RouterOS, Vyatta, pfsense or just vanilla Debian with shell scripts&lt;br /&gt;
&lt;br /&gt;
Other topics:&lt;br /&gt;
&lt;br /&gt;
* Mikus - Remote management: Puppet master, DSC, postfix with kerberos (and AD?)&lt;br /&gt;
* Strongswan gateway&lt;br /&gt;
* OpenVPN gateway, later AD integration&lt;br /&gt;
* Exchange&lt;br /&gt;
* failover/high availability (heartbeat)&lt;br /&gt;
* db clusters/shards/replication (mysql/mariadb)&lt;br /&gt;
* clustered filesystems/servers (clvm, corosync, fenced, gfs)&lt;br /&gt;
* web caches (varnish, squid, nginx)&lt;br /&gt;
* load balancing (haproxy, nginx, simple roundrobin)&lt;br /&gt;
&lt;br /&gt;
==Lectures==&lt;br /&gt;
&lt;br /&gt;
Following lectures are planned:&lt;br /&gt;
&lt;br /&gt;
* 7. sept - Intro, virtualization, containers etc. Relevant story [https://lauri.xn--vsandi-pxa.com/lan/virtualization.html here]&lt;br /&gt;
* 14. sept - Network topology, bridges, tagging, trunking, subnetting, LAN, WAN&lt;br /&gt;
* 21. sept - iptables, ebtables, packet forwarding, DNAT, SNAT, routing tables, empheral ports, listening ports&lt;br /&gt;
* 28. sept - X.509 certificates, certificate authority, TLS, symmetric, asymmetric, keyexchange, Let&#039;s Encrypt, relevant slides [https://docs.google.com/presentation/d/1kqTyhhUu5CfwODmOTIC7odhlYfeEeJALTd4RX7XhPLE/edit?usp=sharing here]&lt;br /&gt;
&lt;br /&gt;
Order to be determined:&lt;br /&gt;
&lt;br /&gt;
* OpenVPN&lt;br /&gt;
* IPSec&lt;br /&gt;
* TBD, there are a lot of topics to discuss&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=124309</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=124309"/>
		<updated>2017-09-19T14:58:30Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 26. September&lt;br /&gt;
&lt;br /&gt;
Credits: 5 points plus extra point for being extra thorough about interpreting what you see.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Deadline: 3. October&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Points: 4 points&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
Points: 4 points&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Raspberry Pi or Ubuntu virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Points: 4 points&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* If you&#039;re using Ubuntu virtual machine approach, see [[Accessing a virtual machine via SSH connection]]&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Set up any of the web applications referenced above. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next Tuesday session, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Raspberry Pi]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: You don&#039;t have to necessarily use Raspberry Pi - Web application installed in Ubuntu VM is also accepted, also if you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Points: 5&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (1p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (1p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (3p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (1p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (1p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=124302</id>
		<title>Category:I600 Introduction to Computers and Informatics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I600_Introduction_to_Computers_and_Informatics&amp;diff=124302"/>
		<updated>2017-09-18T18:00:16Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Assignment: Investigating PC hardware */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this course we&#039;ll give an introduction to variety of topics from hardware to software.&lt;br /&gt;
The course will follow roughly the same structure as [https://lagunita.stanford.edu/courses/Engineering/CS101/Summer2014/about Computer Science 101 at Stanford University] with more hands-on approach. This course substitutes Estonian courses I100 Sissejuhatus informaatikasse and [http://www.pld.ttu.ee/~teet/itarvutid.html I201 Arvutid].&lt;br /&gt;
&lt;br /&gt;
Video recordings: [https://echo360.e-ope.ee/ess/portal/section/f7f2d8d7-7395-40c7-841f-b4522e55e422 2016 fall], [https://echo360.e-ope.ee/ess/portal/section/b685b998-4385-4632-8cb7-5665525fbdde 2015 fall].&lt;br /&gt;
&lt;br /&gt;
Course credits: 6 ECTS&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
E-mail: lauri [donut] vosandi [plus] i600 [ät] gmail [dotchka] com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Grading=&lt;br /&gt;
&lt;br /&gt;
Grade mapping:&lt;br /&gt;
&lt;br /&gt;
* 0-50 points, fail&lt;br /&gt;
* 51-60 points, pass 1&lt;br /&gt;
* 61-70 points, satisfactory 2&lt;br /&gt;
* 71-80 points, average 3&lt;br /&gt;
* 81-90 points, good 4&lt;br /&gt;
* 91-100 points, very good 5&lt;br /&gt;
&lt;br /&gt;
Grading is split between theory and practice&lt;br /&gt;
&lt;br /&gt;
* Exam of 50 points, preparation in lectures and general discussion in workshops.&lt;br /&gt;
* Assignments, see instructions and points below.&lt;br /&gt;
* Extra points for improving quality of wiki articles, extracurricular work and also helping others, see points below.&lt;br /&gt;
&lt;br /&gt;
Exam will be halfway between oral and written: You&#039;ll be given 30 minutes to prepare for several random questions and 15 minutes to discuss what you&#039;ve answered.&lt;br /&gt;
If you don&#039;t have prior experience with the topics, it&#039;s highly recommended to take part of the sessions in order to pass the exam. You can use a calculator and this wiki page, don&#039;t rely on the access to terminal or other software tools. You can not access Internet or any remote computers.&lt;br /&gt;
&lt;br /&gt;
Exam sections:&lt;br /&gt;
&lt;br /&gt;
* Execution of ~10 processor instructions&lt;br /&gt;
* Bunch of randomly selected questions from this page&lt;br /&gt;
* TBD&lt;br /&gt;
&lt;br /&gt;
=Lecture: Computer hardware=&lt;br /&gt;
&lt;br /&gt;
Jargon: CPU, RAM, ROM, HDD, SSD, PCI, PCI Express, USB 2.0, USB 3.0, VGA, HDMI, DVI, LCD, TFT, LED, OLED, AMOLED, CRT, PWM&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1OzaqTBAUfMOzhG0HZeSJVSszCmFyn4ug35teYJWkyfM/edit?usp=sharing Lecture slides] Random access memory, permanent storage, buses, input devices, display technologies, networking&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* Different buses and their uses&lt;br /&gt;
* What are the differences between hard disk drive (HDD) and solid state drive (SSD)? [http://www.storagereview.com/ssd_vs_hdd]&lt;br /&gt;
* What is the purpose of Flash Translation Layer in terms of solid state drives?&lt;br /&gt;
* What are difference between volatile/non-volatile, RAM, ROM, EEPROM and where are they used?&lt;br /&gt;
* What is data retention?&lt;br /&gt;
* What are difference between asynchronous/synchronous, dynamic/static RAM and where are they used?&lt;br /&gt;
* What is [https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory cache]? What is cache coherence?&lt;br /&gt;
* What are differences between resistive and capacitive touchscreen? [http://www.alphr.com/realworld/357325/capacitive-or-resistive-whats-the-best-type-of-touchscreen]&lt;br /&gt;
* Explain how [http://www.bidouille.org/hack/mousecam computer mouse] works? [http://www.topdesignmag.com/mouse-history-in-photos/ History of computer mouse].&lt;br /&gt;
* Explain how [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ computer keyboard] works? [http://computer.howstuffworks.com/keyboard.htm HowStuffworks article] [http://www.explainthatstuff.com/computerkeyboards.html Explain that Stuff article] [http://www.daskeyboard.com/blog/typing-through-time-the-history-of-the-keyboard/ Keyboard History]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Cathode_ray_tube cathode ray tube] (CRT) based screen technology works and name pros/cons. [https://www.youtube.com/watch?v=2czqYV3T_Kc]&lt;br /&gt;
* Explain how [https://en.wikipedia.org/wiki/Liquid-crystal_display liquid crystal displays] (LCD) work and name pros/cons. [https://www.youtube.com/watch?v=nCHgmCxGEzY]&lt;br /&gt;
* Name screen technologies making use of thin film transistor (TFT) technology? [https://en.wikipedia.org/wiki/Thin-film_transistor]&lt;br /&gt;
* Name uses for light polarization filters? [https://en.wikipedia.org/wiki/Polarizing_filter_%28photography%29] [https://en.wikipedia.org/wiki/Polarized_3D_system] &lt;br /&gt;
* What are the benefits of [https://en.wikipedia.org/wiki/Twisted_pair twisted pair cabling] and [https://en.wikipedia.org/wiki/Differential_signaling differential signalling]?&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Active_matrix Active matrix] vs [https://en.wikipedia.org/wiki/Passive_matrix_addressing passive matrix] in display technology&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.bunniestudios.com/blog/?p=3554 Hacking SD cards]&lt;br /&gt;
&lt;br /&gt;
Homework:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=z47Gv2cdFtA Fairchild Semiconductor educational video] about integrated cicruits&lt;br /&gt;
* Check if your computer is susceptible to [https://github.com/google/rowhammer-test Rowhammer] attack&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_PC_hardware Investigating PC hardware]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_embedded_hardware Investigating embedded hardware]&lt;br /&gt;
#test&lt;br /&gt;
&lt;br /&gt;
=Lecture: Storage abstractions=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about permanent storage abstractions: block device, disk, partition, file system, directory/folder, file, journaling, FAT32, NTFS, ext4, HFS+&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1dJ-HMSR9nW8OuZtSTYf5dlFyPsZKGqxlKoEwIHi9h6k/ Lecture slides] &lt;br /&gt;
&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Block_%28data_storage%29 block device]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Logical_block_addressing logical block addressing] and what are the benefits compared to older [https://en.wikipedia.org/wiki/Cylinder-head-sector cylinder-head-sector addressing] method in terms of harddisks?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/Disk_partitioning disk partition]?&lt;br /&gt;
* What is a [https://en.wikipedia.org/wiki/File_system file system]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Journaling_file_system#Write_hazards journaling] in terms of filesystems and what are the benefits? Name some journaled filesystems in use nowadays.&lt;br /&gt;
&lt;br /&gt;
=Lecture: Bootloaders, kernels=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll discuss how a computer boots and how an operating system kernel is loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lecture slides:&lt;br /&gt;
[https://docs.google.com/presentation/d/1ybYQEqCgN1KdVW1sLdwtfRogavgzzMQdUfTcAnxNAf4/ bootloaders],&lt;br /&gt;
[https://docs.google.com/presentation/d/1xDL27k3z_0I-IKzdjKkwhOhBrg0aOnM0w0u1zDwaEWY/ kernels].&lt;br /&gt;
&lt;br /&gt;
Jargon: [https://en.wikipedia.org/wiki/BIOS BIOS] (basic input/output system), [https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface UEFI] (Unified Extensible Firmware Interface), bootloader, kernel, process, context switch, x86 real/protected mode, paged virtual memory, swap/pagefile, [https://en.wikipedia.org/wiki/User_space kernelspace/supervisor mode, userspace], [https://en.wikipedia.org/wiki/Protection_ring#Hypervisor_mode hypervisor mode] (ring -1), [https://en.wikipedia.org/wiki/System_Management_Mode#Problems system management mode] aka (ring -2).&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is the role of BIOS/UEFI in x86-based machines?&lt;br /&gt;
* Explain step by step how operating system is booted up, see slides for flowchart.&lt;br /&gt;
* Describe the functionality provided by general purpose operating system. See architecture of [https://en.wikipedia.org/wiki/Architecture_of_Windows_NT Windows NT], [http://www.elinux.org/Android_Architecture Android], [https://en.wikipedia.org/wiki/Architecture_of_OS_X OS X].&lt;br /&gt;
* What are the main differences between [https://en.wikipedia.org/wiki/Real_mode real mode] and [https://en.wikipedia.org/wiki/Protected_mode protected mode] of x86-based processor?&lt;br /&gt;
* What happens during context switch?&lt;br /&gt;
* What is the purpose of [https://en.wikipedia.org/wiki/Virtual_memory paged virtual memory]?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Security section: [https://en.wikipedia.org/wiki/DMA_attack DMA attack], [http://www.outsidaz.org/blog/2007/10/22/resetting-root-password-via-grubkernel-boot-options/ editing GRUB entries to gain root shell] without password prompt, [http://www.theinquirer.net/inquirer/news/2421402/serious-intel-cpu-security-exploit-spotted-in-old-x86-chips 20 years old security exploit in x86 processors].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Libraries, frameworks=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1q9kGg5AI3AyXglxpJdLjLMpgRLdbF9dl62gauNmDEG8/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: framework, library, [https://en.wikipedia.org/wiki/Application_binary_interface ABI], [https://en.wikipedia.org/wiki/Application_programming_interface API]&lt;br /&gt;
&lt;br /&gt;
Security section: [http://www.fiercecio.com/story/hackers-exploiting-httpsys-bug-crash-iis-web-servers/2015-04-17 HTTP.sys bug crashes IIS web servers], [http://heartbleed.com/ OpenSSL bug Heartbleed].&lt;br /&gt;
&lt;br /&gt;
=Lecture: Programming languages=&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about programming languages&lt;br /&gt;
&lt;br /&gt;
Lecture slides: [https://docs.google.com/presentation/d/1CCZntY7Z-AG_Mice5N2kclDGYI2xVVvRHgWUIs-SxYo/edit programming languages, stack machine]&lt;br /&gt;
&lt;br /&gt;
Jargon: stack machine, lexer/lexeme, token, abstract syntax tree&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major steps of compilation?&lt;br /&gt;
* What are the differences between [https://en.wikipedia.org/wiki/Interpreted_language interpreted], [https://en.wikipedia.org/wiki/Just-in-time_compilation JIT-compilation] and [https://en.wikipedia.org/wiki/Compiler traditional compiling]?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Control_flow control flow]? Loops? Conditional statements?&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Data encoding=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1QV_IMOadIEUTBW7Laqw59j8J7Y8HKwvSDmP-swEEx0s Lecture slides]&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about bits, bytes, integers, strings, pixels, audio encodings, video encoding etc.&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is bit? Nibble? Byte? Word?&lt;br /&gt;
* Write 9375 in binary, hexadecimal?&lt;br /&gt;
* Write 0xDEADBEEF in decimal?&lt;br /&gt;
* How are dates/time stored in binary?&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Quantization_%28signal_processing%29 quantization] in terms of signal processing?&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Integer_%28computer_science%29 integers] stored in binary? What integer range can be described using n bits? How many bits are required to describe integer range from n .. m.&lt;br /&gt;
* How are [https://en.wikipedia.org/wiki/Single-precision_floating-point_format single precision] and [https://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision] floating point numbers stored in binary according to [https://en.wikipedia.org/wiki/IEEE_floating_point IEEE754 standard]? [http://lauri.vosandi.com/hdl/arithmetic/floating-point-representation.html Floating-point multiplication]&lt;br /&gt;
* What is the difference between CMYK and RGB color models? How are YUV, HSV and HSL colorspaces related to RGB? What are sRGB and YCbCr and where are they used?&lt;br /&gt;
* How is data encoded on audio CD-s? What is the [http://lauri.vosandi.com/2013/07/audio-codecs.html capacity of an audio CD]?&lt;br /&gt;
* What is sampling rate? What is bit depth? What is resolution?&lt;br /&gt;
* What is bitrate?&lt;br /&gt;
* What is lossy/lossless compression?&lt;br /&gt;
* What is JPEG suitable for? Is JPEG lossy or lossless compression method?&lt;br /&gt;
* What is PNG suitable for? Does PNG support compression?&lt;br /&gt;
* How are time domain and frequency domain related in terms of signal processing? What is Fourier transform and where it is applied?&lt;br /&gt;
&lt;br /&gt;
Jargon: 44.1kHz sampling rate, 16-bit audio, RGB565 pixel format, RGB888 pixel format&lt;br /&gt;
&lt;br /&gt;
Relevant assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Code execution in processor=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/18wPDLydyZevMi9F0MX7F6eK-NMBZQzGN4mviF_ft8-E/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
It&#039;s highly reccommended to play around with simulators [http://morriswmz.jit.su/static/simple-mips-pipelined.html here is one for MIPS processors].&lt;br /&gt;
&lt;br /&gt;
In this lecture we&#039;ll talk about different processor architectures, instructions, pipelining, function calls, jumps, loops etc.&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Investigating_compilers Investigating compilers]&lt;br /&gt;
&lt;br /&gt;
Exam question:&lt;br /&gt;
&lt;br /&gt;
* Given ~10 instructions and their explainations, follow the instructions and elaborate after every step what happened in the processor?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Microcontrollers=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1qPyzBBfB1TseEzXjcp4-ZjqSnAwbjDmEqyIYcUGFLG0/edit Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Jargon: microprocessor, microcontroller, coprocessor, floating-point unit (FPU), digital signal processor (DSP), field programmable grid array (FPGA), sensors, actuators, digital input/output, analog input, general purpose input/output (GPIO), interrupt, interrupt handler, timer/counter, pulse-width modulation (PWM), &lt;br /&gt;
&lt;br /&gt;
Potential exam question:&lt;br /&gt;
&lt;br /&gt;
* What distinguishes microcontroller from microprocessor?&lt;br /&gt;
* What are the differences between Hardvard architecture and von Neumann architecture?&lt;br /&gt;
* What is an interrupt?&lt;br /&gt;
* What is an timer?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Introduction to Boole algebra=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Y1rXvt2oXROhW-LZ07B0Sg90D-_u8SlLUZeaxds7f1g/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Exam questions:&lt;br /&gt;
&lt;br /&gt;
* Simplify A AND A OR B&lt;br /&gt;
* Show addition of X and Y in binary&lt;br /&gt;
* Show subtraction of X and Y  in binary&lt;br /&gt;
* Show multiplication of X and Y in binary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignments:&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics#Assignment:_Designing_arithmetic-logic_unit Designing arithmetic-logic unit]&lt;br /&gt;
&lt;br /&gt;
=Lecture: Hardware description languages=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1HO9iPfi8S3ZykuW7IHVm09QamLHiVo6s6lUGwWu4eD4/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the uses for hardware description languages?&lt;br /&gt;
* What is latch?&lt;br /&gt;
* What is flip-flop?&lt;br /&gt;
* What is mux (multiplexer)?&lt;br /&gt;
* What is register? Register file?&lt;br /&gt;
* What is ALU?&lt;br /&gt;
* What is floating-point unit?&lt;br /&gt;
* What is a cache?&lt;br /&gt;
* What is a bus?&lt;br /&gt;
* Show the circuit diagram for A OR B AND C, NOT A AND B, &amp;lt;insert some other Boole formula here&amp;gt;?&lt;br /&gt;
* Show the truth table for &amp;lt;insert Boole formula here&amp;gt;?&lt;br /&gt;
* Write the equivalent Boole formula of a circuit diagram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Lecture: Publishing work=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1hCqRjGUx5Yv6iZN4xaz2UICLWbycnM46ctw2zX0g94U/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What are the major implications of MIT, BSD and GPL licenses?&lt;br /&gt;
* What are the differences between copyright, trademark, trade secret?&lt;br /&gt;
* Where would you use waterfall software development model? Where would you use agile?&lt;br /&gt;
* What is the purpose of a version control system?&lt;br /&gt;
* What would you store in a version control system?&lt;br /&gt;
&lt;br /&gt;
=Lecture: Algorithms and data structures=&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1vwJvvRerM0rYBaiE3pEX5GUXRHuVJvjTUDKo8fqTq_A/ Lecture slides]&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1xK-npNPn7zp0ysn_N8yBg3dF3jQT0jNPEnZRAe0pmqk/edit?usp=sharing Lecture slides (shortened)]&lt;br /&gt;
&lt;br /&gt;
Potential exam questions:&lt;br /&gt;
&lt;br /&gt;
* What is time complexity of algorithm?&lt;br /&gt;
* What is space complexity of algorithm?&lt;br /&gt;
* What&#039;s a good algorithm?&lt;br /&gt;
&lt;br /&gt;
=Lecture: History=&lt;br /&gt;
&lt;br /&gt;
Topics: Computer history, Silicon Valley, standards&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/presentation/d/1Ybld2ABpm9QJSLL-Bodr1a5XI5Hk_KM2q_nZVYu2L0c/edit?usp=sharing Lecture slides]&lt;br /&gt;
&lt;br /&gt;
Potential example questions:&lt;br /&gt;
&lt;br /&gt;
* What is [https://en.wikipedia.org/wiki/Moore&#039;s_law Moore&#039;s law]? What is [https://en.wikipedia.org/wiki/Rock&#039;s_law Rock&#039;s law]?&lt;br /&gt;
* What were the major contributing factors for success of Microsoft, Apple, Google, &amp;lt;your favourite company&amp;gt;?&lt;br /&gt;
* What were the major contributing factors to the success of Silicon Valley?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating PC hardware=&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with your [https://en.wikipedia.org/wiki/X86 laptop hardware]. Get out of the comfort zone of your primary operating system and try out other operating systems. Learn about [https://en.wikipedia.org/wiki/Full_virtualization hardware virtualization].&lt;br /&gt;
&lt;br /&gt;
Deadline: 16. September&lt;br /&gt;
&lt;br /&gt;
Credits: 5 points plus extra point for being extra thorough about interpreting what you see.&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] workshop:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Read the instructions before you act&#039;&#039;&#039;.&lt;br /&gt;
* Place your preferred ISO image to a memory stick using &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; or Win32 Disk Imager and boot it on your personal laptop. You do &#039;&#039;&#039;not&#039;&#039;&#039; need to install Ubuntu on your harddisk, simply click &#039;&#039;&#039;Try Ubuntu&#039;&#039;&#039; once the operating system boots off the memory stick and carry out following tasks.&lt;br /&gt;
* Open up terminal by pressing &amp;lt;code&amp;gt;Ctrl-Alt-T&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt; to check what operating system distribution you&#039;re running, try &amp;lt;code&amp;gt;apt install lsb-release&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;uname -sr&amp;lt;/code&amp;gt; to check what operating system kernel you&#039;re running. &lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt; and check processor information. What CPU model and how many cores your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;arch&amp;lt;/code&amp;gt; to check what CPU architecture is being used by the operating system. Is it 32-bit or 64-bit?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/meminfo&amp;lt;/code&amp;gt; to check memory usage. How much RAM your computer has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lspci -t -v -nn&amp;lt;/code&amp;gt; to enumerate PCI and PCI Express devices, attempt to identify what is what, try &amp;lt;code&amp;gt;apt install pciutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsusb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lsusb -t&amp;lt;/code&amp;gt; to enumerate USB devices, again attempt to identify what is what, try &amp;lt;code&amp;gt;apt install usbutils&amp;lt;/code&amp;gt; if command is not available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;sudo fdisk -l&amp;lt;/code&amp;gt; to enumerate disks and partitions. How big is your harddisk? How many and how big partitions it has?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to enumerate block devices.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;xrandr&amp;lt;/code&amp;gt; to enumerate display outputs. What video output resolutions are available and which one is currently used?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;cat /proc/asound/cards&amp;lt;/code&amp;gt; to check which audio devices are available.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;dmidecode&amp;lt;/code&amp;gt; to see even more information about your computer.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;ifconfig -a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ip addr list&amp;lt;/code&amp;gt; to list all network interfaces.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;iw list&amp;lt;/code&amp;gt; to list all wireless network interfaces. Is your wireless network interface detected? If not take a guess why?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;hcitool dev&amp;lt;/code&amp;gt; to list bluetooth host controller. Is your bluetooth device detected?&lt;br /&gt;
* Use &amp;lt;code&amp;gt;glxinfo&amp;lt;/code&amp;gt; to check what 3D rendering capabilities are available, is it hardware accelerated? (hint: is direct rendering enabled?)&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Sound_card audio card] is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Graphics_processing_unit graphics controller] is your machine using? What bus is it using?&lt;br /&gt;
* What webcam is your machine using? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Ethernet wired network] chipset your computer has? What bus is it using? &lt;br /&gt;
* What [https://en.wikipedia.org/wiki/IEEE_802.11 wireless network] chipset your computer has? What bus is it using?&lt;br /&gt;
* What [https://en.wikipedia.org/wiki/Bluetooth Bluetooth] device your computer has? What bus is it using?&lt;br /&gt;
* Is there a [https://en.wikipedia.org/wiki/Mobile_broadband_modem cellular modem] connected and how it&#039;s connected?&lt;br /&gt;
* Boot the ISO image in VirtualBox and follow the same steps as above, &#039;&#039;&#039;what are the differences and why&#039;&#039;&#039;?&lt;br /&gt;
* Answer to questions above and send it as [https://en.wikipedia.org/wiki/Plain_text plain text] e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on my smartphone. When answering to questions phrase the text in a way that is understandable out of context, so I don&#039;t have to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
Note that I can&#039;t expect you to install Ubuntu on your physical machine, but I can help if you want to do that. You should have Ubuntu ready to go in a virtual machine at least for subsequent sessions. We&#039;re using Ubuntu because it&#039;s widely used on servers and in the cloud, so any Ubuntu skills will definitely come handy in future. If you&#039;re already familiar with Linux, it&#039;s suggested to take a look at other interesting operating systems such as [https://www.freebsd.org/ FreeBSD] or [http://www.openbsd.org/ OpenBSD]. Take a look at [https://www.kali.org/ Kali Linux] if you&#039;re interested in penetration testing.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating embedded hardware=&lt;br /&gt;
&lt;br /&gt;
Background: Most of the smartphones nowadays are using [https://en.wikipedia.org/wiki/System_on_a_chip SoC] built around [https://en.wikipedia.org/wiki/ARM_architecture ARM] processor. Raspberry Pi is an excellent piece of hardware to for checking out how an ARM-based machine looks like.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with hardware ARM-based hardware.&lt;br /&gt;
&lt;br /&gt;
Points: 4 points&lt;br /&gt;
&lt;br /&gt;
Use what you learned in [[Getting started with Ubuntu]] and [[Getting started with Raspberry Pi]] workshops:&lt;br /&gt;
&lt;br /&gt;
* Read the instructions before you get busy.&lt;br /&gt;
* Boot Raspbian on Raspberry Pi.&lt;br /&gt;
* Use the commands described in previous assignment to examine the environment of Raspbian on Raspberry Pi. What are the major differences compares to your laptop and virtual machine?&lt;br /&gt;
* What buses is Raspberry Pi making use of?&lt;br /&gt;
* What filesystems is Raspbian making use of?&lt;br /&gt;
* Answer to questions above and send it as e-mail to Lauri, make sure you &#039;&#039;&#039;use the address supplied above with the course code&#039;&#039;&#039;, otherwise your mail is not searchable in my mailbox. Attach collected command outputs as [https://en.wikipedia.org/wiki/Plain_text plain text] file, do &#039;&#039;&#039;not&#039;&#039;&#039; send .odt, .doc files, these are not readable on a phone. When answering to questions phrase the text in a way that is understandable out of context, so it is not necessary to open up wiki to understand what you&#039;re talking about.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Assignment: Set up basic IoT scenario=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Internet_of_Things Internet of Things] is one of the emerging technologies (read: hype). IoT is essentially about getting everything online, including lightbulbs, switches, window shades etc. In this assignment LED symbolizes a light and the task is to implement code which allows user to switch the LED on and off over the network.&lt;br /&gt;
&lt;br /&gt;
[[File:Rpi led.png|400px]]&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar how Python code can be started up. Build basic [https://en.wikipedia.org/wiki/Internet_of_Things IoT] appliance, a light that can be turned on and off via the Internet.&lt;br /&gt;
&lt;br /&gt;
Points: 4 points&lt;br /&gt;
&lt;br /&gt;
* Complete the [http://codeacademy.com/tracks/python Python track at CodeAcademy] if you haven&#039;t done that yet.&lt;br /&gt;
* Follow the wiki page Blinking LED section under [[Getting started with Raspberry Pi]].&lt;br /&gt;
* Get an LED blinking on command-line.&lt;br /&gt;
* Get LED blinking from Python code.&lt;br /&gt;
* Get basic HTTP server running in Python.&lt;br /&gt;
* Combine all of the above, build an HTTP server that can be used to turn LED on and off from via web browser.&lt;br /&gt;
* Optional: Take a peek at next assignment and upload working version to GitHub.&lt;br /&gt;
* Optional: [http://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/ Smoothen the transitions using PWM].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating LAMP=&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP] software bundle is consists of Linux-based OS, [https://en.wikipedia.org/wiki/Apache_HTTP_Server Apache web server], [https://en.wikipedia.org/wiki/PHP PHP programming language] runtime and [https://en.wikipedia.org/wiki/MySQL MySQL database].&lt;br /&gt;
Most of the web applications on the Internet including Facebook are built on top of LAMP-styled software stack.&lt;br /&gt;
Use a Raspberry Pi or Ubuntu virtual machine to set up [https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/ WordPress], [https://doc.owncloud.org/server/8.1/admin_manual/installation/index.html ownCloud] or any well-known web application that makes use of a database such as MySQL.&lt;br /&gt;
To make your life easier also set up SSH public key authentication.&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with LAMP stack. Get comfortable with (SSH) public key authentication.&lt;br /&gt;
&lt;br /&gt;
Points: 4 points&lt;br /&gt;
&lt;br /&gt;
Tasks:&lt;br /&gt;
&lt;br /&gt;
* If you&#039;re using Ubuntu virtual machine approach, see [[Accessing a virtual machine via SSH connection]]&lt;br /&gt;
* Use SSH to connect to your server over the network. If you&#039;re using Windows on your laptop use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] to gain access to command line and [https://winscp.net/ WinSCP] to copy files, otherwise simply boot Ubuntu in a virtual machine and use &amp;lt;code&amp;gt;ssh username@hostname&amp;lt;/code&amp;gt; to invoke commands and &amp;lt;code&amp;gt;sftp://username@hostname&amp;lt;/code&amp;gt; in the file browser to access filesystem.&lt;br /&gt;
* Set up any of the web applications referenced above. You may be interested in reading also [http://howtoubuntu.org/how-to-install-lamp-on-ubuntu this] and [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04 this].&lt;br /&gt;
* Demonstrate that the web application you installed works in next Tuesday session, screenshots/photos with explanation sent to e-mail above also suffice.&lt;br /&gt;
* Optional: Set up SSH public key authentication to &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Optional: [https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md Set up public key authentication to your Raspberry Pi]. Windows users might want to take a look at [https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen PuTTYgen instructions].&lt;br /&gt;
&lt;br /&gt;
Note: You don&#039;t have to necessarily use Raspberry Pi - Web application installed in Ubuntu VM is also accepted, also if you&#039;re maintaining similar installation of a production server that is accepted as well. [http://www.wampserver.com/en/ WAMP] on Windows is also accepted.&lt;br /&gt;
&lt;br /&gt;
=Assignment: Collaborating using Git=&lt;br /&gt;
&lt;br /&gt;
Software development is usually done by several contributors, to facilitate efficient collaboration a distributed version control system is a must. In this assignment you&#039;ll upload your code to GitHub and modify fellow student&#039;s code to reflect changes in the Raspberry Pi setup:&lt;br /&gt;
&lt;br /&gt;
[[File:Raspberry-pi-rgb-led bb.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Points: 5&lt;br /&gt;
&lt;br /&gt;
Goal: Get familiar with distributed version control systems. Collaborate.&lt;br /&gt;
&lt;br /&gt;
* Create [https://github.com/ GitHub] account if you haven&#039;t done so yet.&lt;br /&gt;
* Create a Git repository, eg http://github.com/your-username/rpi-iot-example&lt;br /&gt;
* Install Git on your Raspberry Pi by using &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Clone the repository to your Raspberry Pi using &amp;lt;code&amp;gt;git clone http://github.com/your-username/rpi-iot-example&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Move the Python code created earlier to the Git repository directory.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git add&amp;lt;/code&amp;gt; to add the files.&lt;br /&gt;
* Configure full name: &amp;lt;code&amp;gt;git config --global user.name &amp;quot;Firstname Surname&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Configure e-mail: &amp;lt;code&amp;gt;git config --global user.email first.last@domain.tld&amp;lt;/code&amp;gt; &lt;br /&gt;
* Use &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; to create the [http://blog.no-panic.at/2014/10/20/funny-initial-git-commit-messages/ initial commit].&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt; to push the commits to GitHub server.&lt;br /&gt;
* Set up [https://help.github.com/articles/generating-ssh-keys/ public key authentication between your laptop and GitHub servers], verify that &amp;lt;code&amp;gt;https://github.com/username.keys&amp;lt;/code&amp;gt; gives the expected result.&lt;br /&gt;
* Use &amp;lt;code&amp;gt;git clone&amp;lt;/code&amp;gt; to clone the repository to your laptop. Ubuntu should first &amp;lt;code&amp;gt;apt-get install git&amp;lt;/code&amp;gt;, Windows and Mac users might want to take a look at [http://git-scm.com/download/ Git homepage]. If you&#039;re looking for graphical user interface take a look at [https://desktop.github.com/ GitHub Desktop] or [https://tortoisegit.org/ TortoiseGit].&lt;br /&gt;
* Create [https://en.wikipedia.org/wiki/README README] in the repository directory, populate it with relevant content - what is it about, who made it etc and commit the changes.&lt;br /&gt;
* In your Raspberry Pi setup RGB LED should be connected as shown above.&lt;br /&gt;
* Clone &#039;&#039;&#039;fellow student&#039;s&#039;&#039;&#039; repository and adapt the code to reflect physical changes to the setup, the Python snippet should now permit changing the color of the light, have it blinking and turn it off. Other interesting modes are awarded with extra points, eg use [http://html5tutorial.info/html5-range.php HTML5 input type range].&lt;br /&gt;
* Use either [https://www.atlassian.com/git/tutorials/ Atlassian Tutorials], [http://rogerdudler.github.io/git-guide/ git - the simple guide] or [https://try.github.io/ Try Git] as a reference if you get lost.&lt;br /&gt;
* Document in the README what GPIO pins are used in the code for red, green and blue. Extra points for making the Python code [https://docs.python.org/2/library/argparse.html#module-argparse configurable from command-line].&lt;br /&gt;
* Late submissions will heavily lose points for failure to comply with [http://chris.beams.io/posts/git-commit/ decent commit messages].&lt;br /&gt;
* Send Lauri the URL of your repository at GitHub.&lt;br /&gt;
&lt;br /&gt;
Git resources: [http://git-scm.com/book/en/v2 Pro Git Book] (read the basics to get kickstarted) and [https://www.codecademy.com/en/courses/learn-git/ Codecademy Git course].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating compilers=&lt;br /&gt;
&lt;br /&gt;
Use what you learned in the [https://wiki.itcollege.ee/index.php/Getting_started_with_GCC Getting started with GCC] session.&lt;br /&gt;
See assignment steps below.&lt;br /&gt;
Everything you need to understand ARM instructions should be [http://aelmahmoudy.users.sourceforge.net/electronix/arm/chapter2.htm here].&lt;br /&gt;
Another good resource seems to be [http://www.davespace.co.uk/arm/introduction-to-arm/ Introduction to ARM] by David Thomas.&lt;br /&gt;
See page 14 of [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf Procedure Call Standard for the ARM® Architecture] if you want to learn more about how function calls are implemented on ARM.&lt;br /&gt;
See [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihfddaf.html here] for more information about branching instructions: B, BL, BX.&lt;br /&gt;
&amp;lt;Insert extemely useful link here yourself&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have Ubuntu installed on your machine skip next step and use SSH to perform these steps remotely at &amp;lt;code&amp;gt;enos.itcollege.ee&amp;lt;/code&amp;gt;.&lt;br /&gt;
Otherwise install ARM cross-compiler:&lt;br /&gt;
&lt;br /&gt;
 apt-get install gcc-arm-linux-gnueabi&lt;br /&gt;
&lt;br /&gt;
Consider C snippet for calculating integer [https://en.wikipedia.org/wiki/Exponentiation exponentiation], place it in a file &amp;lt;code&amp;gt;power.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 int power(long base, long exponent) {&lt;br /&gt;
     int counter;&lt;br /&gt;
     int result = 1;&lt;br /&gt;
     for (counter = 0; counter &amp;lt; exponent; counter++)&lt;br /&gt;
         result *= base;&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===Generating assembly===&lt;br /&gt;
&lt;br /&gt;
Compile ARM assembly of the code snippet:&lt;br /&gt;
&lt;br /&gt;
 arm-linux-gnueabi-gcc -Os -S power.c -o power.s   # Cross-compile ARM assembly file power.s from C source code file power.c&lt;br /&gt;
 cat power.s                                       # Dump the assembly file on terminal&lt;br /&gt;
&lt;br /&gt;
The compiler should produce something similar to following:&lt;br /&gt;
&lt;br /&gt;
 	.arch armv5t&lt;br /&gt;
 	.fpu softvfp&lt;br /&gt;
 	.eabi_attribute 20, 1&lt;br /&gt;
 	.eabi_attribute 21, 1&lt;br /&gt;
 	.eabi_attribute 23, 3&lt;br /&gt;
 	.eabi_attribute 24, 1&lt;br /&gt;
 	.eabi_attribute 25, 1&lt;br /&gt;
 	.eabi_attribute 26, 2&lt;br /&gt;
 	.eabi_attribute 30, 2&lt;br /&gt;
 	.eabi_attribute 34, 0&lt;br /&gt;
 	.eabi_attribute 18, 4&lt;br /&gt;
 	.file	&amp;quot;power.c&amp;quot;&lt;br /&gt;
 	.text&lt;br /&gt;
 	.align	2&lt;br /&gt;
 	.global	power&lt;br /&gt;
 	.type	power, %function&lt;br /&gt;
 power:&lt;br /&gt;
 	@ args = 0, pretend = 0, frame = 0&lt;br /&gt;
 	@ frame_needed = 0, uses_anonymous_args = 0&lt;br /&gt;
 	@ link register save eliminated.&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1&lt;br /&gt;
 	cmp	r3, r1&lt;br /&gt;
 	mul	r2, r0, r2&lt;br /&gt;
 	bne	.L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
 	.size	power, .-power&lt;br /&gt;
 	.ident	&amp;quot;GCC: (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3&amp;quot;&lt;br /&gt;
 	.section	.note.GNU-stack,&amp;quot;&amp;quot;,%progbits&lt;br /&gt;
&lt;br /&gt;
===Commenting the assembly===&lt;br /&gt;
&lt;br /&gt;
You can safely ignore the lines starting with dot, these are simply hints for the next stage of the compilation process.&lt;br /&gt;
Thus you&#039;re left only (!!!) 10 actual instructions. Here you can also see what kind of comments are expected from the submission:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0             /* Compare register r1 (second argument) contents against constant 0 */    &lt;br /&gt;
 	mov	r2, #1             /* Copy the constant 1 to register r2 */&lt;br /&gt;
 	ble	.L2                /* Jump to label .L2 if the comparison was false */&lt;br /&gt;
 	mov	r3, #0             /* Copy the constant 0 to register r3 */&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1         /* Perform r3 = r3 + 1 */&lt;br /&gt;
 	cmp	r3, r1             /* Compare register r3 and r1 (second argument) */&lt;br /&gt;
 	mul	r2, r0, r2         /* Perform r2 = r0 (first argument) * r2 */&lt;br /&gt;
 	bne	.L3                /* If r3 and r1 were different jump to label .L3&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2             /* Copy register r2 contents to register r0 */&lt;br /&gt;
 	bx	lr                 /* Jump back to caller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyzing the code===&lt;br /&gt;
&lt;br /&gt;
Code analysis reveals that registers are mapped as following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; and eventually return value&lt;br /&gt;
* &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; - argument &amp;lt;code&amp;gt;exponent&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; - variable &amp;lt;code&amp;gt;counter&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can also see how the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop gets translated into assembly:&lt;br /&gt;
&lt;br /&gt;
 power:&lt;br /&gt;
 	cmp	r1, #0&lt;br /&gt;
 	mov	r2, #1&lt;br /&gt;
 	ble	.L2&lt;br /&gt;
 	mov	r3, #0&lt;br /&gt;
 .L3:&lt;br /&gt;
 	add	r3, r3, #1 &amp;lt;---+&lt;br /&gt;
 	cmp	r3, r1         | 4 instructions are executed repeatedly&lt;br /&gt;
 	mul	r2, r0, r2     | if exponent is greater than 0&lt;br /&gt;
 	bne	.L3 -----------+&lt;br /&gt;
 .L2:&lt;br /&gt;
 	mov	r0, r2&lt;br /&gt;
 	bx	lr&lt;br /&gt;
&lt;br /&gt;
===Stepping through the instructions===&lt;br /&gt;
&lt;br /&gt;
When we execute the function with for example arguments base=5 and exponent=3 following happens in the processor.&lt;br /&gt;
Note that this will essentially calculates 5 ^ 3 (5 to the power of 3) which is 125.&lt;br /&gt;
Following has been done manually to illustrate how much time does it take to execute the the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* When processor enters the function body the arguments are already placed in registers r0=5 (base), r1=3 (exponent) */&lt;br /&gt;
 cmp r1, #0                        /* Compare exponent to 0 */&lt;br /&gt;
 mov r2, #1                        /* Place constant 1 in register r2,&lt;br /&gt;
                                      this corresponds to result = 1 in C code */&lt;br /&gt;
 ble .L2                           /* Exponent was not less than 0, so no jump to L2&lt;br /&gt;
 mov r3, #0                        /* Place constant 0 in register r3,&lt;br /&gt;
                                      this corresponds to variable counter */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 0 + 1 which results in 1 being stored to r3&lt;br /&gt;
                                      this corresponds to first invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (1 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results in 1 * 5 = 5 being placed in r2&lt;br /&gt;
                                      this corresponds to first invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to first invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 1 + 1 which results in 2 being stored to r3&lt;br /&gt;
                                      this corresponds to second invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (2 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 5 * 5 = 25 being placed in r2&lt;br /&gt;
                                      this corresponds to second invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being not equal to exponent, so we jump back to L3&lt;br /&gt;
                                      this corresponds to second invocation of counter &amp;lt; exponent in C code */&lt;br /&gt;
 &lt;br /&gt;
 add r3, r3, #1                    /* Perform r3 = 2 + 1 which results in 3 being stored to r3&lt;br /&gt;
                                      this corresponds to third invocation of counter++ in C code */&lt;br /&gt;
 cmp r3, r1                        /* Compare counter (3 in this case) to exponent (3), this will be used by bne instruction below */&lt;br /&gt;
 mul r2, r0, r2                    /* Perform r2 = r0 * r2 which results 25 * 5 = 125 being placed in r2&lt;br /&gt;
                                      this corresponds to third invocation of result *= base in C code */&lt;br /&gt;
 bne .L3                           /* The comparison resulted in counter being equal to exponent, so we DO NOT jump back to L3 */&lt;br /&gt;
 &lt;br /&gt;
 mov	r0, r2                     /* Copy register r2 contents (125) to register r0 */&lt;br /&gt;
 bx	lr                         /* Jump back to caller */&lt;br /&gt;
 /* Function returns with 125 placed in r0 this is where caller function should expect the return value */&lt;br /&gt;
 /* The other registers will still hold whatever values were left there: r1 = 3, r2 = 125, r3 = 3 */&lt;br /&gt;
&lt;br /&gt;
===ARM registers===&lt;br /&gt;
&lt;br /&gt;
If you get lost with the ARM register naming conventions use following as a guide.&lt;br /&gt;
&lt;br /&gt;
ARM7 has 16x 32-bit registers:&lt;br /&gt;
&lt;br /&gt;
  r0 (a1) - Argument/result/scratch register, this is where first function argument is usually placed&lt;br /&gt;
  r1 (a2) - Argument/result/scratch register, this is where second function argument is placed&lt;br /&gt;
  r2 (a3) - Argument/scratch register 3&lt;br /&gt;
  r3 (a4) - Argument/scratch register 4&lt;br /&gt;
  r4 (v1) - Variable register 1&lt;br /&gt;
  r5 (v2) - Variable register 2&lt;br /&gt;
  r6 (v3) - Variable register 3&lt;br /&gt;
  r7 (v4) - Variable register 4&lt;br /&gt;
  r8 (v5) - Variable register 5&lt;br /&gt;
  r9 (v6) - Variable register 6&lt;br /&gt;
 r10 (v7) - Variable register 7&lt;br /&gt;
 r11 (fp) - Frame pointer, variable register 8 &lt;br /&gt;
 r12 (ip) - Intra-procedure call scratch register&lt;br /&gt;
 r13 (sp) - Stack pointer&lt;br /&gt;
 r14 (lr) - Link register (to which memory address currently&lt;br /&gt;
                           executing function should return to?)&lt;br /&gt;
 r15 (pc) - Program counter (what is the memory address of instruction&lt;br /&gt;
      ^                      that we are going to execute next?)&lt;br /&gt;
      |&lt;br /&gt;
      +- These are simply aliases for the numbered registers and&lt;br /&gt;
         can be used interchangeably.&lt;br /&gt;
&lt;br /&gt;
==Another example==&lt;br /&gt;
&lt;br /&gt;
For learning purposes try to do the steps described above for the different flavours of Fibonacci calculation function below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i;&lt;br /&gt;
     for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using recursion:&lt;br /&gt;
&lt;br /&gt;
 int fib2(int n) {&lt;br /&gt;
     if (n == 1 || n== 2) {&lt;br /&gt;
         return 1;&lt;br /&gt;
     } else {&lt;br /&gt;
         return fib(n-1) + fib(n-2);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Fibonacci calculation using &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt;-loop:&lt;br /&gt;
&lt;br /&gt;
 int fib4(int n) {&lt;br /&gt;
     int a = 1;&lt;br /&gt;
     int b = 1;&lt;br /&gt;
     int i = 0;&lt;br /&gt;
     while(1) {&lt;br /&gt;
         i += 1;&lt;br /&gt;
         if (i &amp;gt;= n) { break; }&lt;br /&gt;
         int s = a + b;&lt;br /&gt;
         a = b;&lt;br /&gt;
         b = s;&lt;br /&gt;
     }&lt;br /&gt;
     return a;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Working with VisUAL==&lt;br /&gt;
&lt;br /&gt;
Software itself you will find at [http://salmanarif.bitbucket.org/visual/ VisUAL - A highly visual ARM emulator]&lt;br /&gt;
&lt;br /&gt;
Be aware, this software is not well optimised and might have memory leaks and high CPU usage.&lt;br /&gt;
&lt;br /&gt;
Also note that this is an emulator, some assembly instructions might be missing and there are syntactic differences, as an example instead of PUSH, STMDB should be used (all credit to Ardi Vaba). Lauri: PUSH and POP instructions are aliases for LDR and STR instructions, use &amp;lt;code&amp;gt;-fverbose-asm&amp;lt;/code&amp;gt; flag and remove optimization flags for GCC to get verbose assembly without aliases.&lt;br /&gt;
&lt;br /&gt;
Code example for VisUAL below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; these four lines are the invocation part of the program, lets say an overly simplified variant of the C file that has main function in it&lt;br /&gt;
	mov	r0, #600	; base value placed in register R0 by the caller&lt;br /&gt;
	mov	r1, #12 	; multiplier value placed in register R1 by the caller&lt;br /&gt;
	bl	multiply	; branch to multiply and store PC+4 in LR or in other words call function multiply&lt;br /&gt;
        end                     ; stops the simulator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; the rest is the library portion of the program&lt;br /&gt;
multiply&lt;br /&gt;
	mov	r2, #0 		; set result to 0&lt;br /&gt;
	mov	r4, #0 		; set counter to 0&lt;br /&gt;
	; next five lines are an optimisation for big number multiplication with small numbers&lt;br /&gt;
        ; when possible it will decrease the amount of loops we need to preform&lt;br /&gt;
	cmp	r0, r1 		; compare values in R0 and R1&lt;br /&gt;
	ble	multiply_loop   ; if value in R1 is bigger or equal then R0 branch to loop&lt;br /&gt;
	mov	r7, r0          ; otherwise swap arguments&lt;br /&gt;
	mov	r0, r1&lt;br /&gt;
	mov	r1, r7&lt;br /&gt;
multiply_loop&lt;br /&gt;
	cmp	r4, r0 		; compare counter to R0&lt;br /&gt;
	bge	multiply_finish ; branch to finish if compare values are grater or equal&lt;br /&gt;
	add	r2, r2, r1 	; add base value to itself and store in R2&lt;br /&gt;
	add	r4, r4, #1 	; increase counter by one&lt;br /&gt;
	b	multiply_loop	; branch to loop, that is - start the loop again	&lt;br /&gt;
multiply_finish&lt;br /&gt;
	mov	r0, r2 		; store result in R0 as per ARM conventions&lt;br /&gt;
        mov     pc, lr          ; same as B LR or in other words return to caller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the libmax.s you can use following snippet to emulate the behaviour of findmax.s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=asm&amp;gt;&lt;br /&gt;
; This stuff is so you could run the libmax.s in the ARM simulator&lt;br /&gt;
; Don&#039;t attempt to compile to assembly the program which has printf and main!&lt;br /&gt;
; Instead try to do it from scratch, it should look something like this:&lt;br /&gt;
; Since the array can have variable length we can&#039;t map them to registers 1:1&lt;br /&gt;
; Instead you pass the pointer to the array, that is the memory address of the array&#039;s contents&lt;br /&gt;
; In the invoking code just use STR instructions to store the numbers in memory&lt;br /&gt;
&lt;br /&gt;
mov     r0, r13            ; pass the memory address where you stored the array&#039;s contents&lt;br /&gt;
mov	r1, #20	   	  ; pass the second argument count to the function&lt;br /&gt;
&lt;br /&gt;
mov r5, #24               ; my birth date&lt;br /&gt;
mov r6, #10               ; my birth month&lt;br /&gt;
mov r7, #12               ; current hour&lt;br /&gt;
mov r8, #53               ; current minute&lt;br /&gt;
mov r9, #25               ; current minute&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}  ; copy register values to memory AND INCREMENT r13 by the number or registers * 4 bytes each&lt;br /&gt;
&lt;br /&gt;
; following just illustrates how you handle more numbers&lt;br /&gt;
mov r5, #123&lt;br /&gt;
mov r6, #624&lt;br /&gt;
mov r7, #873&lt;br /&gt;
mov r8, #762&lt;br /&gt;
mov r9, #543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #-123&lt;br /&gt;
mov r6, #-624&lt;br /&gt;
mov r7, #-873&lt;br /&gt;
mov r8, #-762&lt;br /&gt;
mov r9, #-543&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
mov r5, #54&lt;br /&gt;
mov r6, #34&lt;br /&gt;
mov r7, #98&lt;br /&gt;
mov r8, #76&lt;br /&gt;
mov r9, #84&lt;br /&gt;
stmfa r13, {r5,r6,r7,r8,r9}&lt;br /&gt;
&lt;br /&gt;
bl	max       	  ; place pc+4 into lr and jump to the function max&lt;br /&gt;
end                       ; stops the simulator&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exam question example==&lt;br /&gt;
&lt;br /&gt;
Explainations for the mnemonics used in the assembly snippet below:&lt;br /&gt;
&lt;br /&gt;
  mov r8, r7       -- Copy value from register r7 to register r8&lt;br /&gt;
  add r8, r7, r6   -- Add value of r7 to r6 and store the result in r8&lt;br /&gt;
  sub r8, r7, r6   -- Subtract value of r6 from r7 and store the result in r8&lt;br /&gt;
  b label          -- *Always* jump to label&lt;br /&gt;
  cmp r8, r7       -- Compare r8 and r7 and set flags accordingly&lt;br /&gt;
  blt label        -- Jump to label *only* if the leftmost operand is smaller than the rightmost in previously executed cmp &lt;br /&gt;
&lt;br /&gt;
Follow the instructions and elaborate what are the values left in the registers after the instruction finishes executing.&lt;br /&gt;
&lt;br /&gt;
  magic:&lt;br /&gt;
    mov r2, r0             -- Instruction address 0xff00&lt;br /&gt;
    mov r3, #0             -- Instruction address 0xff04&lt;br /&gt;
  loop:&lt;br /&gt;
    cmp r2, r1             -- Instruction address 0xff08&lt;br /&gt;
    blt finish             -- Instruction address 0xff10&lt;br /&gt;
    add r3, r3, #1         -- Instruction address 0xff14&lt;br /&gt;
    sub r2, r2, r1         -- Instruction address 0xff18&lt;br /&gt;
    b loop                 -- Instruction address 0xff1c&lt;br /&gt;
  finish:&lt;br /&gt;
    mov r0, r2             -- Instruction address 0xff20&lt;br /&gt;
    bx lr                  -- Instruction address 0xff24&lt;br /&gt;
&lt;br /&gt;
Fill in the table:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Registers&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|r0&lt;br /&gt;
|r1&lt;br /&gt;
|r2&lt;br /&gt;
|r3&lt;br /&gt;
|...&lt;br /&gt;
|r13&lt;br /&gt;
|r14&lt;br /&gt;
|r15&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Instruction&lt;br /&gt;
|a1&lt;br /&gt;
|a2&lt;br /&gt;
|a3&lt;br /&gt;
|a4&lt;br /&gt;
|...&lt;br /&gt;
|sp&lt;br /&gt;
|lr&lt;br /&gt;
|pc&lt;br /&gt;
|Top of the stack&lt;br /&gt;
|What happened?&lt;br /&gt;
|-&lt;br /&gt;
|bl magic&lt;br /&gt;
|39&lt;br /&gt;
|17&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|...&lt;br /&gt;
|0x8f00&lt;br /&gt;
|0xfa00&lt;br /&gt;
|0xff00&lt;br /&gt;
|?&lt;br /&gt;
|Function was invoked&lt;br /&gt;
|-&lt;br /&gt;
|mov r2,r0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mov r3,#0&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|...&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What does this function do?&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
&lt;br /&gt;
# Given the function for finding the largest value in an array use ARM cross compiler as shown above to generate the assembly corresponding to the C source code (1p).&lt;br /&gt;
# Remove the compiler hints (mostly lines starting with dot), this should leave you less than 20 instructions. If it&#039;s more than that try different optimization flags. Analyze and comment the assembly as shown above (1p).&lt;br /&gt;
# Use your day of birth, month of birth, current hour, minute, second as arguments as array values and follow the instructions, what values are left in the registers and top of the stack after each instruction finishes?  Use the table from [https://docs.google.com/spreadsheets/d/1H7BtkXRHJb-im29zbTLHIzKKSTbA1Ru8_yg6XwOirCI/edit?usp=sharing here] as a template (3p)&lt;br /&gt;
# Optional/extra: Elaborate step by step what happens in the processor: what instruction is being executed and what values are left in registers after instruction finishes? (1p)&lt;br /&gt;
# Optional/extra: Recompile with different optimization levels: &amp;lt;code&amp;gt;-Os&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-O2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-O3&amp;lt;/code&amp;gt;. What differences did you notice? (1p)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libmax.c the library portion of the program, or simply put the function definition:&lt;br /&gt;
&lt;br /&gt;
  int max(int *m, int count) {&lt;br /&gt;
       int largest = -99999;&lt;br /&gt;
       int i;&lt;br /&gt;
       for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
           if (m[i] &amp;gt; largest) {&lt;br /&gt;
               largest = m[i];&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       return largest;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
findmax.c, the invoking code:&lt;br /&gt;
&lt;br /&gt;
  int main() {&lt;br /&gt;
      int nums[5] = {1,-3,2,0,5};&lt;br /&gt;
      printf(&amp;quot;largest number is: %d&amp;quot;, max(nums, 5));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Investigating microcontrollers=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use Arduino to implement traffic lights for [http://www.nobleled.com/uploads/110833/100_101.jpg crossroads].&lt;br /&gt;
If you don&#039;t care much about doing this assignment hands on, you can give a try [https://123d.circuits.io/ online].&lt;br /&gt;
&lt;br /&gt;
==Assignment steps==&lt;br /&gt;
&lt;br /&gt;
* Install Arduino IDE on your personal machine, on Windows/Mac check out [https://www.arduino.cc/ Arduino homepage] for instructions, on Ubuntu &amp;lt;code&amp;gt;apt install arduino&amp;lt;/code&amp;gt; should suffice. You can also use school computers, Ubuntu has Arduino preinstalled.&lt;br /&gt;
* If you happen to have Java 9 running by default, check with &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; then you might have to switch to Java 8 instead: &amp;lt;code&amp;gt;sudo apt install openjdk-8-jdk; sudo update-java-alternatives -s java-1.8.0-openjdk-amd64&amp;lt;/code&amp;gt;&lt;br /&gt;
* From Arduino IDE menu open up File -&amp;gt; Examples -&amp;gt; 01. Basic -&amp;gt; Blink&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Board -&amp;gt; Arduino Mega2560&lt;br /&gt;
* In Arduino IDE menu Tools -&amp;gt; Serial port -&amp;gt; Select what makes sense&lt;br /&gt;
* On Ubuntu you may have to add yourself to the dialout group before you can access the serial ports. Use the command &amp;lt;code&amp;gt;sudo gpasswd -a $USER dialout&amp;lt;/code&amp;gt;, log out and log in again to your PC.&lt;br /&gt;
* Press the second button in the toolbar to upload the code, make sure the changes take effect on the board. You should see on-board LED blinking.&lt;br /&gt;
* Connect some LED-s to the board. &#039;&#039;&#039;MAKE SURE YOU USE RESISTORS TO PROTECT LED-s AND THE BOARD&#039;&#039;&#039;&lt;br /&gt;
* Implement traffic light cycle using &amp;lt;code&amp;gt;digitalWrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;delay&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;loop&amp;lt;/code&amp;gt; function (3p)&lt;br /&gt;
* Use interrupts to read button presses, see example below. Pressing the button should toggle the LED now (1p)&lt;br /&gt;
* Extra: Use [https://www.arduino.cc/en/Reference/AnalogWrite PWM] to implement smoother blinking (1p)&lt;br /&gt;
* Extra: Use [http://lauri.vosandi.com/arduino/lcd1602-key-shield.html LCD1602] shield to display countdown (1p)&lt;br /&gt;
* Use [https://www.arduino.cc/en/Reference/Serial serial] interface to send messages to your PC.&lt;br /&gt;
* You can find useful code snippets for Robotics club equipment [http://lauri.vosandi.com/arduino here]&lt;br /&gt;
&lt;br /&gt;
==Code example: reading button press with interrupts==&lt;br /&gt;
&lt;br /&gt;
Set up a push button as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Arduino-pushbutton_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Insert following code to Arduino IDE and upload it to Arduino, verify that it works:&lt;br /&gt;
&lt;br /&gt;
 int led = 13;&lt;br /&gt;
 int button  = 2;&lt;br /&gt;
 int flag = LOW;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(led, OUTPUT);         // Set up pin 13 as digital output&lt;br /&gt;
     pinMode(button, INPUT_PULLUP);       // Set up pin 9 as digital input with pull-up resistor enabled&lt;br /&gt;
 &lt;br /&gt;
     // Associate interrupt handler with an event&lt;br /&gt;
     attachInterrupt(digitalPinToInterrupt(button), onButtonPressed, FALLING);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Keep this as short as possible&lt;br /&gt;
     flag = HIGH;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     // Do something useful or let processor sleep here&lt;br /&gt;
     if (flag) {&lt;br /&gt;
         digitalWrite(led, HIGH);&lt;br /&gt;
         delay(2000);&lt;br /&gt;
         flag = LOW;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(led, LOW);&lt;br /&gt;
     delay(50);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Code example: Cycling through different traffic light states==&lt;br /&gt;
&lt;br /&gt;
Add LED-s to the design:&lt;br /&gt;
&lt;br /&gt;
[[File:Traffic-lights_bb.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Use following as hint to implement cycling through traffic light states:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers&lt;br /&gt;
 int car_green = 5;&lt;br /&gt;
 int car_yellow = 6;&lt;br /&gt;
 int car_red = 7;&lt;br /&gt;
 &lt;br /&gt;
 // For LED-s we&#039;re sinking the 5V voltage, hence LED is turned on when voltage on the pin is LOW&lt;br /&gt;
 int on = LOW;&lt;br /&gt;
 int off = HIGH;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     pinMode(car_green, OUTPUT);&lt;br /&gt;
     pinMode(car_yellow, OUTPUT);&lt;br /&gt;
     pinMode(car_red, OUTPUT);&lt;br /&gt;
     digitalWrite(cars_yellow, off);&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
     for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
         digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
         delay(500);&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_green, off);&lt;br /&gt;
     digitalWrite(cars_red, on);&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Skeleton of the final submission==&lt;br /&gt;
&lt;br /&gt;
The real traffic light has of course a little bit more states:&lt;br /&gt;
&lt;br /&gt;
 1. Cars green, pedestrians red for 10 seconds&lt;br /&gt;
 2. Cars green **blinking**, pedestrians red for 2 seconds&lt;br /&gt;
 3. Cars red, pedestrians green for 10 seconds&lt;br /&gt;
 4. Cars red, pedestrians green **blinking** for 2 seconds&lt;br /&gt;
 5. Cars yellow, pedestrians red for 2 seconds&lt;br /&gt;
&lt;br /&gt;
So your final code will look something like this:&lt;br /&gt;
&lt;br /&gt;
 // Define pin numbers here&lt;br /&gt;
 &lt;br /&gt;
 // Initially the flag is low&lt;br /&gt;
 int pedestrian_requested_crossing = LOW;&lt;br /&gt;
  &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Initialize necessary pins as digital outputs&lt;br /&gt;
     // Reset pins with digitalWrite&lt;br /&gt;
 &lt;br /&gt;
     // Initialize button pin as digital input&lt;br /&gt;
     // Enable pull-up resistor on button pin&lt;br /&gt;
     // Associate button interrupt handler function (onButtonPressed) below with the event on the button&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void onButtonPressed() {&lt;br /&gt;
     // Here set pedestrian_requested_crossing flag to HIGH&lt;br /&gt;
     // Don&#039;t do anything else here!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Cars green, pedestrians red for 5 seconds&amp;quot;);&lt;br /&gt;
     digitalWrite(cars_red, off);&lt;br /&gt;
     digitalWrite(cars_green, on);&lt;br /&gt;
     // Set pedestrian lights here&lt;br /&gt;
     delay(5000);&lt;br /&gt;
 &lt;br /&gt;
     if (pedestrian_requested_crossing) {&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Green for cars is blinking 5 seconds&amp;quot;);&lt;br /&gt;
         for(int j = 0; j &amp;lt; 10; j++) {&lt;br /&gt;
             digitalWrite(cars_green, j % 2 == 0);&lt;br /&gt;
             delay(500);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
         Serial.println(&amp;quot;Cars red, pedestrians green for 5 seconds&amp;quot;);&lt;br /&gt;
         digitalWrite(cars_green, off);&lt;br /&gt;
         digitalWrite(cars_red, on);&lt;br /&gt;
         // Set pedestrian lights here&lt;br /&gt;
         delay(5000);&lt;br /&gt;
 &lt;br /&gt;
         // Add another state here&lt;br /&gt;
 &lt;br /&gt;
         // And another state here&lt;br /&gt;
 &lt;br /&gt;
         // Reset flag here&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Adders with NAND gates=&lt;br /&gt;
&lt;br /&gt;
In this assignment we use chips to build an adder. Get max points (4p) by wiring up half adder and double your points (8p) if you can make full adder work as well :)&lt;br /&gt;
&lt;br /&gt;
[[File:53-7400n-detailed.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each SN74HC03N chip contains four NAND gates arranged like this, observe the pit on the left. VCC corresponds to 5V power supply and GND corresponds to ground or 0V.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Half adder==&lt;br /&gt;
&lt;br /&gt;
Each [http://www.ti.com/lit/gpn/sn74hc03 SN74HC03] contains 4 NAND gates.&lt;br /&gt;
Use breadboard to wire up half adder with 7400 chips (4p):&lt;br /&gt;
&lt;br /&gt;
[[File:Half-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
The truth table for half adder:&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1   |  0   | 2&lt;br /&gt;
&lt;br /&gt;
==Full adder==&lt;br /&gt;
&lt;br /&gt;
You can double your points if you manage to wire up a full adder (+4p)&lt;br /&gt;
&lt;br /&gt;
[[File:Nand-full-adder.png]]&lt;br /&gt;
&lt;br /&gt;
On a breadboard it looks a bit messy, but if you pay attention to gate numbering as shown above it should make your life significantly easier.&lt;br /&gt;
The gates 1, 2, 3, 4 are placed in the leftmost chip; 5, 6, 7, 8 are placed in the middle one and gate 9 is the only one in the rightmost chip:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Full-adder_bb.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   A  |  B  | Cin | Cout | Sum  | Human readable (how many bits are high?)&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  0  |  0   |  0   | 0&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  0  |  1  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   0  |  1  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  0  |  0   |  1   | 1&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  0  |  1  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  0  |  1   |  0   | 2&lt;br /&gt;
 -----+-----+-----+------+------+-------------------------------------------&lt;br /&gt;
   1  |  1  |  1  |  1   |  1   | 3&lt;br /&gt;
&lt;br /&gt;
==Unittest==&lt;br /&gt;
&lt;br /&gt;
Use following code snippet on Arduino to test the circuit, it will shuffle through all the possible inputs and test whether the expected output is on the output pins.&lt;br /&gt;
If you see &amp;lt;code&amp;gt;sum&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cout&amp;lt;/code&amp;gt; outputs giving 0 all the time it&#039;s likely you have resistors of too low resistance in the circuit which is draining all the voltage on the NAND gate output pins.&lt;br /&gt;
&lt;br /&gt;
 int PIN_A = 2;&lt;br /&gt;
 int PIN_B = 3;&lt;br /&gt;
 int PIN_CIN = 4;&lt;br /&gt;
 int PIN_SUM = 5;&lt;br /&gt;
 int PIN_COUT = 6;&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
     // Set up serial&lt;br /&gt;
     Serial.begin(9600);&lt;br /&gt;
     &lt;br /&gt;
     // Set up operands&lt;br /&gt;
     pinMode(PIN_A, OUTPUT);&lt;br /&gt;
     pinMode(PIN_B, OUTPUT);&lt;br /&gt;
     pinMode(PIN_CIN, OUTPUT);&lt;br /&gt;
     digitalWrite(PIN_A, HIGH);&lt;br /&gt;
     digitalWrite(PIN_B, HIGH);&lt;br /&gt;
     digitalWrite(PIN_CIN, HIGH);&lt;br /&gt;
     &lt;br /&gt;
     // Set up measurement pins&lt;br /&gt;
     pinMode(PIN_SUM, INPUT_PULLUP);&lt;br /&gt;
     pinMode(PIN_COUT, INPUT_PULLUP);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void test(int a, int b, int cin) {&lt;br /&gt;
     int cout = a &amp;amp;&amp;amp; b || a &amp;amp;&amp;amp; cin || b &amp;amp;&amp;amp; cin;&lt;br /&gt;
     int sum = a ^ b ^ cin;&lt;br /&gt;
     &lt;br /&gt;
     digitalWrite(PIN_A, a);&lt;br /&gt;
     digitalWrite(PIN_B, b);&lt;br /&gt;
     digitalWrite(PIN_CIN, cin);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;Writing: a=&amp;quot;);&lt;br /&gt;
     Serial.print(a);&lt;br /&gt;
     Serial.print(&amp;quot;, b=&amp;quot;);&lt;br /&gt;
     Serial.print(b);&lt;br /&gt;
     Serial.print(&amp;quot;, cin=&amp;quot;);&lt;br /&gt;
     Serial.print(cin);&lt;br /&gt;
     Serial.print(&amp;quot;  Expecting: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(sum);&lt;br /&gt;
     Serial.print(&amp;quot;, cout=&amp;quot;);&lt;br /&gt;
     Serial.print(cout);&lt;br /&gt;
     &lt;br /&gt;
     int measured_sum = digitalRead(PIN_SUM);&lt;br /&gt;
     int measured_cout = digitalRead(PIN_COUT);&lt;br /&gt;
 &lt;br /&gt;
     Serial.print(&amp;quot;  Got: sum=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_sum);&lt;br /&gt;
     Serial.print(&amp;quot; cout=&amp;quot;);&lt;br /&gt;
     Serial.print(measured_cout);&lt;br /&gt;
     &lt;br /&gt;
     Serial.print(&amp;quot;  Test:&amp;quot;);&lt;br /&gt;
     if (measured_sum != sum || measured_cout != cout) {&lt;br /&gt;
         Serial.print(&amp;quot;  FAIL&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         Serial.print(&amp;quot;  GOOD&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     Serial.println();&lt;br /&gt;
     delay(500);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
     Serial.println(&amp;quot;Running test&amp;quot;);&lt;br /&gt;
     test(0, 0, 0);&lt;br /&gt;
     test(0, 0, 1);&lt;br /&gt;
     test(0, 1, 0);&lt;br /&gt;
     test(0, 1, 1);&lt;br /&gt;
     test(1, 0, 0);&lt;br /&gt;
     test(1, 0, 1);&lt;br /&gt;
     test(1, 1, 0);&lt;br /&gt;
     test(1, 1, 1);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=Assignment: Debugging ALU design=&lt;br /&gt;
&lt;br /&gt;
Bob had to ship the ALU design to the hardware manufacturer by yesterday. The project manager is angry about missed deadline. Bob still hasn&#039;t figured out why the ALU is not working properly. Help Bob by figuring out what&#039;s the problem.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 14.04 install GHDL and GtkWave:&lt;br /&gt;
&lt;br /&gt;
 sudo add-apt-repository ppa:pgavin/ghdl&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install ghdl gtkwave git&lt;br /&gt;
&lt;br /&gt;
If you&#039;re on Ubuntu 16.04:&lt;br /&gt;
&lt;br /&gt;
 wget https://launchpad.net/~pgavin/+archive/ubuntu/ghdl/+build/6057094/+files/ghdl_0.31-1pgavin2~trusty2_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/libgnat-4.8_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 wget http://cz.archive.ubuntu.com/ubuntu/pool/universe/g/gnat-4.8/gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb&lt;br /&gt;
 sudo dpkg -i libgnat-4.8_4.8.2-8ubuntu3_amd64.deb  gnat-4.8-base_4.8.2-8ubuntu3_amd64.deb  ghdl_0.31-1pgavin2~trusty2_amd64.deb &lt;br /&gt;
 sudo apt -f install&lt;br /&gt;
 sudo apt install gtkwave&lt;br /&gt;
&lt;br /&gt;
Clone the repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/laurivosandi/vhdl-exercise&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; to compile the components and run the testbench:&lt;br /&gt;
&lt;br /&gt;
 cd path/to/vhdl-exercise&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
Expected output of the testbench:&lt;br /&gt;
&lt;br /&gt;
 alu_testbench.vhd:77:9:@360ns:(report note): Finished testing addition operation of ALU&lt;br /&gt;
 alu_testbench.vhd:106:9:@1us:(report note): Finished testing subtraction operation of ALU&lt;br /&gt;
 alu_testbench.vhd:135:9:@1640ns:(report note): Finished testing NAND operation of ALU&lt;br /&gt;
 alu_testbench.vhd:166:9:@2280ns:(report note): Finished testing NOR operation of ALU&lt;br /&gt;
&lt;br /&gt;
However there are few bugs in &amp;lt;code&amp;gt;alu.vhd&amp;lt;/code&amp;gt;, find the bugs and correct them. If this is your first experience with VHDL, take a look [http://lauri.vosandi.com/hdl/ here].&lt;br /&gt;
&lt;br /&gt;
=Assignment: Publishing your work=&lt;br /&gt;
&lt;br /&gt;
* Clean up your Git repositories and send the URL of a repository that you&#039;ve actively worked on (for example the one from Java course) to Lauri, but before check the following:&lt;br /&gt;
** The repository should show changes you&#039;ve made over at least few days.&lt;br /&gt;
** The repository has to contain only plaintext files unless there is a really good reason not to (eg. images).&lt;br /&gt;
** There has to be authorship information in the files.&lt;br /&gt;
** Add &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file to your GitHub repositories to ignore temporary files, see [https://git-scm.com/docs/gitignore Git docs] for more details.&lt;br /&gt;
** Add [http://opensource.org/licenses LICENSE] file in the repository directory and commit the changes. LICENSE should answer to some important questions&lt;br /&gt;
*** Who is the copyright holder?&lt;br /&gt;
*** Under which conditions is redistribution permitted?&lt;br /&gt;
** Add nicely formatted README file, see [https://help.github.com/articles/markdown-basics/ Markdown] (online editor [http://dillinger.io here]) and [http://sphinx-doc.org/rest.html reStructuredText] for more details. README should answer to several silly questions:&lt;br /&gt;
*** What is the repository about?&lt;br /&gt;
*** Who made it?&lt;br /&gt;
*** How can the author be contacted? E-mail address, IRC chat channel on Freenode, Skype username?&lt;br /&gt;
*** How can the code be used? What hardware is necessary? How should the user wire the circuit to make it work? Add images if necessary.&lt;br /&gt;
*** What is the policy for including changes from third party developers?&lt;br /&gt;
* There will be more details here&lt;br /&gt;
&lt;br /&gt;
=Extra points=&lt;br /&gt;
&lt;br /&gt;
Here you can claim extra credit points for various tasks, this is mostly to improve the quality of wiki.itcollege.ee.&lt;br /&gt;
Once you have taken care of the task insert your name in the end of the line with corresponding date.&lt;br /&gt;
&lt;br /&gt;
* Expand [[Getting started with Ubuntu#Installing in VirtualBox]] section with highlighted screenshots of VirtualBox. Points: 1p&lt;br /&gt;
* Create [[Claiming GitHub Student Developer Pack]] with screenshots how to add @itcollege.ee e-mail to your GitHub profile and claim [https://education.github.com/pack Student Developer Pack] Points: 2p&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:ICS0023_Robotics&amp;diff=124186</id>
		<title>Category:ICS0023 Robotics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:ICS0023_Robotics&amp;diff=124186"/>
		<updated>2017-09-16T05:25:58Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Teams */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Intro==&lt;br /&gt;
&lt;br /&gt;
The Robotics course is intended to provide 6 ECTS for participating in the Robotics Club activities.&lt;br /&gt;
From September until November of 2017 the main focus is to get two basketball robots and four sumorobots ready for Robotex 2017.&lt;br /&gt;
&lt;br /&gt;
Basically attend lectures, pick any of the suggested tasks/projects, confirm with Lauri and earn your ECTS.&lt;br /&gt;
&lt;br /&gt;
==Lectures/meetings==&lt;br /&gt;
&lt;br /&gt;
For September four lectures/meetings will take place:&lt;br /&gt;
&lt;br /&gt;
* 7. September 14:00-15:30 room 410 in College building - Introduction of Robotics Club, it&#039;s equipment, capabilities and resources. Recap of last year, take a look at running projects.&lt;br /&gt;
* 14. September 14:00-15:30 room 410 in College building - Image recognition, OpenCV, Python, video capture/playback&lt;br /&gt;
* 21. September 14:00-15:30 room 410 in College building - Microcontrollers, take a look at Arduino, ESP32 and their capabilities&lt;br /&gt;
* 28. September 14:00-15:30 room 410 in College building - Powering circuits, work safety, measuring tools, form teams for Robotex 2017.&lt;br /&gt;
&lt;br /&gt;
After September students are expected to with their group on a weekly basis at Robotics Club (room 412) to work on their project,&lt;br /&gt;
for easier synchronization there shall be pizza on Thursdays 18:00 :)&lt;br /&gt;
&lt;br /&gt;
24-26. November - Qualify at Robotex with your team&#039;s robot&lt;br /&gt;
&lt;br /&gt;
==Tasks &amp;amp; projects==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Basketball robot source and relevant issues: https://github.com/eik-robo/zoidberg/issues&lt;br /&gt;
&lt;br /&gt;
* K-means clustering for image recognition&lt;br /&gt;
* Pipeline latency measurement&lt;br /&gt;
* Basketball throwing mechanism design and assembly&lt;br /&gt;
&lt;br /&gt;
Sumorobot source and relevant issues: https://github.com/eik-robo/sumoesp&lt;br /&gt;
&lt;br /&gt;
* Conduct workshops for children&lt;br /&gt;
* Web interface development&lt;br /&gt;
* Make sumo programmable in a new programming language&lt;br /&gt;
&lt;br /&gt;
Learn about gadget, publish howto and conduct workshop&lt;br /&gt;
&lt;br /&gt;
* WiFi Pineapple NANO&lt;br /&gt;
* Bash Bunny&lt;br /&gt;
* USB Rubber Ducky&lt;br /&gt;
* LAN Turtle&lt;br /&gt;
* HackRF&lt;br /&gt;
* Proxmark 3&lt;br /&gt;
* Yubikey&lt;br /&gt;
&lt;br /&gt;
Robotics club PR:&lt;br /&gt;
&lt;br /&gt;
* Maintain homepage, write and publish stories&lt;br /&gt;
* Create page at hackerspaces.org&lt;br /&gt;
* Find sponsors&lt;br /&gt;
&lt;br /&gt;
Other&lt;br /&gt;
&lt;br /&gt;
* Set up inventory management/tracking&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==For fun==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Solder [https://github.com/laurivosandi/nixiesp12 Nixie clocks]&lt;br /&gt;
* Build space probe&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Teams=&lt;br /&gt;
&lt;br /&gt;
==Teh space probe==&lt;br /&gt;
&lt;br /&gt;
Members: Mikus, Frank&lt;br /&gt;
&lt;br /&gt;
Hardware missing: none?&lt;br /&gt;
&lt;br /&gt;
==Zoidberg &amp;amp; Nibbler vol2==&lt;br /&gt;
&lt;br /&gt;
Members: Marek, Madis, Taivo, Fred&lt;br /&gt;
&lt;br /&gt;
Hardware needed: ?&lt;br /&gt;
&lt;br /&gt;
==Linefollower==&lt;br /&gt;
&lt;br /&gt;
Members: Madis H, Henri, Madis V&lt;br /&gt;
&lt;br /&gt;
Hardware needed: suitable motors? 3D printed frame?&lt;br /&gt;
&lt;br /&gt;
==Boat==&lt;br /&gt;
&lt;br /&gt;
Members: Andreas&lt;br /&gt;
&lt;br /&gt;
Hardware needed: ?&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:ICS0023_Robotics&amp;diff=124185</id>
		<title>Category:ICS0023 Robotics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:ICS0023_Robotics&amp;diff=124185"/>
		<updated>2017-09-16T05:22:10Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Intro==&lt;br /&gt;
&lt;br /&gt;
The Robotics course is intended to provide 6 ECTS for participating in the Robotics Club activities.&lt;br /&gt;
From September until November of 2017 the main focus is to get two basketball robots and four sumorobots ready for Robotex 2017.&lt;br /&gt;
&lt;br /&gt;
Basically attend lectures, pick any of the suggested tasks/projects, confirm with Lauri and earn your ECTS.&lt;br /&gt;
&lt;br /&gt;
==Lectures/meetings==&lt;br /&gt;
&lt;br /&gt;
For September four lectures/meetings will take place:&lt;br /&gt;
&lt;br /&gt;
* 7. September 14:00-15:30 room 410 in College building - Introduction of Robotics Club, it&#039;s equipment, capabilities and resources. Recap of last year, take a look at running projects.&lt;br /&gt;
* 14. September 14:00-15:30 room 410 in College building - Image recognition, OpenCV, Python, video capture/playback&lt;br /&gt;
* 21. September 14:00-15:30 room 410 in College building - Microcontrollers, take a look at Arduino, ESP32 and their capabilities&lt;br /&gt;
* 28. September 14:00-15:30 room 410 in College building - Powering circuits, work safety, measuring tools, form teams for Robotex 2017.&lt;br /&gt;
&lt;br /&gt;
After September students are expected to with their group on a weekly basis at Robotics Club (room 412) to work on their project,&lt;br /&gt;
for easier synchronization there shall be pizza on Thursdays 18:00 :)&lt;br /&gt;
&lt;br /&gt;
24-26. November - Qualify at Robotex with your team&#039;s robot&lt;br /&gt;
&lt;br /&gt;
==Tasks &amp;amp; projects==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Basketball robot source and relevant issues: https://github.com/eik-robo/zoidberg/issues&lt;br /&gt;
&lt;br /&gt;
* K-means clustering for image recognition&lt;br /&gt;
* Pipeline latency measurement&lt;br /&gt;
* Basketball throwing mechanism design and assembly&lt;br /&gt;
&lt;br /&gt;
Sumorobot source and relevant issues: https://github.com/eik-robo/sumoesp&lt;br /&gt;
&lt;br /&gt;
* Conduct workshops for children&lt;br /&gt;
* Web interface development&lt;br /&gt;
* Make sumo programmable in a new programming language&lt;br /&gt;
&lt;br /&gt;
Learn about gadget, publish howto and conduct workshop&lt;br /&gt;
&lt;br /&gt;
* WiFi Pineapple NANO&lt;br /&gt;
* Bash Bunny&lt;br /&gt;
* USB Rubber Ducky&lt;br /&gt;
* LAN Turtle&lt;br /&gt;
* HackRF&lt;br /&gt;
* Proxmark 3&lt;br /&gt;
* Yubikey&lt;br /&gt;
&lt;br /&gt;
Robotics club PR:&lt;br /&gt;
&lt;br /&gt;
* Maintain homepage, write and publish stories&lt;br /&gt;
* Create page at hackerspaces.org&lt;br /&gt;
* Find sponsors&lt;br /&gt;
&lt;br /&gt;
Other&lt;br /&gt;
&lt;br /&gt;
* Set up inventory management/tracking&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==For fun==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Solder [https://github.com/laurivosandi/nixiesp12 Nixie clocks]&lt;br /&gt;
* Build space probe&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Teams=&lt;br /&gt;
&lt;br /&gt;
==Teh space probe==&lt;br /&gt;
&lt;br /&gt;
Members: Mikus, Frank&lt;br /&gt;
&lt;br /&gt;
Hardware missing: none?&lt;br /&gt;
&lt;br /&gt;
==Zoidberg vol2==&lt;br /&gt;
&lt;br /&gt;
Members: Marek, Madis, Taivo&lt;br /&gt;
&lt;br /&gt;
Hardware needed: ?&lt;br /&gt;
&lt;br /&gt;
==Linefollower==&lt;br /&gt;
&lt;br /&gt;
Members: Madis H, Henri, Madis V&lt;br /&gt;
&lt;br /&gt;
Hardware needed: suitable motors? 3D printed frame?&lt;br /&gt;
&lt;br /&gt;
==Boat==&lt;br /&gt;
&lt;br /&gt;
Members: Andreas&lt;br /&gt;
&lt;br /&gt;
Hardware needed: ?&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:ICS0023_Robotics&amp;diff=124184</id>
		<title>Category:ICS0023 Robotics</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:ICS0023_Robotics&amp;diff=124184"/>
		<updated>2017-09-16T05:21:50Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Intro==&lt;br /&gt;
&lt;br /&gt;
The Robotics course is intended to provide 6 ECTS for participating in the Robotics Club activities.&lt;br /&gt;
From September until November of 2017 the main focus is to get two basketball robots and four sumorobots ready for Robotex 2017.&lt;br /&gt;
&lt;br /&gt;
Basically attend lectures, pick any of the suggested tasks/projects, confirm with Lauri and earn your ECTS.&lt;br /&gt;
&lt;br /&gt;
==Lectures/meetings==&lt;br /&gt;
&lt;br /&gt;
For September four lectures/meetings will take place:&lt;br /&gt;
&lt;br /&gt;
* 7. September 14:00-15:30 room 410 in College building - Introduction of Robotics Club, it&#039;s equipment, capabilities and resources. Recap of last year, take a look at running projects.&lt;br /&gt;
* 14. September 14:00-15:30 room 410 in College building - Image recognition, OpenCV, Python, video capture/playback&lt;br /&gt;
* 21. September 14:00-15:30 room 410 in College building - Microcontrollers, take a look at Arduino, ESP32 and their capabilities&lt;br /&gt;
* 28. September 14:00-15:30 room 410 in College building - Powering circuits, work safety, measuring tools, form teams for Robotex 2017.&lt;br /&gt;
&lt;br /&gt;
After September students are expected to with their group on a weekly basis at Robotics Club (room 412) to work on their project,&lt;br /&gt;
for easier synchronization there shall be pizza on Thursdays 18:00 :)&lt;br /&gt;
&lt;br /&gt;
24-26. November - Qualify at Robotex with your team&#039;s robot&lt;br /&gt;
&lt;br /&gt;
==Tasks &amp;amp; projects==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Basketball robot source and relevant issues: https://github.com/eik-robo/zoidberg/issues&lt;br /&gt;
&lt;br /&gt;
* K-means clustering for image recognition&lt;br /&gt;
* Pipeline latency measurement&lt;br /&gt;
* Basketball throwing mechanism design and assembly&lt;br /&gt;
&lt;br /&gt;
Sumorobot source and relevant issues: https://github.com/eik-robo/sumoesp&lt;br /&gt;
&lt;br /&gt;
* Conduct workshops for children&lt;br /&gt;
* Web interface development&lt;br /&gt;
* Make sumo programmable in a new programming language&lt;br /&gt;
&lt;br /&gt;
Learn about gadget, publish howto and conduct workshop&lt;br /&gt;
&lt;br /&gt;
* WiFi Pineapple NANO&lt;br /&gt;
* Bash Bunny&lt;br /&gt;
* USB Rubber Ducky&lt;br /&gt;
* LAN Turtle&lt;br /&gt;
* HackRF&lt;br /&gt;
* Proxmark 3&lt;br /&gt;
* Yubikey&lt;br /&gt;
&lt;br /&gt;
Robotics club PR:&lt;br /&gt;
&lt;br /&gt;
* Maintain homepage, write and publish stories&lt;br /&gt;
* Create page at hackerspaces.org&lt;br /&gt;
* Find sponsors&lt;br /&gt;
&lt;br /&gt;
Other&lt;br /&gt;
&lt;br /&gt;
* Set up inventory management/tracking&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==For fun==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Solder [https://github.com/laurivosandi/nixiesp12 Nixie clocks]&lt;br /&gt;
* Build space probe&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Teams=&lt;br /&gt;
&lt;br /&gt;
==Teh space probe==&lt;br /&gt;
&lt;br /&gt;
Members: Mikus, Frank&lt;br /&gt;
Hardware missing: none?&lt;br /&gt;
&lt;br /&gt;
==Zoidberg vol2==&lt;br /&gt;
&lt;br /&gt;
Members: Marek, Madis, Taivo&lt;br /&gt;
Hardware needed: ?&lt;br /&gt;
&lt;br /&gt;
==Linefollower==&lt;br /&gt;
&lt;br /&gt;
Members: Madis H, Henri, Madis V&lt;br /&gt;
Hardware needed: suitable motors? 3D printed frame?&lt;br /&gt;
&lt;br /&gt;
==Boat==&lt;br /&gt;
&lt;br /&gt;
Members: Andreas&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=124174</id>
		<title>Category:I802 Firewalls and VPN IPSec (2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Category:I802_Firewalls_and_VPN_IPSec_(2017)&amp;diff=124174"/>
		<updated>2017-09-15T03:57:41Z</updated>

		<summary type="html">&lt;p&gt;Lvosandi: /* Lectures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Firewalls and VPN/IPSec=&lt;br /&gt;
&lt;br /&gt;
==General information==&lt;br /&gt;
&lt;br /&gt;
ECTS: 4&lt;br /&gt;
&lt;br /&gt;
Lecturer: Lauri Võsandi&lt;br /&gt;
&lt;br /&gt;
To register to this course send your SSH public key to Lauri and state which service you want to configure.&lt;br /&gt;
&lt;br /&gt;
==Scenario==&lt;br /&gt;
&lt;br /&gt;
In this course we will attempt to set up a network similar to a corporate network with multiple offices, eg http://docplayer.it/docs-images/20/596222/images/25-0.png&lt;br /&gt;
&lt;br /&gt;
Our virtual company&#039;s story is based on [http://futurama.wikia.com/wiki/MomCorp Mom&#039;s Friendly Robot Company].&lt;br /&gt;
&lt;br /&gt;
We will use VPN software to connect subnets to each other and we will use VPN software to connect our personal computers to the intranet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Hardware==&lt;br /&gt;
&lt;br /&gt;
School&#039;s infra provides with public subnet for 62 hosts:&lt;br /&gt;
&lt;br /&gt;
* IPv4 address: 193.40.244.129-188&lt;br /&gt;
* Subnet: /26&lt;br /&gt;
* Gateway: 193.40.244.188&lt;br /&gt;
* DNS: 8.8.8.8&lt;br /&gt;
&lt;br /&gt;
That network is physically routed to 413-6-16 port in room 413.&lt;br /&gt;
&lt;br /&gt;
We have total of about 264GB of RAM and couple of terabytes of SSD storage:&lt;br /&gt;
&lt;br /&gt;
* Marek&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s (hosts 130-139)&lt;br /&gt;
* Madis&#039; box HP Proliant G5, 4x quadcore Opteron, 64GB RAM, 2 NIC-s (hosts 140-149)&lt;br /&gt;
* Erik&#039;s box Sun 32GB, 2x 256GB SSD (hosts 155-159)&lt;br /&gt;
* Lauri&#039;s box HP Proliant G5 2x quadcore Xeon, 64G RAM, 2 NIC-s, 4x 250G SSD (hosts 160-179)&lt;br /&gt;
* Frank&#039;s box DELL 16GB, 2x 256GB SSD, 6 NIC (hosts 180-185)&lt;br /&gt;
* Another Sun box with 24G of RAM, dying harddisks&lt;br /&gt;
&lt;br /&gt;
NB! Replace BIOS batteries; replace thermal paste&lt;br /&gt;
&lt;br /&gt;
==Grading==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to do pick a topic from the services list below.&lt;br /&gt;
Send your SSH public key to Lauri and state which service you want to take care of.&lt;br /&gt;
&lt;br /&gt;
Collect 100p in total to pass the course, note that there are opportunities to collect much more points in total:&lt;br /&gt;
&lt;br /&gt;
* Get the service up and running (15p)&lt;br /&gt;
* Configure Let&#039;s Encrypt certificates for your service if applicable (15p)&lt;br /&gt;
* Add your service to monitoring at mon.momcorp.eu (15p)&lt;br /&gt;
* Enable log forwarding to log.momcorp.eu, if applicable configure auditing for your service (15p)&lt;br /&gt;
* Configure your service to send e-mails (mail.momcorp.eu) if applicable (15p)&lt;br /&gt;
* Keep the service up and running through the semester (up to -20p)&lt;br /&gt;
* Keep the bad guys out from your servers (up to -30p)&lt;br /&gt;
* Have a disaster recovery plan (up to -20p)&lt;br /&gt;
* Configure layer3 firewall (15p)&lt;br /&gt;
* Configure application firewall(s) if applicable&lt;br /&gt;
* Configure your laptop to connect to intranet using OpenVPN and IPSec (15p)&lt;br /&gt;
* Configure your mobile device to connect to intranet using OpenVPN or IPSec (15p)&lt;br /&gt;
* Configure your service to use authentication from AD (20p)&lt;br /&gt;
&lt;br /&gt;
We will start with services facing the public internet, see what&#039;s the worst that can happen in that case and later migrate some services to intranet only. Some services will retain connectivity to public internet due to their nature (eg OwnCloud, mailserver) and some services will be available only in the intranet (eg fileserver)&lt;br /&gt;
&lt;br /&gt;
==Services==&lt;br /&gt;
&lt;br /&gt;
To support our virtual company in everyday business we need to provide them with a variety of services:&lt;br /&gt;
&lt;br /&gt;
* www.momcorp.eu - Install webserver/load balancer and create a homepage for the company and link to remaining sites. Olusiji&lt;br /&gt;
* shop.momcorp.eu - Install Magento and add some fictive products like dark matter and neutron star. Sander&lt;br /&gt;
* wiki.momcorp.eu - Install MediaWiki, later integrate with AD. Peep&lt;br /&gt;
* blog.momcorp.eu - Install WordPress, later integrate with AD. Steven&lt;br /&gt;
* chat.momcorp.eu - Install IRC server, provide  multiple channels for developers. Install some web based software for customer helldesk. Ardi&lt;br /&gt;
* ns1.momcorp.eu - Primary Bind9 installation, later also add DNSSEC. Erik J&lt;br /&gt;
* ns2.momcorp.eu - Secondary Bind9 installation in another physical host. ???&lt;br /&gt;
* git.momcorp.eu - Gogs installation. ???&lt;br /&gt;
* mon.momcorp.eu - Nagios monitoring. Nika&lt;br /&gt;
* mail.momcorp.eu - Mailserver with Postfix (postfw, greylisting, dkim, spf, setup secondary mx), later with AD integration if exchange won&#039;t be used. Andris&lt;br /&gt;
* ca.momcorp.eu - Java servlet container, EJBCA installation for certificate management. ???&lt;br /&gt;
* nas.momcorp.eu - Samba fileserver. Hindrek&lt;br /&gt;
* log.momcorp.eu - Graylog or similar for central logging. Kaspar, Sten-Erik&lt;br /&gt;
* vpn.momcorp.eu - OpenVPN gateway. Moira&lt;br /&gt;
* cs.momcorp.eu - Teamspeak and/or gaming server for entertainment. Christopher&lt;br /&gt;
&lt;br /&gt;
Additionally for each physical box listed under Hardware we could set up:&lt;br /&gt;
&lt;br /&gt;
* Person responsible for the hypervisor on that box&lt;br /&gt;
* Virtual machine with router OS - Mikrotik RouterOS, Vyatta, pfsense or just vanilla Debian with shell scripts&lt;br /&gt;
&lt;br /&gt;
Other topics:&lt;br /&gt;
&lt;br /&gt;
* Mikus - Remote management: Puppet master, DSC, postfix with kerberos (and AD?)&lt;br /&gt;
* Strongswan gateway&lt;br /&gt;
* OpenVPN gateway, later AD integration&lt;br /&gt;
* Exchange&lt;br /&gt;
* failover/high availability (heartbeat)&lt;br /&gt;
* db clusters/shards/replication (mysql/mariadb)&lt;br /&gt;
* clustered filesystems/servers (clvm, corosync, fenced, gfs)&lt;br /&gt;
* web caches (varnish, squid, nginx)&lt;br /&gt;
* load balancing (haproxy, nginx, simple roundrobin)&lt;br /&gt;
&lt;br /&gt;
==Lectures==&lt;br /&gt;
&lt;br /&gt;
Following lectures are planned:&lt;br /&gt;
&lt;br /&gt;
* 7. sept - Intro, virtualization, containers etc. Relevant story [https://lauri.xn--vsandi-pxa.com/lan/virtualization.html here]&lt;br /&gt;
* 14. sept - Network topology, bridges, tagging, trunking, subnetting, LAN, WAN&lt;br /&gt;
* 21. sept - iptables, ebtables, packet forwarding, DNAT, SNAT, routing tables&lt;br /&gt;
* 28. sept - X.509 certificates, certificate authority, TLS, symmetric, asymmetric, keyexchange, Let&#039;s Encrypt, relevant slides [https://docs.google.com/presentation/d/1kqTyhhUu5CfwODmOTIC7odhlYfeEeJALTd4RX7XhPLE/edit?usp=sharing here]&lt;br /&gt;
&lt;br /&gt;
Order to be determined:&lt;br /&gt;
&lt;br /&gt;
* OpenVPN&lt;br /&gt;
* IPSec&lt;br /&gt;
* TBD, there are a lot of topics to discuss&lt;/div&gt;</summary>
		<author><name>Lvosandi</name></author>
	</entry>
</feed>