Skip to content

Commit

Permalink
Merge pull request #9 from Lord-Turmoil/feat--support-assembly
Browse files Browse the repository at this point in the history
Add support for more languages
  • Loading branch information
Lord-Turmoil authored Oct 19, 2024
2 parents 1c9ba98 + 24f0069 commit 96f0272
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 14 deletions.
5 changes: 4 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
"makefile",
"cmake",
"sql",
"verilog"
"verilog",
"nasm",
"llvm",
"diff"
],
"plugins": [
"line-numbers",
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
"build:res": "shx cp -r src/res src/favicon.png dist",
"build:version": "python minify_json.py src/version.json dist/version.json",
"build": "rimraf dist && npm-run-all build:*",
"dev:html": "posthtml -c posthtml.json",
"dev:js": "webpack --mode=development",
"dev:css": "postcss src/css -d dist/css",
"dev:res": "shx cp -r src/res src/favicon.png dist",
"dev:version": "shx cp src/version.json dist/version.json",
"dev": "npm-run-all dev:*",
"watch:html": "onchange \"src/views\" -- npm run dev:html",
"watch:js": "onchange \"src/js\" -- webpack --mode=development",
"watch:css": "onchange \"src/css\" -- npm run dev:css",
"watch:res": "onchange \"src/res\" -- npm run dev:res",
"watch:version": "onchange \"src/version.json\" -- npm run dev:version",
"watch": "npm-run-all dev && run-p watch:*",
"build-dev:html": "posthtml -c posthtml.json",
"build-dev:js": "webpack --mode=development",
"build-dev:css": "postcss src/css -d dist/css",
"build-dev:res": "shx cp -r src/res src/favicon.png dist",
"build-dev:version": "shx cp src/version.json dist/version.json",
"build-dev": "npm-run-all build-dev:*",
"watch:html": "onchange \"src/views\" -- npm run build-dev:html",
"watch:js": "onchange \"src/js\" -- npm run build-dev:js",
"watch:css": "onchange \"src/css\" -- npm run build-dev:css",
"watch:res": "onchange \"src/res\" -- npm run build-dev:res",
"watch:version": "onchange \"src/version.json\" -- npm run build-dev:version",
"dev": "npm-run-all build-dev && run-p watch:*",
"init": "shx touch src/views/components/notification.html src/views/components/support.html src/views/components/statistics.html",
"eslint-init": ".\\node_modules\\.bin\\eslint --init",
"eslint-fix": ".\\node_modules\\.bin\\eslint src\\** --fix"
Expand Down
45 changes: 44 additions & 1 deletion src/js/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,46 @@ end
endmodule`;

const CODE_NASM = `section .data
msg db 'Ready, assemble!', 0xA
len equ $ - msg
section .text
global _start
_start:
mov eax, 4 ; syscall number for sys_write
mov ebx, 1 ; file descriptor 1 (stdout)
mov ecx, msg ; pointer to the message
mov edx, len ; length of the message
int 0x80 ; make the syscall
mov eax, 1 ; syscall number for sys_exit
xor ebx, ebx ; exit status 0
int 0x80 ; make the syscall
`;

const CODE_LLVM = `; Function Attrs: noinline nounwind optnone uwtable
define dso_local i32 @add(i32 %0, i32 %1) #0 {
%3 = alloca i32, align 4
%4 = alloca i32, align 4
store i32 %0, i32* %3, align 4
store i32 %1, i32* %4, align 4
%5 = load i32, i32* %3, align 4
%6 = load i32, i32* %4, align 4
%7 = add i32 %5, %6
ret i32 %7
}
`;

const CODE_GIT_DIFF = `
- Jedi Order
+ Sith Empire
- Kamino
- Alderaan
+ Mandalore
`;

const CODE_SET = {
c: CODE_C,
cpp: CODE_CPP,
Expand Down Expand Up @@ -307,7 +347,10 @@ const CODE_SET = {
makefile: CODE_MAKEFILE,
cmake: CODE_CMAKE,
sql: CODE_SQL,
verilog: CODE_VERILOG
verilog: CODE_VERILOG,
nasm: CODE_NASM,
llvm: CODE_LLVM,
diff: CODE_GIT_DIFF,
};

class CodeSet {
Expand Down
3 changes: 3 additions & 0 deletions src/views/parts/toolbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
<optgroup label="Others">
<option value="sql">SQL</option>
<option value="verilog">Verilog</option>
<option value="nasm">Assembly</option>
<option value="llvm">LLVM IR</option>
<option value="diff">Git Diff</option>
</optgroup>
</select>
</div>
Expand Down

0 comments on commit 96f0272

Please sign in to comment.