ram
Aus ProgrammingWiki
Archivierte Version vom 2015-06-25T06:46:03+00:00. Aktuelle Version
Kreativaufgabe RAM Programm
Aufgabenstellung
Geben Sie mind. ein RAM-Programm zur Berechnung der Funktion w : \N \mapsto \N mit w(n) = \left\lfloor \sqrt{n} \right\rfloor an.
RAM Programm 1
| BNr | Befehl | Kommenter |
|---|---|---|
| | 0 | R0 = 5 | R0 = n |
| | 1 | R3 = 1 | Inkrement-/Dekrement-Variable |
| | 2 | IFZERO R2 GOTO 6 | todo |
| | 3 | R4 += R1 | todo |
| | 4 | R2 -= R3 | todo |
| | 5 | GOTO 2 | todo |
| | 6 | R4 -= R0 | todo |
| | 7 | IFZERO R4 GOTO 9 | todo |
| | 8 | GOTO 12 | todo |
| | 9 | R1 += R3 | todo |
| | 10 | R2 = R1 | todo |
| | 11 | GOTO 2 | todo |
| | 12 | R1 -= R3 | todo |
| | 13 | R0 = R1 | Ergebnis nach R0 übernehmen |
| | 14 | STOP | Programmende |