Skip to content

Commit e95c360

Browse files
committed
assembly x86
1 parent e518b8d commit e95c360

5 files changed

Lines changed: 163 additions & 3 deletions

File tree

install_prerequisite.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,20 @@ else
137137
rm -rf evcxr-v0.17.0-x86_64-unknown-linux-gnu
138138
fi
139139

140-
140+
#install rappel, nasm and set all the required dependencies
141+
if [ -e "/usr/local/bin/rappel" ]; then
142+
echo "File /usr/local/bin/rappel exists."
143+
else
144+
echo "File /usr/local/bin/rappel does not exist. installing..."
145+
apt-get install -y --no-install-recommends libedit-dev
146+
apt-get install -y --no-install-recommends nasm
147+
git clone https://github.com/yrp604/rappel.git
148+
cd rappel
149+
make
150+
ln -s $GOTTY_DIR/rappel/bin/rappel /usr/local/bin/rappel
151+
chmod 755 /usr/local/bin/rappel
152+
cd ..
153+
fi
141154

142155
#install gointerpreter
143156
git clone https://github.com/vickeykumar/Go-interpreter.git
@@ -236,6 +249,7 @@ if [ $run_tests -eq 1 ]; then
236249
"sqlite3 --version"
237250
"tsc --version"
238251
"ts-node --version"
252+
"echo "nop" | rappel"
239253
)
240254

241255

src/containers/container.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var Commands2memLimitMap = map[string]int64{
3535
"evcxr": 50, // rust REPL
3636
"sqlite3": 10,
3737
"ts-node": 50,
38+
"rappel": 2,
3839
}
3940

4041
var memLimitMutex sync.Mutex

src/resources/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ <h1 class="hero__title" itemprop="name" ><span class="hero__title_pre">Open</spa
241241
<option value="tclsh" data-editor="tcl">Tcl</option>
242242
<option value="evcxr" data-editor="rust">Rust</option>
243243
<option value="sqlite3" data-editor="sql">SQLite</option>
244+
<option value="rappel" data-editor="assembly_x86">Assembly x86</option>
244245
</select>
245246

246247
<div class="widget" id="fork-widget" style="margin:7px;font-size:15px;height:25px;">
@@ -360,7 +361,7 @@ <h2>Welcome to <span class="go__color">Open</span>REPL</h2>
360361
<option value="ada" disabled>ADA</option>
361362
<option value="apache_conf" disabled>Apache Conf</option>
362363
<option value="asciidoc" disabled>AsciiDoc</option>
363-
<option value="assembly_x86" disabled>Assembly x86</option>
364+
<option value="assembly_x86">Assembly x86</option>
364365
<option value="autohotkey" disabled>AutoHotKey</option>
365366
<option value="batchfile">BatchFile</option>
366367
<option value="bro" disabled>Bro</option>

