Differences

This shows you the differences between two versions of the page.

Link to this comparison view

alf:teme:tema_en_1 [2021/03/06 13:55]
alexandru.radovici
alf:teme:tema_en_1 [2021/03/17 16:21] (current)
alexandru.radovici [Rules]
Line 1: Line 1:
-====== Homework 1 - CPU Simulation ​===== +====== Homework 1 - Simulator ​===== 
  
  
Line 7: Line 7:
 Deadline: **21st of March, 23:55**\\ Deadline: **21st of March, 23:55**\\
 Points: **1 point** out of the final grade\\ Points: **1 point** out of the final grade\\
-Link: \\ +Link: [[https://​classroom.github.com/​a/​olSpOMPY|Homework 1]]\\ 
-Late upload: **not allowed**\\+Late upload: **1p / day** (maximum 2 days)\\
 </​note>​ </​note>​
  
Line 109: Line 109:
  ; stack is [ 10 ]  ; stack is [ 10 ]
  </​code>​ |  </​code>​ |
-| jumpz | integer number / label | If the top value from the stack is zero, it works the same way as `jump`, otherwise it does nothing ​ | <code asm> ; example ignore+| jumpz | integer number / label | If the top value from the stack is zero, it works the same way as ''​jump''​, otherwise it does nothing ​ | <code asm> ; example ignore
  push 5  ​  push 5  ​
  jumpz two ; ignored, stack top is 5  jumpz two ; ignored, stack top is 5
Line 126: Line 126:
  ; stack is [ 0 ]  ; stack is [ 0 ]
  </​code>​ |  </​code>​ |
-| jumpnz | integer number / label | If the top value from the stack is not zero, it works the same way as `jump`, otherwise it does nothing ​ | <code asm> ; example ignore+| jumpnz | integer number / label | If the top value from the stack is not zero, it works the same way as ''​jump''​, otherwise it does nothing ​ | <code asm> ; example ignore
  push 5  ​  push 5  ​
  jumpz two ; jumps, stack top is not 0  jumpz two ; jumps, stack top is not 0
Line 165: Line 165:
 | stack underflow | the simulator tries to execute an instruction that pops some values from the stack, but the stack does not have enough values | <code asm>push 1 | stack underflow | the simulator tries to execute an instruction that pops some values from the stack, but the stack does not have enough values | <code asm>push 1
  mul ; ERROR (mul): stack underflow</​code>​|  mul ; ERROR (mul): stack underflow</​code>​|
-| unable to open file `filename(`node error message`) | the simulator tries to open a file that it cannot open | <code bash>$ node index not_a_filename.asm +| unable to open file ''​filename'' ​(''​node error message''​) | the simulator tries to open a file that it cannot open | <code bash>$ node index not_a_filename.asm 
-ERROR unable to open file filename.asm(ENOENT:​ no such file or directory, open '​filename.asm'​)</​code>​|+ERROR unable to open file filename.asm(ENOENT:​ no such  
 +file or directory, open '​filename.asm'​)</​code>​|
 | undefined label | the simulator tries to jump to a label that is not defined | <code asm>jump jumper ; ERROR (jump): undefined label jumper</​code>​| | undefined label | the simulator tries to jump to a label that is not defined | <code asm>jump jumper ; ERROR (jump): undefined label jumper</​code>​|
 | invalid jump address | the simulator tries to jump to an address (line number) that does not exist in the file | <code asm> jump 2 ; ERROR (mul): invalid jump address 2</​code>​| | invalid jump address | the simulator tries to jump to an address (line number) that does not exist in the file | <code asm> jump 2 ; ERROR (mul): invalid jump address 2</​code>​|
- 
- 
  
  
Line 191: Line 190:
  
 <​note>​The $ in the examples is the shell'​s prompt and is not part of the command</​note>​ <​note>​The $ in the examples is the shell'​s prompt and is not part of the command</​note>​
 +
 +===== Grading Tests =====
 +The homework tests will have the following format:
 +
 +All tests will have debug instructions.
 +
 +^ Grade ^ Tests ^
 +| 50% | stack and mathematical instructions |
 +| 20% | jump instructions |
 +| 10% | labels |
 +| 10% | register instructions |
 +| 10% | errors |
 +
 +
 +===== Implementation advice =====
 +
 +The homework has a lot of features that have to be implemented,​ we suggest you start like this:
 +  - Read the input file into s string and implement the ''​no file''​ error
 +  - Split the read input by ''​\n''​ (''​\r\n''​ if using windows, make sure top change it before you commit to git) string using the [[https://​developer.mozilla.org/​en-US/​docs/​Web/​JavaScript/​Reference/​Global_Objects/​String/​split|split]] function
 +  - Split each line by ' ' and extract the instruction and its parameters
 +  - Implement the ''​unknown instruction''​ error
 +  - Implement the ''​push''​ and ''​pop''​ instructions using an array of numbers for the stack
 +  - Implement the math instructions
 +  - Implement all the instructions
  
 ===== Bonus ===== ===== Bonus =====
  
-For an additional **0.25p**, implement the calculator to work for complex numbers for addition, subtraction and multiply. The input format ​will be: +For an additional **2p**, implement ​a memory for the CPU. The simulator ​will receive another parameter in the command line that represents the number of memory locations available.
-<code bash> +
-#add a1+b1i with a2+b2i +
-node main.js a1 b1 a2 b2 complex ++
  
-#subtract a1+b1i with a2+b2i +Implement the following memory instructions:​
-node main.js a1 b1 a2 b2 complex -+
  
-#multiply a1+b1i with a2+b2i +^ Instruction ^ Parameter ^ Details ^ 
-node main.js a1 b1 a2 b2 complex mul +| write | - | Pops two numbers from the stack and writes the first one to the memory location defined by the second one | 
-</​code>​+| read | - | Pops a number from the stack and reads a number from the memory location defined bu the popped number and pushes it to the stack |
  
 <​note>​ <​note>​
Line 211: Line 230:
 ===== Rules ===== ===== Rules =====
  
-  - You may not use //RegEx// or any other library that would use regular expressions +  - You may not use //RegEx// or any other library that would use regular expressions (except \r?\n for splitting the input lines of the source)
-  - Files must have "use strict"​ +
-  - You files need to pass jshint ​(with node: true, esnext: true)+
   - Source code needs to be indented (-0.1p)   - Source code needs to be indented (-0.1p)
-  - You need to write a file named Readme and explain how you wrote the homework (-0.1p)+  - You need to explain ​in details in the Readme.md ​how you wrote the homework (-1p)
  
 ===== Copying ===== ===== Copying =====
Line 223: Line 240:
 ===== Questions ===== ===== Questions =====
  
-If you have any questions related to the homework, please ask them by posting an issue on the github [[https://​github.com/​alexandruradovici/alf2018.git|repository]] with the title format //[calculator] <your question title>//​. You will need a github account for that.+If you have any questions related to the homework, please ask them by posting an issue on the github [[https://​github.com/​UPB-FILS-ALF/questions|quiestions ​repository]] with the title format //[simulator] <your question title>//​. You will need a github account for that.
  
 <note warning> <note warning>
Line 229: Line 246:
 </​note>​ </​note>​
  
-If you want to receive an email when issues are posted or when there are new messages, got to the github [[https://​github.com/​alexandruradovici/alf2018|repository]] and click //Watch//.+If you want to receive an email when issues are posted or when there are new messages, got to the github [[https://​github.com/​UPB-FILS-ALF/questions|questions ​repository]] and click //Watch//.
   ​   ​
-===== Testing ===== 
- 
-The homework will be tested automatically using  a set of public and private tests. 
- 
-==== Public Tests ==== 
- 
-You can download the public tests from the GitHub [[https://​github.com/​upb-fils/​alf.git|repository]]. 
- 
-To run the tests, download the contents of the repository in the folder with the homework. Enter the //​Devoirs/​calculator/​verify//​ folder and run ./​run_all.sh .. . 
- 
-Copy the homework contents into the //​Devoirs/​caclulator//​ folder. 
- 
-<code bash> 
-cd Devoirs/​calculator/​verify 
-rm -rf node_modules 
-./​run_all.sh .. 
-</​code>​ 
- 
-You will need bash for that. You can use either Linux or [[https://​msdn.microsoft.com/​en-us/​commandline/​wsl/​install_guide|Windows Linux Subsystem]]. 
- 
-<​note>​ 
-To install nodejs in Linux or Windows Linux Subsystem, do the following: 
- 
-<code bash> 
-wget https://​nodejs.org/​dist/​v10.15.1/​node-v10.15.1-linux-x64.tar.xz 
-tar xvfJ node-v10.15.1-linux-x64.tar.xz 
-cd node-v10.15.1-linux-x64 
-sudo cp -R -v * /usr 
-</​code>​ 
-  ​ 
-</​note>​ 
- 
-==== Private Tests ==== 
-When uploading the homework, we might have some private tests that it needs to pass. vmchecker will run them. 
- 
-<​note>​ 
-You may always upload the homework as many times you want until the deadline. This will run all the tests for you and display the result. 
-</​note>​ 
- 
-===== Upload the homework ===== 
-The homework needs to be uploaded to [[https://​vmchecker.cs.pub.ro|vmchecker]]. Login with your moodle user name, select the //Automates et Langages Formelles (FILS)// course and upload the [[#​homework-archive|homework archive]]. 
- 
-==== Readme ==== 
-The readme file has the following format: 
- 
-<​code>​ 
-Your full name 
-Group 
- 
-An explanation how you wrote your homework, what did you use, what are the main ideas. 
-</​code>​ 
- 
- 
-==== Homework Archive ==== 
-To upload your homework, please follow the following: 
- 
-  - Create a zip (not rar, ace, 7zip or anything else) archive containing: 
-    * your main javascript file (the same as specified in package.json)  ​ 
-    * your javascript files (*.js) 
-    * the package.json file 
-    * the Readme file 
-  - sign in with [[https://​vmchecker.cs.pub.ro|vmchecker]] 
-  - select the //Automates et Langages Formelles (FILS)// course 
-  - select //1. Calculator//​ 
-  - upload the archive 
- 
- 
-<​note>​ 
-The archive needs to contain the files in its root, not in a folder. DO NOT archive a folder with the files, archive DIRECTLY the files. 
- 
-DO NOT include //​node_modules//​. 
-</​note>​ 
- 
-When the archive is uploaded, vmchecker will run: 
- 
-<code bash> 
-unzip archive.zip homework 
-cd homework 
-npm install 
-echo '{ "​node":​true,​ "​esnext":​true }' > .jshintrc 
-jshint *.js 
-</​code>​ 
- 
- 
  
alf/teme/tema_en_1.1615031744.txt.gz · Last modified: 2021/03/06 13:55 by alexandru.radovici
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0