├── .gitignore
├── logo.png
├── examples
├── getRandomNumberInR0.S
├── breakpointExample.S
├── incrementR2EachSecond.S
├── allEightSegmentsDisplaysAt6.S
├── cas3.S
├── angel_swi_syscalls
│ ├── remove.S
│ ├── system.S
│ ├── open.S
│ ├── openAndClose.s
│ └── rename.S
├── blinkThreeLeds.S
├── cas2.S
├── cas4.S
├── test8seg.S
├── cas1.S
├── SimpleExemple.S
└── routines.md
├── vendor
├── dockfx
│ └── dockfx
│ │ ├── maven-metadata.xml.md5
│ │ ├── maven-metadata.xml.sha1
│ │ ├── 0.5.1-valentin
│ │ ├── dockfx-0.5.1-valentin.jar.md5
│ │ ├── dockfx-0.5.1-valentin.pom.md5
│ │ ├── dockfx-0.5.1-valentin.jar.sha1
│ │ ├── dockfx-0.5.1-valentin.pom.sha1
│ │ ├── dockfx-0.5.1-valentin.jar
│ │ └── dockfx-0.5.1-valentin.pom
│ │ └── maven-metadata.xml
└── unicorn
│ └── unicorn
│ ├── maven-metadata.xml.md5
│ ├── maven-metadata.xml.sha1
│ ├── 1.0-armstrong
│ ├── unicorn-1.0-armstrong.jar.md5
│ ├── unicorn-1.0-armstrong.pom.md5
│ ├── unicorn-1.0-armstrong.jar.sha1
│ ├── unicorn-1.0-armstrong.pom.sha1
│ ├── unicorn-1.0-armstrong.jar
│ └── unicorn-1.0-armstrong.pom
│ └── maven-metadata.xml
├── small_logo.png
├── images
├── Classes.png
├── cli_s1.png
├── cli_s2.png
├── gui_s1.png
├── gui_s2.png
└── Interpretor.png
├── src
├── resources
│ ├── run.png
│ ├── cancel.png
│ ├── ledOff.png
│ ├── ledOn.png
│ ├── logo.png
│ ├── mleft.png
│ ├── prompt.png
│ ├── reload.png
│ ├── save.png
│ ├── stop.png
│ ├── switch.png
│ ├── leverOff.png
│ ├── leverOn.png
│ ├── warning.png
│ ├── runByStep.png
│ ├── pushingButton.png
│ ├── 8_segment
│ │ ├── 8seg_1.png
│ │ ├── 8seg_2.png
│ │ ├── 8seg_3.png
│ │ ├── 8seg_4.png
│ │ ├── 8seg_5.png
│ │ ├── 8seg_6.png
│ │ ├── 8seg_7.png
│ │ ├── 8seg_8.png
│ │ └── 8seg_base.png
│ ├── Anonymous_Pro_B.ttf
│ ├── detachedWindow.png
│ ├── EditorView.fxml
│ ├── ConsoleView.fxml
│ ├── 26025.svg
│ ├── aboutView.fxml
│ ├── warning.fxml
│ ├── simpleMemoryView.fxml
│ ├── style.css
│ ├── MemoryView.fxml
│ └── preferences.fxml
├── natives
│ ├── kstool-amd64
│ ├── kstool-x86.exe
│ ├── kstool-amd64.exe
│ ├── libunicorn_java-amd64.so
│ ├── libunicorn_java-x86.dll
│ └── libunicorn_java-amd64.dll
└── projetarm_v2
│ ├── simulator
│ ├── core
│ │ ├── syscalls
│ │ │ ├── io
│ │ │ │ ├── OpenedFile.java
│ │ │ │ ├── FileDescriptors.java
│ │ │ │ ├── SVCIOCall.java
│ │ │ │ ├── FileMode.java
│ │ │ │ ├── SVCCallClose.java
│ │ │ │ └── SVCCallOpen.java
│ │ │ ├── SVCCallTest.java
│ │ │ ├── SVCCallTime.java
│ │ │ ├── SVCLinuxHandler.java
│ │ │ ├── SVCCallSystem.java
│ │ │ ├── SVCCallRemove.java
│ │ │ ├── SVCCallRename.java
│ │ │ ├── SVCCall.java
│ │ │ └── SVCHandler.java
│ │ ├── io
│ │ │ ├── IOLed.java
│ │ │ ├── IOSegment.java
│ │ │ ├── IOSwitch.java
│ │ │ ├── IO8Segment.java
│ │ │ ├── IOButton.java
│ │ │ ├── IOComponent.java
│ │ │ ├── PORTManager.java
│ │ │ └── IOx.java
│ │ ├── InvalidAssemblyException.java
│ │ ├── routines
│ │ │ ├── CpuBreakpoint.java
│ │ │ ├── CpuConsolePutChar.java
│ │ │ ├── CpuSleep.java
│ │ │ ├── CpuRandom.java
│ │ │ ├── CpuConsolePutString.java
│ │ │ ├── CpuConsoleClear.java
│ │ │ ├── CpuPutFile.java
│ │ │ ├── CpuGetFile.java
│ │ │ ├── CpuConsoleGetChar.java
│ │ │ ├── CpuConsoleGetString.java
│ │ │ └── CpuRoutine.java
│ │ ├── SimpleRegister.java
│ │ ├── Register.java
│ │ ├── UnicornRegister.java
│ │ ├── RamRegister.java
│ │ ├── RamChunk.java
│ │ ├── save
│ │ │ ├── InterfaceAdapterArrayList.java
│ │ │ └── Save.java
│ │ ├── Assembler.java
│ │ ├── Preprocessor.java
│ │ ├── Ram.java
│ │ ├── Cpsr.java
│ │ └── Cpu.java
│ ├── ui
│ │ ├── javafx
│ │ │ ├── FormatException.java
│ │ │ ├── ramview
│ │ │ │ ├── OutputType.java
│ │ │ │ ├── ShowType.java
│ │ │ │ ├── RamObservableListAdapter.java
│ │ │ │ └── NewLineRam.java
│ │ │ ├── RegisterObjectView.java
│ │ │ ├── EightSegmentDisplay.java
│ │ │ ├── Preferences.java
│ │ │ ├── ArmToolBar.java
│ │ │ ├── ConsoleView.java
│ │ │ ├── Interpreter.java
│ │ │ ├── CodeEditor.java
│ │ │ ├── ArmMenuBar.java
│ │ │ └── LedView.java
│ │ └── cli
│ │ │ └── Cli.java
│ ├── boilerplate
│ │ └── InvalidInstructionException.java
│ ├── utils
│ │ ├── OSValidator.java
│ │ └── NativeJarGetter.java
│ └── Main.java
│ └── gpl
│ ├── TableCellSkinFixed.java
│ └── TextFieldTableCellFixed.java
├── .settings
├── org.eclipse.m2e.core.prefs
└── org.eclipse.jdt.core.prefs
├── .project
├── .idea
└── compiler.xml
├── README.md
├── .classpath
├── tests
└── tests
│ └── projetarm_v2
│ └── simulator
│ └── core
│ └── CpsrTdd.java
└── pom.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 | /target/
3 | /.idea/
--------------------------------------------------------------------------------
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/logo.png
--------------------------------------------------------------------------------
/examples/getRandomNumberInR0.S:
--------------------------------------------------------------------------------
1 | ldr r1,=0x1F0014
2 | mov r0,#0
3 |
4 | blx r1
--------------------------------------------------------------------------------
/vendor/dockfx/dockfx/maven-metadata.xml.md5:
--------------------------------------------------------------------------------
1 | 0f80d06600d24d0caa66c8282504b305
--------------------------------------------------------------------------------
/vendor/unicorn/unicorn/maven-metadata.xml.md5:
--------------------------------------------------------------------------------
1 | adf9121ef653406c3c3d8b6ec71037eb
--------------------------------------------------------------------------------
/small_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/small_logo.png
--------------------------------------------------------------------------------
/vendor/dockfx/dockfx/maven-metadata.xml.sha1:
--------------------------------------------------------------------------------
1 | eee1f8b532be5b2ed4216e4ab79e5962fb03d4d4
--------------------------------------------------------------------------------
/vendor/unicorn/unicorn/maven-metadata.xml.sha1:
--------------------------------------------------------------------------------
1 | cfc1455bd532679d9fd46571b1749db0cdbc9de3
--------------------------------------------------------------------------------
/images/Classes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/images/Classes.png
--------------------------------------------------------------------------------
/images/cli_s1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/images/cli_s1.png
--------------------------------------------------------------------------------
/images/cli_s2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/images/cli_s2.png
--------------------------------------------------------------------------------
/images/gui_s1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/images/gui_s1.png
--------------------------------------------------------------------------------
/images/gui_s2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/images/gui_s2.png
--------------------------------------------------------------------------------
/src/resources/run.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/run.png
--------------------------------------------------------------------------------
/vendor/dockfx/dockfx/0.5.1-valentin/dockfx-0.5.1-valentin.jar.md5:
--------------------------------------------------------------------------------
1 | 69275f2847401f681a26d266aa582c41
--------------------------------------------------------------------------------
/vendor/dockfx/dockfx/0.5.1-valentin/dockfx-0.5.1-valentin.pom.md5:
--------------------------------------------------------------------------------
1 | 4985bfd38614707382e9e73eff0cbac8
--------------------------------------------------------------------------------
/vendor/unicorn/unicorn/1.0-armstrong/unicorn-1.0-armstrong.jar.md5:
--------------------------------------------------------------------------------
1 | 1ecc8508e76797f84db104295af4be0b
--------------------------------------------------------------------------------
/vendor/unicorn/unicorn/1.0-armstrong/unicorn-1.0-armstrong.pom.md5:
--------------------------------------------------------------------------------
1 | ee741b81344dc468a4421c6f8e675fee
--------------------------------------------------------------------------------
/images/Interpretor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/images/Interpretor.png
--------------------------------------------------------------------------------
/src/natives/kstool-amd64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/natives/kstool-amd64
--------------------------------------------------------------------------------
/src/resources/cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/cancel.png
--------------------------------------------------------------------------------
/src/resources/ledOff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/ledOff.png
--------------------------------------------------------------------------------
/src/resources/ledOn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/ledOn.png
--------------------------------------------------------------------------------
/src/resources/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/logo.png
--------------------------------------------------------------------------------
/src/resources/mleft.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/mleft.png
--------------------------------------------------------------------------------
/src/resources/prompt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/prompt.png
--------------------------------------------------------------------------------
/src/resources/reload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/reload.png
--------------------------------------------------------------------------------
/src/resources/save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/save.png
--------------------------------------------------------------------------------
/src/resources/stop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/stop.png
--------------------------------------------------------------------------------
/src/resources/switch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/switch.png
--------------------------------------------------------------------------------
/examples/breakpointExample.S:
--------------------------------------------------------------------------------
1 | ldr r1,=0x1F0018
2 | mov r0,#0
3 |
4 | kek: add r0,r0,#1
5 | blx r1
6 | b kek
--------------------------------------------------------------------------------
/src/natives/kstool-x86.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/natives/kstool-x86.exe
--------------------------------------------------------------------------------
/src/resources/leverOff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/leverOff.png
--------------------------------------------------------------------------------
/src/resources/leverOn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/leverOn.png
--------------------------------------------------------------------------------
/src/resources/warning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/warning.png
--------------------------------------------------------------------------------
/vendor/dockfx/dockfx/0.5.1-valentin/dockfx-0.5.1-valentin.jar.sha1:
--------------------------------------------------------------------------------
1 | 12ed0f0e235a759998d63c0eae329986d7509d4d
--------------------------------------------------------------------------------
/vendor/dockfx/dockfx/0.5.1-valentin/dockfx-0.5.1-valentin.pom.sha1:
--------------------------------------------------------------------------------
1 | 557abecdee0806f59414c569e78990903ff4d248
--------------------------------------------------------------------------------
/vendor/unicorn/unicorn/1.0-armstrong/unicorn-1.0-armstrong.jar.sha1:
--------------------------------------------------------------------------------
1 | 36681a20988033982d486abbb3175cc616b0dbd6
--------------------------------------------------------------------------------
/vendor/unicorn/unicorn/1.0-armstrong/unicorn-1.0-armstrong.pom.sha1:
--------------------------------------------------------------------------------
1 | d38a71fe5ed7bedc8b80d6d65e83bcb5710f939f
--------------------------------------------------------------------------------
/src/natives/kstool-amd64.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/natives/kstool-amd64.exe
--------------------------------------------------------------------------------
/src/resources/runByStep.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/runByStep.png
--------------------------------------------------------------------------------
/src/resources/pushingButton.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/pushingButton.png
--------------------------------------------------------------------------------
/src/resources/8_segment/8seg_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/8_segment/8seg_1.png
--------------------------------------------------------------------------------
/src/resources/8_segment/8seg_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/8_segment/8seg_2.png
--------------------------------------------------------------------------------
/src/resources/8_segment/8seg_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/8_segment/8seg_3.png
--------------------------------------------------------------------------------
/src/resources/8_segment/8seg_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/8_segment/8seg_4.png
--------------------------------------------------------------------------------
/src/resources/8_segment/8seg_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/8_segment/8seg_5.png
--------------------------------------------------------------------------------
/src/resources/8_segment/8seg_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/8_segment/8seg_6.png
--------------------------------------------------------------------------------
/src/resources/8_segment/8seg_7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/8_segment/8seg_7.png
--------------------------------------------------------------------------------
/src/resources/8_segment/8seg_8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/8_segment/8seg_8.png
--------------------------------------------------------------------------------
/src/resources/Anonymous_Pro_B.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/Anonymous_Pro_B.ttf
--------------------------------------------------------------------------------
/src/resources/detachedWindow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/detachedWindow.png
--------------------------------------------------------------------------------
/examples/incrementR2EachSecond.S:
--------------------------------------------------------------------------------
1 | ldr r1,=0x1F0010
2 | mov r0,#1000
3 | mov r2,#0
4 |
5 | kek: add r2,r2,#1
6 | blx r1
7 | b kek
--------------------------------------------------------------------------------
/src/natives/libunicorn_java-amd64.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/natives/libunicorn_java-amd64.so
--------------------------------------------------------------------------------
/src/natives/libunicorn_java-x86.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/natives/libunicorn_java-x86.dll
--------------------------------------------------------------------------------
/src/natives/libunicorn_java-amd64.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/natives/libunicorn_java-amd64.dll
--------------------------------------------------------------------------------
/src/resources/8_segment/8seg_base.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/src/resources/8_segment/8seg_base.png
--------------------------------------------------------------------------------
/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/examples/allEightSegmentsDisplaysAt6.S:
--------------------------------------------------------------------------------
1 | ldr r0,=0x1f1000
2 | mov r2,#0x7D
3 | mov r1,#0
4 |
5 | kek: str r2,[r0,r1]
6 |
7 | add r1,r1,#1
8 | cmp r1,#15
9 |
10 | bne kek
--------------------------------------------------------------------------------
/vendor/dockfx/dockfx/0.5.1-valentin/dockfx-0.5.1-valentin.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/vendor/dockfx/dockfx/0.5.1-valentin/dockfx-0.5.1-valentin.jar
--------------------------------------------------------------------------------
/vendor/unicorn/unicorn/1.0-armstrong/unicorn-1.0-armstrong.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linouxis9/ARMStrong/HEAD/vendor/unicorn/unicorn/1.0-armstrong/unicorn-1.0-armstrong.jar
--------------------------------------------------------------------------------
/examples/cas3.S:
--------------------------------------------------------------------------------
1 | ldr r0,=kek @ File path
2 | mov r1,#0x3000 @ Where to write File bytes
3 | ldr r2,=0x1F0020 @ Open file routine's address
4 | blx r2 @ Calls routine
5 | kek: .asciz "C:\\kek.txt"
--------------------------------------------------------------------------------
/examples/angel_swi_syscalls/remove.S:
--------------------------------------------------------------------------------
1 | ldr r1,=struct
2 | ldr r2,=string
3 | str r2,[r1]
4 | svc #0x0e
5 |
6 | .stop
7 |
8 | struct:.word 0
9 | length:.word 7
10 | string:.asciz "/tmp/sb"
11 |
--------------------------------------------------------------------------------
/examples/angel_swi_syscalls/system.S:
--------------------------------------------------------------------------------
1 | ldr r1,=struct
2 | ldr r2,=string
3 | str r2,[r1]
4 | svc #0x12
5 |
6 | .stop
7 |
8 | struct:.word 0
9 | length:.word 13
10 | string:.asciz "mkdir /tmp/sa"
11 |
--------------------------------------------------------------------------------
/examples/angel_swi_syscalls/open.S:
--------------------------------------------------------------------------------
1 | ldr r1,=struct
2 | ldr r2,=string
3 | str r2,[r1]
4 | svc #0x01
5 |
6 | .stop
7 |
8 | struct:.word 0
9 | .word 5
10 | length:.word 7
11 | string:.asciz "/tmp/sb"
12 |
13 |
--------------------------------------------------------------------------------
/examples/blinkThreeLeds.S:
--------------------------------------------------------------------------------
1 | mov r0,#100
2 | ldr r1,=0x1F0010
3 | ldr r4,=0x1F1000
4 |
5 |
6 | deb:
7 | mov r5,0b101
8 | str r5,[r4]
9 |
10 | blx r1
11 |
12 | mov r5,0b010
13 | str r5,[r4]
14 |
15 | blx r1
16 |
17 | b deb
18 |
--------------------------------------------------------------------------------
/examples/cas2.S:
--------------------------------------------------------------------------------
1 | mov r0,0x3000 @ Address to save / print string
2 | ldr r1,=0x1F000C @ Routine to get String out of the GUI console
3 | blx r1 @ Calls routine
4 | ldr r1,=0x1F0008 @ Routine to print string in RAM
5 | blx r1 @ Calls routine
--------------------------------------------------------------------------------
/examples/cas4.S:
--------------------------------------------------------------------------------
1 | ldr r0,=kek @ File path (\0 terminated)
2 | ldr r1,=content @ Address of content to write (\0 terminated)
3 | ldr r2,=0x1F001C @ Write file routine's address
4 | blx r2 @ Jump to routine
5 | kek: .asciz "C:\\tmp\\kek.txt"
6 | content: .asciz "salut toi!"
--------------------------------------------------------------------------------
/examples/angel_swi_syscalls/openAndClose.s:
--------------------------------------------------------------------------------
1 | ldr r1,=struct
2 | ldr r2,=string
3 | str r2,[r1]
4 | svc #0x01
5 |
6 | mov r1,#0x3000
7 | str r0,[r1]
8 | svc #0x02
9 |
10 | .stop
11 |
12 | struct:.word 0
13 | .word 5
14 | length:.word 7
15 | string:.asciz "/tmp/sb"
16 |
17 |
--------------------------------------------------------------------------------
/examples/test8seg.S:
--------------------------------------------------------------------------------
1 | mov r0,#25
2 | ldr r1,=0x1F0010
3 | ldr r4,=0x1F1000
4 | mov r6,#-1
5 |
6 | if:mov r5,0x80
7 | add r6,r6,#1
8 | deb:strb r5,[r4,r6]
9 |
10 | blx r1
11 |
12 | mov r5,r5, LSR #1
13 | cmp r5,#0x0
14 | beq if
15 |
16 | blx r1
17 |
18 | cmp r6,#15
19 |
20 | bne deb
21 |
--------------------------------------------------------------------------------
/examples/cas1.S:
--------------------------------------------------------------------------------
1 | b start @ Branch to start label
2 | kek: .asciz "test"
3 | .align @ Align memory as the string string "test\0" isn't a multiple of 4
4 | start: ldr r0,=kek @ Program entrypoint, load the string address inside the r0 register
5 | ldr r1,=0x1F0008 @ Load routine address to show a string in register r1
6 | blx r1 @ Calls routine
--------------------------------------------------------------------------------
/examples/angel_swi_syscalls/rename.S:
--------------------------------------------------------------------------------
1 | ldr r1,=newAddress
2 | ldr r2,=newName
3 | str r2,[r1]
4 |
5 | ldr r1,=oldAddress
6 | ldr r2,=oldName
7 | str r2,[r1]
8 |
9 | svc #0xf
10 |
11 | .stop
12 |
13 | struct:
14 | oldAddress:.word 0
15 | oldLength:.word 7
16 | newAddress:.word 0
17 | newLength:.word 7
18 | oldName:.asciz "/tmp/sa"
19 | newName:.asciz "/tmp/sb"
20 |
21 |
22 |
--------------------------------------------------------------------------------
/vendor/unicorn/unicorn/maven-metadata.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | unicorn
4 | unicorn
5 |
6 | 1.0-armstrong
7 |
8 | 1.0-armstrong
9 |
10 | 20190106181302
11 |
12 |
13 |
--------------------------------------------------------------------------------
/vendor/dockfx/dockfx/maven-metadata.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | dockfx
4 | dockfx
5 |
6 | 0.5.1-valentin
7 |
8 | 0.5-armstrong
9 | 0.5.1-valentin
10 |
11 | 20190109191818
12 |
13 |
14 |
--------------------------------------------------------------------------------
/vendor/dockfx/dockfx/0.5.1-valentin/dockfx-0.5.1-valentin.pom:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | dockfx
6 | dockfx
7 | 0.5.1-valentin
8 |
9 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/syscalls/io/OpenedFile.java:
--------------------------------------------------------------------------------
1 | package projetarm_v2.simulator.core.syscalls.io;
2 |
3 | import java.io.File;
4 |
5 | public class OpenedFile {
6 | private File file;
7 | private FileMode mode;
8 |
9 | public OpenedFile(File file, FileMode mode) {
10 | this.file = file;
11 | this.mode = mode;
12 | }
13 |
14 | public File getFile() {
15 | return file;
16 | }
17 |
18 | public FileMode getMode() {
19 | return mode;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/vendor/unicorn/unicorn/1.0-armstrong/unicorn-1.0-armstrong.pom:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | unicorn
6 | unicorn
7 | 1.0-armstrong
8 |
9 |
--------------------------------------------------------------------------------
/examples/SimpleExemple.S:
--------------------------------------------------------------------------------
1 | @ Comparaison et branchement
2 |
3 | cmp r4, r5
4 | beq conditionvraie @ tester les codes eq, ne, ge, gt, le et lt
5 | @ et essayer de déterminer leur signification
6 | b conditionfausse
7 |
8 | conditionvraie: @ la condition est vraie
9 | ldr r0, =chaine1
10 | ldr r1, =0x1F0008
11 | blx r1
12 | b fin
13 | conditionfausse: @ la condition est fausse
14 | ldr r0, =chaine2
15 | ldr r1, =0x1F0008
16 | blx r1
17 |
18 | fin:
19 | .stop
20 |
21 | @ Données
22 | chaine1: .asciz "La condition est vraie"
23 | chaine2: .asciz "La condition est fausse !"
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/ui/javafx/FormatException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.ui.javafx;
10 |
11 | /**
12 | * thrown when the representation of numbers typed by user is not recognized
13 | */
14 | public class FormatException extends RuntimeException {
15 | }
16 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | projetarm_v2
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.m2e.core.maven2Nature
21 | org.eclipse.jdt.core.javanature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/io/IOLed.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.io;
10 |
11 | import projetarm_v2.simulator.core.RamRegister;
12 |
13 | public class IOLed extends IOComponent {
14 |
15 | public IOLed(RamRegister register, int shift, int portNb) {
16 | super(register, shift, portNb);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/io/IOSegment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.io;
10 |
11 | import projetarm_v2.simulator.core.RamRegister;
12 |
13 | public class IOSegment extends IOComponent {
14 |
15 | protected IOSegment(RamRegister port, int shift, int portNb) {
16 | super(port, shift, portNb);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/InvalidAssemblyException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core;
10 |
11 | public class InvalidAssemblyException extends RuntimeException {
12 |
13 | private static final long serialVersionUID = -751189391151339140L;
14 |
15 | public InvalidAssemblyException(String message) {
16 | super(message);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/examples/routines.md:
--------------------------------------------------------------------------------
1 | CpuConsolePutChar 0x1F0000
2 | - r0 @ ASCII
3 | - r0 -> stdout
4 |
5 | CpuConsoleGetChar 0x1F0004
6 | - r0 @ ASCII
7 | - 1 char consoleBuffer -> r0
8 |
9 | CpuConsolePutString 0x1F0008
10 | - r0 -> Pointer to a null-terminated string
11 | - *r0 -> stdout
12 |
13 | CpuConsoleGetString 0x1F000C
14 | - r0 @ Pointer to a buffer
15 | - whole consoleBuffer -> *r0
16 |
17 | CpuSleep 0x1F0010
18 | - r0 @ Wait in ms
19 | - sleep(r0)
20 |
21 | CpuRandom 0x1F0014
22 | - Random 32 bits integer -> r0
23 |
24 | CpuBreakpoint 0x1F0018
25 | - Halt execution
26 |
27 | CpuPutFile 0x10001C
28 | - r0 @ File path
29 | - r1 @ Where to read content
30 |
31 | CpuGetFile 0x1F0020
32 | - r0 @ File path
33 | - r1 @ Where to save content
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/io/IOSwitch.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.io;
10 |
11 | import projetarm_v2.simulator.core.RamRegister;
12 |
13 | public class IOSwitch extends IOComponent {
14 |
15 | protected IOSwitch(RamRegister port, int shift, int portNb) {
16 | super(port, shift, portNb);
17 | }
18 |
19 | public boolean flip() {
20 | this.set(!this.isOn());
21 | return this.isOn();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 
2 | ## A fast and simple ARM Simulator made for education
3 |
4 | ## Installation
5 |
6 | Download the [latest project-armstrong.jar](https://github.com/linouxis9/ARMStrong/releases/latest) and enjoy!
7 |
8 | ## Graphical User Interface
9 | 
10 | 
11 | ```bash
12 | java -jar project-armstrong.jar
13 | ```
14 |
15 | ## Command-line Interface
16 | 
17 | 
18 | ```
19 | java -jar project-armstrong.jar cli
20 | ```
21 |
22 | ## Information
23 |
24 | ### Requirements
25 | - Java 11
26 | - Windows x86/x64 or Linux x64
27 |
28 | ### Libraries used
29 | - Unicorn
30 | - Keystone
31 | - JavaFX
32 | - DockFX
33 |
34 | > Made with :heart: by the #@RMStrong Team
35 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/syscalls/SVCCallTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.syscalls;
10 |
11 | import projetarm_v2.simulator.core.Cpu;
12 |
13 | public class SVCCallTest extends SVCCall {
14 |
15 | public SVCCallTest(Cpu cpu) {
16 | super(cpu);
17 | }
18 |
19 | @Override
20 | protected int getSvcNumber() {
21 | return 25;
22 | }
23 |
24 | @Override
25 | protected void primitive() {
26 | System.out.println("First syscall o/");
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6 | org.eclipse.jdt.core.compiler.compliance=11
7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
13 | org.eclipse.jdt.core.compiler.release=enabled
14 | org.eclipse.jdt.core.compiler.source=11
15 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/boilerplate/InvalidInstructionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.boilerplate;
10 |
11 | public class InvalidInstructionException extends RuntimeException {
12 |
13 | private static final long serialVersionUID = 5458289081653091341L;
14 | private final int line;
15 |
16 | public InvalidInstructionException(String message, int line) {
17 | super(message);
18 | this.line = line;
19 | }
20 |
21 | public int getLine() {
22 | return line;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/syscalls/io/FileDescriptors.java:
--------------------------------------------------------------------------------
1 | package projetarm_v2.simulator.core.syscalls.io;
2 |
3 | import java.util.Map;
4 | import java.util.concurrent.ConcurrentHashMap;
5 | import java.util.concurrent.atomic.AtomicInteger;
6 |
7 | public class FileDescriptors {
8 | private Map map;
9 | private AtomicInteger newId;
10 |
11 |
12 | public FileDescriptors() {
13 | this.map = new ConcurrentHashMap<>();
14 | this.newId = new AtomicInteger(3);
15 | }
16 |
17 | public OpenedFile getFileDescriptor(int no) {
18 | return this.map.get(no);
19 | }
20 |
21 | public int addNewFile(OpenedFile file) {
22 | int id = this.newId.getAndIncrement();
23 | this.map.put(id, file);
24 | return id;
25 | }
26 |
27 | public boolean closeFile(int fd) {
28 | return this.map.remove(fd) != null;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/resources/EditorView.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
8 |
10 |
12 |
13 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/utils/OSValidator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.utils;
10 |
11 | public class OSValidator {
12 |
13 | private static String OS = System.getProperty("os.name").toLowerCase();
14 |
15 | private OSValidator() {}
16 |
17 | public static boolean isWindows() {
18 | return OS.contains("win");
19 | }
20 |
21 | public static boolean isMac() {
22 | return OS.contains("mac");
23 | }
24 |
25 | public static boolean isLinux() {
26 | return OS.contains("nux");
27 | }
28 | }
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/routines/CpuBreakpoint.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.routines;
10 |
11 |
12 | import projetarm_v2.simulator.core.Cpu;
13 |
14 | public class CpuBreakpoint extends CpuRoutine {
15 |
16 | public static final long ROUTINE_ADDRESS = 0x1F0018L;
17 |
18 | public CpuBreakpoint(Cpu cpu) {
19 | super(cpu);
20 | }
21 |
22 | public long getRoutineAddress() {
23 | return ROUTINE_ADDRESS;
24 | }
25 |
26 | @Override
27 | protected void primitive() {
28 | this.getCpu().interruptMe();
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/ui/javafx/ramview/OutputType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.ui.javafx.ramview;
10 |
11 | /**
12 | * represent a output mode
13 | */
14 | public enum OutputType {
15 | /**
16 | * the hexadecimal representation of ram content
17 | */
18 | HEX,
19 | /**
20 | * the signed decimal representation of ram content
21 | */
22 | SIG_DEC,
23 | /**
24 | * the unsigned decimal representation of ram content
25 | */
26 | UNSIG_DEC,
27 | /**
28 | * the ascii representation of ram content
29 | */
30 | ASCII;
31 | }
32 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/syscalls/SVCCallTime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.syscalls;
10 |
11 | import java.io.IOException;
12 |
13 | import projetarm_v2.simulator.core.Cpu;
14 |
15 | public class SVCCallTime extends SVCCall {
16 |
17 | public SVCCallTime(Cpu cpu) {
18 | super(cpu);
19 | }
20 |
21 | @Override
22 | protected int getSvcNumber() {
23 | return 0x11;
24 | }
25 |
26 | @Override
27 | protected void primitive() {
28 | this.getCpu().getRegister(0).setValue((int)java.time.Instant.now().getEpochSecond());
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/SimpleRegister.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core;
10 |
11 | import java.util.concurrent.atomic.AtomicInteger;
12 |
13 | public class SimpleRegister implements Register {
14 | private AtomicInteger value = new AtomicInteger(0);
15 |
16 | public SimpleRegister() {}
17 |
18 | public SimpleRegister(int value) {
19 | this.value.set(value);
20 | }
21 |
22 | public int getValue() {
23 | return this.value.get();
24 | }
25 |
26 | @Override
27 | public void setValue(int value) {
28 | this.value.set(value);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/io/IO8Segment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.io;
10 |
11 | public class IO8Segment {
12 |
13 | private final IOSegment[] segments;
14 |
15 | protected IO8Segment(IOSegment[] segments) {
16 | this.segments = segments;
17 | }
18 |
19 | public boolean getSegmentState(int noSegment) {
20 | return segments[noSegment].isOn();
21 | }
22 |
23 | public IOSegment getSegment(int noSegment) {
24 | return segments[noSegment];
25 | }
26 |
27 | public void setSegment(int noSegment, boolean value) {
28 | this.getSegment(noSegment).set(value);;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/io/IOButton.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.io;
10 |
11 | import projetarm_v2.simulator.core.RamRegister;
12 |
13 | public class IOButton extends IOComponent {
14 |
15 | protected IOButton(RamRegister port, int shift, int portNb) {
16 | super(port, shift, portNb);
17 | }
18 |
19 | public synchronized void push() {
20 | new Thread(() -> {
21 | this.set(true);
22 | try {
23 | Thread.sleep(1000);
24 | } catch (InterruptedException e) {
25 | Thread.currentThread().interrupt();
26 | }
27 | this.set(false);
28 | }).start();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/ui/javafx/ramview/ShowType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.ui.javafx.ramview;
10 |
11 | /**
12 | * represent a type of display
13 | */
14 | public enum ShowType {
15 | /**
16 | * word, 32 bits representation of data
17 | */
18 | WORD,
19 | /**
20 | * halfword, 16 bits representation of data
21 | */
22 | HALFWORD,
23 | /**
24 | * byte, 8 bits representation of data
25 | */
26 | BYTE;
27 |
28 | public int toOffset() {
29 | switch (this) {
30 | case WORD:
31 | return 4;
32 | case HALFWORD:
33 | return 2;
34 | default:
35 | case BYTE:
36 | return 1;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/routines/CpuConsolePutChar.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.routines;
10 |
11 |
12 | import projetarm_v2.simulator.core.Cpu;
13 |
14 | public class CpuConsolePutChar extends CpuRoutine {
15 |
16 | public static final long ROUTINE_ADDRESS = 0x1F0000L;
17 |
18 | public CpuConsolePutChar(Cpu cpu) {
19 | super(cpu);
20 | }
21 |
22 | public long getRoutineAddress() {
23 | return ROUTINE_ADDRESS;
24 | }
25 |
26 | @Override
27 | protected void primitive() {
28 | int r0 = this.getRegister(0).getValue();
29 |
30 | System.out.format("[OUTPUT] %s%n",Character.toString((char) r0));
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/routines/CpuSleep.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.routines;
10 |
11 |
12 | import projetarm_v2.simulator.core.Cpu;
13 |
14 | public class CpuSleep extends CpuRoutine {
15 |
16 | public static final long ROUTINE_ADDRESS = 0x1F0010L;
17 |
18 | public CpuSleep(Cpu cpu) {
19 | super(cpu);
20 | }
21 |
22 | public long getRoutineAddress() {
23 | return ROUTINE_ADDRESS;
24 | }
25 |
26 | @Override
27 | protected void primitive() {
28 | try {
29 | Thread.sleep(this.getRegister(0).getValue());
30 | } catch (InterruptedException e) {
31 | Thread.currentThread().interrupt();
32 | }
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/resources/ConsoleView.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/Register.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core;
10 |
11 | public interface Register {
12 |
13 | public int getValue();
14 |
15 | public void setValue(int value);
16 |
17 | public default boolean getBit(int shift) {
18 | return intToBool((this.getValue() >> shift) & 0x1);
19 | }
20 |
21 | public default void setBit(int shift, boolean bit) {
22 | int value = this.getValue() & ~(1 << shift);
23 | this.setValue(value | (boolToInt(bit) << shift));
24 | }
25 |
26 | private static boolean intToBool(int value) {
27 | return value == 1;
28 | }
29 |
30 | private static int boolToInt(boolean bool) {
31 | return bool ? 1 : 0;
32 | }
33 | }
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/syscalls/SVCLinuxHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.syscalls;
10 |
11 | import projetarm_v2.simulator.core.Cpu;
12 |
13 | public class SVCLinuxHandler extends SVCCall {
14 |
15 | public SVCLinuxHandler(Cpu cpu) {
16 | super(cpu);
17 | }
18 |
19 | @Override
20 | protected int getSvcNumber() {
21 | return 0;
22 | }
23 |
24 | @Override
25 | protected void primitive() {
26 | System.out.println("[WARNING] This is the Linux syscall handler that aims to emulate some Linux syscalls.\n[WARNING] It is not yet made and you shouldn't rely on it.");
27 |
28 | int syscall = this.getCpu().getRegister(7).getValue();
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/routines/CpuRandom.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.routines;
10 |
11 | import java.util.Random;
12 |
13 | import projetarm_v2.simulator.core.Cpu;
14 | import projetarm_v2.simulator.ui.javafx.ConsoleView;
15 |
16 | public class CpuRandom extends CpuRoutine {
17 |
18 | public static final long ROUTINE_ADDRESS = 0x1F0014L;
19 | private Random random;
20 |
21 |
22 | public CpuRandom(Cpu cpu) {
23 | super(cpu);
24 | this.random = new Random();
25 | }
26 |
27 | public long getRoutineAddress() { return ROUTINE_ADDRESS; }
28 |
29 |
30 | @Override
31 | protected void primitive()
32 | {
33 | this.getCpu().getRegister(0).setValue(this.random.nextInt());
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/UnicornRegister.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core;
10 |
11 | import unicorn.Unicorn;
12 |
13 | public class UnicornRegister implements Register {
14 | private final Unicorn u;
15 | private int register;
16 |
17 | public UnicornRegister(Unicorn u, int register) {
18 | this.u = u;
19 | this.register = register;
20 | }
21 |
22 | /* (non-Javadoc)
23 | * @see projetarm_v2.Registers#getValue()
24 | */
25 | @Override
26 | public int getValue() {
27 | return ((Long)u.reg_read(this.register)).intValue();
28 | }
29 |
30 | /* (non-Javadoc)
31 | * @see projetarm_v2.Registers#setValue(long)
32 | */
33 | @Override
34 | public void setValue(int value) {
35 | u.reg_write(this.register, value);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/RamRegister.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core;
10 |
11 | import java.io.Serializable;
12 |
13 | public class RamRegister implements Register, Serializable {
14 | private static final long serialVersionUID = -7962046527990859276L;
15 | private final transient Ram ram;
16 | private final long myAddress;
17 |
18 | public RamRegister(Ram ram, long address) {
19 | this.ram = ram;
20 | this.myAddress = address;
21 | }
22 |
23 | @Override
24 | public int getValue() {
25 | return this.ram.getValue(this.myAddress);
26 | }
27 |
28 | @Override
29 | public void setValue(int value) {
30 | this.ram.setValue(this.myAddress, value);
31 | }
32 |
33 | public long getAddress() {
34 | return this.myAddress;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/syscalls/io/SVCIOCall.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.syscalls.io;
10 |
11 | import java.io.UnsupportedEncodingException;
12 | import java.util.ArrayList;
13 | import java.util.List;
14 | import java.util.Map;
15 |
16 | import projetarm_v2.simulator.core.Cpu;
17 | import projetarm_v2.simulator.core.Ram;
18 | import projetarm_v2.simulator.core.syscalls.SVCCall;
19 |
20 |
21 | public abstract class SVCIOCall extends SVCCall {
22 | private FileDescriptors fileDescriptors;
23 |
24 | public SVCIOCall(Cpu cpu, FileDescriptors fileDescriptors) {
25 | super(cpu);
26 | this.fileDescriptors = fileDescriptors;
27 |
28 | }
29 |
30 | protected FileDescriptors getFileDescriptors() {
31 | return this.fileDescriptors;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/syscalls/io/FileMode.java:
--------------------------------------------------------------------------------
1 | package projetarm_v2.simulator.core.syscalls.io;
2 |
3 | public enum FileMode {
4 | ReadOnly(0),
5 | ReadBinaryOnly(1),
6 | ReadAndWrite(2),
7 | ReadAndWriteBinary(3),
8 | WriteOnly(4),
9 | WriteBinary(5),
10 | WriteAndRead(6),
11 | WriteAndReadBinary(7),
12 | Append(8),
13 | AppendBinary(9),
14 | AppendAndRead(10),
15 | AppendAndReadBinary(11);
16 |
17 |
18 | private int no;
19 |
20 | private FileMode(int no) {
21 | this.no = no;
22 | }
23 |
24 | public int getNo() {
25 | return this.no;
26 | }
27 |
28 | public static FileMode fromNo(int no) {
29 | switch(no) {
30 | case 0: return ReadOnly;
31 | case 1: return ReadBinaryOnly;
32 | case 2: return ReadAndWrite;
33 | case 3: return ReadAndWriteBinary;
34 | case 4: return WriteOnly;
35 | case 5: return WriteBinary;
36 | case 6: return WriteAndRead;
37 | case 7: return WriteAndReadBinary;
38 | case 8: return Append;
39 | case 9: return AppendBinary;
40 | case 10: return AppendAndRead;
41 | case 11: return AppendAndReadBinary;
42 | default: return null;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/syscalls/io/SVCCallClose.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.syscalls.io;
10 |
11 | import java.io.File;
12 | import java.io.IOException;
13 | import java.util.Map;
14 |
15 | import projetarm_v2.simulator.core.Cpu;
16 |
17 | public class SVCCallClose extends SVCIOCall {
18 |
19 | public SVCCallClose(Cpu cpu, FileDescriptors fileDescriptors) {
20 | super(cpu, fileDescriptors);
21 | }
22 |
23 | @Override
24 | protected int getSvcNumber() {
25 | return 0x02;
26 | }
27 |
28 | @Override
29 | protected void primitive() {
30 | int fd = this.getRam().getValue(this.getCpu().getRegister(1).getValue());
31 |
32 | boolean success = this.getFileDescriptors().closeFile(fd);
33 |
34 | this.getCpu().getRegister(0).setValue(success ? 0 : -1);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/routines/CpuConsolePutString.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.routines;
10 |
11 | import java.io.UnsupportedEncodingException;
12 |
13 | import projetarm_v2.simulator.core.Cpu;
14 |
15 | public class CpuConsolePutString extends CpuRoutine {
16 |
17 | public static final long ROUTINE_ADDRESS = 0x1F0008L;
18 |
19 | public CpuConsolePutString(Cpu cpu) { super(cpu); }
20 |
21 | public long getRoutineAddress() { return ROUTINE_ADDRESS; }
22 |
23 | @Override
24 | protected void primitive() {
25 | long address = (long) this.getRegister(0).getValue();
26 |
27 | try
28 | {
29 | System.out.println("[OUTPUT] " + this.longToString(address));
30 | }
31 | catch(UnsupportedEncodingException e)
32 | {
33 | e.printStackTrace();
34 | }
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/routines/CpuConsoleClear.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.routines;
10 |
11 | import projetarm_v2.simulator.core.Cpu;
12 | import projetarm_v2.simulator.ui.javafx.ConsoleView;
13 |
14 | public class CpuConsoleClear extends CpuRoutine {
15 |
16 | public static final long ROUTINE_ADDRESS = 0x1F0024L;
17 | private ConsoleView consoleView;
18 |
19 | public CpuConsoleClear(Cpu cpu) {
20 | super(cpu);
21 | }
22 |
23 | public void setConsoleView(ConsoleView consoleView) {
24 | this.consoleView = consoleView;
25 | }
26 |
27 | public long getRoutineAddress() { return ROUTINE_ADDRESS; }
28 |
29 | public static boolean shouldBeManuallyAdded() { return true; }
30 |
31 | @Override
32 | protected void primitive()
33 | {
34 | if (consoleView != null) {
35 | this.consoleView.clear();
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/syscalls/SVCCallSystem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.syscalls;
10 |
11 | import java.io.BufferedReader;
12 | import java.io.IOException;
13 | import java.io.InputStreamReader;
14 |
15 | import projetarm_v2.simulator.core.Cpu;
16 |
17 | public class SVCCallSystem extends SVCCall {
18 |
19 | public SVCCallSystem(Cpu cpu) {
20 | super(cpu);
21 | }
22 |
23 | @Override
24 | protected int getSvcNumber() {
25 | return 0x12;
26 | }
27 |
28 | @Override
29 | protected void primitive() {
30 | try {
31 | int length = this.getRam().getValue(this.getCpu().getRegister(1).getValue()+4);
32 | String command = this.longToString(this.getRam().getValue(this.getCpu().getRegister(1).getValue()), length);
33 | Process p = Runtime.getRuntime().exec(command);
34 | } catch (IOException e) {
35 | e.printStackTrace();
36 | }
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/io/IOComponent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.io;
10 |
11 | import projetarm_v2.simulator.core.RamRegister;
12 |
13 | public abstract class IOComponent {
14 |
15 | private final RamRegister register;
16 | public final int shift;
17 | public final int portNb;
18 |
19 | protected IOComponent(RamRegister port, int shift, int portNb) {
20 | this.register = port;
21 | this.shift = shift;
22 | this.portNb = portNb;
23 | }
24 |
25 | public boolean isOn() {
26 | return this.register.getBit(shift);
27 | }
28 |
29 | public void set(boolean value) {
30 | this.register.setBit(shift, value);
31 | }
32 |
33 | public long getPortAddress() {
34 | return this.register.getAddress();
35 | }
36 |
37 | public String toString() {
38 | return "[Adr: 0x" + Long.toHexString(this.register.getAddress()) + ", Bits N°" + this.shift + "]";
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/syscalls/SVCCallRemove.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.syscalls;
10 |
11 | import java.io.BufferedReader;
12 | import java.io.File;
13 | import java.io.IOException;
14 | import java.io.InputStreamReader;
15 |
16 | import projetarm_v2.simulator.core.Cpu;
17 |
18 | public class SVCCallRemove extends SVCCall {
19 |
20 | public SVCCallRemove(Cpu cpu) {
21 | super(cpu);
22 | }
23 |
24 | @Override
25 | protected int getSvcNumber() {
26 | return 0x0e;
27 | }
28 |
29 | @Override
30 | protected void primitive() {
31 | try {
32 | int length = this.getRam().getValue(this.getCpu().getRegister(1).getValue()+4);
33 | String name = this.longToString(this.getRam().getValue(this.getCpu().getRegister(1).getValue()), length);
34 |
35 | File file = new File(name);
36 | boolean success = file.delete();
37 | this.getCpu().getRegister(0).setValue(success ? 0 : -1);
38 | } catch (IOException e) {
39 | e.printStackTrace();
40 | }
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/RamChunk.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core;
10 |
11 | import java.util.Arrays;
12 |
13 | public class RamChunk {
14 | public final long startingAddress;
15 | private byte[] bytes;
16 |
17 | public RamChunk(long startingAddress, RamChunk ramChunk) {
18 | this.startingAddress = startingAddress;
19 | byte[] pattern = ramChunk.getChunk();
20 | this.bytes = new byte[pattern.length];
21 | System.arraycopy(pattern, 0, this.bytes, 0, this.bytes.length);
22 | }
23 |
24 | public RamChunk(long startingAddress, int size) {
25 | this.startingAddress = startingAddress;
26 | this.bytes = new byte[size];
27 | }
28 |
29 | public byte getByte(int offset) {
30 | return this.bytes[offset];
31 | }
32 |
33 | public void setByte(int offset, byte value) {
34 | this.bytes[offset] = value;
35 | }
36 |
37 | public byte[] getChunk() {
38 | return this.bytes;
39 | }
40 |
41 | @Override
42 | public String toString() {
43 | return "RamChunk [startingAddress=0x" + Long.toHexString(startingAddress) +", bytes=" + Arrays.toString(bytes) + "]";
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/routines/CpuPutFile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.routines;
10 |
11 | import projetarm_v2.simulator.core.Cpu;
12 |
13 | import java.io.*;
14 |
15 | public class CpuPutFile extends CpuRoutine
16 | {
17 | public static final long ROUTINE_ADDRESS = 0x1F001CL;
18 |
19 | public CpuPutFile(Cpu cpu) { super(cpu); }
20 |
21 | public long getRoutineAddress() { return ROUTINE_ADDRESS; }
22 |
23 | @Override
24 | protected void primitive() {
25 | long address = (long) this.getRegister(0).getValue();
26 | long dest = (long) this.getRegister(1).getValue();
27 |
28 | try {
29 | String fileName = this.longToString(address);
30 | File file = new File(fileName);
31 | FileWriter fileWriter = new FileWriter(file);
32 |
33 | System.out.println("[INFO] Writing " + fileName + " from 0x" + Long.toHexString(dest));
34 |
35 | String str = this.longToString(dest);
36 | fileWriter.write(str);
37 | fileWriter.close();
38 |
39 | } catch(Exception e) {
40 | System.out.println("[ERROR] Writing" + e.getMessage());
41 | }
42 | }
43 | }
44 |
45 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/routines/CpuGetFile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.routines;
10 |
11 | import projetarm_v2.simulator.core.Cpu;
12 |
13 | import java.nio.file.Files;
14 | import java.nio.file.Path;
15 |
16 | public class CpuGetFile extends CpuRoutine
17 | {
18 | public static final long ROUTINE_ADDRESS = 0x1F0020L;
19 |
20 | public CpuGetFile(Cpu cpu) {
21 | super(cpu);
22 | }
23 |
24 | @Override
25 | public long getRoutineAddress() {
26 | return ROUTINE_ADDRESS;
27 | }
28 |
29 | @Override
30 | protected void primitive()
31 | {
32 | long address = (long) this.getRegister(0).getValue();
33 | long dest = (long) this.getRegister(1).getValue();
34 |
35 | try {
36 | String path = this.longToString(address);
37 | System.out.println("[INFO] Reading " + path + " to 0x" + Long.toHexString(dest));
38 | byte[] array = Files.readAllBytes(Path.of(path));
39 | for(byte myByte: array)
40 | {
41 | this.getRam().setByte(dest,myByte);
42 | dest++;
43 | }
44 |
45 | } catch(Exception e) {
46 | System.out.println("[ERROR] Reading " + e.getMessage());
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/Main.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator;
10 |
11 | import projetarm_v2.simulator.boilerplate.ArmSimulator;
12 | import projetarm_v2.simulator.ui.cli.Cli;
13 | import projetarm_v2.simulator.ui.javafx.Gui;
14 |
15 | public class Main {
16 | public static void main(String[] args) {
17 | System.out.print(">>> Launching Test sequence\n");
18 |
19 | ArmSimulator simulator = new ArmSimulator(); // PC is set @ 0x1000, 2 MB of RAM by default
20 | simulator.setProgram("b start;" +
21 | "kek: .asciz \"test\";" +
22 | ".align;" +
23 | "start: ldr r0,=kek;" +
24 | "ldr r1,=0x1F0008;" +
25 | "blx r1");
26 |
27 | simulator.run();
28 |
29 | System.out.print(">>> Emulation done. Below is the CPU context\n");
30 |
31 | for (int i = 0; i < 16; i++) {
32 | System.out.print(String.format(">>> R%d = 0x%x%n", i,simulator.getRegisterValue(i)));
33 | }
34 |
35 | System.out.format(">>> Processor Flags : %s%n", simulator.getCpu().getCPSR());
36 | System.out.println(simulator.getRam());
37 |
38 | if (args.length == 0) {
39 | Gui.main(new String[0]);
40 | return;
41 | }
42 |
43 | Cli.main(new String[0]);
44 | }
45 | }
--------------------------------------------------------------------------------
/src/resources/26025.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
50 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/syscalls/SVCCallRename.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.syscalls;
10 |
11 | import java.io.BufferedReader;
12 | import java.io.File;
13 | import java.io.IOException;
14 | import java.io.InputStreamReader;
15 |
16 | import projetarm_v2.simulator.core.Cpu;
17 |
18 | public class SVCCallRename extends SVCCall {
19 |
20 | public SVCCallRename(Cpu cpu) {
21 | super(cpu);
22 | }
23 |
24 | @Override
25 | protected int getSvcNumber() {
26 | return 0xf;
27 | }
28 |
29 | @Override
30 | protected void primitive() {
31 | try {
32 | int originalLength = this.getRam().getValue(this.getCpu().getRegister(1).getValue()+4);
33 | int newLength = this.getRam().getValue(this.getCpu().getRegister(1).getValue()+12);
34 | String originalName = this.longToString(this.getRam().getValue(this.getCpu().getRegister(1).getValue()), originalLength);
35 | String newName = this.longToString(this.getRam().getValue(this.getCpu().getRegister(1).getValue())+8, newLength);
36 |
37 | File file = new File(originalName);
38 | boolean success = file.renameTo(new File(newName));
39 | this.getCpu().getRegister(0).setValue(success ? 0 : -1);
40 | } catch (IOException e) {
41 | e.printStackTrace();
42 | }
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/syscalls/SVCCall.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.syscalls;
10 |
11 | import java.io.UnsupportedEncodingException;
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | import projetarm_v2.simulator.core.Cpu;
16 | import projetarm_v2.simulator.core.Ram;
17 |
18 |
19 | public abstract class SVCCall {
20 |
21 | private Cpu cpu;
22 |
23 | public SVCCall(Cpu cpu) {
24 | this.cpu = cpu;
25 | }
26 |
27 | protected Cpu getCpu() {
28 | return this.cpu;
29 | }
30 |
31 | protected Ram getRam() {
32 | return this.cpu.getRam();
33 | }
34 |
35 | protected String longToString(long address, int length) throws UnsupportedEncodingException
36 | {
37 |
38 | List list = new ArrayList<>();
39 | byte c = this.getRam().getByte(address++);
40 |
41 | for (int i = 0; i < length; i++) {
42 | list.add(c);
43 | c = this.getRam().getByte(address++);
44 | }
45 |
46 | byte[] array = new byte[list.size()];
47 |
48 | int i= 0;
49 | for (Byte current : list) {
50 | array[i] = current;
51 | i++;
52 | }
53 |
54 | return new String(array, "UTF-8");
55 |
56 | }
57 |
58 | protected abstract int getSvcNumber();
59 |
60 | protected abstract void primitive();
61 |
62 | protected void run() {
63 | this.primitive();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/ui/javafx/RegisterObjectView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.ui.javafx;
10 |
11 | import javafx.beans.property.SimpleStringProperty;
12 |
13 | //TODO: didi je te laisse faire la javadoc ce truc wtf xD
14 | public class RegisterObjectView {
15 |
16 | private final SimpleStringProperty nameRegister;
17 | private final SimpleStringProperty valueRegister;
18 | private int myRegisterNumber;
19 |
20 |
21 | RegisterObjectView(int register, String fName, String fValue) {
22 | this.nameRegister = new SimpleStringProperty(fName);
23 | this.valueRegister = new SimpleStringProperty(fValue);
24 | this.myRegisterNumber = register;
25 | }
26 |
27 | public String getNameRegister() {
28 | return this.nameRegister.get();
29 | }
30 |
31 | public void setNameRegister(String fName) {
32 | this.nameRegister.set(fName);
33 | }
34 |
35 | public String getValueRegister() {
36 | return this.valueRegister.get();
37 | }
38 |
39 | public void setValueRegister(String fValue) {
40 | this.valueRegister.set(fValue);
41 | }
42 |
43 | public int getRegister() {
44 | return this.myRegisterNumber;
45 | }
46 |
47 | public void setRegister(int fRegister) {
48 | this.myRegisterNumber = fRegister;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/routines/CpuConsoleGetChar.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.routines;
10 |
11 | import projetarm_v2.simulator.core.Cpu;
12 |
13 | import java.util.concurrent.ConcurrentLinkedQueue;
14 | import java.util.concurrent.atomic.AtomicBoolean;
15 |
16 | public class CpuConsoleGetChar extends CpuRoutine {
17 |
18 | public static final long ROUTINE_ADDRESS = 0x1F0004L;
19 | private ConcurrentLinkedQueue consoleBuffer;
20 | private AtomicBoolean waitingForInput;
21 |
22 | public CpuConsoleGetChar(Cpu cpu, ConcurrentLinkedQueue consoleBuffer, AtomicBoolean waitingForInput) {
23 | super(cpu);
24 | this.consoleBuffer = consoleBuffer;
25 | this.waitingForInput = waitingForInput;
26 | }
27 |
28 | public long getRoutineAddress() { return ROUTINE_ADDRESS; }
29 |
30 | public static boolean shouldBeManuallyAdded() { return true; }
31 |
32 | @Override
33 | protected void primitive()
34 | {
35 | System.out.println("[INPUT] Waiting for input");
36 |
37 | this.waitingForInput.set(true);
38 | while (this.consoleBuffer.peek() == null) {
39 | try {
40 | Thread.sleep(50);
41 | } catch (InterruptedException e) {
42 | Thread.currentThread().interrupt();
43 | }
44 | }
45 | this.waitingForInput.set(false);
46 |
47 | this.getRegister(0).setValue(this.consoleBuffer.poll());
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/syscalls/io/SVCCallOpen.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.syscalls.io;
10 |
11 | import java.io.File;
12 | import java.io.IOException;
13 | import java.util.Map;
14 |
15 | import projetarm_v2.simulator.core.Cpu;
16 |
17 | public class SVCCallOpen extends SVCIOCall {
18 |
19 | public SVCCallOpen(Cpu cpu, FileDescriptors fileDescriptors) {
20 | super(cpu, fileDescriptors);
21 | }
22 |
23 | @Override
24 | protected int getSvcNumber() {
25 | return 0x01;
26 | }
27 |
28 | @Override
29 | protected void primitive() {
30 | try {
31 | int length = this.getRam().getValue(this.getCpu().getRegister(1).getValue()+8);
32 | String name = this.longToString(this.getRam().getValue(this.getCpu().getRegister(1).getValue()), length);
33 | int mode = this.getRam().getValue(this.getCpu().getRegister(1).getValue()+4);
34 |
35 | File file = new File(name);
36 | FileMode fileMode = FileMode.fromNo(mode);
37 | if (fileMode == null) {
38 | this.getCpu().getRegister(0).setValue(-1);
39 | return;
40 | }
41 |
42 | OpenedFile openedFile = new OpenedFile(file, fileMode);
43 |
44 | int fd = this.getFileDescriptors().addNewFile(openedFile);
45 |
46 | this.getCpu().getRegister(0).setValue(fd);
47 | } catch (IOException e) {
48 | e.printStackTrace();
49 | this.getCpu().getRegister(0).setValue(-1);
50 | }
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/resources/aboutView.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/routines/CpuConsoleGetString.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.routines;
10 |
11 | import projetarm_v2.simulator.core.Cpu;
12 |
13 | import java.util.concurrent.ConcurrentLinkedQueue;
14 | import java.util.concurrent.atomic.AtomicBoolean;
15 |
16 | public class CpuConsoleGetString extends CpuRoutine {
17 |
18 | public static final long ROUTINE_ADDRESS = 0x1F000CL;
19 | private ConcurrentLinkedQueue consoleBuffer;
20 |
21 | private AtomicBoolean waitingForInput;
22 |
23 | public CpuConsoleGetString(Cpu cpu, ConcurrentLinkedQueue consoleBuffer, AtomicBoolean waitingForInput) {
24 | super(cpu);
25 | this.waitingForInput = waitingForInput;
26 | this.consoleBuffer = consoleBuffer;
27 | }
28 |
29 | public long getRoutineAddress() { return ROUTINE_ADDRESS; }
30 |
31 | public static boolean shouldBeManuallyAdded() { return true; }
32 |
33 | @Override
34 | protected void primitive()
35 | {
36 | System.out.println("[INPUT] Waiting for input");
37 | this.waitingForInput.set(true);
38 | while (this.consoleBuffer.peek() == null) {
39 | try {
40 | Thread.sleep(50);
41 | } catch (InterruptedException e) {
42 | Thread.currentThread().interrupt();
43 | }
44 | }
45 | this.waitingForInput.set(false);
46 |
47 | long address = (long) this.getRegister(0).getValue();
48 |
49 | for(Character ch : this.consoleBuffer)
50 | {
51 | this.getRam().setByte(address,(byte)(char)ch);
52 | address++;
53 | }
54 | this.getRam().setByte(address,(byte)0);
55 | this.consoleBuffer.clear();
56 | }
57 |
58 | public boolean isWaitingForInput() {
59 | return this.waitingForInput.get();
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/resources/warning.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/save/InterfaceAdapterArrayList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.save;
10 |
11 |
12 | import com.google.gson.*;
13 |
14 | import java.lang.reflect.Type;
15 | import java.util.ArrayList;
16 |
17 | public final class InterfaceAdapterArrayList implements JsonSerializer>, JsonDeserializer> {
18 | public JsonElement serialize(ArrayList object, Type interfaceType, JsonSerializationContext context) {
19 | JsonArray array = new JsonArray();
20 | for (T item : object) {
21 | final JsonObject wrapper = new JsonObject();
22 | wrapper.add("data", context.serialize(item));
23 | wrapper.add("type", context.serialize(item.getClass().getName()));
24 | array.add(wrapper);
25 | }
26 | return array;
27 | }
28 |
29 | public ArrayList deserialize(JsonElement elem, Type interfaceType, JsonDeserializationContext context) throws JsonParseException {
30 | final JsonArray wrapper = (JsonArray) elem;
31 | ArrayList items = new ArrayList<>();
32 |
33 | for (JsonElement _item: wrapper) {
34 | JsonObject item = (JsonObject)_item;
35 | final JsonElement typeName = get(item, "type");
36 | final JsonElement data = get(item, "data");
37 | final Type actualType = typeForName(typeName);
38 | items.add((T)context.deserialize(data, actualType));
39 | }
40 |
41 | return items;
42 | }
43 |
44 | private Type typeForName(final JsonElement typeElem) {
45 | try {
46 | return Class.forName(typeElem.getAsString());
47 | } catch (ClassNotFoundException e) {
48 | throw new JsonParseException(e);
49 | }
50 | }
51 |
52 | private JsonElement get(final JsonObject wrapper, String memberName) {
53 | final JsonElement elem = wrapper.get(memberName);
54 | if (elem == null) throw new JsonParseException("no '" + memberName + "' member found in what was expected to be an interface wrapper");
55 | return elem;
56 | }
57 | }
--------------------------------------------------------------------------------
/src/resources/simpleMemoryView.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/Assembler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core;
10 |
11 | import java.io.BufferedReader;
12 | import java.io.File;
13 | import java.io.IOException;
14 | import java.io.InputStreamReader;
15 | import java.util.regex.Matcher;
16 | import java.util.regex.Pattern;
17 |
18 | import projetarm_v2.simulator.utils.NativeJarGetter;
19 | import projetarm_v2.simulator.utils.OSValidator;
20 |
21 | public class Assembler {
22 | /**
23 | * Temporary directory which will contain the library.
24 | */
25 | private Pattern pattern = Pattern.compile("\\[ (.*) \\]");
26 | private Pattern errorPattern = Pattern.compile("'(.*) \\(.*'");
27 | private static Assembler assembler;
28 | private File executable;
29 |
30 | public static Assembler getInstance() {
31 | if (Assembler.assembler == null) {
32 | try {
33 | Assembler.assembler = new Assembler();
34 | } catch (IOException e) {
35 | e.printStackTrace();
36 | System.exit(-1);
37 | }
38 | }
39 | return Assembler.assembler;
40 | }
41 |
42 | private Assembler() throws IOException {
43 | this.executable = NativeJarGetter.getInstance().getNativeExecutable("kstool");
44 | }
45 |
46 | public byte[] assemble(String assembly, long startingAddress) {
47 | try {
48 | if (OSValidator.isWindows()) {
49 | assembly = assembly.replaceAll("\"", "\\\\\"");
50 | }
51 |
52 | Process p = new ProcessBuilder(executable.getAbsolutePath(), "arm", assembly, Long.toHexString(startingAddress))
53 | .start();
54 |
55 | String result = new String(p.getInputStream().readAllBytes(), "ASCII");
56 |
57 | Matcher matcher = pattern.matcher(result);
58 |
59 | if (!matcher.find()) {
60 | Matcher errorMatcher = errorPattern.matcher(result);
61 | if (!errorMatcher.find()) {
62 | return new byte[0];
63 | }
64 | throw new InvalidAssemblyException (errorMatcher.group(1));
65 | }
66 |
67 | String[] output = matcher.group(1).split(" ");
68 |
69 | byte[] bytes = new byte[output.length];
70 |
71 | for (int i = 0; i < output.length; i++) {
72 | bytes[i] = (byte) Integer.parseInt(output[i], 16);
73 | }
74 |
75 | return bytes;
76 | } catch (IOException e) {
77 | throw new InvalidAssemblyException(e.toString());
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/resources/style.css:
--------------------------------------------------------------------------------
1 | @font-face {
2 | src: url("Anonymous_Pro_B.ttf"),
3 | /*src: url("1 Minecraft-Regular.otf"),*/
4 | }
5 |
6 | .root {
7 | -fx-focus-color: transparent;
8 | -fx-font-family: "Anonymous Pro Bold";
9 | -fx-font-size: 1.2em;
10 | }
11 |
12 | .button, #button8Bit, #button16Bit, #button32Bit{
13 | -fx-background-radius: 10px;
14 | -fx-border-radius: 10px;
15 | -fx-border-width: 1.5px;
16 | }
17 |
18 |
19 | .dock-close-button {
20 | -fx-graphic: url(cancel.png);
21 | }
22 |
23 | .dock-state-button {
24 | -fx-graphic: url(detachedWindow.png);
25 | }
26 |
27 | .text-area {
28 | -fx-font-size: 15;
29 | -fx-display-caret:true;
30 | -fx-text-fill: black;
31 | }
32 |
33 |
34 | .tab-pane > .tab-header-area > .tab-header-background {
35 | -fx-background-color:transparent;
36 | }
37 |
38 | .tab-header-area{
39 | -fx-padding: 0;
40 | }
41 |
42 | .registersTable .table-row-cell {
43 | -fx-cell-size: 23px;
44 | }
45 |
46 | .tab{
47 | -fx-border-radius: 5px 5px 0px 0px;
48 | }
49 |
50 | .dock-close-button {
51 | -fx-background-color: #d63031;
52 | -fx-graphic: url(cancel.png);
53 | }
54 |
55 | .dock-close-button:hover {
56 | -fx-background-color: #e17055;
57 | }
58 |
59 | .dock-state-button {
60 | -fx-background-color: #0984e3;
61 | -fx-graphic: url(detachedWindow.png);
62 | }
63 |
64 | .dock-state-button:hover {
65 | -fx-background-color: #74b9ff;
66 | }
67 |
68 | .table-row-cell:empty {
69 | -fx-background: #f4f4f4;
70 | -fx-border-color: #f4f4f4;
71 | }
72 |
73 | .table-view {
74 | -fx-background-color: transparent, -fx-control-inner-background;
75 | -fx-background-insets: 0, 1;
76 | -fx-padding: 1;
77 | }
78 |
79 | .table-row-cell:empty .table-cell {
80 | -fx-border-width: 0px;
81 | }
82 |
83 | .table-view *.scroll-bar:vertical *.increment-button,
84 | .table-view *.scroll-bar:vertical *.decrement-button {
85 | -fx-background-color: null;
86 | -fx-background-radius: 0;
87 | -fx-background-insets: 0;
88 | -fx-padding: 0;
89 | }
90 |
91 | .table-view *.scroll-bar:vertical *.increment-arrow,
92 | .table-view *.scroll-bar:vertical *.decrement-arrow {
93 | -fx-background-color: null;
94 | -fx-background-radius: 0;
95 | -fx-background-insets: 0;
96 | -fx-padding: 0;
97 | -fx-shape: null;
98 | }
99 |
100 | .disableButton{
101 | -fx-background-color: white;
102 | -fx-text-fill: #2C3E50;
103 | }
104 |
105 | .enableButton{
106 | -fx-background-color: #2C3E50;
107 | -fx-text-fill: white;
108 | }
109 |
110 |
111 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/routines/CpuRoutine.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.routines;
10 |
11 | import projetarm_v2.simulator.core.Cpu;
12 | import projetarm_v2.simulator.core.Ram;
13 | import projetarm_v2.simulator.core.Register;
14 | import unicorn.CodeHook;
15 | import unicorn.Unicorn;
16 |
17 | import java.io.UnsupportedEncodingException;
18 | import java.util.ArrayList;
19 | import java.util.List;
20 |
21 | public abstract class CpuRoutine {
22 |
23 | private Cpu cpu;
24 |
25 | public CpuRoutine(Cpu cpu) {
26 | this.cpu = cpu;
27 | }
28 |
29 | protected Cpu getCpu() {
30 | return this.cpu;
31 | }
32 |
33 | protected Ram getRam() {
34 | return this.cpu.getRam();
35 | }
36 |
37 | protected Register getRegister(int registerId) {
38 | return this.cpu.getRegister(registerId);
39 | }
40 |
41 | protected abstract void primitive();
42 |
43 | public abstract long getRoutineAddress();
44 |
45 | public CodeHook getNewHook() {
46 | return new RoutineHook(this);
47 | }
48 |
49 | public static boolean shouldBeManuallyAdded() {
50 | return false;
51 | }
52 |
53 | protected String longToString(long address) throws UnsupportedEncodingException
54 | {
55 | int i= 0;
56 | List list = new ArrayList<>();
57 | byte c = this.getRam().getByte(address++);
58 |
59 | while (c != 0) {
60 | list.add(c);
61 | c = this.getRam().getByte(address++);
62 | }
63 |
64 | byte[] array = new byte[list.size()];
65 |
66 | for (Byte current : list) {
67 | array[i] = current;
68 | i++;
69 | }
70 |
71 | return new String(array, "ASCII");
72 | }
73 |
74 | private class RoutineHook implements CodeHook {
75 | private final CpuRoutine cpuRoutine;
76 |
77 | public RoutineHook(CpuRoutine cpuRoutine) {
78 | this.cpuRoutine = cpuRoutine;
79 | }
80 |
81 | public void hook(Unicorn u, long address, int size, Object user_data) {
82 | if (address != this.cpuRoutine.getRoutineAddress()) {
83 | return;
84 | }
85 |
86 | System.out.println("[INFO] System call " + this.cpuRoutine.getClass().getSimpleName()
87 | + " @ 0x" + Long.toHexString(this.cpuRoutine.getRoutineAddress()));
88 |
89 | this.cpuRoutine.primitive();
90 |
91 | this.cpuRoutine.getCpu().setCurrentAddress((long) this.cpuRoutine.getCpu().getRegister(14).getValue()-4);
92 | }
93 |
94 | }
95 | }
96 |
97 |
--------------------------------------------------------------------------------
/src/resources/MemoryView.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/save/Save.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.save;
10 |
11 | import java.io.IOException;
12 | import java.io.Serializable;
13 | import java.nio.file.Files;
14 | import java.nio.file.Path;
15 | import java.nio.file.Paths;
16 | import java.util.ArrayList;
17 | import java.util.Collections;
18 | import java.util.List;
19 |
20 | import com.google.gson.Gson;
21 | import com.google.gson.GsonBuilder;
22 | import com.google.gson.reflect.TypeToken;
23 |
24 | import projetarm_v2.simulator.core.io.IOComponent;
25 |
26 | public class Save implements Serializable {
27 | private static final long serialVersionUID = -7923487851230607241L;
28 | @SuppressWarnings("unused")
29 | private double version = 1.0;
30 | @SuppressWarnings("unused")
31 | private String copyright = "(C) 2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi";
32 | private String program;
33 | private List components;
34 | private static Gson gson = new GsonBuilder().setPrettyPrinting().registerTypeAdapter(new TypeToken>(){}.getRawType(), new InterfaceAdapterArrayList()).create();
35 |
36 | public Save() {
37 | this.program = "";
38 | this.components = new ArrayList<>();
39 | }
40 |
41 | public static Save fromPath(String filePath) throws IOException {
42 | Path path = Paths.get(filePath);
43 | String json = Files.readString(path);
44 |
45 | return Save.deserialize(json);
46 | }
47 |
48 | public String serialize() {
49 | return gson.toJson(this);
50 | }
51 |
52 | public static Save deserialize(String json) {
53 | return gson.fromJson(json, Save.class);
54 | }
55 |
56 |
57 | public void setProgram(String program) {
58 | this.program = program;
59 | }
60 |
61 | public String getProgram() {
62 | return this.program;
63 | }
64 |
65 | public void saveToFile(String filePath) throws IOException {
66 | Files.writeString(Paths.get(filePath), this.serialize());
67 | }
68 |
69 | public void addComponent(IOComponent component) {
70 | this.components.add(component);
71 | }
72 |
73 | public void removeComponent(IOComponent component) {
74 | this.components.remove(component);
75 | }
76 |
77 | public List getComponentsAndReset() {
78 | List toReturn = Collections.unmodifiableList(this.components);
79 |
80 | this.components = new ArrayList<>();
81 |
82 | return toReturn;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/projetarm_v2/gpl/TableCellSkinFixed.java:
--------------------------------------------------------------------------------
1 | package projetarm_v2.gpl;
2 |
3 | /*
4 | * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Oracle designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Oracle in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
24 | * or visit www.oracle.com if you need additional information or have any
25 | * questions.
26 | */
27 |
28 | import javafx.beans.property.ReadOnlyObjectProperty;
29 | import javafx.scene.Node;
30 | import javafx.scene.control.*;
31 | import javafx.scene.control.skin.TableCellSkin;
32 |
33 | import javafx.beans.property.BooleanProperty;
34 | import javafx.beans.property.ReadOnlyDoubleProperty;
35 |
36 | /**
37 | * Default skin implementation for the {@link TableCell} control.
38 | *
39 | * @param The type of the UI control (e.g. the type of the 'row').
40 | * @param The type of the content in the cell, based on its {@link TableColumn}.
41 | * @see TableCell
42 | * @since 9
43 | */
44 | public class TableCellSkinFixed extends TableCellSkin {
45 | public TableCellSkinFixed(TableCell control) {
46 | super(control);
47 | }
48 |
49 |
50 |
51 | /***************************************************************************
52 | * *
53 | * Public API *
54 | * *
55 | **************************************************************************/
56 |
57 | /** {@inheritDoc} */
58 | @Override public void dispose() {
59 |
60 | }
61 |
62 | /** {@inheritDoc} */
63 | @Override public ReadOnlyObjectProperty> tableColumnProperty() {
64 | if (getSkinnable() != null)
65 | return getSkinnable().tableColumnProperty();
66 | return null;
67 | }
68 | }
69 |
70 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/utils/NativeJarGetter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.utils;
10 |
11 | import java.io.File;
12 | import java.io.IOException;
13 | import java.io.InputStream;
14 | import java.nio.file.Files;
15 | import java.nio.file.StandardCopyOption;
16 |
17 | public class NativeJarGetter {
18 |
19 | private static final String NATIVE_DIR = "/natives/";
20 | private static NativeJarGetter nativeGetter;
21 | private File temporaryDir;
22 |
23 | private NativeJarGetter() throws IOException {
24 | temporaryDir = this.createTempDirectory("projectarm");
25 | }
26 |
27 | public static NativeJarGetter getInstance() {
28 | if (NativeJarGetter.nativeGetter == null) {
29 | try {
30 | NativeJarGetter.nativeGetter = new NativeJarGetter();
31 | } catch (IOException e) {
32 | e.printStackTrace();
33 | }
34 | }
35 | return NativeJarGetter.nativeGetter;
36 | }
37 |
38 | public void loadLibraryFromJar(String libraryName) throws IOException {
39 | System.load(this.getNativeLibrary(libraryName).getAbsolutePath());
40 | }
41 |
42 | public File getNativeLibrary(String libraryName) throws IOException {
43 | return this.getFile(libraryName + "-" + System.getProperty("os.arch") + NativeJarGetter.getDynamicLibraryExtension());
44 | }
45 |
46 | public File getNativeExecutable(String executableName) throws IOException {
47 | return this.getFile(executableName + "-" + System.getProperty("os.arch") + NativeJarGetter.getExecutableExtension());
48 | }
49 |
50 | public File getFile(String executableName) throws IOException {
51 | File temp = new File(temporaryDir, executableName);
52 |
53 | InputStream is = NativeJarGetter.class.getResourceAsStream(NativeJarGetter.NATIVE_DIR + executableName);
54 | Files.copy(is, temp.toPath(), StandardCopyOption.REPLACE_EXISTING);
55 |
56 | temp.setExecutable(true);
57 |
58 | return temp;
59 | }
60 |
61 | private static String getExecutableExtension() {
62 | if (OSValidator.isWindows()) {
63 | return ".exe";
64 | }
65 | return "";
66 | }
67 |
68 | private static String getDynamicLibraryExtension() {
69 | if (OSValidator.isWindows()) {
70 | return ".dll";
71 | } else if (OSValidator.isMac()) {
72 | return ".dylib";
73 | }
74 | return ".so"; // Assumes a *NIX (Linux, FreeBSD, Solaris..) using ELF
75 | }
76 |
77 | public File createTempDirectory(String prefix) throws IOException {
78 | String tempDir = System.getProperty("java.io.tmpdir");
79 | File generatedDir = new File(tempDir, prefix + System.nanoTime());
80 |
81 | if (!generatedDir.mkdir())
82 | throw new IOException("Failed to create temp directory " + generatedDir.getName());
83 |
84 | generatedDir.deleteOnExit();
85 |
86 | return generatedDir;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/src/resources/preferences.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/ui/javafx/EightSegmentDisplay.java:
--------------------------------------------------------------------------------
1 | package projetarm_v2.simulator.ui.javafx;
2 |
3 | import javafx.scene.image.Image;
4 | import javafx.scene.image.ImageView;
5 | import javafx.scene.layout.AnchorPane;
6 | import javafx.scene.layout.HBox;
7 | import javafx.scene.layout.VBox;
8 | import javafx.scene.text.Text;
9 | import org.dockfx.DockNode;
10 | import projetarm_v2.simulator.boilerplate.ArmSimulator;
11 | import projetarm_v2.simulator.core.io.IO8Segment;
12 |
13 | import java.util.ArrayList;
14 |
15 | public class EightSegmentDisplay {
16 | HBox mainPane;
17 | DockNode dockNode;
18 |
19 | Text address;
20 | ArrayList> images;
21 | ArrayList segments;
22 |
23 | private ArmSimulator simulator;
24 |
25 | /**
26 | * creates a 8segment window
27 | * @param simulator the simulator
28 | */
29 | public EightSegmentDisplay(ArmSimulator simulator){
30 |
31 | this.simulator = simulator;
32 | this.mainPane = new HBox();
33 | images = new ArrayList<>();
34 | segments = new ArrayList<>();
35 |
36 |
37 |
38 | for(int j = 0; j<15; j++) {
39 | VBox currentVBox = new VBox();
40 | this.mainPane.getChildren().add(currentVBox);
41 | AnchorPane imagesContainer = new AnchorPane();
42 | currentVBox.getChildren().add(imagesContainer);
43 | imagesContainer.getChildren().add(new ImageView(new Image(getClass().getResource("/resources/8_segment/8seg_base.png").toExternalForm())));
44 | images.add(new ArrayList<>());
45 | for (int i = 0; i < 8; i++) {
46 | ImageView currentImage = new ImageView(new Image(getClass().getResource("/resources/8_segment/8seg_" + (i + 1) + ".png").toExternalForm()));
47 | imagesContainer.getChildren().add(currentImage);
48 | images.get(j).add(currentImage);
49 | currentImage.setVisible(false);
50 | }
51 | segments.add(simulator.newIO8Segment());
52 | currentVBox.getChildren().add(new Text("0x" + Long.toHexString(segments.get(j).getSegment(0).getPortAddress())));
53 | }
54 |
55 | this.dockNode = new DockNode(mainPane, "8 segment view");
56 | dockNode.setPrefSize(460,666);
57 |
58 | }
59 |
60 | /**
61 | * gets and display the new 8segments state
62 | */
63 | public void refresh() {
64 | for (int j=0; j<15; j++){
65 | for (int i=0; i<8; i++){
66 | images.get(j).get(i).setVisible(segments.get(j).getSegmentState(i));
67 | }
68 | }
69 | }
70 |
71 | /**
72 | * get the dock node
73 | * @return dockNode
74 | */
75 | public DockNode getNode() {
76 | return dockNode;
77 | }
78 |
79 | /**
80 | * called when user pushes the close button on the dockfx node
81 | * closes the node and removes the components
82 | */
83 | public void close() {
84 | this.dockNode.close();
85 | for(IO8Segment segment : segments){
86 | this.simulator.removeIOComponent(segment);
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/Preprocessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core;
10 |
11 | import java.util.regex.Matcher;
12 | import java.util.regex.Pattern;
13 |
14 | import projetarm_v2.simulator.core.routines.CpuBreakpoint;
15 | import projetarm_v2.simulator.core.routines.CpuConsoleClear;
16 |
17 | public class Preprocessor {
18 |
19 | private static final String START_OF_LINE = "(?m)^\\s*";
20 | public static final String LABEL_PATTERN = START_OF_LINE + "(([a-zA-Z]|[0-9])*):";
21 | public static final Pattern labelPattern = Pattern.compile(LABEL_PATTERN);
22 | public static final Pattern emptyLabelPattern = Pattern.compile(LABEL_PATTERN + "\\s*$");
23 | public static final Pattern multiLinesComments = Pattern.compile("(?s)(\\/\\*.*?\\*\\/)", Pattern.DOTALL);
24 | private static final Pattern equPattern = Pattern.compile(START_OF_LINE + "\\.equ +(.*),(.*)");
25 |
26 | public static String pass1(String assembly) {
27 | Matcher matcher = equPattern.matcher(assembly);
28 |
29 | while (matcher.find()) {
30 | assembly = assembly.replaceAll("#"+ matcher.group(1), "#"+matcher.group(2));
31 | assembly = assembly.replaceAll("="+ matcher.group(1), "="+matcher.group(2));
32 | }
33 |
34 | matcher = labelPattern.matcher(assembly);
35 | while (matcher.find()) {
36 | assembly = assembly.replaceAll(matcher.group(1), escapeDigit(matcher.group(1)));
37 | }
38 |
39 | matcher = multiLinesComments.matcher(assembly);
40 | while (matcher.find()) {
41 | assembly = assembly.replace(matcher.group(1), ";".repeat(matcher.group(1).split("\\R").length-1));
42 | }
43 |
44 | assembly = assembly
45 | .replaceAll("@.*", "")
46 | .replaceAll(START_OF_LINE + "\\.breakpoint", "blx #" + CpuBreakpoint.ROUTINE_ADDRESS)
47 | .replaceAll(START_OF_LINE + "\\.clear", "blx #" + CpuConsoleClear.ROUTINE_ADDRESS)
48 | .replaceAll(START_OF_LINE + "\\.stop", ".word 0")
49 | .replaceAll(START_OF_LINE + "\\.end", ".word 0")
50 | .replaceAll(START_OF_LINE +"\\.equ +.*", "");
51 |
52 |
53 | return assembly.replaceAll("\\R",";");
54 | }
55 |
56 | private static String escapeDigit(String group) {
57 | StringBuilder builder = new StringBuilder();
58 |
59 | for (char digit : group.toCharArray()) {
60 | switch(digit) {
61 | default: builder.append(digit); break;
62 | case '0': builder.append("Z"); break;
63 | case '1': builder.append("O"); break;
64 | case '2': builder.append("T"); break;
65 | case '3': builder.append("Th"); break;
66 | case '4': builder.append("F"); break;
67 | case '5': builder.append("Fi"); break;
68 | case '6': builder.append("S"); break;
69 | case '7': builder.append("Se"); break;
70 | case '8': builder.append("E"); break;
71 | case '9': builder.append("N"); break;
72 | case '_': builder.append("Und"); break;
73 | case '-': builder.append("Min"); break;
74 | }
75 | }
76 |
77 | return builder.toString();
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/ui/javafx/Preferences.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.ui.javafx;
10 |
11 | import javafx.fxml.FXMLLoader;
12 | import javafx.scene.Scene;
13 | import javafx.scene.control.Button;
14 | import javafx.scene.control.TextField;
15 | import javafx.scene.layout.Pane;
16 | import javafx.stage.Modality;
17 | import javafx.stage.Stage;
18 | import projetarm_v2.simulator.boilerplate.ArmSimulator;
19 |
20 | import java.io.IOException;
21 |
22 | /**
23 | * The preferences window
24 | */
25 | public class Preferences {
26 |
27 | private Stage preferencesStage;
28 | /**
29 | * Creates a new instance of a preferences window
30 | * @param simulator
31 | */
32 | public Preferences(ArmSimulator simulator, Gui gui){
33 | preferencesStage = new Stage();
34 |
35 | preferencesStage.setTitle("Preferences");
36 |
37 | preferencesStage.initModality(Modality.APPLICATION_MODAL);
38 |
39 | try {
40 | Pane main = FXMLLoader.load(Gui.class.getResource("/resources/preferences.fxml"));
41 | preferencesStage.setScene(new Scene(main, 500, 280));
42 | preferencesStage.setResizable(false);
43 |
44 | TextField programAt = (TextField) main.lookup("#programAt");
45 | programAt.setText(String.format("0x%x",simulator.getStartingAddress()));
46 |
47 | Button cleanRdm = (Button) main.lookup("#cleanRdm");
48 | cleanRdm.setOnAction(ActionEvent -> {
49 | simulator.removeRandomPattern();
50 | System.out.println("[INFO] Random RAM pattern removed !");
51 | gui.getArmMenuBar().getReloadMenuItem().fire();
52 | });
53 |
54 |
55 | Button buttonRdm = (Button) main.lookup("#buttonRdm");
56 | buttonRdm.setOnAction(ActionEvent -> {
57 | simulator.setRandomPattern();
58 | System.out.println("[INFO] Random RAM pattern set !");
59 | simulator.setProgram(simulator.getProgramFromSave());
60 | gui.getArmMenuBar().getReloadMenuItem().fire();
61 | });
62 |
63 | Button applyAndCloseButton = (Button) main.lookup("#applyAndCloseButton");
64 | applyAndCloseButton.setOnAction(e -> {
65 | try {
66 | int startingAddress = Gui.parseUserAdress(programAt.getText());
67 | if (Integer.compareUnsigned(startingAddress, simulator.getRamSize()) >= 0) {
68 | Gui.warningPopup("This starting address is invalid.", (_e) -> {});
69 | return;
70 | }
71 | if ((startingAddress % 4) != 0) {
72 | Gui.warningPopup("The startingAddress should be aligned on a word bound.", (_e) -> {});
73 | return;
74 | }
75 | simulator.setStartingAddress(startingAddress);
76 | preferencesStage.close();
77 | } catch (FormatException exception) {}
78 | });
79 | preferencesStage.show();
80 | } catch (IOException e) {
81 | e.printStackTrace();
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/tests/tests/projetarm_v2/simulator/core/CpsrTdd.java:
--------------------------------------------------------------------------------
1 | package tests.projetarm_v2.simulator.core;
2 |
3 | import static org.junit.jupiter.api.Assertions.*;
4 |
5 | import org.junit.jupiter.api.BeforeEach;
6 | import org.junit.jupiter.api.Test;
7 |
8 | import projetarm_v2.simulator.boilerplate.ArmSimulator;
9 | import projetarm_v2.simulator.core.Cpsr;
10 |
11 | class CpsrTdd {
12 | private ArmSimulator simulator;
13 | private Cpsr cpsr;
14 |
15 | @BeforeEach
16 | public void Test() {
17 | this.simulator = new ArmSimulator();
18 | this.cpsr = this.simulator.getCpu().getCPSR();
19 | }
20 |
21 | @Test
22 | public void testN() {
23 | this.simulator.setProgram("mov r0,#20; mov r1,#15; cmp r0,r1");
24 | this.simulator.run();
25 | assertFalse(this.simulator.getN());
26 |
27 | this.simulator.resetState();
28 |
29 | this.simulator.setProgram("movs r0,#-1;");
30 | this.simulator.run();
31 | assertTrue(this.simulator.getN());
32 | }
33 |
34 | @Test
35 | public void testSetN() {
36 | this.cpsr.setN(false);
37 | assertFalse(this.simulator.getN());
38 | this.cpsr.setN(true);
39 | assertTrue(this.simulator.getN());
40 | }
41 |
42 | @Test
43 | public void testZ() {
44 | this.simulator.setProgram("mov r0,#20; mov r1,#20; cmp r0,r1");
45 | this.simulator.run();
46 | assertTrue(this.simulator.getZ());
47 |
48 | this.simulator.resetState();
49 |
50 | this.simulator.setProgram("movs r0,#15;");
51 | this.simulator.run();
52 | assertFalse(this.simulator.getZ());
53 | }
54 |
55 | @Test
56 | public void testSetZ() {
57 | this.cpsr.setZ(false);
58 | assertFalse(this.simulator.getZ());
59 | this.cpsr.setZ(true);
60 | assertTrue(this.simulator.getZ());
61 | }
62 |
63 | @Test
64 | public void testC() {
65 | this.simulator.setProgram("mov r0,#1; mov r1,#1; cmp r0,r1");
66 | this.simulator.run();
67 | assertTrue(this.simulator.getC());
68 |
69 | this.simulator.resetState();
70 |
71 | this.simulator.setProgram("mov r0,#15; adds r0,r0,r0;");
72 | this.simulator.run();
73 | assertFalse(this.simulator.getC());
74 | }
75 |
76 | @Test
77 | public void testSetC(){
78 | this.cpsr.setC(true);
79 | assertTrue(this.simulator.getC());
80 | this.cpsr.setC(false);
81 | assertFalse(this.simulator.getC());
82 | }
83 |
84 | @Test
85 | public void testV() {
86 | this.simulator.setProgram("mov r0, #0x80000000; mov r1, #1; subs r2, r0, r1");
87 | this.simulator.run();
88 | assertTrue(this.simulator.getV());
89 |
90 | this.simulator.resetState();
91 |
92 | this.simulator.setProgram("mov r0, #5; mov r1, #-15; subs r2, r0, r1;");
93 | this.simulator.run();
94 | assertFalse(this.simulator.getC());
95 | }
96 |
97 | @Test
98 | public void testSetV(){
99 | this.cpsr.setV(true);
100 | assertTrue(this.simulator.getV());
101 | this.cpsr.setV(false);
102 | assertFalse(this.simulator.getV());
103 | }
104 |
105 | @Test
106 | public void testQ() {
107 | this.simulator.setProgram("mov r2,#0x70000000; qadd r3,r2,r2");
108 | this.simulator.run();
109 | assertTrue(this.simulator.getQ());
110 |
111 | this.simulator.resetState();
112 |
113 | this.simulator.setProgram("mov r0,#0; mov r2,#0x70000000; qadd r3,r2,r0");
114 | this.simulator.run();
115 | assertFalse(this.simulator.getQ());
116 | }
117 |
118 | @Test
119 | public void testSetQ() {
120 | this.cpsr.setQ(false);
121 | assertFalse(this.simulator.getQ());
122 | this.cpsr.setQ(true);
123 | assertTrue(this.simulator.getQ());
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/core/syscalls/SVCHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.core.syscalls;
10 |
11 | import java.lang.reflect.InvocationTargetException;
12 | import java.util.HashMap;
13 | import java.util.Map;
14 | import java.util.Set;
15 |
16 | import org.reflections.Reflections;
17 |
18 | import projetarm_v2.simulator.core.Cpu;
19 | import projetarm_v2.simulator.core.syscalls.io.FileDescriptors;
20 | import projetarm_v2.simulator.core.syscalls.io.OpenedFile;
21 | import projetarm_v2.simulator.core.syscalls.io.SVCIOCall;
22 | import unicorn.InterruptHook;
23 | import unicorn.Unicorn;
24 |
25 | /* http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0040d/Bcedijji.html */
26 |
27 |
28 | public class SVCHandler {
29 | private Cpu cpu;
30 |
31 | private Map interruptVector;
32 |
33 | private FileDescriptors fileDescriptors;
34 |
35 |
36 | public SVCHandler(Cpu cpu) {
37 | this.cpu = cpu;
38 | this.interruptVector = new HashMap<>();
39 | this.fileDescriptors = new FileDescriptors();
40 |
41 | findSyscalls();
42 | findIOSyscalls();
43 | }
44 |
45 | public void findSyscalls() {
46 | Reflections reflections = new Reflections("projetarm_v2.simulator.core.syscalls");
47 |
48 | Set> calls = reflections.getSubTypesOf(SVCCall.class);
49 |
50 | for (Class extends SVCCall> classCall : calls) {
51 | try {
52 | SVCCall call = (SVCCall)(classCall.getDeclaredConstructor(Cpu.class).newInstance(this.cpu));
53 | this.interruptVector.put(call.getSvcNumber(),call);
54 | } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {}
55 | }
56 | }
57 |
58 | public void findIOSyscalls() {
59 | Reflections reflections = new Reflections("projetarm_v2.simulator.core.syscalls.io");
60 |
61 | Set> calls = reflections.getSubTypesOf(SVCIOCall.class);
62 |
63 | for (Class extends SVCIOCall> classCall : calls) {
64 | try {
65 | SVCCall call = (SVCIOCall)(classCall.getDeclaredConstructor(Cpu.class, FileDescriptors.class).newInstance(this.cpu, this.fileDescriptors));
66 | this.interruptVector.put(call.getSvcNumber(),call);
67 | } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {}
68 | }
69 | }
70 |
71 | public InterruptHook getSVCCallHandler() {
72 | return new SVCCallHook(this.cpu);
73 | }
74 |
75 | private class SVCCallHook implements InterruptHook {
76 | private Cpu cpu;
77 |
78 | private SVCCallHook(Cpu cpu) {
79 | this.cpu = cpu;
80 | }
81 |
82 | public void hook(Unicorn u, int intno, Object user) {
83 | if (intno == 2) {
84 | int instruction = this.cpu.getRam().getValue(this.cpu.getCurrentAddress());
85 | int svcCallNo = (instruction << 8) >> 8;
86 |
87 | SVCCall call = interruptVector.get(svcCallNo);
88 |
89 | if (call == null) {
90 | System.out.println("[WARNING] Unimplemented SVC call 0x" + Integer.toHexString(svcCallNo) + "... Ignoring");
91 | return;
92 | }
93 |
94 | call.run();
95 | } else {
96 | System.out.println("[ERROR] Unknown CPU exception no" + intno);
97 | System.out.println("[ERROR] EMULATION ABORTED!");
98 | this.cpu.interruptMe();
99 | }
100 | }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/src/projetarm_v2/simulator/ui/javafx/ArmToolBar.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package projetarm_v2.simulator.ui.javafx;
10 |
11 | import javafx.scene.Node;
12 | import javafx.scene.control.Button;
13 | import javafx.scene.control.Separator;
14 | import javafx.scene.control.ToolBar;
15 | import javafx.scene.control.Tooltip;
16 | import javafx.scene.image.Image;
17 | import javafx.scene.image.ImageView;
18 |
19 | import java.util.HashSet;
20 |
21 | public class ArmToolBar {
22 |
23 | private ToolBar toolBar;
24 |
25 | private Button switchButton;
26 | private Button runButton;
27 | private Button stepByStepButton;
28 | private Button reloadButton;
29 | private Button stopButton;
30 |
31 | private HashSet