Spaces to tabs
This commit is contained in:
parent
c163efd83d
commit
20a9a96dc7
52
README.md
52
README.md
@ -2,43 +2,43 @@ This project for me just for fun to not spending time for routine operations
|
|||||||
|
|
||||||
1. std
|
1. std
|
||||||
- print
|
- print
|
||||||
- str
|
- str
|
||||||
- int
|
- int
|
||||||
- [ ] float
|
- ~~float~~
|
||||||
- [ ] hex
|
- ~~hex~~
|
||||||
- char
|
- char
|
||||||
- bin
|
- bin
|
||||||
- nl
|
- nl
|
||||||
- exit
|
- exit
|
||||||
2. file
|
2. file
|
||||||
- open
|
- open
|
||||||
- close
|
- close
|
||||||
- content
|
- content
|
||||||
- [ ] size
|
- ~~size~~
|
||||||
- [ ] next_line
|
- ~~next_line~~
|
||||||
3. path
|
3. path
|
||||||
- filename
|
- filename
|
||||||
- [ ] join
|
- ~~join~~
|
||||||
- [ ] is_dir
|
- ~~is_dir~~
|
||||||
- [ ] is_file
|
- ~~is_file~~
|
||||||
4. string
|
4. string
|
||||||
- copy
|
- copy
|
||||||
- len
|
- len
|
||||||
- [ ] split
|
- ~~split~~
|
||||||
- [ ] replace
|
- ~~replace~~
|
||||||
- [ ] find
|
- ~~find~~
|
||||||
- [ ] parse_int
|
- ~~parse_int~~
|
||||||
- [ ] parse_float
|
- ~~parse_float~~
|
||||||
5. network
|
5. network
|
||||||
- get_ip
|
- get_ip
|
||||||
- IP_to_str
|
- IP_to_str
|
||||||
6. dns
|
6. dns
|
||||||
- send
|
- send
|
||||||
- get_field
|
- get_field
|
||||||
7. [dnstoys](https://www.dns.toys/)
|
7. [dnstoys](https://www.dns.toys/)
|
||||||
- myip
|
- myip
|
||||||
- [ ] weather and other
|
- ~~weather and other~~
|
||||||
8. [ ] http
|
8. ~~http~~
|
||||||
9. [ ] json
|
9. ~~json~~
|
||||||
|
|
||||||
<sup>A lot of shit code included</sup>
|
<sup>A lot of shit code included</sup>
|
||||||
|
Binary file not shown.
@ -8,7 +8,7 @@ extrn print.nl
|
|||||||
extrn exit
|
extrn exit
|
||||||
|
|
||||||
macro nl {
|
macro nl {
|
||||||
call print.nl
|
call print.nl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -18,16 +18,16 @@ str1 db "Hello world!", 0
|
|||||||
|
|
||||||
section '.text' executable
|
section '.text' executable
|
||||||
_start:
|
_start:
|
||||||
push dword 123
|
push dword 123
|
||||||
call print.int
|
call print.int
|
||||||
nl
|
nl
|
||||||
|
|
||||||
push dword 123
|
push dword 123
|
||||||
call print.bin
|
call print.bin
|
||||||
nl
|
nl
|
||||||
|
|
||||||
push str1
|
push str1
|
||||||
call print.str
|
call print.str
|
||||||
nl
|
nl
|
||||||
|
|
||||||
call exit
|
call exit
|
||||||
|
Binary file not shown.
@ -10,7 +10,7 @@ extrn exit
|
|||||||
|
|
||||||
|
|
||||||
section '.strtab'
|
section '.strtab'
|
||||||
filename db "/home/sweetbread/headers", 0
|
filename db "makefile", 0
|
||||||
|
|
||||||
|
|
||||||
section '.bss' writeable
|
section '.bss' writeable
|
||||||
@ -19,21 +19,22 @@ file_ rd 1
|
|||||||
|
|
||||||
section '.text' executable
|
section '.text' executable
|
||||||
_start:
|
_start:
|
||||||
push filename
|
push filename
|
||||||
call file.open
|
call file.open
|
||||||
pop eax
|
pop eax
|
||||||
mov [file_], eax
|
mov [file_], eax
|
||||||
|
|
||||||
push dword [file_]
|
push dword [file_]
|
||||||
call print.str
|
call print.str
|
||||||
call print.nl
|
call print.nl
|
||||||
call print.nl
|
call print.nl
|
||||||
|
|
||||||
push dword [file_]
|
push dword [file_]
|
||||||
call file.content
|
call file.content
|
||||||
call print.str
|
call print.str
|
||||||
|
call print.nl
|
||||||
|
|
||||||
push dword [file_]
|
push dword [file_]
|
||||||
call file.close
|
call file.close
|
||||||
|
|
||||||
call exit
|
call exit
|
||||||
|
Binary file not shown.
@ -21,4 +21,3 @@ main: ../../file.o ../../std.o ../../path.o ../../string.o
|
|||||||
|
|
||||||
clear:
|
clear:
|
||||||
rm main.o main
|
rm main.o main
|
||||||
|
|
||||||
|
@ -15,14 +15,14 @@ hostname db "google.com", 0
|
|||||||
|
|
||||||
section '.text' executable
|
section '.text' executable
|
||||||
_start:
|
_start:
|
||||||
call dnstoys.myip
|
call dnstoys.myip
|
||||||
call print.str
|
call print.str
|
||||||
call print.nl
|
call print.nl
|
||||||
|
|
||||||
push hostname
|
push hostname
|
||||||
call network.get_ip
|
call network.get_ip
|
||||||
call network.IP_to_str
|
call network.IP_to_str
|
||||||
call print.str
|
call print.str
|
||||||
call print.nl
|
call print.nl
|
||||||
|
|
||||||
call exit
|
call exit
|
||||||
|
@ -12,32 +12,32 @@ section '.strtab'
|
|||||||
dnstoys db "dns.toys", 0
|
dnstoys db "dns.toys", 0
|
||||||
|
|
||||||
endpoints:
|
endpoints:
|
||||||
.ip db "ip", 0
|
.ip db "ip", 0
|
||||||
|
|
||||||
section '.bss' writeable
|
section '.bss' writeable
|
||||||
response rb 200
|
response rb 200
|
||||||
DNS_server sockaddr 00,53, ?,?,?,?
|
DNS_server sockaddr 00,53, ?,?,?,?
|
||||||
DNS_request dnsreq
|
DNS_request dnsreq
|
||||||
|
|
||||||
section '.dnstoys.text'
|
section '.dnstoys.text'
|
||||||
myip:
|
myip:
|
||||||
push 0
|
push 0
|
||||||
prelude
|
prelude
|
||||||
|
|
||||||
push dnstoys
|
push dnstoys
|
||||||
call network.get_ip
|
call network.get_ip
|
||||||
pop eax
|
pop eax
|
||||||
mov eax, [eax]
|
mov eax, [eax]
|
||||||
mov [DNS_server+4], eax
|
mov [DNS_server+4], eax
|
||||||
|
|
||||||
push dword 200
|
push dword 200
|
||||||
push response
|
push response
|
||||||
push DNS_server
|
push DNS_server
|
||||||
push endpoints.ip
|
push endpoints.ip
|
||||||
call dns.send
|
call dns.send
|
||||||
|
|
||||||
push response
|
push response
|
||||||
push dword 0
|
push dword 0
|
||||||
call dns.get_field
|
call dns.get_field
|
||||||
pop eax
|
pop eax
|
||||||
push eax
|
push eax
|
||||||
@ -50,8 +50,8 @@ myip:
|
|||||||
@@:
|
@@:
|
||||||
add eax, 2*3+4+1
|
add eax, 2*3+4+1
|
||||||
|
|
||||||
mov ebx, [ebp+2*4]
|
mov ebx, [ebp+2*4]
|
||||||
mov [ebp+4], ebx
|
mov [ebp+4], ebx
|
||||||
mov [ebp+2*4], eax
|
mov [ebp+2*4], eax
|
||||||
postlude
|
postlude
|
||||||
ret
|
ret
|
||||||
|
283
src/file.asm
283
src/file.asm
@ -1,6 +1,6 @@
|
|||||||
format ELF
|
format ELF
|
||||||
public open as 'file.open'
|
public open as 'file.open'
|
||||||
public close as 'file.close'
|
public close as 'file.close'
|
||||||
public content as 'file.content'
|
public content as 'file.content'
|
||||||
|
|
||||||
include '../include/_file.inc'
|
include '../include/_file.inc'
|
||||||
@ -11,13 +11,13 @@ extrn path.filename
|
|||||||
|
|
||||||
|
|
||||||
section '.strtab'
|
section '.strtab'
|
||||||
str1 db "File object ", 0
|
str1 db "File object ", 0
|
||||||
; str2 db " at "
|
; str2 db " at "
|
||||||
|
|
||||||
|
|
||||||
section '.bss' writeable
|
section '.bss' writeable
|
||||||
pointer rd 1
|
pointer rd 1
|
||||||
fd rd 1
|
fd rd 1
|
||||||
memory rd 1
|
memory rd 1
|
||||||
sizes_ sizes
|
sizes_ sizes
|
||||||
file_stat stat
|
file_stat stat
|
||||||
@ -25,170 +25,169 @@ file_stat stat
|
|||||||
|
|
||||||
section '.file.text' executable
|
section '.file.text' executable
|
||||||
open:
|
open:
|
||||||
prelude
|
prelude
|
||||||
|
|
||||||
; open
|
; open
|
||||||
mov eax, 5
|
mov eax, 5
|
||||||
mov ebx, [ebp+2*4]
|
mov ebx, [ebp+2*4]
|
||||||
mov ecx, O_RDONLY
|
mov ecx, O_RDONLY
|
||||||
mov edx, O_DIRECTORY
|
mov edx, O_DIRECTORY
|
||||||
int 80h
|
int 80h
|
||||||
|
|
||||||
mov [fd], eax
|
mov [fd], eax
|
||||||
|
|
||||||
; fstat
|
; fstat
|
||||||
mov eax, 108
|
mov eax, 108
|
||||||
mov ebx, [fd]
|
mov ebx, [fd]
|
||||||
mov ecx, file_stat
|
mov ecx, file_stat
|
||||||
int 80h
|
int 80h
|
||||||
|
|
||||||
push str1
|
push str1
|
||||||
call string.len
|
call string.len
|
||||||
pop eax
|
pop eax
|
||||||
mov [sizes_.str1], al
|
mov [sizes_.str1], al
|
||||||
|
|
||||||
push dword [ebp+2*4]
|
push dword [ebp+2*4]
|
||||||
call string.len
|
call string.len
|
||||||
pop eax
|
pop eax
|
||||||
mov [sizes_.full_filename], al
|
mov [sizes_.full_filename], al
|
||||||
|
|
||||||
push dword [ebp+2*4]
|
push dword [ebp+2*4]
|
||||||
call path.filename
|
call path.filename
|
||||||
call string.len
|
call string.len
|
||||||
pop ebx
|
pop ebx
|
||||||
mov [sizes_.filename], bl
|
mov [sizes_.filename], bl
|
||||||
|
|
||||||
mov eax, [file_stat.off_t]
|
mov eax, [file_stat.off_t]
|
||||||
add al , [sizes_.str1]
|
add al , [sizes_.str1]
|
||||||
add al , [sizes_.full_filename]
|
add al , [sizes_.full_filename]
|
||||||
add al , [sizes_.filename]
|
add al , [sizes_.filename]
|
||||||
add al , [sizes_.fd]
|
add al , [sizes_.fd]
|
||||||
add al , [sizes_.all_size]
|
add al , [sizes_.all_size]
|
||||||
mov [memory], eax
|
mov [memory], eax
|
||||||
push eax
|
push eax
|
||||||
|
|
||||||
; mmap2
|
; mmap2
|
||||||
mov eax, 192
|
mov eax, 192
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
pop ecx
|
pop ecx
|
||||||
mov edx, PROT_READ
|
mov edx, PROT_READ
|
||||||
or edx, PROT_WRITE
|
or edx, PROT_WRITE
|
||||||
mov esi, MAP_PRIVATE
|
mov esi, MAP_PRIVATE
|
||||||
or esi, MAP_ANONYMOUS
|
or esi, MAP_ANONYMOUS
|
||||||
mov edi, -1
|
mov edi, -1
|
||||||
push ebp
|
push ebp
|
||||||
xor ebp, ebp
|
xor ebp, ebp
|
||||||
int 80h
|
int 80h
|
||||||
pop ebp
|
pop ebp
|
||||||
|
|
||||||
mov [pointer], eax
|
mov [pointer], eax
|
||||||
|
|
||||||
push str1
|
push str1
|
||||||
push eax
|
push eax
|
||||||
call string.copy
|
call string.copy
|
||||||
|
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
mov bl , [sizes_.str1]
|
mov bl , [sizes_.str1]
|
||||||
add eax, ebx
|
add eax, ebx
|
||||||
mov ebx, [ebp+2*4]
|
mov ebx, [ebp+2*4]
|
||||||
push ebx
|
push ebx
|
||||||
call path.filename
|
call path.filename
|
||||||
push eax
|
push eax
|
||||||
call string.copy
|
call string.copy
|
||||||
|
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
mov bl , [sizes_.filename]
|
mov bl , [sizes_.filename]
|
||||||
add eax, ebx
|
add eax, ebx
|
||||||
inc eax
|
inc eax
|
||||||
push dword [ebp+2*4]
|
push dword [ebp+2*4]
|
||||||
push eax
|
push eax
|
||||||
call string.copy
|
call string.copy
|
||||||
|
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
mov bl , [sizes_.full_filename]
|
mov bl , [sizes_.full_filename]
|
||||||
add eax, ebx
|
add eax, ebx
|
||||||
inc eax
|
inc eax
|
||||||
mov ebx, [fd]
|
mov ebx, [fd]
|
||||||
mov [eax], ebx
|
mov [eax], ebx
|
||||||
|
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
mov bl , [sizes_.fd]
|
mov bl , [sizes_.fd]
|
||||||
add eax, ebx
|
add eax, ebx
|
||||||
mov ebx, [memory]
|
mov ebx, [memory]
|
||||||
mov [eax], ebx
|
mov [eax], ebx
|
||||||
|
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
mov bl , [sizes_.all_size]
|
mov bl , [sizes_.all_size]
|
||||||
add eax, ebx
|
add eax, ebx
|
||||||
inc eax
|
inc eax
|
||||||
push eax
|
push eax
|
||||||
|
|
||||||
; read
|
; read
|
||||||
mov eax, 3
|
mov eax, 3
|
||||||
mov ebx, [fd]
|
mov ebx, [fd]
|
||||||
pop ecx
|
pop ecx
|
||||||
mov edx, [file_stat.off_t]
|
mov edx, [file_stat.off_t]
|
||||||
int 80h
|
int 80h
|
||||||
|
|
||||||
mov eax, [pointer]
|
mov eax, [pointer]
|
||||||
mov [ebp+2*4], eax
|
mov [ebp+2*4], eax
|
||||||
|
|
||||||
postlude
|
postlude
|
||||||
ret
|
ret
|
||||||
|
|
||||||
close:
|
close:
|
||||||
prelude
|
prelude
|
||||||
|
|
||||||
mov eax, [ebp+2*4]
|
mov eax, [ebp+2*4]
|
||||||
push eax
|
push eax
|
||||||
call string.len
|
call string.len
|
||||||
pop ebx
|
pop ebx
|
||||||
add eax, ebx
|
add eax, ebx
|
||||||
inc eax
|
inc eax
|
||||||
push eax
|
push eax
|
||||||
call string.len
|
call string.len
|
||||||
pop ebx
|
pop ebx
|
||||||
add eax, ebx
|
add eax, ebx
|
||||||
inc eax
|
inc eax
|
||||||
|
|
||||||
push eax
|
push eax
|
||||||
|
|
||||||
; close
|
; close
|
||||||
mov ebx, [eax]
|
mov ebx, [eax]
|
||||||
mov eax, 6
|
mov eax, 6
|
||||||
int 80h
|
int 80h
|
||||||
|
|
||||||
; munmap
|
; munmap
|
||||||
mov eax, 91
|
mov eax, 91
|
||||||
mov ebx, [ebp+2*4]
|
mov ebx, [ebp+2*4]
|
||||||
pop ecx
|
pop ecx
|
||||||
add ecx, 4
|
add ecx, 4
|
||||||
mov ecx, [ecx]
|
mov ecx, [ecx]
|
||||||
int 80h
|
int 80h
|
||||||
|
|
||||||
mov eax, [ebp+4]
|
mov eax, [ebp+4]
|
||||||
mov [ebp+2*4], eax
|
mov [ebp+2*4], eax
|
||||||
|
|
||||||
postlude
|
postlude
|
||||||
add esp, 4
|
add esp, 4
|
||||||
ret
|
ret
|
||||||
|
|
||||||
content:
|
content:
|
||||||
prelude
|
prelude
|
||||||
|
|
||||||
mov eax, [ebp+2*4]
|
mov eax, [ebp+2*4]
|
||||||
push eax
|
push eax
|
||||||
call string.len
|
call string.len
|
||||||
pop ebx
|
pop ebx
|
||||||
add eax, ebx
|
add eax, ebx
|
||||||
inc eax
|
inc eax
|
||||||
push eax
|
push eax
|
||||||
call string.len
|
call string.len
|
||||||
pop ebx
|
pop ebx
|
||||||
add eax, ebx
|
add eax, ebx
|
||||||
add eax, 1+4+4+1
|
add eax, 1+4+4+1
|
||||||
|
|
||||||
mov [ebp+2*4], eax
|
|
||||||
postlude
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
mov [ebp+2*4], eax
|
||||||
|
postlude
|
||||||
|
ret
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
format ELF
|
format ELF
|
||||||
public get_ip as 'network.get_ip'
|
public get_ip as 'network.get_ip'
|
||||||
public IP_to_str as 'network.IP_to_str'
|
public IP_to_str as 'network.IP_to_str'
|
||||||
|
|
||||||
include '../include/_macros.inc'
|
include '../include/_macros.inc'
|
||||||
include '../include/_dns.inc'
|
include '../include/_dns.inc'
|
||||||
@ -15,11 +15,11 @@ response rb 200
|
|||||||
|
|
||||||
section '.network.text' executable
|
section '.network.text' executable
|
||||||
get_ip:
|
get_ip:
|
||||||
prelude
|
prelude
|
||||||
|
|
||||||
push dword 200
|
push dword 200
|
||||||
push response
|
push response
|
||||||
push DNS_server
|
push DNS_server
|
||||||
push dword [ebp+2*4]
|
push dword [ebp+2*4]
|
||||||
call dns.send
|
call dns.send
|
||||||
push response
|
push response
|
||||||
@ -36,14 +36,14 @@ get_ip:
|
|||||||
@@:
|
@@:
|
||||||
add eax, 2*3+4
|
add eax, 2*3+4
|
||||||
|
|
||||||
mov [ebp+2*4], eax
|
mov [ebp+2*4], eax
|
||||||
postlude
|
postlude
|
||||||
ret
|
ret
|
||||||
|
|
||||||
IP_to_str:
|
IP_to_str:
|
||||||
prelude
|
prelude
|
||||||
|
|
||||||
mov ecx, [ebp+2*4]
|
mov ecx, [ebp+2*4]
|
||||||
|
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
mov esi, IP_str
|
mov esi, IP_str
|
||||||
@ -85,6 +85,6 @@ IP_to_str:
|
|||||||
.break:
|
.break:
|
||||||
mov [esi], byte 0
|
mov [esi], byte 0
|
||||||
|
|
||||||
mov [ebp+2*4], dword IP_str
|
mov [ebp+2*4], dword IP_str
|
||||||
postlude
|
postlude
|
||||||
ret
|
ret
|
36
src/path.asm
36
src/path.asm
@ -6,24 +6,24 @@ extrn string.len
|
|||||||
|
|
||||||
section '.text' executable
|
section '.text' executable
|
||||||
filename:
|
filename:
|
||||||
prelude
|
prelude
|
||||||
|
|
||||||
mov eax, [ebp+2*4]
|
mov eax, [ebp+2*4]
|
||||||
push eax
|
push eax
|
||||||
call string.len
|
call string.len
|
||||||
pop ebx
|
pop ebx
|
||||||
|
|
||||||
.loop:
|
.loop:
|
||||||
cmp [ebx+eax], byte '/'
|
cmp [ebx+eax], byte '/'
|
||||||
je .break
|
je .break
|
||||||
cmp ebx, 0
|
cmp ebx, 0
|
||||||
je .break
|
je .break
|
||||||
|
|
||||||
dec ebx
|
dec ebx
|
||||||
jmp .loop
|
jmp .loop
|
||||||
.break:
|
.break:
|
||||||
add eax, ebx
|
add eax, ebx
|
||||||
inc eax
|
inc eax
|
||||||
mov [ebp+2*4], eax
|
mov [ebp+2*4], eax
|
||||||
postlude
|
postlude
|
||||||
ret
|
ret
|
||||||
|
228
src/std.asm
228
src/std.asm
@ -15,159 +15,159 @@ buffer rb 32
|
|||||||
|
|
||||||
section '.std.text' executable
|
section '.std.text' executable
|
||||||
char:
|
char:
|
||||||
prelude
|
prelude
|
||||||
|
|
||||||
mov cl, [ebp+2*4]
|
mov cl, [ebp+2*4]
|
||||||
mov [buffer], cl
|
mov [buffer], cl
|
||||||
|
|
||||||
mov eax, 4
|
mov eax, 4
|
||||||
mov ebx, 1
|
mov ebx, 1
|
||||||
mov ecx, buffer
|
mov ecx, buffer
|
||||||
mov edx, 1
|
mov edx, 1
|
||||||
int 80h
|
int 80h
|
||||||
|
|
||||||
mov [buffer], byte 0
|
mov [buffer], byte 0
|
||||||
|
|
||||||
mov eax, [ebp+4]
|
mov eax, [ebp+4]
|
||||||
mov [ebp+2*4], eax
|
mov [ebp+2*4], eax
|
||||||
|
|
||||||
postlude
|
postlude
|
||||||
add esp, 4
|
add esp, 4
|
||||||
ret
|
ret
|
||||||
|
|
||||||
_str:
|
_str:
|
||||||
prelude
|
prelude
|
||||||
|
|
||||||
mov ecx, [ebp+2*4]
|
mov ecx, [ebp+2*4]
|
||||||
|
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
|
|
||||||
@@:
|
@@:
|
||||||
cmp [ecx+edx], byte 0
|
cmp [ecx+edx], byte 0
|
||||||
je @f
|
je @f
|
||||||
inc edx
|
inc edx
|
||||||
jmp @b
|
jmp @b
|
||||||
@@:
|
@@:
|
||||||
mov eax, 4
|
mov eax, 4
|
||||||
mov ebx, 1
|
mov ebx, 1
|
||||||
int 80h
|
int 80h
|
||||||
|
|
||||||
mov eax, [ebp+4]
|
mov eax, [ebp+4]
|
||||||
mov [ebp+2*4], eax
|
mov [ebp+2*4], eax
|
||||||
|
|
||||||
postlude
|
postlude
|
||||||
add esp, 4
|
add esp, 4
|
||||||
ret
|
ret
|
||||||
|
|
||||||
nl:
|
nl:
|
||||||
push _new_line
|
push _new_line
|
||||||
call char
|
call char
|
||||||
ret
|
ret
|
||||||
|
|
||||||
_bin:
|
_bin:
|
||||||
prelude
|
prelude
|
||||||
|
|
||||||
mov eax, [ebp+2*4]
|
mov eax, [ebp+2*4]
|
||||||
|
|
||||||
push 2
|
push 2
|
||||||
mov ebx, 2
|
mov ebx, 2
|
||||||
|
|
||||||
@@:
|
@@:
|
||||||
cmp eax, 2
|
cmp eax, 2
|
||||||
jl @f
|
jl @f
|
||||||
|
|
||||||
div ebx
|
div ebx
|
||||||
push edx
|
push edx
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
jmp @b
|
jmp @b
|
||||||
@@:
|
@@:
|
||||||
push eax
|
push eax
|
||||||
mov ebx, buffer
|
mov ebx, buffer
|
||||||
@@:
|
@@:
|
||||||
pop eax
|
pop eax
|
||||||
cmp al, 2
|
cmp al, 2
|
||||||
je @f
|
je @f
|
||||||
|
|
||||||
add al, '0'
|
add al, '0'
|
||||||
mov [ebx], al
|
mov [ebx], al
|
||||||
inc ebx
|
inc ebx
|
||||||
|
|
||||||
jmp @b
|
jmp @b
|
||||||
@@:
|
@@:
|
||||||
push buffer
|
push buffer
|
||||||
call _str
|
call _str
|
||||||
|
|
||||||
mov eax, buffer
|
mov eax, buffer
|
||||||
|
|
||||||
@@:
|
@@:
|
||||||
cmp eax, ebx
|
cmp eax, ebx
|
||||||
je @f
|
je @f
|
||||||
|
|
||||||
mov [ebx-1], byte 0
|
mov [ebx-1], byte 0
|
||||||
dec ebx
|
dec ebx
|
||||||
|
|
||||||
jmp @b
|
jmp @b
|
||||||
@@:
|
@@:
|
||||||
mov eax, [ebp+4]
|
mov eax, [ebp+4]
|
||||||
mov [ebp+2*4], eax
|
mov [ebp+2*4], eax
|
||||||
|
|
||||||
postlude
|
postlude
|
||||||
add esp, 4
|
add esp, 4
|
||||||
ret
|
ret
|
||||||
|
|
||||||
_int:
|
_int:
|
||||||
prelude
|
prelude
|
||||||
mov eax, [ebp+2*4]
|
mov eax, [ebp+2*4]
|
||||||
|
|
||||||
push 10
|
push 10
|
||||||
mov ebx, 10
|
mov ebx, 10
|
||||||
|
|
||||||
@@:
|
@@:
|
||||||
cmp eax, 10
|
cmp eax, 10
|
||||||
jl @f
|
jl @f
|
||||||
|
|
||||||
div ebx
|
div ebx
|
||||||
push edx
|
push edx
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
jmp @b
|
jmp @b
|
||||||
@@:
|
@@:
|
||||||
push eax
|
push eax
|
||||||
mov ebx, buffer
|
mov ebx, buffer
|
||||||
@@:
|
@@:
|
||||||
pop eax
|
pop eax
|
||||||
cmp al, 10
|
cmp al, 10
|
||||||
je @f
|
je @f
|
||||||
|
|
||||||
add al, '0'
|
add al, '0'
|
||||||
mov [ebx], al
|
mov [ebx], al
|
||||||
inc ebx
|
inc ebx
|
||||||
|
|
||||||
jmp @b
|
jmp @b
|
||||||
@@:
|
@@:
|
||||||
mov [ebx], byte 0
|
mov [ebx], byte 0
|
||||||
push buffer
|
push buffer
|
||||||
call _str
|
call _str
|
||||||
|
|
||||||
mov eax, buffer
|
mov eax, buffer
|
||||||
|
|
||||||
@@:
|
@@:
|
||||||
cmp eax, ebx
|
cmp eax, ebx
|
||||||
je @f
|
je @f
|
||||||
|
|
||||||
mov [ebx-1], byte 0
|
mov [ebx-1], byte 0
|
||||||
dec ebx
|
dec ebx
|
||||||
|
|
||||||
jmp @b
|
jmp @b
|
||||||
@@:
|
@@:
|
||||||
mov eax, [ebp+4]
|
mov eax, [ebp+4]
|
||||||
mov [ebp+2*4], eax
|
mov [ebp+2*4], eax
|
||||||
|
|
||||||
postlude
|
postlude
|
||||||
add esp, 4
|
add esp, 4
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
mov eax, 1
|
mov eax, 1
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
int 80h
|
int 80h
|
||||||
|
@ -6,41 +6,41 @@ include "../include/_macros.inc"
|
|||||||
|
|
||||||
section '.string.text' executable
|
section '.string.text' executable
|
||||||
copy:
|
copy:
|
||||||
prelude
|
prelude
|
||||||
|
|
||||||
mov eax, [ebp+3*4]
|
mov eax, [ebp+3*4]
|
||||||
mov ebx, [ebp+2*4]
|
mov ebx, [ebp+2*4]
|
||||||
xor ecx, ecx
|
xor ecx, ecx
|
||||||
|
|
||||||
.loop:
|
.loop:
|
||||||
cmp [eax+ecx], byte 0
|
cmp [eax+ecx], byte 0
|
||||||
je .break
|
je .break
|
||||||
|
|
||||||
mov dl, [eax+ecx]
|
mov dl, [eax+ecx]
|
||||||
mov [ebx+ecx], dl
|
mov [ebx+ecx], dl
|
||||||
inc ecx
|
inc ecx
|
||||||
|
|
||||||
jmp .loop
|
jmp .loop
|
||||||
.break:
|
.break:
|
||||||
mov eax, [ebp+4]
|
mov eax, [ebp+4]
|
||||||
mov [ebp+3*4], eax
|
mov [ebp+3*4], eax
|
||||||
postlude
|
postlude
|
||||||
add esp, 4*2
|
add esp, 4*2
|
||||||
ret
|
ret
|
||||||
|
|
||||||
len:
|
len:
|
||||||
prelude
|
prelude
|
||||||
|
|
||||||
mov eax, [ebp+2*4]
|
mov eax, [ebp+2*4]
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
|
|
||||||
.loop:
|
.loop:
|
||||||
cmp [eax+ebx], byte 0
|
cmp [eax+ebx], byte 0
|
||||||
je .break
|
je .break
|
||||||
|
|
||||||
inc ebx
|
inc ebx
|
||||||
jmp .loop
|
jmp .loop
|
||||||
.break:
|
.break:
|
||||||
mov [ebp+2*4], ebx
|
mov [ebp+2*4], ebx
|
||||||
postlude
|
postlude
|
||||||
ret
|
ret
|
||||||
|
Reference in New Issue
Block a user