-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added nasm #75
base: master
Are you sure you want to change the base?
added nasm #75
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Netwide Assembler | ||
|
||
This is the (Nasm) Netwide assembler and it is meant to be used in the binary compatibility mode of Unikraft. | ||
|
||
## Content | ||
sinamhdv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- `sample_code.s`: a sample assembly code file that can be assembled using Nasm | ||
- `usr/bin/nasm`: the Nasm binary | ||
- `lib/` & `lib64/`: the required libraries for Nasm | ||
|
||
## Extract Dynamic Libraries | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add wording. Say: "Use the |
||
```console | ||
../extract.sh usr/bin/nasm | ||
``` | ||
|
||
output: | ||
sinamhdv marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add wording. |
||
|
||
``` | ||
Copying /lib/x86_64-linux-gnu/libc.so.6 ... | ||
Copying /lib64/ld-linux-x86-64.so.2 ... | ||
``` | ||
|
||
## Run on Linux | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add wording. |
||
```console | ||
nasm sample_code.s | ||
``` | ||
|
||
## Run on Unikraft | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add wording. |
||
```console | ||
./run.sh -r ../dynamic-apps/nasm/ usr/bin/nasm sample_code.s | ||
``` | ||
|
||
This should generate the output file `sample_code` which is the assembled machine code generated by Nasm. | ||
|
||
We can use this command to check that everything worked properly: | ||
|
||
```console | ||
objdump -D -b binary -m i386 -M intel,x86-64 sample_code | ||
``` | ||
|
||
sinamhdv marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove extra white line at the end. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
BITS 64 | ||
|
||
xor rax, rax | ||
test rdi, rdi | ||
jz end | ||
|
||
loop: | ||
cmp byte [rdi], 0 | ||
jz end | ||
|
||
xor rbx, rbx | ||
mov bl, byte [rdi] | ||
cmp bl, 0x5a | ||
ja loop_end | ||
|
||
push rax | ||
push rdi | ||
mov rdi, rbx | ||
mov rax, 0x403000 | ||
call rax | ||
pop rdi | ||
mov byte [rdi], al | ||
pop rax | ||
inc rax | ||
|
||
loop_end: | ||
inc rdi | ||
jmp loop | ||
|
||
end: | ||
ret |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.