{"id":464430,"date":"2025-06-25T03:01:27","date_gmt":"2025-06-25T03:01:27","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=464430"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=464430","title":{"rendered":"<span>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0435\u0433\u043e \u044f\u0434\u0440\u0430 \u043d\u0430 Rust. \u0427\u0430\u0441\u0442\u044c 2<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h4>\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b: \u0447\u0442\u043e \u044d\u0442\u043e, \u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u044b \u044f\u0434\u0440\u0443 \u0438 \u043a\u0430\u043a \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442<\/h4>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e <strong>\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u0430\u0445 (syscall)<\/strong> \u2014 \u0432\u0430\u0436\u043d\u0435\u0439\u0448\u0435\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u043a\u043e\u0434\u043e\u043c \u0438 \u044f\u0434\u0440\u043e\u043c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<br \/>\u041c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c:<\/p>\n<ul>\n<li>\n<p>\u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0438 \u0437\u0430\u0447\u0435\u043c \u043e\u043d\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0443\u0436\u043d\u044b<\/p>\n<\/li>\n<li>\n<p>\u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043a \u044f\u0434\u0440\u0443<\/p>\n<\/li>\n<li>\n<p>\u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c syscall \u0432 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u044f\u0434\u0440\u0435 \u043d\u0430 Rust<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f0d\/b1d\/5bf\/f0db1d5bf4217fd007e5febe019a1db9.png\" width=\"1536\" height=\"1024\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/f0d\/b1d\/5bf\/f0db1d5bf4217fd007e5febe019a1db9.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f0d\/b1d\/5bf\/f0db1d5bf4217fd007e5febe019a1db9.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<blockquote>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0451 \u043d\u0435 \u0447\u0438\u0442\u0430\u043b\u0438 <strong>\u043f\u0435\u0440\u0432\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u0438<\/strong>, \u0433\u0434\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u044f\u0434\u0440\u043e \u043d\u0430 Rust \u0441 VGA-\u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 \u2014 \u043d\u0430\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u043d\u0435\u0451: \ud83d\udc49 <a href=\"https:\/\/habr.com\/p\/920554\/\" rel=\"noopener noreferrer nofollow\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0435\u0433\u043e \u044f\u0434\u0440\u0430 \u043d\u0430 Rust. \u0427\u0430\u0441\u0442\u044c 1<\/a> <\/p>\n<\/blockquote>\n<p>\u0412\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0448\u0430\u0433\u043d\u0451\u043c \u0434\u0430\u043b\u044c\u0448\u0435 \u2014 <strong>\u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044f\u0434\u0440\u0430 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e<\/strong>. \u042d\u0442\u043e \u0432\u0430\u0436\u043d\u044b\u0439 \u0440\u0443\u0431\u0435\u0436: \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 syscall \u0432\u0430\u0448\u0435 \u044f\u0434\u0440\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0438\u0437 &#171;\u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b&#187; \u0432 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u041e\u0421, \u0433\u0434\u0435 \u044f\u0434\u0440\u043e \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0447\u0435\u0440\u0435\u0437 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430.<\/p>\n<p>\u0413\u043e\u0442\u043e\u0432\u044b? \u041f\u043e\u0433\u043d\u0430\u043b\u0438.<\/p>\n<hr\/>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0438 \u0437\u0430\u0447\u0435\u043c \u043e\u043d\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0443\u0436\u043d\u044b<\/h2>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b (<strong>system calls<\/strong>, \u0438\u043b\u0438 <strong>syscalls<\/strong>) \u2014 \u044d\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e <strong>\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/strong>, \u0442\u0430\u043a\u0438\u043c \u043a\u0430\u043a:<\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0432\u043e\u0434 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d,<\/p>\n<\/li>\n<li>\n<p>\u0447\u0442\u0435\u043d\u0438\u0435 \u0441 \u0434\u0438\u0441\u043a\u0430,<\/p>\n<\/li>\n<li>\n<p>\u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438,<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u0442. \u0434.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u0434 <strong>\u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u044e<\/strong> \u0438\u043b\u0438 \u043a \u043f\u0430\u043c\u044f\u0442\u0438 \u044f\u0434\u0440\u0430. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e \u0441\u043e\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0438 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438: \u043e\u0434\u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u0432\u0440\u0435\u0434\u0438\u0442\u044c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u0437 \u044f\u0434\u0440\u0430?<\/h3>\n<p>\u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u041e\u0421 \u043f\u0430\u043c\u044f\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u0430 <strong>\u0440\u0435\u0436\u0438\u043c \u044f\u0434\u0440\u0430 (kernel mode)<\/strong> \u0438 <strong>\u0440\u0435\u0436\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (user mode)<\/strong>.<br \/>\u041a\u043e\u0433\u0434\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u00ab\u043f\u0435\u0441\u043e\u0447\u043d\u0438\u0446\u0435\u00bb, \u043d\u0435 \u0438\u043c\u0435\u044f \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c \u0438 \u044f\u0434\u0440\u0443.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0447\u0442\u043e\u0431\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <strong>\u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0441\u0438\u043c\u0432\u043e\u043b \u043d\u0430 \u044d\u043a\u0440\u0430\u043d<\/strong>, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 \u0432\u0438\u0434\u0435\u043e\u043f\u0430\u043c\u044f\u0442\u044c. \u041e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 <strong>\u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u044f\u0434\u0440\u043e<\/strong>: \u00ab\u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u0432\u044b\u0432\u0435\u0434\u0438 \u0441\u0438\u043c\u0432\u043e\u043b H \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 (10, 5)\u00bb.<\/p>\n<p>\u0412\u043e\u0442 \u0442\u0443\u0442 \u0438 \u0432\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u0432 \u0438\u0433\u0440\u0443 <strong>\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b<\/strong> \u2014 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0443\u0442\u0438 \u0441\u0432\u044f\u0437\u0438 \u0441 \u044f\u0434\u0440\u043e\u043c. \u041e\u043d\u0438:<\/p>\n<ul>\n<li>\n<p>\u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0442 <strong>\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432 \u0440\u0435\u0436\u0438\u043c \u044f\u0434\u0440\u0430<\/strong>;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 <strong>\u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u044f\u0434\u0440\u0443<\/strong> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0438 \u0441\u0438\u043c\u0432\u043e\u043b);<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 <strong>\u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u044f\u0434\u0440\u0430<\/strong> \u043f\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c\u0443 \u043d\u043e\u043c\u0435\u0440\u0443;<\/p>\n<\/li>\n<li>\n<p>\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 (\u0435\u0441\u043b\u0438 \u043e\u043d \u0435\u0441\u0442\u044c) \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u0434.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u044f<\/h3>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u043a\u0430\u043a <strong>\u043e\u043a\u043d\u043e \u043d\u0430 \u0441\u0442\u043e\u0439\u043a\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438<\/strong>. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c (\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430) \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0439\u0442\u0438 \u0432 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0443\u044e (\u044f\u0434\u0440\u043e) \u0438 \u043f\u043e\u043a\u043e\u043f\u0430\u0442\u044c\u0441\u044f \u2014 \u043e\u043d \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043a \u043e\u043a\u043d\u0443, \u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441, \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0435\u0433\u043e \u0437\u0430 \u043d\u0435\u0433\u043e.<br \/>\u042d\u0442\u043e \u043e\u043a\u043d\u043e \u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f, \u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u0442 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0438 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0432\u0441\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0432 Linux<\/h3>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">Syscall<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041d\u043e\u043c\u0435\u0440<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>write<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 stdout<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>read<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 stdin<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>exit<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">60<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0417\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>getpid<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">39<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c ID \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<hr\/>\n<h2>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043a \u044f\u0434\u0440\u0443<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043c\u043e\u0433\u043b\u0430 <em>\u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0443 \u044f\u0434\u0440\u0430 \u0447\u0442\u043e-\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c<\/em>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0441\u0438\u043c\u0432\u043e\u043b \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0438\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u2014 \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u043d\u0443\u0442\u0440\u044c \u044f\u0434\u0440\u0430. \u041d\u043e \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442?<\/p>\n<p>\u0412\u0441\u0451 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 <strong>\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430<\/strong> \u2014 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u043a\u043e\u0434\u043e\u043c \u0438 \u044f\u0434\u0440\u043e\u043c.<\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0441\u0430\u043c\u044b\u0439 \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u2014 <strong>\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 (assembly)<\/strong>, \u0432\u0435\u0434\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a <strong>\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430<\/strong>, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c <strong>\u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f<\/strong> \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430?<\/h3>\n<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0440 \u2014 \u044d\u0442\u043e \u043a\u0440\u043e\u0448\u0435\u0447\u043d\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0438 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u041f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u044b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u0440\u044f\u043c\u043e \u0432 \u044d\u0442\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b.<\/p>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043f\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u043c (x86_64 ABI):<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0420\u0435\u0433\u0438\u0441\u0442\u0440<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>rax<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u043e\u043c\u0435\u0440 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>rdi<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 (<code>arg1<\/code>)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>rsi<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0412\u0442\u043e\u0440\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 (<code>arg2<\/code>)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>rdx<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0422\u0440\u0435\u0442\u0438\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 (<code>arg3<\/code>)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>rcx<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0427\u0435\u0442\u0432\u0451\u0440\u0442\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 (<code>arg4<\/code>)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>r8<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u044f\u0442\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 (<code>arg5<\/code>)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>r9<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0428\u0435\u0441\u0442\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 (<code>arg6<\/code>)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u2014 \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c<\/h3>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u2014 \u044d\u0442\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 &#171;\u0437\u0430\u043f\u0440\u043e\u0441&#187; \u043e\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043a \u044f\u0434\u0440\u0443. \u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<ol>\n<li>\n<p><strong>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/strong><br \/>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u043e\u0447\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u044f\u0434\u0440\u0443:<\/p>\n<ul>\n<li>\n<p>\u0427\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c? (\u043d\u043e\u043c\u0435\u0440 \u0432\u044b\u0437\u043e\u0432\u0430 \u0432 <code>rax<\/code>)<\/p>\n<\/li>\n<li>\n<p>\u0421 \u043a\u0430\u043a\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438? (\u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0445)<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u0412\u044b\u0437\u043e\u0432 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f<\/strong><br \/>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f <code>int 0x80<\/code> \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435. \u041f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u044f\u0434\u0440\u043e.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u0432 \u044f\u0434\u0440\u043e<\/strong><br \/>\u041d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f\u0434\u0440\u0430 \u0431\u044b\u043b\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u0430 IDT (\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439), \u0438 0x80-\u044f \u044f\u0447\u0435\u0439\u043a\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u044f\u0434\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>syscall_entry<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/strong><br \/>\u042f\u0434\u0440\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0432\u0441\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u043d\u0430 \u0441\u0442\u0435\u043a, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u0412\u044b\u0437\u043e\u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430<\/strong><br \/>\u042f\u0434\u0440\u043e \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>syscall_handler<\/code>), \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0442\u0443\u0434\u0430 \u043d\u043e\u043c\u0435\u0440 \u0432\u044b\u0437\u043e\u0432\u0430 \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b.<\/p>\n<\/li>\n<li>\n<p><strong>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0442<\/strong><br \/>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u044f\u0434\u0440\u043e:<\/p>\n<ul>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 <code>rax<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 <code>iretq<\/code> \u2014 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0438\u0437 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>ASCII-\u0441\u0445\u0435\u043c\u0430 \u0432\u044b\u0437\u043e\u0432\u0430<\/h3>\n<p>\u0412\u043e\u0442 \u0441\u0445\u0435\u043c\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u0434             \u042f\u0434\u0440\u043e (syscall_entry)                \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a ----------------------          -------------------------           ------------------- rax = syscall_number        \u2192   \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b              \u2192   match syscall_number rdi = arg1                  \u2192   \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c rdi \u2192 rsi              \u2192   \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 rsi = arg2                  \u2192   \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c rsi \u2192 rdx              \u2192   (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u0432\u043e\u0434 \u0442\u0435\u043a\u0441\u0442\u0430) rdx = arg3                  \u2192   ... rcx = arg4  int 0x80   \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25b6   [\u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u044f\u0434\u0440\u043e]                             \u2500\u25b6   \u0432\u044b\u0437\u043e\u0432 syscall_handler()                             \u25c0\u2500   \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 rax \u25c0\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500   iretq (\u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u0434) <\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u2014 \u044d\u0442\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 &#171;\u043c\u043e\u0441\u0442\u0438\u043a&#187; \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u043a\u043e\u0434\u043e\u043c \u0438 \u044f\u0434\u0440\u043e\u043c. \u0427\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u044f\u0434\u0440\u0430, \u0441\u0442\u0440\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u044f, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c. \u042d\u0442\u043e \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438, \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432 \u043b\u044e\u0431\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435.<\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u043c\u044b \u0443\u0436\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 <strong>Rust + Assembly<\/strong>.<\/p>\n<hr\/>\n<h2>\u041a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c syscall \u0432 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u044f\u0434\u0440\u0435 \u043d\u0430 Rust<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0438 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043a \u044f\u0434\u0440\u0443, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c <strong>\u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 syscall<\/strong> \u0432 \u0441\u0432\u043e\u0451\u043c \u044f\u0434\u0440\u0435 \u043d\u0430 Rust.<\/p>\n<h3>\u0427\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e?<\/h3>\n<p>\u0427\u0442\u043e\u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c syscall, \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f:<\/p>\n<ol>\n<li>\n<p><strong>\u041d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c IDT \u0438 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f <\/strong><code><strong>int 0x80<\/strong><\/code><strong>.<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u043e\u0447\u043a\u0443 \u0432\u0445\u043e\u0434\u0430 \u043d\u0430 Assembly (<\/strong><code><strong>syscall_entry<\/strong><\/code><strong>) \u2014 \u043e\u043d\u0430 \u0432\u044b\u0437\u043e\u0432\u0435\u0442\u0441\u044f \u043f\u0440\u0438 <\/strong><code><strong>int 0x80<\/strong><\/code><strong>.<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <\/strong><code><strong>syscall_handler()<\/strong><\/code><strong> \u043d\u0430 Rust \u2014 \u043b\u043e\u0433\u0438\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u0432.<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u0412\u044b\u0437\u044b\u0432\u0430\u0442\u044c syscall \u0438\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e\/\u044f\u0434\u0440\u043e\u0432\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0447\u0435\u0440\u0435\u0437 <\/strong><code><strong>asm!<\/strong><\/code><strong>.<\/strong><\/p>\n<\/li>\n<\/ol>\n<h3>1) \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 IDT: \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430<\/h3>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u044f\u0434\u0440\u0443, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f <code>int 0x80<\/code>. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 IDT:<\/p>\n<pre><code class=\"rust\">IDT[0x80].set_handler_addr(x86_64::VirtAddr::new(syscall_entry as u64));<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c <code>syscall_entry<\/code> \u2014 \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043e\u043f\u0438\u0448\u0435\u043c \u043d\u0430 Assembly. \u041e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u043f\u0440\u0438 <code>int 0x80<\/code>.<\/p>\n<h3>2) Assembly: syscall_entry<\/h3>\n<p>\u042d\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u0441\u043b\u043e\u0439 \u2014 \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b, \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>syscall_handler<\/code>.<\/p>\n<pre><code class=\"assembly\">global_asm!(     r#\"     .att_syntax .globl syscall_entry .text syscall_entry:     \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b     push %rax      \/\/ [rsp+0]     push %rdi      \/\/ [rsp+8]     push %rsi      \/\/ [rsp+16]     push %rdx      \/\/ [rsp+24]     push %rcx      \/\/ [rsp+32]     push %r8       \/\/ [rsp+40]     push %r9       \/\/ [rsp+48]     push %r10     push %r11      \/\/ \u0420\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u043e \u0441\u0442\u0435\u043a\u0443     mov 64(%rsp), %rdi   \/\/ syscall number (\u0438\u0437 RAX)     mov 56(%rsp), %rsi   \/\/ arg1 (\u0438\u0437 RDI)     mov 48(%rsp), %rdx   \/\/ arg2 (\u0438\u0437 RSI)     mov 40(%rsp), %rcx   \/\/ arg3 (\u0438\u0437 RDX)     mov 32(%rsp), %r8    \/\/ arg4 (\u0438\u0437 RCX)     mov 24(%rsp), %r9    \/\/ arg5 (\u0438\u0437 R8)      \/\/ \u0412\u044b\u0437\u043e\u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430     mov $syscall_handler, %rax     call *%rax      \/\/ \u0412\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b     pop %r11     pop %r10     pop %r9     pop %r8     pop %rcx     pop %rdx     pop %rsi     pop %rdi     pop %rax      iretq \"# );<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u0431\u043b\u043e\u043a <code>syscall_entry<\/code>, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 Assembly. \u042d\u0442\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0430\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 <strong>\u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/strong> \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430 (\u0438\u043b\u0438 \u043a\u043e\u0434\u0430 \u0443\u0440\u043e\u0432\u043d\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f) \u043d\u0430 <strong>\u044f\u0434\u0440\u043e<\/strong>, \u0438 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e <strong>\u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e<\/strong>.<\/p>\n<h3>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 syscall_entry<\/h3>\n<pre><code class=\"assembly\">global_asm!(     r#\"     .att_syntax .globl syscall_entry .text syscall_entry:<\/code><\/pre>\n<h4>\u042d\u0442\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430<\/h4>\n<ul>\n<li>\n<p><code>.att_syntax<\/code> \u2014 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043d\u0430 AT&amp;T (\u043f\u0440\u0438\u043d\u044f\u0442 \u0432 GCC).<\/p>\n<\/li>\n<li>\n<p><code>.globl syscall_entry<\/code> \u2014 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442 <code>syscall_entry<\/code> \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u0438\u0437\u0432\u043d\u0435.<\/p>\n<\/li>\n<li>\n<p><code>.text<\/code> \u2014 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435 \u0438\u0434\u0451\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<\/li>\n<\/ul>\n<h4>\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b<\/h4>\n<pre><code class=\"assembly\">    push %rax      \/\/ [rsp+0]     push %rdi      \/\/ [rsp+8]     push %rsi      \/\/ [rsp+16]     push %rdx      \/\/ [rsp+24]     push %rcx      \/\/ [rsp+32]     push %r8       \/\/ [rsp+40]     push %r9       \/\/ [rsp+48]     push %r10     push %r11<\/code><\/pre>\n<p><strong>\u0417\u0430\u0447\u0435\u043c:<\/strong> \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>int 0x80<\/code>, \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0432\u0441\u0435 \u0435\u0451 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0431\u0443\u0434\u0443\u0442 \u0442\u0430\u043a\u0438\u043c\u0438 \u0436\u0435, \u043a\u0430\u043a \u0434\u043e \u043d\u0435\u0433\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 <strong>\u043c\u044b \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c<\/strong> \u0438\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0432 \u0441\u0442\u0435\u043a\u0435.<\/p>\n<p>\u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f <strong>\u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430<\/strong>: \u0435\u0441\u043b\u0438 \u043c\u044b \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c, syscall \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u0440\u0435\u0434\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430.<\/p>\n<h4>\u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b<\/h4>\n<pre><code class=\"assembly\">    mov 64(%rsp), %rdi   \/\/ syscall number (\u0438\u0437 RAX)     mov 56(%rsp), %rsi   \/\/ arg1 (\u0438\u0437 RDI)     mov 48(%rsp), %rdx   \/\/ arg2 (\u0438\u0437 RSI)     mov 40(%rsp), %rcx   \/\/ arg3 (\u0438\u0437 RDX)     mov 32(%rsp), %r8    \/\/ arg4 (\u0438\u0437 RCX)     mov 24(%rsp), %r9    \/\/ arg5 (\u0438\u0437 R8)<\/code><\/pre>\n<p><strong>\u041e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435:<\/strong> \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0431\u044b\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u043f\u0435\u0440\u0435\u0434 <code>int 0x80<\/code>, \u043d\u043e <strong>\u043c\u044b \u0443\u0436\u0435 \u0438\u0445 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u043b\u0438 <\/strong><code><strong>push<\/strong><\/code><strong>-\u0430\u043c\u0438<\/strong>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0441\u0442\u0430\u0451\u043c \u0441\u0442\u0430\u0440\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0441\u0442\u0435\u043a\u0430:<\/p>\n<ul>\n<li>\n<p><code>%rdi<\/code> \u2190 <code>%rax<\/code> (\u043d\u043e\u043c\u0435\u0440 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430)<\/p>\n<\/li>\n<li>\n<p><code>%rsi<\/code> \u2190 <code>%rdi<\/code> (1-\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442)<\/p>\n<\/li>\n<li>\n<p>\u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435\u2026<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0442\u0435\u043a \u0440\u0430\u0441\u0442\u0451\u0442 \u0432\u043d\u0438\u0437, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <code>64(%rsp)<\/code> \u2014 \u044d\u0442\u043e \u0432\u0435\u0440\u0445\u043d\u044f\u044f \u0442\u043e\u0447\u043a\u0430, \u0433\u0434\u0435 \u043b\u0435\u0436\u0438\u0442 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 <code>rax<\/code>.<\/p>\n<h4>\u0412\u044b\u0437\u043e\u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430<\/h4>\n<pre><code class=\"assembly\">    mov $syscall_handler, %rax     call *%rax<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>syscall_handler<\/code>, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u043d\u0430 Rust. \u0412\u0441\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0443\u0436\u0435 \u043b\u0435\u0436\u0430\u0442 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0445, \u043a\u0430\u043a \u0442\u0440\u0435\u0431\u0443\u0435\u0442 <strong>\u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435 \u043e \u0432\u044b\u0437\u043e\u0432\u0430\u0445 System V ABI (Linux)<\/strong>:<\/p>\n<ul>\n<li>\n<p><code>%rdi<\/code> \u2192 1-\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442<\/p>\n<\/li>\n<li>\n<p><code>%rsi<\/code> \u2192 2-\u0439<\/p>\n<\/li>\n<li>\n<p><code>%rdx<\/code> \u2192 3-\u0439<\/p>\n<\/li>\n<li>\n<p><code>%rcx<\/code> \u2192 4-\u0439<\/p>\n<\/li>\n<li>\n<p><code>%r8<\/code>  \u2192 5-\u0439<\/p>\n<\/li>\n<li>\n<p><code>%r9<\/code>  \u2192 6-\u0439<\/p>\n<\/li>\n<\/ul>\n<h4>\u0412\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432<\/h4>\n<pre><code class=\"assembly\">    pop %r11     pop %r10     pop %r9     pop %r8     pop %rcx     pop %rdx     pop %rsi     pop %rdi     pop %rax<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 <code>syscall_handler<\/code> \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b \u0440\u0430\u0431\u043e\u0442\u0443 \u0438 \u0432\u0435\u0440\u043d\u0443\u043b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 (\u0432 <code>rax<\/code>), \u043c\u044b <strong>\u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0435 \u0440\u0430\u043d\u0435\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b<\/strong> \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.<\/p>\n<h4>\u0417\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435<\/h4>\n<pre><code class=\"assembly\">    iretq \"# ); <\/code><\/pre>\n<p><code>iretq<\/code> \u2014 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f <strong>\u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0438\u0437 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f<\/strong> \u043d\u0430 x86_64. \u041e\u043d\u0430:<\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0435\u0442 <strong>\u0441\u0442\u0430\u0440\u044b\u0439 RIP, CS \u0438 RFLAGS<\/strong> \u0438\u0437 \u0441\u0442\u0435\u043a\u0430,<\/p>\n<\/li>\n<li>\n<p>\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <strong>\u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u0432\u0430\u043b\u0430 <code>int 0x80<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 <code>ret<\/code>, \u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043f\u0430\u043b\u0430 \u2014 <code>iretq<\/code> \u043d\u0443\u0436\u0435\u043d \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0438\u0437 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0438 \u0444\u043b\u0430\u0433\u0438.<\/p>\n<h2>3) Rust: syscall_handler<\/h2>\n<p>\u042d\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u043e\u043c\u0435\u0440 \u0432\u044b\u0437\u043e\u0432\u0430 \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"rust\">#[no_mangle] pub extern \"C\" fn syscall_handler(     num: u64,     arg1: u64,     arg2: u64,     arg3: u64,     arg4: u64,     arg5: u64,     arg6: u64, ) -&gt; u64 {     match num {         0 =&gt; {             \/\/ sys_print_char(x, y, ch, color)             write_char(arg1 as usize, arg2 as usize, arg3 as u8, arg4 as u8);             0         }         1 =&gt; {             \/\/ sys_print_string(x, y, ptr, color)             unsafe {                 let ptr = arg3 as *const u8;                 let color = arg4 as u8;                  let mut len = 0;                 while *ptr.add(len) != 0 {                     len += 1;                 }                  let slice = core::slice::from_raw_parts(ptr, len);                 if let Ok(s) = core::str::from_utf8(slice) {                     write_string(arg1 as usize, arg2 as usize, s, color);                 }             }             0         }         2 =&gt; {             \/\/ sys_get_ticks()             TICKS.load(core::sync::atomic::Ordering::Relaxed)         },         3 =&gt; { ... },     \/\/ sys_get_last_key         0x10 =&gt; { ... },  \/\/ sys_get_heap_size         0x11 =&gt; { ... },  \/\/ sys_alloc         0x12 =&gt; { ... },  \/\/ sys_dealloc         _ =&gt; 0,     } }<\/code><\/pre>\n<h3>syscall_handler: \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d<\/h3>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>syscall_handler<\/code> \u2014 \u044d\u0442\u043e <strong>\u044f\u0434\u0440\u043e \u0432\u0441\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432<\/strong>. \u041e\u043d\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 <code>int 0x80<\/code>, \u0438 \u0432 \u043d\u0435\u0451 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u044f\u0434\u0440\u0443 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<h3>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h3>\n<p>\u041f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0438\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e, \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 (<code>syscall_entry<\/code>) \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u044d\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 <code>syscall_handler<\/code> \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<h3>\u041b\u043e\u0433\u0438\u043a\u0430 \u0432\u044b\u0431\u043e\u0440\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439<\/h3>\n<pre><code class=\"rust\">match num {     0 =&gt; { ... },     \/\/ sys_print_char     1 =&gt; { ... },     \/\/ sys_print_string     2 =&gt; { ... },     \/\/ sys_get_ticks     3 =&gt; { ... },     \/\/ sys_get_last_key     0x10 =&gt; { ... },  \/\/ sys_get_heap_size     0x11 =&gt; { ... },  \/\/ sys_alloc     0x12 =&gt; { ... },  \/\/ sys_dealloc     _ =&gt; 0,           \/\/ \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u2014 \u0432\u0435\u0440\u043d\u0443\u0442\u044c 0 }<\/code><\/pre>\n<p>\u041f\u043e \u043d\u043e\u043c\u0435\u0440\u0443 \u0432\u044b\u0437\u043e\u0432\u0430 (<code>num<\/code>) \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043d\u0443\u0436\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430:<\/p>\n<ul>\n<li>\n<p><code><strong>0<\/strong><\/code><strong> \u2014 <\/strong><code><strong>sys_print_char<\/strong><\/code>:<br \/>\u0412\u044b\u0432\u043e\u0434 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u043f\u043e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c <code>x<\/code> \u0438 <code>y<\/code>, \u0441 \u0446\u0432\u0435\u0442\u043e\u043c <code>color<\/code>.<br \/>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <code>write_char(x, y, ch, color)<\/code>.<\/p>\n<\/li>\n<li>\n<p><code><strong>1<\/strong><\/code><strong> \u2014 <\/strong><code><strong>sys_print_string<\/strong><\/code>:<br \/>\u0412\u044b\u0432\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0438, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e (<code>arg3<\/code>) \u043d\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u044e <code>x<\/code>, <code>y<\/code> \u0441 \u0446\u0432\u0435\u0442\u043e\u043c <code>color<\/code>.<br \/>\u0421\u0442\u0440\u043e\u043a\u0430 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043e \u043d\u0443\u043b\u0435\u0432\u043e\u0433\u043e \u0431\u0430\u0439\u0442\u0430 (<code>0x00<\/code>) \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0432 <code>write_string(...)<\/code>.<\/p>\n<\/li>\n<li>\n<p><code><strong>2<\/strong><\/code><strong> \u2014 <\/strong><code><strong>sys_get_ticks<\/strong><\/code>:<br \/>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0442\u0438\u043a\u043e\u0432 \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u044f\u0434\u0440\u0430.<br \/>\u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>TICKS<\/code>.<\/p>\n<\/li>\n<li>\n<p><code><strong>3<\/strong><\/code><strong> \u2014 <\/strong><code><strong>sys_get_last_key<\/strong><\/code>:<br \/>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u043d\u0430\u0436\u0430\u0442\u043e\u0439 \u043a\u043b\u0430\u0432\u0438\u0448\u0438 \u0441 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b.<br \/>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <code>LAST_KEYCODE<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044e \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b.<\/p>\n<\/li>\n<li>\n<p><code><strong>0x10<\/strong><\/code><strong> \u2014 <\/strong><code><strong>sys_get_heap_size<\/strong><\/code>:<br \/>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u0449\u0438\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u043a\u0443\u0447\u0438 (<code>HEAP_SIZE<\/code>), \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0438 \u043e\u0446\u0435\u043d\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><code><strong>0x11<\/strong><\/code><strong> \u2014 <\/strong><code><strong>sys_alloc(size)<\/strong><\/code>:<br \/>\u041f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0443\u0447\u0430\u0441\u0442\u043e\u043a \u043f\u0430\u043c\u044f\u0442\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c <code>size<\/code> \u0431\u0430\u0439\u0442 \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c (\u0430\u0434\u0440\u0435\u0441).<br \/>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f 0.<\/p>\n<\/li>\n<li>\n<p><code><strong>0x12<\/strong><\/code><strong> \u2014 <\/strong><code><strong>sys_dealloc(ptr, size)<\/strong><\/code>:<br \/>\u041e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442 \u0440\u0430\u043d\u0435\u0435 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <code>ptr<\/code> \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c <code>size<\/code>.<\/p>\n<\/li>\n<\/ul>\n<h3>4) \u0412\u044b\u0437\u043e\u0432 syscall \u0438\u0437 \u043a\u043e\u0434\u0430<\/h3>\n<p>\u0414\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0438\u0437 \u044f\u0434\u0440\u0430 \u0438\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c inline-assembly:<\/p>\n<pre><code class=\"rust\">#[inline(always)] pub fn sys_print_char(x: u64, y: u64, ch: u8, color: u8) {     unsafe {         core::arch::asm!(             \"int 0x80\",             in(\"rax\") 0,              \/\/ syscall number             in(\"rdi\") x,              \/\/ x             in(\"rsi\") y,              \/\/ y             in(\"rdx\") ch as u64,      \/\/ character             in(\"rcx\") color as u64,   \/\/ color             options(nostack)         );     } }<\/code><\/pre>\n<h4>\u0414\u0438\u0441\u043a\u043b\u0435\u0439\u043c\u0435\u0440:<\/h4>\n<blockquote>\n<p>\u0412 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>sys_print_char<\/code>) \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c, \u0430 \u043d\u0435 \u0438\u0437 \u0441\u0430\u043c\u043e\u0433\u043e \u044f\u0434\u0440\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0446\u0435\u043b\u044f\u0445 \u0442\u0430\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u0440\u044f\u043c\u043e \u0432 \u044f\u0434\u0440\u0435 \u2014 \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b <code>syscall<\/code>.<\/p>\n<p>\u041f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u043f\u0430\u043c\u044f\u0442\u0438 (user\/kernel space) \u0442\u0430\u043a\u0438\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u044f\u0434\u0440\u043e\u043c \u0447\u0435\u0440\u0435\u0437 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 API.<\/p>\n<\/blockquote>\n<h2>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u044f\u0434\u0440\u043e \u043c\u043e\u0436\u0435\u0442:<\/p>\n<ul>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b \u043e\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c (\u0432\u044b\u0432\u043e\u0434 \u0442\u0435\u043a\u0441\u0442\u0430, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e).<\/p>\n<\/li>\n<li>\n<p>\u0413\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c: \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f <strong>\u0442\u043e\u043b\u044c\u043a\u043e<\/strong> \u043a \u0442\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 <code>syscall_handler<\/code>.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h2>\u0412\u044b\u0432\u043e\u0434<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0432 \u044f\u0434\u0440\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u041c\u044b \u0443\u0432\u0438\u0434\u0435\u043b\u0438, \u043a\u0430\u043a \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b, \u043a\u0430\u043a \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 <code>int 0x80<\/code>, \u0437\u0430\u0447\u0435\u043c \u043e\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0438 \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0430\u043c\u043e\u0433\u043e \u044f\u0434\u0440\u0430.<br \/>\u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u0443\u0447\u0438\u043b\u0438, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0435 <code>syscall<\/code>-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 Rust, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f inline-assembly, \u0438 \u043a\u0430\u043a \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043a \u044f\u0434\u0440\u0443 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e.<\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0434\u043b\u044f \u0432\u0430\u0441 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435!<\/p>\n<p>\ud83d\udcce \u041f\u043e\u043b\u043d\u044b\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u043e \u0441\u0431\u043e\u0440\u043a\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0437\u0434\u0435\u0441\u044c: \ud83d\udc49 <a href=\"https:\/\/github.com\/Elieren\/NeonForge\" rel=\"noopener noreferrer nofollow\"><strong>https:\/\/github.com\/Elieren\/NeonForge<\/strong><\/a><\/p>\n<p><strong>P.S.<\/strong> \u041e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0442\u0451\u043f\u043b\u044b\u0435 \u0438 \u0434\u043e\u0431\u0440\u044b\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u043f\u043e\u0434 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e \u2014 \u0432\u0430\u0448\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430\u0434 \u044d\u0442\u043e\u0439 \u0441\u0435\u0440\u0438\u0435\u0439 \u0438 \u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0437\u043d\u0430\u043d\u0438\u044f\u043c\u0438 \u0432 \u0442\u0430\u043a\u043e\u0439 \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043d\u043e \u0443\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u0435\u043c\u0435.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/921500\/\"> https:\/\/habr.com\/ru\/articles\/921500\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h4>\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b: \u0447\u0442\u043e \u044d\u0442\u043e, \u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u044b \u044f\u0434\u0440\u0443 \u0438 \u043a\u0430\u043a \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442<\/h4>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e <strong>\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u0430\u0445 (syscall)<\/strong> \u2014 \u0432\u0430\u0436\u043d\u0435\u0439\u0448\u0435\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u043a\u043e\u0434\u043e\u043c \u0438 \u044f\u0434\u0440\u043e\u043c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<br \/>\u041c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c:<\/p>\n<ul>\n<li>\n<p>\u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0438 \u0437\u0430\u0447\u0435\u043c \u043e\u043d\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0443\u0436\u043d\u044b<\/p>\n<\/li>\n<li>\n<p>\u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043a \u044f\u0434\u0440\u0443<\/p>\n<\/li>\n<li>\n<p>\u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c syscall \u0432 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u044f\u0434\u0440\u0435 \u043d\u0430 Rust<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><\/figure>\n<blockquote>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0451 \u043d\u0435 \u0447\u0438\u0442\u0430\u043b\u0438 <strong>\u043f\u0435\u0440\u0432\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u0438<\/strong>, \u0433\u0434\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u044f\u0434\u0440\u043e \u043d\u0430 Rust \u0441 VGA-\u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 \u2014 \u043d\u0430\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u043d\u0435\u0451: \ud83d\udc49 <a href=\"https:\/\/habr.com\/p\/920554\/\" rel=\"noopener noreferrer nofollow\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0435\u0433\u043e \u044f\u0434\u0440\u0430 \u043d\u0430 Rust. \u0427\u0430\u0441\u0442\u044c 1<\/a> <\/p>\n<\/blockquote>\n<p>\u0412\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0448\u0430\u0433\u043d\u0451\u043c \u0434\u0430\u043b\u044c\u0448\u0435 \u2014 <strong>\u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044f\u0434\u0440\u0430 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e<\/strong>. \u042d\u0442\u043e \u0432\u0430\u0436\u043d\u044b\u0439 \u0440\u0443\u0431\u0435\u0436: \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 syscall \u0432\u0430\u0448\u0435 \u044f\u0434\u0440\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0438\u0437 &#171;\u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b&#187; \u0432 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u041e\u0421, \u0433\u0434\u0435 \u044f\u0434\u0440\u043e \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0447\u0435\u0440\u0435\u0437 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430.<\/p>\n<p>\u0413\u043e\u0442\u043e\u0432\u044b? \u041f\u043e\u0433\u043d\u0430\u043b\u0438.<\/p>\n<hr\/>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0438 \u0437\u0430\u0447\u0435\u043c \u043e\u043d\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0443\u0436\u043d\u044b<\/h2>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b (<strong>system calls<\/strong>, \u0438\u043b\u0438 <strong>syscalls<\/strong>) \u2014 \u044d\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e <strong>\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/strong>, \u0442\u0430\u043a\u0438\u043c \u043a\u0430\u043a:<\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0432\u043e\u0434 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d,<\/p>\n<\/li>\n<li>\n<p>\u0447\u0442\u0435\u043d\u0438\u0435 \u0441 \u0434\u0438\u0441\u043a\u0430,<\/p>\n<\/li>\n<li>\n<p>\u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438,<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u0442. \u0434.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u0434 <strong>\u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u044e<\/strong> \u0438\u043b\u0438 \u043a \u043f\u0430\u043c\u044f\u0442\u0438 \u044f\u0434\u0440\u0430. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e \u0441\u043e\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0438 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438: \u043e\u0434\u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u0432\u0440\u0435\u0434\u0438\u0442\u044c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u0437 \u044f\u0434\u0440\u0430?<\/h3>\n<p>\u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u041e\u0421 \u043f\u0430\u043c\u044f\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u0430 <strong>\u0440\u0435\u0436\u0438\u043c \u044f\u0434\u0440\u0430 (kernel mode)<\/strong> \u0438 <strong>\u0440\u0435\u0436\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (user mode)<\/strong>.<br \/>\u041a\u043e\u0433\u0434\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u00ab\u043f\u0435\u0441\u043e\u0447\u043d\u0438\u0446\u0435\u00bb, \u043d\u0435 \u0438\u043c\u0435\u044f \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c \u0438 \u044f\u0434\u0440\u0443.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0447\u0442\u043e\u0431\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <strong>\u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0441\u0438\u043c\u0432\u043e\u043b \u043d\u0430 \u044d\u043a\u0440\u0430\u043d<\/strong>, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 \u0432\u0438\u0434\u0435\u043e\u043f\u0430\u043c\u044f\u0442\u044c. \u041e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 <strong>\u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u044f\u0434\u0440\u043e<\/strong>: \u00ab\u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u0432\u044b\u0432\u0435\u0434\u0438 \u0441\u0438\u043c\u0432\u043e\u043b H \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 (10, 5)\u00bb.<\/p>\n<p>\u0412\u043e\u0442 \u0442\u0443\u0442 \u0438 \u0432\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u0432 \u0438\u0433\u0440\u0443 <strong>\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b<\/strong> \u2014 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0443\u0442\u0438 \u0441\u0432\u044f\u0437\u0438 \u0441 \u044f\u0434\u0440\u043e\u043c. \u041e\u043d\u0438:<\/p>\n<ul>\n<li>\n<p>\u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0442 <strong>\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432 \u0440\u0435\u0436\u0438\u043c \u044f\u0434\u0440\u0430<\/strong>;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 <strong>\u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u044f\u0434\u0440\u0443<\/strong> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0438 \u0441\u0438\u043c\u0432\u043e\u043b);<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 <strong>\u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u044f\u0434\u0440\u0430<\/strong> \u043f\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c\u0443 \u043d\u043e\u043c\u0435\u0440\u0443;<\/p>\n<\/li>\n<li>\n<p>\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 (\u0435\u0441\u043b\u0438 \u043e\u043d \u0435\u0441\u0442\u044c) \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u0434.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u044f<\/h3>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u043a\u0430\u043a <strong>\u043e\u043a\u043d\u043e \u043d\u0430 \u0441\u0442\u043e\u0439\u043a\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438<\/strong>. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c (\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430) \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0439\u0442\u0438 \u0432 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0443\u044e (\u044f\u0434\u0440\u043e) \u0438 \u043f\u043e\u043a\u043e\u043f\u0430\u0442\u044c\u0441\u044f \u2014 \u043e\u043d \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043a \u043e\u043a\u043d\u0443, \u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441, \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0435\u0433\u043e \u0437\u0430 \u043d\u0435\u0433\u043e.<br \/>\u042d\u0442\u043e \u043e\u043a\u043d\u043e \u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f, \u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u0442 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0438 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0432\u0441\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0432 Linux<\/h3>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">Syscall<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041d\u043e\u043c\u0435\u0440<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>write<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 stdout<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>read<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 stdin<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>exit<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">60<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0417\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>getpid<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">39<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c ID \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<hr\/>\n<h2>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043a \u044f\u0434\u0440\u0443<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043c\u043e\u0433\u043b\u0430 <em>\u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0443 \u044f\u0434\u0440\u0430 \u0447\u0442\u043e-\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c<\/em>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0441\u0438\u043c\u0432\u043e\u043b \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0438\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u2014 \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u043d\u0443\u0442\u0440\u044c \u044f\u0434\u0440\u0430. \u041d\u043e \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442?<\/p>\n<p>\u0412\u0441\u0451 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 <strong>\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430<\/strong> \u2014 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u043a\u043e\u0434\u043e\u043c \u0438 \u044f\u0434\u0440\u043e\u043c.<\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0441\u0430\u043c\u044b\u0439 \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u2014 <strong>\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 (assembly)<\/strong>, \u0432\u0435\u0434\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a <strong>\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430<\/strong>, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c <strong>\u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f<\/strong> \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430?<\/h3>\n<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0440 \u2014 \u044d\u0442\u043e \u043a\u0440\u043e\u0448\u0435\u0447\u043d\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0438 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u041f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u044b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u0440\u044f\u043c\u043e \u0432 \u044d\u0442\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b.<\/p>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043f\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u043c (x86_64 ABI):<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0420\u0435\u0433\u0438\u0441\u0442\u0440<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>rax<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u043e\u043c\u0435\u0440 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>rdi<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 (<code>arg1<\/code>)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>rsi<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0412\u0442\u043e\u0440\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 (<code>arg2<\/code>)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>rdx<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0422\u0440\u0435\u0442\u0438\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 (<code>arg3<\/code>)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>rcx<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0427\u0435\u0442\u0432\u0451\u0440\u0442\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 (<code>arg4<\/code>)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>r8<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u044f\u0442\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 (<code>arg5<\/code>)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>r9<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0428\u0435\u0441\u0442\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 (<code>arg6<\/code>)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u2014 \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c<\/h3>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u2014 \u044d\u0442\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 &#171;\u0437\u0430\u043f\u0440\u043e\u0441&#187; \u043e\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043a \u044f\u0434\u0440\u0443. \u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<ol>\n<li>\n<p><strong>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/strong><br \/>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u043e\u0447\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u044f\u0434\u0440\u0443:<\/p>\n<ul>\n<li>\n<p>\u0427\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c? (\u043d\u043e\u043c\u0435\u0440 \u0432\u044b\u0437\u043e\u0432\u0430 \u0432 <code>rax<\/code>)<\/p>\n<\/li>\n<li>\n<p>\u0421 \u043a\u0430\u043a\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438? (\u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0445)<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u0412\u044b\u0437\u043e\u0432 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f<\/strong><br \/>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f <code>int 0x80<\/code> \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435. \u041f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u044f\u0434\u0440\u043e.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u0432 \u044f\u0434\u0440\u043e<\/strong><br \/>\u041d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f\u0434\u0440\u0430 \u0431\u044b\u043b\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u0430 IDT (\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439), \u0438 0x80-\u044f \u044f\u0447\u0435\u0439\u043a\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u044f\u0434\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>syscall_entry<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/strong><br \/>\u042f\u0434\u0440\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0432\u0441\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u043d\u0430 \u0441\u0442\u0435\u043a, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u0412\u044b\u0437\u043e\u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430<\/strong><br \/>\u042f\u0434\u0440\u043e \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>syscall_handler<\/code>), \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0442\u0443\u0434\u0430 \u043d\u043e\u043c\u0435\u0440 \u0432\u044b\u0437\u043e\u0432\u0430 \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b.<\/p>\n<\/li>\n<li>\n<p><strong>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0442<\/strong><br \/>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u044f\u0434\u0440\u043e:<\/p>\n<ul>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 <code>rax<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 <code>iretq<\/code> \u2014 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0438\u0437 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>ASCII-\u0441\u0445\u0435\u043c\u0430 \u0432\u044b\u0437\u043e\u0432\u0430<\/h3>\n<p>\u0412\u043e\u0442 \u0441\u0445\u0435\u043c\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u0434             \u042f\u0434\u0440\u043e (syscall_entry)                \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a ----------------------          -------------------------           ------------------- rax = syscall_number        \u2192   \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b              \u2192   match syscall_number rdi = arg1                  \u2192   \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c rdi \u2192 rsi              \u2192   \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 rsi = arg2                  \u2192   \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c rsi \u2192 rdx              \u2192   (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u0432\u043e\u0434 \u0442\u0435\u043a\u0441\u0442\u0430) rdx = arg3                  \u2192   ... rcx = arg4  int 0x80   \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25b6   [\u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u044f\u0434\u0440\u043e]                             \u2500\u25b6   \u0432\u044b\u0437\u043e\u0432 syscall_handler()                             \u25c0\u2500   \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 rax \u25c0\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500   iretq (\u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u0434) <\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u2014 \u044d\u0442\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 &#171;\u043c\u043e\u0441\u0442\u0438\u043a&#187; \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u043a\u043e\u0434\u043e\u043c \u0438 \u044f\u0434\u0440\u043e\u043c. \u0427\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u044f\u0434\u0440\u0430, \u0441\u0442\u0440\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u044f, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c. \u042d\u0442\u043e \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438, \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432 \u043b\u044e\u0431\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435.<\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u043c\u044b \u0443\u0436\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 <strong>Rust + Assembly<\/strong>.<\/p>\n<hr\/>\n<h2>\u041a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c syscall \u0432 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u044f\u0434\u0440\u0435 \u043d\u0430 Rust<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0438 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043a \u044f\u0434\u0440\u0443, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c <strong>\u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 syscall<\/strong> \u0432 \u0441\u0432\u043e\u0451\u043c \u044f\u0434\u0440\u0435 \u043d\u0430 Rust.<\/p>\n<h3>\u0427\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e?<\/h3>\n<p>\u0427\u0442\u043e\u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c syscall, \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f:<\/p>\n<ol>\n<li>\n<p><strong>\u041d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c IDT \u0438 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f <\/strong><code><strong>int 0x80<\/strong><\/code><strong>.<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u043e\u0447\u043a\u0443 \u0432\u0445\u043e\u0434\u0430 \u043d\u0430 Assembly (<\/strong><code><strong>syscall_entry<\/strong><\/code><strong>) \u2014 \u043e\u043d\u0430 \u0432\u044b\u0437\u043e\u0432\u0435\u0442\u0441\u044f \u043f\u0440\u0438 <\/strong><code><strong>int 0x80<\/strong><\/code><strong>.<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <\/strong><code><strong>syscall_handler()<\/strong><\/code><strong> \u043d\u0430 Rust \u2014 \u043b\u043e\u0433\u0438\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u0432.<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u0412\u044b\u0437\u044b\u0432\u0430\u0442\u044c syscall \u0438\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e\/\u044f\u0434\u0440\u043e\u0432\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0447\u0435\u0440\u0435\u0437 <\/strong><code><strong>asm!<\/strong><\/code><strong>.<\/strong><\/p>\n<\/li>\n<\/ol>\n<h3>1) \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 IDT: \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430<\/h3>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u044f\u0434\u0440\u0443, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f <code>int 0x80<\/code>. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 IDT:<\/p>\n<pre><code class=\"rust\">IDT[0x80].set_handler_addr(x86_64::VirtAddr::new(syscall_entry as u64));<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c <code>syscall_entry<\/code> \u2014 \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043e\u043f\u0438\u0448\u0435\u043c \u043d\u0430 Assembly. \u041e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u043f\u0440\u0438 <code>int 0x80<\/code>.<\/p>\n<h3>2) Assembly: syscall_entry<\/h3>\n<p>\u042d\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u0441\u043b\u043e\u0439 \u2014 \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b, \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>syscall_handler<\/code>.<\/p>\n<pre><code class=\"assembly\">global_asm!(     r#\"     .att_syntax .globl syscall_entry .text syscall_entry:     \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b     push %rax      \/\/ [rsp+0]     push %rdi      \/\/ [rsp+8]     push %rsi      \/\/ [rsp+16]     push %rdx      \/\/ [rsp+24]     push %rcx      \/\/ [rsp+32]     push %r8       \/\/ [rsp+40]     push %r9       \/\/ [rsp+48]     push %r10     push %r11      \/\/ \u0420\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u043e \u0441\u0442\u0435\u043a\u0443     mov 64(%rsp), %rdi   \/\/ syscall number (\u0438\u0437 RAX)     mov 56(%rsp), %rsi   \/\/ arg1 (\u0438\u0437 RDI)     mov 48(%rsp), %rdx   \/\/ arg2 (\u0438\u0437 RSI)     mov 40(%rsp), %rcx   \/\/ arg3 (\u0438\u0437 RDX)     mov 32(%rsp), %r8    \/\/ arg4 (\u0438\u0437 RCX)     mov 24(%rsp), %r9    \/\/ arg5 (\u0438\u0437 R8)      \/\/ \u0412\u044b\u0437\u043e\u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430     mov $syscall_handler, %rax     call *%rax      \/\/ \u0412\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b     pop %r11     pop %r10     pop %r9     pop %r8     pop %rcx     pop %rdx     pop %rsi     pop %rdi     pop %rax      iretq \"# );<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u0431\u043b\u043e\u043a <code>syscall_entry<\/code>, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 Assembly. \u042d\u0442\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0430\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 <strong>\u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/strong> \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430 (\u0438\u043b\u0438 \u043a\u043e\u0434\u0430 \u0443\u0440\u043e\u0432\u043d\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f) \u043d\u0430 <strong>\u044f\u0434\u0440\u043e<\/strong>, \u0438 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e <strong>\u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e<\/strong>.<\/p>\n<h3>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 syscall_entry<\/h3>\n<pre><code class=\"assembly\">global_asm!(     r#\"     .att_syntax .globl syscall_entry .text syscall_entry:<\/code><\/pre>\n<h4>\u042d\u0442\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430<\/h4>\n<ul>\n<li>\n<p><code>.att_syntax<\/code> \u2014 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043d\u0430 AT&amp;T (\u043f\u0440\u0438\u043d\u044f\u0442 \u0432 GCC).<\/p>\n<\/li>\n<li>\n<p><code>.globl syscall_entry<\/code> \u2014 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442 <code>syscall_entry<\/code> \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u0438\u0437\u0432\u043d\u0435.<\/p>\n<\/li>\n<li>\n<p><code>.text<\/code> \u2014 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435 \u0438\u0434\u0451\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<\/li>\n<\/ul>\n<h4>\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b<\/h4>\n<pre><code class=\"assembly\">    push %rax      \/\/ [rsp+0]     push %rdi      \/\/ [rsp+8]     push %rsi      \/\/ [rsp+16]     push %rdx      \/\/ [rsp+24]     push %rcx      \/\/ [rsp+32]     push %r8       \/\/ [rsp+40]     push %r9       \/\/ [rsp+48]     push %r10     push %r11<\/code><\/pre>\n<p><strong>\u0417\u0430\u0447\u0435\u043c:<\/strong> \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>int 0x80<\/code>, \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0432\u0441\u0435 \u0435\u0451 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0431\u0443\u0434\u0443\u0442 \u0442\u0430\u043a\u0438\u043c\u0438 \u0436\u0435, \u043a\u0430\u043a \u0434\u043e \u043d\u0435\u0433\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 <strong>\u043c\u044b \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c<\/strong> \u0438\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0432 \u0441\u0442\u0435\u043a\u0435.<\/p>\n<p>\u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f <strong>\u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430<\/strong>: \u0435\u0441\u043b\u0438 \u043c\u044b \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c, syscall \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u0440\u0435\u0434\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430.<\/p>\n<h4>\u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b<\/h4>\n<pre><code class=\"assembly\">    mov 64(%rsp), %rdi   \/\/ syscall number (\u0438\u0437 RAX)     mov 56(%rsp), %rsi   \/\/ arg1 (\u0438\u0437 RDI)     mov 48(%rsp), %rdx   \/\/ arg2 (\u0438\u0437 RSI)     mov 40(%rsp), %rcx   \/\/ arg3 (\u0438\u0437 RDX)     mov 32(%rsp), %r8    \/\/ arg4 (\u0438\u0437 RCX)     mov 24(%rsp), %r9    \/\/ arg5 (\u0438\u0437 R8)<\/code><\/pre>\n<p><strong>\u041e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435:<\/strong> \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0431\u044b\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u043f\u0435\u0440\u0435\u0434 <code>int 0x80<\/code>, \u043d\u043e <strong>\u043c\u044b \u0443\u0436\u0435 \u0438\u0445 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u043b\u0438 <\/strong><code><strong>push<\/strong><\/code><strong>-\u0430\u043c\u0438<\/strong>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0441\u0442\u0430\u0451\u043c \u0441\u0442\u0430\u0440\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0441\u0442\u0435\u043a\u0430:<\/p>\n<ul>\n<li>\n<p><code>%rdi<\/code> \u2190 <code>%rax<\/code> (\u043d\u043e\u043c\u0435\u0440 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430)<\/p>\n<\/li>\n<li>\n<p><code>%rsi<\/code> \u2190 <code>%rdi<\/code> (1-\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442)<\/p>\n<\/li>\n<li>\n<p>\u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435\u2026<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0442\u0435\u043a \u0440\u0430\u0441\u0442\u0451\u0442 \u0432\u043d\u0438\u0437, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <code>64(%rsp)<\/code> \u2014 \u044d\u0442\u043e \u0432\u0435\u0440\u0445\u043d\u044f\u044f \u0442\u043e\u0447\u043a\u0430, \u0433\u0434\u0435 \u043b\u0435\u0436\u0438\u0442 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 <code>rax<\/code>.<\/p>\n<h4>\u0412\u044b\u0437\u043e\u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430<\/h4>\n<pre><code class=\"assembly\">    mov $syscall_handler, %rax     call *%rax<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>syscall_handler<\/code>, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u043d\u0430 Rust. \u0412\u0441\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0443\u0436\u0435 \u043b\u0435\u0436\u0430\u0442 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0445, \u043a\u0430\u043a \u0442\u0440\u0435\u0431\u0443\u0435\u0442 <strong>\u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435 \u043e \u0432\u044b\u0437\u043e\u0432\u0430\u0445 System V ABI (Linux)<\/strong>:<\/p>\n<ul>\n<li>\n<p><code>%rdi<\/code> \u2192 1-\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442<\/p>\n<\/li>\n<li>\n<p><code>%rsi<\/code> \u2192 2-\u0439<\/p>\n<\/li>\n<li>\n<p><code>%rdx<\/code> \u2192 3-\u0439<\/p>\n<\/li>\n<li>\n<p><code>%rcx<\/code> \u2192 4-\u0439<\/p>\n<\/li>\n<li>\n<p><code>%r<\/code><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-464430","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/464430","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=464430"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/464430\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=464430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=464430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=464430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}