coderick14 / armed Goto Github PK
View Code? Open in Web Editor NEWA terminal-based emulator of the ARM instruction set written in Golang
License: MIT License
A terminal-based emulator of the ARM instruction set written in Golang
License: MIT License
Example SOURCE_FILE :
ADDI X0, XZR, #3;
BL fact;
B Exit;
fact: SUBI SP, SP, #8;
STUR LR, [SP, #4];
STUR X0, [SP, #0];
SUBIS X9, X0, #1;
B.GE L1;
ADDI X1, XZR, #1;
ADDI SP, SP, #8;
BR LR;
L1: SUBI X0, X0, #1;
BL fact;
LDUR X0, [SP, #0];
LDUR LR, [SP, #4];
ADDI SP, SP, #8;
ADD X1, X0, X1;
BR LR;
Exit:;
ADD X1, X0, X1;
should be MUL X1, X0, X1
Luiss-MacBook-Pro:bin luisschubert$ ./ARMed /Users/luisschubert/dev/comparchitecture/fact_example
Executing : ADDI X0, XZR, #3
+----------+----------------+-----------+
| REGISTER | PREVIOUS VALUE | NEW VALUE |
+----------+----------------+-----------+
| R0 | 0 | 3 |
+----------+----------------+-----------+
Executing : BL fact
+----------+----------------+-----------+
| REGISTER | PREVIOUS VALUE | NEW VALUE |
+----------+----------------+-----------+
| R30 | 0 | 2 |
+----------+----------------+-----------+
Executing : SUBI SP, SP, #8
+----------+----------------+-----------+
| REGISTER | PREVIOUS VALUE | NEW VALUE |
+----------+----------------+-----------+
| R28 | 16384 | 16376 |
+----------+----------------+-----------+
Executing : STUR LR, [SP, #4]
Executing : STUR X0, [SP, #0]
Executing : SUBIS X9, X0, #1
+----------+----------------+-----------+
| REGISTER | PREVIOUS VALUE | NEW VALUE |
+----------+----------------+-----------+
| R9 | 0 | 2 |
+----------+----------------+-----------+
Executing : B.GE L1
Executing : SUBI X0, X0, #1
+----------+----------------+-----------+
| REGISTER | PREVIOUS VALUE | NEW VALUE |
+----------+----------------+-----------+
| R0 | 3 | 2 |
+----------+----------------+-----------+
Executing : BL fact
+----------+----------------+-----------+
| REGISTER | PREVIOUS VALUE | NEW VALUE |
+----------+----------------+-----------+
| R30 | 2 | 13 |
+----------+----------------+-----------+
Executing : SUBI SP, SP, #8
+----------+----------------+-----------+
| REGISTER | PREVIOUS VALUE | NEW VALUE |
+----------+----------------+-----------+
| R28 | 16376 | 16368 |
+----------+----------------+-----------+
Executing : STUR LR, [SP, #4]
Executing : STUR X0, [SP, #0]
Executing : SUBIS X9, X0, #1
+----------+----------------+-----------+
| REGISTER | PREVIOUS VALUE | NEW VALUE |
+----------+----------------+-----------+
| R9 | 2 | 1 |
+----------+----------------+-----------+
Executing : B.GE L1
Executing : SUBI X0, X0, #1
+----------+----------------+-----------+
| REGISTER | PREVIOUS VALUE | NEW VALUE |
+----------+----------------+-----------+
| R0 | 2 | 1 |
+----------+----------------+-----------+
Executing : BL fact
Executing : SUBI SP, SP, #8
+----------+----------------+-----------+
| REGISTER | PREVIOUS VALUE | NEW VALUE |
+----------+----------------+-----------+
| R28 | 16368 | 16360 |
+----------+----------------+-----------+
Executing : STUR LR, [SP, #4]
Executing : STUR X0, [SP, #0]
Executing : SUBIS X9, X0, #1
+----------+----------------+-----------+
| REGISTER | PREVIOUS VALUE | NEW VALUE |
+----------+----------------+-----------+
| R9 | 1 | 0 |
+----------+----------------+-----------+
Executing : B.GE L1
Executing : SUBI X0, X0, #1
+----------+----------------+-----------+
| REGISTER | PREVIOUS VALUE | NEW VALUE |
+----------+----------------+-----------+
| R0 | 1 | 0 |
+----------+----------------+-----------+
Executing : BL fact
Executing : SUBI SP, SP, #8
+----------+----------------+-----------+
| REGISTER | PREVIOUS VALUE | NEW VALUE |
+----------+----------------+-----------+
| R28 | 16360 | 16352 |
+----------+----------------+-----------+
Executing : STUR LR, [SP, #4]
Executing : STUR X0, [SP, #0]
Executing : SUBIS X9, X0, #1
+----------+----------------+-----------+
| REGISTER | PREVIOUS VALUE | NEW VALUE |
+----------+----------------+-----------+
| R9 | 0 | -1 |
+----------+----------------+-----------+
Executing : B.GE L1
Executing : ADDI X1, XZR, #1
+----------+----------------+-----------+
| REGISTER | PREVIOUS VALUE | NEW VALUE |
+----------+----------------+-----------+
| R1 | 0 | 1 |
+----------+----------------+-----------+
Executing : ADDI SP, SP, #8
Stack underflow error in : ADDI SP, SP, #8
ADDI X0, XZR, #3
this line is putting 3 as the argument for the fact function.
3! = 321 = 6
I don't see 6 anywhere in the registers, so there must be something wrong with the program.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.