-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e778cc1
commit 112beed
Showing
7 changed files
with
235 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
SYS_READ equ 0 | ||
SYS_WRITE equ 1 | ||
SYS_OPEN equ 2 | ||
SYS_CLOSE equ 3 | ||
SYS_SOCKET equ 41 | ||
SYS_SENDTO equ 44 | ||
SYS_RECVFROM equ 45 | ||
SYS_EXIT equ 60 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
; tw protocol | ||
MSG_CTRL_TOKEN db 0x04, 0x00, 0x00, 0x0FF, 0xFF, 0xFF, 0xFF, 0x05, 0x51, 0x3B, 0x59, 0x46, 512 dup (0x00) | ||
MSG_CTRL_TOKEN_LEN equ $ - MSG_CTRL_TOKEN | ||
NET_MAX_PACKETSIZE equ 1400 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
hex_to_char: | ||
; hex_to_char [rax] | ||
; | ||
; moves byte in `rax` as hex string into | ||
; the `hex_str` variable | ||
; https://stackoverflow.com/a/18879886/6287070 | ||
push rbx | ||
push rax | ||
mov rbx, HEX_TABLE | ||
|
||
mov ah, al | ||
shr al, 4 | ||
and ah, 0x0f | ||
xlat | ||
xchg ah, al | ||
xlat | ||
|
||
mov rbx, hex_str | ||
xchg ah, al | ||
mov [rbx], rax | ||
|
||
pop rax | ||
pop rbx | ||
ret | ||
|
||
print_hex_byte: | ||
; print_hex [rax] | ||
; | ||
; prints given arg as hex string | ||
; to stdout | ||
push rax | ||
push rdi | ||
push rsi | ||
push rdx | ||
push rcx | ||
|
||
call hex_to_char | ||
|
||
mov eax, SYS_WRITE | ||
mov edi, STDOUT | ||
mov rsi, hex_str ; movabs | ||
mov edx, 0x2 | ||
syscall | ||
|
||
pop rcx | ||
pop rdx | ||
pop rsi | ||
pop rdi | ||
pop rax | ||
ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.