src/resources/js/scribbler.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,8 @@ $(function() {
14431443
'tcl': 'tcl',
14441444
'rs': 'rust',
14451445
'sql': 'sql',
1446-
'ts': 'typescript'
1446+
'ts': 'typescript',
1447+
'asm': 'assembly_x86'
14471448
};
14481449
const imageext = ['jpg', 'jpeg', 'gif', 'png', 'bmp', 'webp', 'svg', 'ico'];
14491450
const archiveext = ['zip', 'rar', '7z', 'tar', 'gz', 'bz2'];

src/resources/meta/demos.xml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2260,6 +2260,149 @@ if [ $? -eq 0 ] &amp;&amp; [ -f "$WORKDIR/$FILE" ]; then
22602260
fi
22612261
fi
22622262
printf "\n";
2263+
sleep 0.05
2264+
</Compiler>
2265+
</Demo>
2266+
2267+
<!-- Assembly demo -->
2268+
<Demo>
2269+
<Name>rappel</Name>
2270+
<Github>https://github.com/yrp604/rappel</Github>
2271+
<Doc>https://cs.lmu.edu/~ray/notes/nasmtutorial/</Doc>
2272+
<Codes>
2273+
<Code>
2274+
<Prompt>&gt;</Prompt>
2275+
<Statement>.help</Statement>
2276+
<Result>Commands:
2277+
.quit - quit
2278+
.help - display this help
2279+
.info - display registers
2280+
.begin - start a block, input will not be assembled/run until '.end'
2281+
.end - assemble and run the prior block
2282+
.showmap - shortcut for cat /proc/&lt;pid&gt;/maps
2283+
.allregs &lt;on|off&gt; - toggle all register display
2284+
.read &lt;address&gt; [amount] - read &lt;amount&gt; bytes of data from address using ptrace [16]
2285+
.write &lt;address&gt; &lt;data&gt; - write data starting at address using ptrace
2286+
</Result>
2287+
</Code>
2288+
</Codes>
2289+
<Codes>
2290+
<Code>
2291+
<Prompt>&gt;</Prompt>
2292+
<Statement>inc rax</Statement>
2293+
<Result>rax=0000000000000001 rbx=0000000000000000 rcx=0000000000000000
2294+
rdx=0000000000000000 rsi=0000000000000000 rdi=0000000000000000
2295+
rip=0000000000400004 rsp=00007ffdedb264a0 rbp=0000000000000000
2296+
r8=0000000000000000 r9=0000000000000000 r10=0000000000000000
2297+
r11=0000000000000000 r12=0000000000000000 r13=0000000000000000
2298+
r14=0000000000000000 r15=0000000000000000
2299+
[cf:0, zf:0, of:0, sf:0, pf:0, af:0, df:0]
2300+
cs=0033 ss=002b ds=0000 es=0000 fs=0000 gs=0000 efl=00000202</Result>
2301+
</Code>
2302+
<Code>
2303+
<Prompt>&gt;</Prompt>
2304+
<Statement>push rax</Statement>
2305+
<Result>rax=0000000000000001 rbx=0000000000000000 rcx=0000000000000000
2306+
rdx=0000000000000000 rsi=0000000000000000 rdi=0000000000000000
2307+
rip=0000000000400002 rsp=00007ffdedb26498 rbp=0000000000000000
2308+
r8=0000000000000000 r9=0000000000000000 r10=0000000000000000
2309+
r11=0000000000000000 r12=0000000000000000 r13=0000000000000000
2310+
r14=0000000000000000 r15=0000000000000000
2311+
[cf:0, zf:0, of:0, sf:0, pf:0, af:0, df:0]
2312+
cs=0033 ss=002b ds=0000 es=0000 fs=0000 gs=0000 efl=00000202</Result>
2313+
</Code>
2314+
</Codes>
2315+
<Codes>
2316+
<Code>
2317+
<Prompt>&gt;</Prompt>
2318+
<Statement>pop rbx</Statement>
2319+
<Result>rax=0000000000000001 rbx=0000000000000001 rcx=0000000000000000
2320+
rdx=0000000000000000 rsi=0000000000000000 rdi=0000000000000000
2321+
rip=0000000000400002 rsp=00007ffdedb264a0 rbp=0000000000000000
2322+
r8=0000000000000000 r9=0000000000000000 r10=0000000000000000
2323+
r11=0000000000000000 r12=0000000000000000 r13=0000000000000000
2324+
r14=0000000000000000 r15=0000000000000000
2325+
[cf:0, zf:0, of:0, sf:0, pf:0, af:0, df:0]
2326+
cs=0033 ss=002b ds=0000 es=0000 fs=0000 gs=0000 efl=00000202</Result>
2327+
</Code>
2328+
<Code>
2329+
<Prompt>&gt;</Prompt>
2330+
<Statement>cmp rax, rbx</Statement>
2331+
<Result>rax=0000000000000001 rbx=0000000000000001 rcx=0000000000000000
2332+
rdx=0000000000000000 rsi=0000000000000000 rdi=0000000000000000
2333+
rip=0000000000400004 rsp=00007ffdedb264a0 rbp=0000000000000000
2334+
r8=0000000000000000 r9=0000000000000000 r10=0000000000000000
2335+
r11=0000000000000000 r12=0000000000000000 r13=0000000000000000
2336+
r14=0000000000000000 r15=0000000000000000
2337+
[cf:0, zf:1, of:0, sf:0, pf:1, af:0, df:0]
2338+
cs=0033 ss=002b ds=0000 es=0000 fs=0000 gs=0000 efl=00000246</Result>
2339+
</Code>
2340+
<Code>
2341+
<Prompt>&gt;</Prompt>
2342+
<Statement>.quit</Statement>
2343+
<Result>$</Result>
2344+
</Code>
2345+
</Codes>
2346+
<Usage>
2347+
<Command>.help</Command>
2348+
<Description>Print command help</Description>
2349+
</Usage>
2350+
<Usage>
2351+
<Command>.quit</Command>
2352+
<Description>Quit evaluation and exit</Description>
2353+
</Usage>
2354+
<Content>;-------- Welcome to OpenREPL! ---------
2355+
2356+
section .data
2357+
hello db 'Hello, World!', 0
2358+
2359+
section .text
2360+
global _start
2361+
2362+
_start:
2363+
; write Hello, World! to stdout
2364+
mov eax, 4 ; sys_write
2365+
mov ebx, 1 ; file descriptor 1 (stdout)
2366+
mov ecx, hello ; message to write
2367+
mov edx, 13 ; message length
2368+
int 0x80 ; call kernel
2369+
2370+
; exit the program
2371+
mov eax, 1 ; sys_exit
2372+
xor ebx, ebx ; exit code 0
2373+
int 0x80 ; call kernel
2374+
</Content>
2375+
<Compiler>
2376+
COMPILER=nasm
2377+
FILE=test.asm
2378+
debug=false
2379+
WORKDIR=$HOME
2380+
if [ "$CompilerOption" = "debug" ]; then
2381+
debug=true;
2382+
fi
2383+
2384+
if [ "$IdeFileName" != "" ]; then
2385+
WORKDIR=$(dirname "$IdeFileName");
2386+
FILE=$(basename "$IdeFileName");
2387+
else
2388+
echo $0|base64 --decode > "$WORKDIR/$FILE";
2389+
fi
2390+
2391+
cd $WORKDIR;
2392+
if [ $? -eq 0 ] &amp;&amp; [ -f "$WORKDIR/$FILE" ]; then
2393+
$COMPILER -felf64 "$WORKDIR/$FILE" $@;
2394+
fi
2395+
2396+
if [ $? -eq 0 ] &amp;&amp; [ -f "$WORKDIR/$FILE.o" ]; then
2397+
ld -o "$WORKDIR/$FILE".out "$WORKDIR/$FILE".o
2398+
if $debug; then
2399+
gdb "$WORKDIR/$FILE".out $@;
2400+
else
2401+
#second quoate with escape, as -c option takes a string argument.
2402+
$SHELL -c "\"$WORKDIR/$FILE\".out $@";
2403+
fi
2404+
fi
2405+
printf "\n";
22632406
sleep 0.05
22642407
</Compiler>
22652408
</Demo>

0 commit comments

Comments
 (0)