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 14:15]
alexandru.radovici
alf:teme:tema_en_1 [2021/03/17 16:21] (current)
alexandru.radovici [Rules]
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  ERROR unable to open file filename.asm(ENOENT:​ no such 
 file or directory, open '​filename.asm'​)</​code>​| 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 201: Line 199:
 | 50% | stack and mathematical instructions | | 50% | stack and mathematical instructions |
 | 20% | jump instructions | | 20% | jump instructions |
-20% | labels |+10% | labels |
 | 10% | register instructions | | 10% | register instructions |
 | 10% | errors | | 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 =====
Line 213: Line 222:
  
 ^ Instruction ^ Parameter ^ Details ^ ^ Instruction ^ Parameter ^ Details ^
-| write | number ​| Pops a number ​from the stack and writes ​it to the memory location defined by the parameter ​+| write | | Pops two numbers ​from the stack and writes ​the first one to the memory location defined by the second one 
-| read | number ​Reads a number from the memory location and pushes it to the stack |+| 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 221: 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)
   - Source code needs to be indented (-0.1p)   - Source code needs to be indented (-0.1p)
   - You need to explain in details in the Readme.md how you wrote the homework (-1p)   - You need to explain in details in the Readme.md how you wrote the homework (-1p)
alf/teme/tema_en_1.1615032916.txt.gz · Last modified: 2021/03/06 14:15 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