Addres BAG

This commit is contained in:
german 2026-03-08 18:38:59 +04:00
parent e7eb74e587
commit 543766bad1
8 changed files with 50 additions and 3 deletions

22
EXAMPLES.md Normal file
View File

@ -0,0 +1,22 @@
# Примеры на ассемблере NTSYS
Это небольшой набор примеров для ассемблера NTSYS.
## Hello, world!
```asm
main: ; Метка main
push.string "Hello, world!\n" ; Записываем строку
push byte, 0x00 ; Запись номера SYSCALL
syscall ; Системный вызов
```
## Читаем имя пользователя
```asm
main:
push.string "Введите ваше имя: " ; Строка
push byte, 0x00
syscall
getch:
push db getch
push byte, 0x01
syscall
push byte, 0x0A
neq byte
```

View File

@ -74,8 +74,9 @@ static void __str_slice(char* str) {
char* ntsys_get_arg(ntsys_asm_cache_t save) {
char* str = save->cache;
printf("Cache : %s\n", save->cache);
while (1) {
if (!is_space(str[0]) || str[0] == '\0') {
if ((!is_space(str[0])) || str[0] == '\0') {
break;
}
str ++;
@ -90,9 +91,12 @@ char* ntsys_get_arg(ntsys_asm_cache_t save) {
}
n_p ++;
}
save->cache = &str[n_p + 1];
byte_t t = 1;
if (n_p + t > strlen(str)) t = 0;
save->cache = &str[n_p + t];
str[n_p] = '\0';
}
printf("Switch : %s\n", save->cache);
if (str[strlen(str) - 1] == '\n' || str[strlen(str) - 1] == '\r') str[strlen(str) - 1] = '\0';
if (strlen(str) == 0) {
str = NULL;
@ -134,6 +138,7 @@ char* ntsys_get_arg(ntsys_asm_cache_t save) {
}
}
save->string = str;
printf("Loading : %s\n", str);
return str;
}

BIN
dump.bin

Binary file not shown.

View File

@ -1,4 +1,4 @@
main: ; Метка main
push.string "Hello, world!\n" ; Записываем строку
push byte, 0x00 ; Запись номера SYSCALL
push byte 0x00 ; Запись номера SYSCALL
syscall ; Системный вызов

10
input.asm Normal file
View File

@ -0,0 +1,10 @@
main:
push.string "Введите ваше имя: " ; Строка
push byte 0x00
syscall
getch:
push db getch
push byte 0x01
syscall
push byte 0x0A
neq byte

BIN
input.exe Normal file

Binary file not shown.

View File

@ -587,6 +587,8 @@ static void nt_fs_syscall(void) {
case 0x00:
{
fputs((char*)stack + sp, stdout);
size_t len = strlen((char*)stack + sp);
sp += len;
}
break;
case 0x01:
@ -601,6 +603,14 @@ static void nt_fs_syscall(void) {
cnt = __ntsys_buffer_size - 1;
}
break;
case 0x03:
{
if ((fGH6VSEzu7qNiGVE_stat = system((char*)stack + sp)) != EXIT_SUCCESS)
cnt = __ntsys_buffer_size - 1;
size_t len = strlen((char*)stack + sp);
sp += len;
}
break;
}
}

BIN
ntsys

Binary file not shown.