string.parse_int added, fixed print.int
This commit is contained in:
parent
dc6d943e5c
commit
96decefa64
42
README.md
42
README.md
@ -1,44 +1,6 @@
|
|||||||
This project for me just for fun to not spending time for routine operations
|
This project for me just for fun to not spending time for routine operations
|
||||||
|
|
||||||
1. std
|
[Wiki](https://github.com/VerySweetBread/asm_libs/wiki)
|
||||||
- print
|
[Examples](https://github.com/VerySweetBread/asm_libs/tree/main/examples)
|
||||||
- str
|
|
||||||
- int
|
|
||||||
- ~~float~~
|
|
||||||
- ~~hex~~
|
|
||||||
- char
|
|
||||||
- bin
|
|
||||||
- nl
|
|
||||||
- exit
|
|
||||||
2. file
|
|
||||||
- open
|
|
||||||
- close
|
|
||||||
- content
|
|
||||||
- ~~size~~
|
|
||||||
- ~~next_line~~
|
|
||||||
3. path
|
|
||||||
- filename
|
|
||||||
- ~~join~~
|
|
||||||
- ~~is_dir~~
|
|
||||||
- ~~is_file~~
|
|
||||||
4. string
|
|
||||||
- copy
|
|
||||||
- len
|
|
||||||
- ~~split~~
|
|
||||||
- ~~replace~~
|
|
||||||
- ~~find~~
|
|
||||||
- ~~parse_int~~
|
|
||||||
- ~~parse_float~~
|
|
||||||
5. network
|
|
||||||
- get_ip
|
|
||||||
- IP_to_str
|
|
||||||
6. dns
|
|
||||||
- send
|
|
||||||
- get_field
|
|
||||||
7. [dnstoys](https://www.dns.toys/)
|
|
||||||
- myip
|
|
||||||
- ~~weather and other~~
|
|
||||||
8. ~~http~~
|
|
||||||
9. ~~json~~
|
|
||||||
|
|
||||||
<sup>A lot of shit code included</sup>
|
<sup>A lot of shit code included</sup>
|
||||||
|
Binary file not shown.
@ -5,6 +5,7 @@ extrn print.int
|
|||||||
extrn print.bin
|
extrn print.bin
|
||||||
extrn print.str
|
extrn print.str
|
||||||
extrn print.nl
|
extrn print.nl
|
||||||
|
extrn string.parse_int
|
||||||
extrn exit
|
extrn exit
|
||||||
|
|
||||||
macro nl {
|
macro nl {
|
||||||
@ -13,7 +14,13 @@ macro nl {
|
|||||||
|
|
||||||
|
|
||||||
section '.strtab'
|
section '.strtab'
|
||||||
str1 db "Hello world!", 0
|
str1 db "Hello world!", 10, 0
|
||||||
|
str2 db "Enter the number: ", 0
|
||||||
|
str3 db " + 10 = ", 0
|
||||||
|
|
||||||
|
|
||||||
|
section '.bss' writeable
|
||||||
|
buffer rb 11
|
||||||
|
|
||||||
|
|
||||||
section '.text' executable
|
section '.text' executable
|
||||||
@ -28,6 +35,28 @@ _start:
|
|||||||
|
|
||||||
push str1
|
push str1
|
||||||
call print.str
|
call print.str
|
||||||
|
|
||||||
|
push str2
|
||||||
|
call print.str
|
||||||
|
mov eax, 3
|
||||||
|
mov ebx, 0
|
||||||
|
mov ecx, buffer
|
||||||
|
mov edx, 11
|
||||||
|
int 80h
|
||||||
|
|
||||||
|
mov [buffer+eax-1], 0
|
||||||
|
|
||||||
|
push buffer
|
||||||
|
call print.str
|
||||||
|
push str3
|
||||||
|
call print.str
|
||||||
|
|
||||||
|
push buffer
|
||||||
|
call string.parse_int
|
||||||
|
pop eax
|
||||||
|
add eax, 10
|
||||||
|
push eax
|
||||||
|
call print.int
|
||||||
nl
|
nl
|
||||||
|
|
||||||
call exit
|
call exit
|
||||||
|
Binary file not shown.
@ -1,7 +1,7 @@
|
|||||||
all: main
|
all: main
|
||||||
|
|
||||||
main: ../../std.o main.o
|
main: ../../std.o ../../string.o main.o
|
||||||
ld -m elf_i386 main.o ../../std.o --output main
|
ld -m elf_i386 main.o ../../std.o ../../string.o --output main
|
||||||
|
|
||||||
main.o:
|
main.o:
|
||||||
fasm main.asm
|
fasm main.asm
|
||||||
@ -9,5 +9,8 @@ main.o:
|
|||||||
../../std.o:
|
../../std.o:
|
||||||
make -C ../../ std.o
|
make -C ../../ std.o
|
||||||
|
|
||||||
|
../../string.o:
|
||||||
|
make -C ../../ string.o
|
||||||
|
|
||||||
clear:
|
clear:
|
||||||
rm main.o main
|
rm main.o main
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -19,7 +19,7 @@ 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' executable
|
||||||
myip:
|
myip:
|
||||||
push 0
|
push 0
|
||||||
prelude
|
prelude
|
||||||
|
@ -121,6 +121,7 @@ _int:
|
|||||||
|
|
||||||
push 10
|
push 10
|
||||||
mov ebx, 10
|
mov ebx, 10
|
||||||
|
xor edx, edx
|
||||||
|
|
||||||
@@:
|
@@:
|
||||||
cmp eax, 10
|
cmp eax, 10
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
format ELF
|
format ELF
|
||||||
public copy as 'string.copy'
|
public copy as 'string.copy'
|
||||||
public len as 'string.len'
|
public len as 'string.len'
|
||||||
|
public parse_int as 'string.parse_int'
|
||||||
|
|
||||||
include "../include/_macros.inc"
|
include "../include/_macros.inc"
|
||||||
|
|
||||||
@ -44,3 +45,40 @@ len:
|
|||||||
mov [ebp+2*4], ebx
|
mov [ebp+2*4], ebx
|
||||||
postlude
|
postlude
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
parse_int:
|
||||||
|
prelude
|
||||||
|
|
||||||
|
mov eax, [ebp+4*2]
|
||||||
|
xor ebx, ebx
|
||||||
|
mov ecx, 1
|
||||||
|
push word 10
|
||||||
|
|
||||||
|
@@:
|
||||||
|
cmp [eax], byte '0'
|
||||||
|
jl @f
|
||||||
|
cmp [eax], byte '9'
|
||||||
|
ja @f
|
||||||
|
|
||||||
|
mov bl, [eax]
|
||||||
|
sub bl, '0'
|
||||||
|
push bx
|
||||||
|
inc eax
|
||||||
|
jmp @b
|
||||||
|
@@:
|
||||||
|
xor eax, eax
|
||||||
|
mov ecx, 1
|
||||||
|
@@:
|
||||||
|
pop bx
|
||||||
|
|
||||||
|
cmp bx, 10
|
||||||
|
je @f
|
||||||
|
|
||||||
|
imul ebx, ecx
|
||||||
|
imul ecx, 10
|
||||||
|
add eax, ebx
|
||||||
|
jmp @b
|
||||||
|
@@:
|
||||||
|
mov [ebp+4*2], eax
|
||||||
|
postlude
|
||||||
|
ret
|
||||||
|
Reference in New Issue
Block a user