From 46e6ac72c3d2ae1357a932a14bc04a68acf0fae8 Mon Sep 17 00:00:00 2001 From: german Date: Fri, 20 Mar 2026 15:01:44 +0400 Subject: [PATCH] Project structure --- EXAMPLES.md | 101 ++++++++++++++++++++ example.asm => examples/example.asm | 0 hello.asm => examples/hello.asm | 0 hello_user.asm => examples/hello_user.asm | 0 hello_world.hex => examples/hello_world.hex | 0 input.asm => examples/input.asm | 0 loop.asm => examples/loop.asm | 0 set_mov.asm => examples/set_mov.asm | 0 swap.asm => examples/swap.asm | 0 wait.asm => examples/wait.asm | 0 hello.exe | Bin 28 -> 0 bytes hello_user.exe | Bin 240 -> 0 bytes hello_world.exe | Bin 28 -> 0 bytes input.exe | Bin 42 -> 0 bytes project_files/.view.ini | 4 + project_files/example.txt | 8 -- set_mov.exe | Bin 44 -> 0 bytes swap.exe | Bin 53 -> 0 bytes wait.exe | Bin 88 -> 0 bytes 19 files changed, 105 insertions(+), 8 deletions(-) rename example.asm => examples/example.asm (100%) rename hello.asm => examples/hello.asm (100%) rename hello_user.asm => examples/hello_user.asm (100%) rename hello_world.hex => examples/hello_world.hex (100%) rename input.asm => examples/input.asm (100%) rename loop.asm => examples/loop.asm (100%) rename set_mov.asm => examples/set_mov.asm (100%) rename swap.asm => examples/swap.asm (100%) rename wait.asm => examples/wait.asm (100%) delete mode 100644 hello.exe delete mode 100644 hello_user.exe delete mode 100644 hello_world.exe delete mode 100644 input.exe create mode 100644 project_files/.view.ini delete mode 100644 project_files/example.txt delete mode 100644 set_mov.exe delete mode 100644 swap.exe delete mode 100644 wait.exe diff --git a/EXAMPLES.md b/EXAMPLES.md index 9a9d972..e1b49c1 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -57,4 +57,105 @@ main: ; Метка main swap word ; Блок размером в 2 байта push byte 0x00 ; Дескриптор syscall ; Системный вызов +``` +## Запрос ввода у пользователя +```asm +global db main ; Точка входа + +readmem: ; Функция чтения из памяти + push dw 0x00 ; Адрес + mread dw ; Читаем + ret ; Конец функции + +insub: ; Уменьшение адреса + push dw 1 ; На сколько уменьшать + push byte 2 ; Поменять два места + swap dw ; Тип данных - size_t + sub dw ; Уменьшить + ret ; Конец функции + +writemem: ; Функция записи в память + push dw 0x00 ; Адрес + mwrt dw ; Записываем + ret ; Конец функции + +decrement: ; Управление данными + rcall db readmem ; Прочитать + rcall db insub ; Уменьшить + rcall db writemem ; Записать + ret ; Конец функции + +main: ; Точка входа + push.string "Введите ваше имя: " ; Строка + push byte 0x00 ; Дескриптор + syscall ; Выводим + +begin: ; Настройка адресов + push dw 0x02 ; Указатель + push dw 0x00 ; Адрес + mwrt dw ; Записываем + +inloop: ; Цикл чтения символов + push byte 0x01 ; Дескриптор + syscall ; Читаем + copy byte ; Копируем char + + push dw 0x00 ; Адрес + mread dw ; Читаем + + mwrt byte ; Записываем + + push dw 0x00 ; Читаем + mread dw ; Указатель + + push dw 0x01 ; Увеличить + add dw ; На 1 + + push dw 0x00 ; Адрес + mwrt word ; Сохраняем указатель + + push byte 0x0A ; Символ переноса + push db inloop ; Цикл + push byte 2 ; Кол-во слов + swap word ; Меняем их местами + neq byte ; Если не \n - повторить цикл + +userhello: ; Приветствие + push.string "Привет, " ; Текст + push byte 0x00 ; Дескриптор + syscall ; Выводим + rcall db decrement ; Уменьшаем + push byte 0x00 ; Символ конца строки + +readcycle: ; Цикл чтения + push db writeusername ; Конец цикла + push dw 0x00 ; Адрес + mread dw ; Указатель + push dw 0x01 ; Число + eq dw ; Если равно - выйти + + push db rdecrem ; Адрес + + push dw 0x00 ; Иначе + mread dw ; Читаем указатель + mread byte ; Читаем байт по указателю + + push byte 0x0A ; Если символ переноса + eq byte ; Пропускаем добавление на стек + + push dw 0x00 ; Иначе + mread dw ; Читаем указатель + mread byte ; Читаем байт по указателю + +rdecrem: ; Уменьшение указателя + rcall db decrement ; Уменьшаем + push db readcycle ; Указатель на цикл + jmp ; Повторить цикл + +writeusername: ; Выводим имя + push byte 0x00 ; Дескриптор + syscall ; Выводим + push.string "!\n" ; Выводим ! + push byte 0x00 ; Дескриптор + syscall ; Выводим ``` \ No newline at end of file diff --git a/example.asm b/examples/example.asm similarity index 100% rename from example.asm rename to examples/example.asm diff --git a/hello.asm b/examples/hello.asm similarity index 100% rename from hello.asm rename to examples/hello.asm diff --git a/hello_user.asm b/examples/hello_user.asm similarity index 100% rename from hello_user.asm rename to examples/hello_user.asm diff --git a/hello_world.hex b/examples/hello_world.hex similarity index 100% rename from hello_world.hex rename to examples/hello_world.hex diff --git a/input.asm b/examples/input.asm similarity index 100% rename from input.asm rename to examples/input.asm diff --git a/loop.asm b/examples/loop.asm similarity index 100% rename from loop.asm rename to examples/loop.asm diff --git a/set_mov.asm b/examples/set_mov.asm similarity index 100% rename from set_mov.asm rename to examples/set_mov.asm diff --git a/swap.asm b/examples/swap.asm similarity index 100% rename from swap.asm rename to examples/swap.asm diff --git a/wait.asm b/examples/wait.asm similarity index 100% rename from wait.asm rename to examples/wait.asm diff --git a/hello.exe b/hello.exe deleted file mode 100644 index 65b9e18bdb75bd843faead1e3c7aa455ffa93f6f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 28 jcmeZ`l4W3EXkcLSNX^N~*HI|XFUm<#c=`b-0q(H?ft(%`K)B{K-ar=D3=W*fv4Zo|n?AMCm$sqO#+!JAOFUYAhwH%` z00n674gis2BRxMGc8r;Dd{4l0pSl!k9ZDlvLa25l%UQS;`<7MVHt8z;0htFUjsO4v diff --git a/hello_world.exe b/hello_world.exe deleted file mode 100644 index 7d306c69efc6289dffcdabdfc6a8251b8d8a2396..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 28 jcmeZ`l3`$AXkcLSNX^N~*HI|XFUm<#>_XkcJUP0q+yxG?F$hKn5+wkllMabeHJek%o)&|udfE(QihW+?zwU=K|I diff --git a/project_files/.view.ini b/project_files/.view.ini new file mode 100644 index 0000000..8064423 --- /dev/null +++ b/project_files/.view.ini @@ -0,0 +1,4 @@ +[git] +files= +names= +info=None files diff --git a/project_files/example.txt b/project_files/example.txt deleted file mode 100644 index 3848d38..0000000 --- a/project_files/example.txt +++ /dev/null @@ -1,8 +0,0 @@ -Lorem ipsum dolor sit amet, consectetur -adipiscing elit, sed do eiusmod tempor incididunt ut -labore et dolore magna aliqua. Ut enim ad minim veniam, -quis nostrud exercitation ullamco laboris nisi ut -aliquip ex ea commodo consequat. Duis aute irure dolor -in reprehenderit in voluptate velit esse cillum dolore -eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, -sunt in culpa qui officia deserunt mollit anim id est laborum diff --git a/set_mov.exe b/set_mov.exe deleted file mode 100644 index fa405f6e5d1c60ba0d351ab37cbbe5d40e1e4744..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 44 ycmeZ`(q&*^XkcJq;$q-sU}TU|U|>>UkY(~n&B@8vQ7F$Z%1Ke=0!p(o$O8a|-Ug!p diff --git a/swap.exe b/swap.exe deleted file mode 100644 index 77107b3252bfd4521337f68302a8cc08f763d9bf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 53 qcmeZ`GGkz1XkcLSNX^N~*HI|XFUm<#