{"id":356927,"date":"2024-05-20T23:39:58","date_gmt":"2024-05-20T23:39:58","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=356927"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-20T23:39:58","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=356927","title":{"rendered":"<span>\u041f\u0438\u0448\u0435\u043c printf \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430 FASM<\/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<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430, \u0438 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0441\u043f\u043e\u043d\u0442\u0430\u043d\u043d\u043e, \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0438\u043a\u043e\u0435 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u0438\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u043e &#171;\u0447\u0442\u043e-\u043b\u0438\u0431\u043e&#187; \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0438 \u0432\u044b\u0448\u0435. \u0422\u0430\u043a \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0430\u043d\u0435\u0435 \u0438\u0437-\u0437\u0430 \u0442\u0430\u043a\u043e\u0433\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u044f \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0442\u0435\u043a\u043e\u0432\u0443\u044e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0433\u043b\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u0431\u0430\u0439\u0442-\u043a\u043e\u0434 \u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c, \u0434\u0430\u043b\u0435\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0433 \u0431\u044b \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044f\u0437\u044b\u043a \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430 \u0432 \u044d\u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u0431\u0430\u0439\u0442-\u043a\u043e\u0434, \u0430 \u043f\u043e\u0441\u043b\u0435 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 <a href=\"https:\/\/habr.com\/ru\/articles\/703036\/\" rel=\"noopener noreferrer nofollow\">LISP-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u044f\u0437\u044b\u043a<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u0440\u0430\u043d\u0435\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b.<\/p>\n<p>\u0418 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043d\u0430 \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0442\u044f\u0433\u0435 \u0436\u0435\u043b\u0430\u043d\u0438\u044f \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0438\u0434\u0435\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u043d\u0443\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>printf<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0434\u0430\u043b\u0435\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043a \u044f\u0437\u044b\u043a\u0443 \u0421\u0438 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0435\u044e \u043d\u0430 \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u0435 \u0431\u0435\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a. \u0418 \u0437\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c\u0441\u044f \u0432\u043f\u043e\u043b\u043d\u0435 \u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c &#8212; \u0437\u0430\u0447\u0435\u043c \u0438 \u0434\u043b\u044f \u0447\u0435\u0433\u043e? \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b \u0434\u0432\u0430 \u043e\u0442\u0432\u0435\u0442\u0430: 1) \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u044b\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e; 2) printf \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u0430\u043c, \u0438\u0437\u0443\u0447\u0430\u044e\u0449\u0438\u043c \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440. <\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u0443\u043d\u043a\u0442 \u0432\u0441\u0451 \u0436\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0439. \u041d\u0430 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u0430\u0445 \u041e\u0410\u0438\u041f (\u043e\u0441\u043d\u043e\u0432\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f) \u0438\u043b\u0438 \u0410\u0410\u0421 (\u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u0440\u0435\u0434\u0441\u0442\u0432) \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u0430\u043c \u0438\u043d\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0430\u0442\u044c \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443. \u0418 \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0438, \u0442\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0438\u043d\u0443\u0442\/\u0447\u0430\u0441\u043e\u0432 \u043d\u0430 \u043f\u043e\u0438\u0441\u043a \u0431\u0430\u0433\u0430. \u0421 \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a\u0430\u043c\u0438 \u043d\u0435 \u0432\u0441\u0435 \u0443\u043c\u0435\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043d\u043e \u0441 \u043f\u0440\u0438\u043d\u0442\u0430\u043c\u0438 \u0432\u0441\u0435 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u043e. \u0418 \u0434\u0430\u043d\u043d\u044b\u0439 printf \u043c\u043e\u0436\u0435\u0442 \u043a\u0430\u043a \u0440\u0430\u0437 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u044d\u0442\u0443 \u0441\u0430\u043c\u0443\u044e \u0440\u043e\u043b\u044c &#8212; \u0447\u0442\u043e\u0431\u044b \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u0430, \u0441\u0442\u0440\u043e\u043a\u0438, \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0435 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0445.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8a8\/7a3\/b86\/8a87a3b86a45443cf84154ceb2a1c2a6.png\" width=\"1333\" height=\"450\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8a8\/7a3\/b86\/8a87a3b86a45443cf84154ceb2a1c2a6.png\"\/><\/figure>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>\u041d\u0430\u0448 printf \u0431\u0443\u0434\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u044b\u043c \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u043c \u043b\u0438\u0448\u044c \u0442\u0440\u0435\u043c\u044f-\u0447\u0435\u0442\u044b\u0440\u044c\u043c\u044f \u0441\u043f\u0435\u0446-\u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438: <code>%s<\/code>, <code>%c<\/code>, <code>%d<\/code> \u0438 <code>%%<\/code>. \u042f \u043d\u0435 \u0441\u0442\u0430\u043b \u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0438\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 <code>%f<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u0434\u0430\u043b\u0438\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 <code>%x<\/code> (<strong>hex<\/strong>, 16-\u044b\u043c\u0438), <code>%o<\/code> (<strong>oct<\/strong>, 8-\u044b\u043c\u0438) \u0438 <code>%b<\/code> (<strong>bin<\/strong>, 2-\u044b\u043c\u0438) \u0447\u0438\u0441\u043b\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u0438 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c. \u0422\u0430\u043a\u0436\u0435 \u0432\u0435\u0441\u044c \u043d\u0438\u0436\u0435\u0438\u0437\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, \u0441\u043a\u043e\u0440\u0435\u0435 \u0434\u0430\u0436\u0435 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0434\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0441\u0432\u043e\u0435\u0433\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435 \u0441 \u0447\u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043d\u0430\u0447\u0430\u0442\u044c &#8212; \u044d\u0442\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441 \u0441\u0430\u043c\u043e\u0439 \u043f\u0435\u0447\u0430\u0442\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0430 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432. \u0412\u0435\u0441\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043d\u0430 <strong>Linux<\/strong> \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 \u0441 <strong>64-\u0431\u0438\u0442\u043d\u043e\u0439<\/strong> \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043e\u0439. \u041d\u043e \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043f\u0443\u0433\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u0433\u043e \u0444\u0430\u043a\u0442\u0430, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u041e\u0421 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f Linux&#8217;\u043e\u043c. \u0421\u0443\u0442\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u043c\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c \u0432\u044b\u0437\u043e\u0432\u0430\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043b\u0438\u0448\u044c \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043a\u043e\u0434\u0430. \u0412\u0435\u0441\u044c \u0436\u0435 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0439\u0441\u044f \u043a\u043e\u0434 &#8212; \u044d\u0442\u043e \u0447\u0438\u0441\u0442\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u0434 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <strong>Windows<\/strong>, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043b\u0438\u0448\u044c \u044d\u0442\u0443 \u043c\u0430\u043b\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430, \u043d\u0435 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435. <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0435\u0447\u0430\u0442\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u041d\u0430 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u0441\u0435 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0435\u0441\u043b\u0438 \u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0434 \u0434\u0440\u0443\u0433\u0443\u044e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0443, \u0442\u043e \u0432\u0441\u0451 \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c &#8212; \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c <code>print_char<\/code>.<\/p>\n<pre><code class=\"assembly\">section '.print_char' executable ; | input ; rax = char print_char:     push rax     push rdx     push rsi     push rdi      push rax          mov rsi, rsp ; \u043d\u0430\u0447\u0430\u043b\u043e \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0430\u043c\u044f\u0442\u0438     mov rdi, 1   ; 1 \u0431\u0430\u0439\u0442     mov rdx, 1   ; stdout     mov rax, 1   ; write     call do_syscall      pop rax      pop rdi     pop rsi     pop rdx     pop rax     ret  section '.do_syscall' executable do_syscall:     ; syscall rewrite (rcx, r11)     push rcx     push r11       syscall      pop r11      pop rcx      ret <\/code><\/pre>\n<p>\u0412 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 amd64 \u043d\u0435\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u043f\u043e \u043f\u043e\u0434\u043e\u0431\u0438\u044e <strong>pusha \/ popa<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0432 \u0441\u0442\u0435\u043a \u0438 \u0432\u044b\u0433\u0440\u0443\u0437\u0438\u043b\u0438 \u0438\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451 \u0432\u0440\u0443\u0447\u043d\u0443\u044e. \u0414\u0430\u043b\u0435\u0435, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 <strong>rax<\/strong> \u043a\u043b\u0430\u0434\u0451\u0442\u0441\u044f \u0432 \u0441\u0442\u0435\u043a, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b 64-\u0431\u0438\u0442\u043d\u044b\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0441\u043c\u043e\u0433 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0441\u0438\u043c\u0432\u043e\u043b \u0438\u0437 \u0441\u0442\u0435\u043a\u0430. \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043f\u043e\u0434 Linux x86-64 \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f <a href=\"https:\/\/chromium.googlesource.com\/chromiumos\/docs\/+\/master\/constants\/syscalls.md#x86_64-64_bit\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <strong>syscall<\/strong> \u0431\u044b\u043b \u043e\u0431\u0451\u0440\u043d\u0443\u0442 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 <strong>do_syscall<\/strong>. \u0421\u0443\u0442\u044c \u0442\u0430\u043a\u043e\u0433\u043e \u043c\u0430\u043d\u0451\u0432\u0440\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e 64-\u0431\u0438\u0442\u043d\u044b\u0439 syscall \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u043d\u0435\u044f\u0432\u043d\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b <strong>rcx<\/strong> \u0438 <strong>r11<\/strong>, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435. <\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b `print_char`<\/summary>\n<div class=\"spoiler__content\">\n<p><strong>\u041a\u043e\u0434<\/strong><\/p>\n<pre><code class=\"assembly\">; main.asm format ELF64  public _start  section '.text' executable _start:     mov rax, 'h'     call print_char     mov rax, 'e'     call print_char     mov rax, 'l'     call print_char     mov rax, 'l'     call print_char     mov rax, 'o'     call print_char     mov rax, 0xA     call print_char exit:     mov rax, 60     xor rdi, rdi      syscall   section '.print_char' executable ; | input ; rax = char print_char:     push rax     push rdx     push rsi     push rdi      push rax          mov rsi, rsp     mov rdi, 1     mov rdx, 1     mov rax, 1     call do_syscall      pop rax      pop rdi     pop rsi     pop rdx     pop rax     ret  section '.do_syscall' executable do_syscall:     push rcx     push r11       syscall      pop r11      pop rcx      ret <\/code><\/pre>\n<p><strong>\u0417\u0430\u043f\u0443\u0441\u043a<\/strong><\/p>\n<pre><code>$ fasm main.asm &amp;&amp; ld main.o -o main &amp;&amp; .\/main flat assembler  version 1.73.31  (16384 kilobytes memory, x64) 3 passes, 1168 bytes. hello<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0438\u0437 \u043f\u0435\u0447\u0430\u0442\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u043f\u0435\u0447\u0430\u0442\u044c \u0446\u0435\u043b\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. \u0425\u043e\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <strong>write<\/strong> \u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u0441\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u0447\u0442\u043e \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0432\u044b\u0432\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0437 \u043f\u043e\u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0434\u0430\u0451\u0442 \u0434\u0432\u0430 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430: 1) \u0432\u044b\u0432\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c \u043e\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432; 2) \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u0434\u043e\u043f. \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0432 \u043b\u0438\u0446\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 &#8212; \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0447\u0438\u0442\u0430\u0442\u044c \u043b\u0438\u0448\u044c \u0434\u043e \u043d\u0443\u043b\u0435\u0432\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 (\u0441\u0442\u0430\u0440\u044b\u0439 \u0434\u043e\u0431\u0440\u044b\u0439 \u0421\u0438\u0448\u043d\u044b\u0439 \u0441\u0442\u0438\u043b\u044c).<\/p>\n<pre><code class=\"assembly\">section '.print_string' executable ; | input ; rax = string print_string:     push rbx     xor rbx, rbx     .next_iter:         cmp [rax+rbx], byte 0         je .close         push rax          mov rax, [rax+rbx]         call print_char         pop rax          inc rbx         jmp .next_iter     .close:         pop rbx         ret<\/code><\/pre>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b <code>print_string<\/code> \u043a\u0440\u0430\u0439\u043d\u0435 \u043f\u0440\u043e\u0441\u0442:<\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c <strong>i-\u044b\u0439<\/strong> \u0441\u0438\u043c\u0432\u043e\u043b \u0432 \u0441\u0442\u0440\u043e\u043a\u0435,<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 <strong>i-\u044b\u0439<\/strong> \u0441\u0438\u043c\u0432\u043e\u043b \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u0435\u0432\u043e\u043c\u0443, \u0442\u043e\u0433\u0434\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435,<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0441\u0438\u043c\u0432\u043e\u043b (print_char),<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>i<\/strong>,<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u043f\u0443\u043d\u043a\u0442 [1].<\/p>\n<\/li>\n<\/ol>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b `print_string`<\/summary>\n<div class=\"spoiler__content\">\n<p><strong>\u041a\u043e\u0434<\/strong><\/p>\n<pre><code class=\"assembly\">; main.asm format ELF64  public _start  section '.data' writeable     string db \"hello\", 0xA, 0  section '.text' executable _start:     mov rax, string      call print_string exit:     mov rax, 60     xor rdi, rdi      syscall   section '.print_string' executable ; | input ; rax = string print_string:     push rbx     xor rbx, rbx     .next_iter:         cmp [rax+rbx], byte 0         je .close         push rax          mov rax, [rax+rbx]         call print_char         pop rax          inc rbx         jmp .next_iter     .close:         pop rbx         ret  section '.print_char' executable ; | input ; rax = char print_char:     push rax     push rdx     push rsi     push rdi      push rax          mov rsi, rsp     mov rdi, 1     mov rdx, 1     mov rax, 1     call do_syscall      pop rax      pop rdi     pop rsi     pop rdx     pop rax     ret  section '.do_syscall' executable do_syscall:     push rcx     push r11       syscall      pop r11      pop rcx      ret  <\/code><\/pre>\n<p><strong>\u0417\u0430\u043f\u0443\u0441\u043a<\/strong><\/p>\n<pre><code>fasm main.asm &amp;&amp; ld main.o -o main &amp;&amp; .\/main                                               \ue0b2 INT \u2718  flat assembler  version 1.73.31  (16384 kilobytes memory, x64) 4 passes, 1240 bytes. $ hello<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u0443\u0436\u0435 \u0432\u044b\u0432\u043e\u0434 \u0441\u0438\u043c\u0432\u043e\u043b\u0430, \u0432\u044b\u0432\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0448\u044c \u0432\u044b\u0432\u043e\u0434 \u0447\u0438\u0441\u043b\u0430 \u0438 \u043f\u043e\u0441\u043b\u0435 \u0443\u0436\u0435 \u0432\u0441\u0451 \u044d\u0442\u043e \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 printf \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0412\u044b\u0432\u043e\u0434 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u043d\u0443\u0436\u043d\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u043f\u043e\u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e \u0446\u0438\u0444\u0440\u0430-\u0437\u0430-\u0446\u0438\u0444\u0440\u043e\u0439 \u0432\u0441\u0451 \u0447\u0438\u0441\u043b\u043e, \u043d\u043e \u0438 \u0442\u0430\u043a\u0436\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0435 \u0447\u0438\u0441\u043b\u043e &#8212; \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0438\u043b\u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435. <\/p>\n<pre><code class=\"assembly\">section '.print_decimal' executable ; | input: ; rax = number print_decimal:     push rax     push rbx     push rcx     push rdx     xor rcx, rcx     cmp rax, 0     jl .is_minus     jmp .next_iter     .is_minus:         neg rax         push rax         mov rax, '-'         call print_char         pop rax     .next_iter:         mov rbx, 10         xor rdx, rdx         div rbx         push rdx         inc rcx         cmp rax, 0         je .print_iter         jmp .next_iter     .print_iter:         cmp rcx, 0         je .close         pop rax         add rax, '0'         call print_char         dec rcx         jmp .print_iter     .close:         pop rdx         pop rcx         pop rbx         pop rax         ret<\/code><\/pre>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b <code>print_decimal<\/code> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:<\/p>\n<ol>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e <strong>\u043c\u0435\u043d\u044c\u0448\u0435 \u043d\u0443\u043b\u044f<\/strong>, \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0441\u0438\u043c\u0432\u043e\u043b <strong>\u043c\u0438\u043d\u0443\u0441<\/strong>,<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u043d\u0430 <strong>10<\/strong>, \u0432\u0437\u044f\u0442\u044c <strong>\u0447\u0430\u0441\u0442\u043d\u043e\u0435<\/strong> \u0438 <strong>\u043e\u0441\u0442\u0430\u0442\u043e\u043a<\/strong> \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f,<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u043e\u0436\u0438\u0442\u044c <strong>\u043e\u0441\u0442\u0430\u0442\u043e\u043a<\/strong> \u0432 \u0441\u0442\u0435\u043a,<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c <strong>\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/strong> <strong>i<\/strong>,<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 <strong>\u0447\u0430\u0441\u0442\u043d\u043e\u0435<\/strong> \u043d\u0435 \u0440\u0430\u0432\u043d\u043e 0, \u0442\u043e\u0433\u0434\u0430  \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u043f\u0443\u043d\u043a\u0442 [2],<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 <strong>\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 i<\/strong> \u0440\u0430\u0432\u043d\u043e 0, \u0442\u043e\u0433\u0434\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435,<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0438\u0437 \u0441\u0442\u0435\u043a\u0430 (\u043e\u0441\u0442\u0430\u0442\u043e\u043a),<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u043e\u0441\u0442\u0430\u0442\u043a\u0443 <strong>\u0441\u0438\u043c\u0432\u043e\u043b &#8216;0&#8217;<\/strong> (\u0447\u0438\u0441\u043b\u043e 48 \u043f\u043e ASCII),<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u0441\u0438\u043c\u0432\u043e\u043b (print_char),<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c <strong>\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 i<\/strong>,<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u043f\u0443\u043d\u043a\u0442 [6].<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u043e\u0438\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442 &#8212; \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 <code>print_decimal<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 64-\u0431\u0438\u0442\u043d\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438, \u0430 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0430\u043a\u0442\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0448\u044c \u043a\u043e\u0433\u0434\u0430 \u0442\u0430\u043a\u043e\u0432\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 64-\u0431\u0438\u0442\u043d\u044b\u043c. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e 32-\u0431\u0438\u0442\u043d\u043e\u0435 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435, \u0442\u043e \u043e\u043d\u043e \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b 64-\u0431\u0438\u0442\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0430\u043a\u0442\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a <strong>unsigned<\/strong>, \u0442\u043e \u0435\u0441\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0431\u0435\u0437 \u0437\u043d\u0430\u043a\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b `print_decimal`<\/summary>\n<div class=\"spoiler__content\">\n<p><strong>\u041a\u043e\u0434<\/strong><\/p>\n<pre><code class=\"assembly\">; main.asm format ELF64  public _start  section '.text' executable _start:     mov rax, 571      call print_decimal     mov rax, 0xA     call print_char exit:     mov rax, 60     xor rdi, rdi      syscall   section '.print_decimal' executable ; | input: ; rax = number print_decimal:     push rax     push rbx     push rcx     push rdx     xor rcx, rcx     cmp rax, 0     jl .is_minus     jmp .next_iter     .is_minus:         neg rax         push rax         mov rax, '-'         call print_char         pop rax     .next_iter:         mov rbx, 10         xor rdx, rdx         div rbx         add rdx, '0'         push rdx         inc rcx         cmp rax, 0         je .print_iter         jmp .next_iter     .print_iter:         cmp rcx, 0         je .close         pop rax         call print_char         dec rcx         jmp .print_iter     .close:         pop rdx         pop rcx         pop rbx         pop rax         ret  section '.print_char' executable ; | input ; rax = char print_char:     push rax     push rdx     push rsi     push rdi      push rax          mov rsi, rsp     mov rdi, 1     mov rdx, 1     mov rax, 1     call do_syscall      pop rax      pop rdi     pop rsi     pop rdx     pop rax     ret  section '.do_syscall' executable do_syscall:     push rcx     push r11       syscall      pop r11      pop rcx      ret  <\/code><\/pre>\n<p><strong>\u0417\u0430\u043f\u0443\u0441\u043a<\/strong><\/p>\n<pre><code>$ fasm main.asm &amp;&amp; ld main.o -o main &amp;&amp; .\/main                                                         \ue0b2 \u2714  flat assembler  version 1.73.31  (16384 kilobytes memory, x64) 4 passes, 1224 bytes. 571<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u043c\u044b \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0444\u0438\u043d\u0430\u043b\u0443 &#8212; \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 printf. \u0417\u0434\u0435\u0441\u044c \u043b\u043e\u0433\u0438\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0431\u044b\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b. \u041e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u0441\u0435 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043e\u0434\u043d\u0443 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e.<\/p>\n<pre><code class=\"assembly\">section '.printf' executable ; | input: ; rax = format ; stack = values ; | output: ; rax = count printf:     push rbx     push rcx      ; call\/ret    = 8byte     ; rax+rbx+rcx = 24byte     mov rbx, 32      ; count of format elements     xor rcx, rcx      .next_iter:         cmp [rax], byte 0         je .close         cmp [rax], byte '%'         je .special_char         jmp .default_char         .special_char:             inc rax             cmp [rax], byte 's'             je .print_string             cmp [rax], byte 'd'             je .print_decimal             cmp [rax], byte 'c'             je .print_char             cmp [rax], byte '%'             je .default_char             jmp .is_error         .print_string:             push rax             mov rax, [rsp+rbx]             call print_string             pop rax             jmp .shift_stack         .print_decimal:             push rax             mov rax, [rsp+rbx]             call print_decimal             pop rax             jmp .shift_stack         .print_char:             push rax             mov rax, [rsp+rbx]             call print_char             pop rax             jmp .shift_stack         .default_char:             push rax             mov rax, [rax]             call print_char             pop rax             jmp .next_step         .shift_stack:             inc rcx             add rbx, 8         .next_step:             inc rax             jmp .next_iter     .is_error:         mov rcx, -1     .close:         mov rax, rcx         pop rcx         pop rbx         ret<\/code><\/pre>\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u0434\u0430 \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441 \u043f\u0440\u043e\u0448\u043b\u044b\u043c\u0438 \u043a\u043e\u0434\u0430\u043c\u0438, \u043b\u043e\u0433\u0438\u043a\u0430 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0439:<\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c <strong>i-\u044b\u0439<\/strong> \u0441\u0438\u043c\u0432\u043e\u043b \u0432 \u0441\u0442\u0440\u043e\u043a\u0435,<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0438\u043c\u0432\u043e\u043b \u0440\u0430\u0432\u0435\u043d <strong>%<\/strong>, \u0442\u043e\u0433\u0434\u0430 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u043f\u0443\u043d\u043a\u0442 [7],<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0438\u043c\u0432\u043e\u043b \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e, \u0442\u043e\u0433\u0434\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435,<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0430\u0447\u0435, \u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c <strong>i-\u044b\u0439<\/strong> \u0441\u0438\u043c\u0432\u043e\u043b,<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>i<\/strong>,<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u043f\u0443\u043d\u043a\u0442 [1],<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>i<\/strong>,<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 <strong>i-\u044b\u0439<\/strong> \u0441\u0438\u043c\u0432\u043e\u043b \u0440\u0430\u0432\u0435\u043d <strong>%<\/strong>, \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0435\u0433\u043e,<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 <strong>i-\u044b\u0439<\/strong> \u0441\u0438\u043c\u0432\u043e\u043b \u0440\u0430\u0432\u0435\u043d <strong>d<\/strong>, \u0442\u043e\u0433\u0434\u0430 \u0432\u0437\u044f\u0442\u044c \u0438\u0437 \u0441\u0442\u0435\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e (print_decimal),<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 <strong>i-\u044b\u0439<\/strong> \u0441\u0438\u043c\u0432\u043e\u043b \u0440\u0430\u0432\u0435\u043d <strong>s<\/strong>, \u0442\u043e\u0433\u0434\u0430 \u0432\u0437\u044f\u0442\u044c \u0438\u0437 \u0441\u0442\u0435\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 (print_string),<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 <strong>i-\u044b\u0439<\/strong> \u0441\u0438\u043c\u0432\u043e\u043b \u0440\u0430\u0432\u0435\u043d <strong>c<\/strong>, \u0442\u043e\u0433\u0434\u0430 \u0432\u0437\u044f\u0442\u044c \u0438\u0437 \u0441\u0442\u0435\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0441\u0438\u043c\u0432\u043e\u043b (print_char),<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0430\u0447\u0435, \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u0438 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u043f\u0443\u043d\u043a\u0442 [3],<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>i<\/strong>,<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u043f\u0443\u043d\u043a\u0442 [1].<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u044f \u043d\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b \u043b\u0438\u0448\u044c \u043e\u0431 \u043e\u0434\u043d\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 &#8212; \u043f\u043e\u0434\u0441\u0447\u0451\u0442\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442-\u0441\u0442\u0440\u043e\u043a, \u0442\u043e \u0435\u0441\u0442\u044c <code>%c<\/code>, <code>%s<\/code>, <code>%d<\/code>, <code>%%<\/code>.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b `printf`<\/summary>\n<div class=\"spoiler__content\">\n<p><strong>\u041a\u043e\u0434<\/strong><\/p>\n<pre><code class=\"assembly\">; main.asm format ELF64 public _start  extrn printf  section '.data' writeable     input   db \"{ %s, %d%c }\", 0xA, 0     string  db \"hello\", 0     decimal dq 571     symbol  dq '!'  section '.text' executable _start:     mov rax, input     push [symbol]     push [decimal]     push string     call printf exit:     mov rax, 60     xor rdi, rdi      syscall <\/code><\/pre>\n<pre><code class=\"assembly\">; printf.asm format ELF64  include \"print_decimal.asm\" include \"print_string.asm\" include \"print_char.asm\"  public printf  section '.printf' executable ; | input: ; rax = format ; stack = values ; | output: ; rax = count printf:     push rbx     push rcx      ; call\/ret    = 8byte     ; rax+rbx+rcx = 24byte     mov rbx, 32      ; count of format elements     xor rcx, rcx      .next_iter:         cmp [rax], byte 0         je .close         cmp [rax], byte '%'         je .special_char         jmp .default_char         .special_char:             inc rax             cmp [rax], byte 's'             je .print_string             cmp [rax], byte 'd'             je .print_decimal             cmp [rax], byte 'c'             je .print_char             cmp [rax], byte '%'             je .default_char             jmp .is_error         .print_string:             push rax             mov rax, [rsp+rbx]             call print_string             pop rax             jmp .shift_stack         .print_decimal:             push rax             mov rax, [rsp+rbx]             call print_decimal             pop rax             jmp .shift_stack         .print_char:             push rax             mov rax, [rsp+rbx]             call print_char             pop rax             jmp .shift_stack         .default_char:             push rax             mov rax, [rax]             call print_char             pop rax             jmp .next_step         .shift_stack:             inc rcx             add rbx, 8         .next_step:             inc rax             jmp .next_iter     .is_error:         mov rcx, -1     .close:         mov rax, rcx         pop rcx         pop rbx         ret<\/code><\/pre>\n<pre><code class=\"assembly\">; print_char.asm section '.print_char' executable ; | input ; rax = char print_char:     push rax     push rdx     push rsi     push rdi      push rax          mov rsi, rsp     mov rdi, 1     mov rdx, 1     mov rax, 1     call do_syscall      pop rax      pop rdi     pop rsi     pop rdx     pop rax     ret  section '.do_syscall' executable do_syscall:     ; syscall rewrite (rcx, r11)     push rcx     push r11       syscall      pop r11      pop rcx      ret <\/code><\/pre>\n<pre><code class=\"assembly\">; print_string.asm section '.print_string' executable ; | input ; rax = string print_string:     push rbx     xor rbx, rbx     .next_iter:         cmp [rax+rbx], byte 0         je .close         push rax          mov rax, [rax+rbx]         call print_char         pop rax          inc rbx         jmp .next_iter     .close:         pop rbx         ret<\/code><\/pre>\n<pre><code class=\"assembly\">; print_decimal.asm section '.print_decimal' executable ; | input: ; rax = number print_decimal:     push rax     push rbx     push rcx     push rdx     xor rcx, rcx     cmp rax, 0     jl .is_minus     jmp .next_iter     .is_minus:         neg rax         push rax         mov rax, '-'         call print_char         pop rax     .next_iter:         mov rbx, 10         xor rdx, rdx         div rbx         push rdx         inc rcx         cmp rax, 0         je .print_iter         jmp .next_iter     .print_iter:         cmp rcx, 0         je .close         pop rax         add rax, '0'         call print_char         dec rcx         jmp .print_iter     .close:         pop rdx         pop rcx         pop rbx         pop rax         ret<\/code><\/pre>\n<p><strong>\u0417\u0430\u043f\u0443\u0441\u043a<\/strong><\/p>\n<pre><code>$ fasm main.asm &amp;&amp; fasm printf.asm flat assembler  version 1.73.31  (16384 kilobytes memory, x64) 1 passes, 816 bytes. flat assembler  version 1.73.31  (16384 kilobytes memory, x64) 6 passes, 1592 bytes. $ ld main.o printf.o -o main  $ .\/main { hello, 571! }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e printf. \u041f\u043e\u0436\u0430\u043b\u0443\u0439 \u0438\u0437 \u043d\u044e\u0430\u043d\u0441\u043e\u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0434\u0435\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u0447\u0442\u043e printf \u0447\u0438\u0442\u0430\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043d\u0435 \u0441\u0432\u0435\u0440\u0445\u0443-\u0432\u043d\u0438\u0437, \u0430 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 &#8212; \u0441\u043d\u0438\u0437\u0443-\u0432\u0432\u0435\u0440\u0445. \u0421\u0432\u044f\u0437\u0430\u043d\u043e \u044d\u0442\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0441\u0442\u0435\u043a, \u0433\u0434\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u043d\u0435\u0441\u0451\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043a \u044f\u0432\u043b\u044f\u043b\u043e\u0441\u044c \u043f\u0435\u0440\u0432\u044b\u043c \u0432\u0437\u044f\u0442\u044b\u043c \u0438\u0437 \u0441\u0442\u0435\u043a\u0430. \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043d\u0430\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 <strong>LIFO<\/strong> (last in, first out). \u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u043d, \u043a\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434. \u0421\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0421\u0438\u0448\u043a\u0438, \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c.<\/p>\n<h2>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c printf \u043a \u044f\u0437\u044b\u043a\u0443 \u0421\u0438<\/h2>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043d\u0430\u0448\u0435\u0439 \u0446\u0435\u043b\u044c\u044e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0431\u0443\u0434\u0435\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 printf \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u044f\u0437\u044b\u043a\u0430 \u0421\u0438. \u0417\u0430\u0434\u0430\u0447\u0430 \u043b\u0451\u0433\u043a\u0430\u044f \u0438 \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u043a \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044e <strong>ABI<\/strong> (application binary interface) \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0421\u0438\u0448\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430. \u0412 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 <strong>gcc<\/strong>. \u0422\u0440\u0430\u043a\u0442\u043e\u0432\u043a\u0430 \u043f\u0440\u0430\u0432\u0438\u043b ABI \u0434\u043b\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440 \u044f\u0437\u044b\u043a\u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430 \u0438 \u0421\u0438\u0448\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f:<\/p>\n<blockquote>\n<p>\u041f\u0435\u0440\u0432\u044b\u0435 \u0448\u0435\u0441\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0445: <strong>rdi, rsi, rdx, rcx, r8, r9<\/strong>,<\/p>\n<p>\u041e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u0432 <strong>\u0441\u0442\u0435\u043a<\/strong>,<\/p>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u0432 <strong>rax<\/strong>.<\/p>\n<\/blockquote>\n<p>\u0414\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b \u043d\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443-\u043e\u0431\u0451\u0440\u0442\u043a\u0443 \u043f\u043e\u0434 \u0443\u0436\u0435 \u0438\u043c\u0435\u044e\u0449\u0443\u044e\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044e printf. \u041d\u0430\u0437\u043e\u0432\u0451\u043c \u044d\u0442\u0443 \u043e\u0431\u0451\u0440\u0442\u043e\u0447\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u0430\u043a <code>c_printf<\/code>.<\/p>\n<pre><code class=\"assembly\">; c_printf.asm format ELF64  extrn printf  public c_printf  section '.c_printf' executable c_printf:     pop r10      push r9     push r8     push rcx     push rdx     push rsi      mov rax, rdi     call printf      pop rsi     pop rdx     pop rcx     pop r8     pop r9      push r10      ret  <\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u0441\u0451 \u043f\u043e \u043b\u043e\u0433\u0438\u043a\u0435 ABI, \u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0441\u0442\u0435\u043a \u043a\u043b\u0430\u0434\u0443\u0442\u0441\u044f \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435. \u0422\u0435\u043f\u0435\u0440\u044c, \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043d\u0430\u043c\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 printf, \u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0438\u0433\u0440\u0430\u0435\u0442 \u043d\u0430\u043c \u043b\u0438\u0448\u044c \u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0421\u0438\u0448\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0438\u0434\u0442\u0438 \u0441\u043b\u0435\u0432\u0430-\u043d\u0430\u043f\u0440\u0430\u0432\u043e, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a\u0430\u043a \u0438 \u043d\u0443\u0436\u043d\u043e.<\/p>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u0447\u0438\u0441\u0435\u043b \u0432 \u0441\u0442\u0435\u043a\u0435 \u0437\u0434\u0435\u0441\u044c \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u043a\u0438\u0439 \u0445\u0430\u043a \u0432 \u043b\u0438\u0446\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 <strong>r10<\/strong> \u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 <strong>call \/ ret<\/strong>. \u0421\u0443\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u0445\u0430\u043a\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e ABI \u0447\u0438\u0442\u0430\u0435\u0442 \u0432\u0441\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0443\u0436\u0435 \u0438\u0437 \u0441\u0442\u0435\u043a\u0430, \u043d\u043e \u0432 \u0441\u0442\u0435\u043a\u0435 \u0443 \u043d\u0430\u0441 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0435\u0434\u044c\u043c\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0445\u0440\u0430\u043d\u0438\u043b\u043e\u0441\u044c \u0431\u044b \u043d\u0435 \u043d\u0443\u0436\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0430 \u0430\u0434\u0440\u0435\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u0442\u0430\u0432\u0438\u0442 call \u0438 \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f ret. \u0414\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0434\u0435\u0441\u044c \u044f \u0436\u0435\u0440\u0442\u0432\u0443\u044e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u043c r10. <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0435\u0441\u043b\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0421\u0438\u0448\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441 \u043e\u043f\u0446\u0438\u0435\u0439 <code>-nostdlib<\/code>, \u0442\u043e \u0443 \u043d\u0430\u0441 \u0441\u0431\u0440\u043e\u0441\u044f\u0442\u0441\u044f \u0432\u0441\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430 (\u0442\u043e \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f main), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0432\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0442\u043e\u0447\u043a\u043e\u0439 \u0432\u0445\u043e\u0434\u0430, \u0442\u043e \u043f\u0440\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043d\u0443\u043b\u044f \u043e\u043d\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0430 \u043f\u043e\u0442\u043e\u043c\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 <strong>UB<\/strong> (undefined behaviour). \u0421 \u044d\u0442\u043e\u0439 \u0446\u0435\u043b\u044c\u044e \u043d\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 <code>c_exit<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u044b \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 main \u0441 \u043a\u043e\u0434\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.<\/p>\n<pre><code class=\"assembly\">; c_exit.asm format ELF64  public c_exit  section '.c_exit' executable c_exit:     mov rax, 60     syscall  <\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <strong>rdi<\/strong> \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0421\u0438\u0448\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0441\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u043e\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c \u0432\u044b\u0437\u043e\u0432\u043e\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0440\u043e\u043c\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u043e\u043c\u0435\u0440\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 <strong>= 60<\/strong> (exit). <\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0435\u0440\u0444\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0441\u0442\u0430\u043c \u043d\u0435 \u0447\u0438\u0442\u0430\u0442\u044c!<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043c\u0438\u043d\u0443\u0441 \u0432 \u043c\u0435\u0442\u043a\u0435 <code>c_exit<\/code>. \u042d\u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0435 \u0447\u0442\u043e \u0438\u043d\u043e\u0435, \u043a\u0430\u043a \u043c\u0435\u0442\u043a\u0430, \u043d\u043e \u0421\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c c_exit \u043a\u0430\u043a \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e <strong>call<\/strong>, \u0430 \u043d\u0435 <strong>jmp<\/strong>. \u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u0432 \u0441\u0442\u0435\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u043b\u0438\u0448\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u043d\u043e \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0438 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435, \u043d\u0438 \u043d\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b, \u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u043f\u0430\u0442\u044c \u043d\u0435\u0440\u0432\u044b \u043f\u0435\u0440\u0444\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0441\u0442\u0430\u043c \u043c\u043e\u0436\u0435\u0442.<\/p>\n<\/div>\n<\/details>\n<p>\u0418 \u0442\u0435\u043f\u0435\u0440\u044c, \u0432\u0441\u0451 \u0447\u0442\u043e \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c &#8212; \u044d\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0421\u0438\u0448\u043d\u044b\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u043b \u0434\u0432\u0435 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b: <code>c_printf<\/code> \u0438 <code>c_exit<\/code>.<\/p>\n<pre><code class=\"cpp\">\/\/ main.c typedef long long int int64_t;  extern void c_exit(int ret); extern int64_t c_printf(char *fmt, ...);  void _start(void) {     char *string = \"hello\";     int64_t decimal = 571;     char symbol = '!';      int64_t ret = c_printf(         \"{ %s, %d%c }\\n\",         string, decimal, symbol     );     c_printf(\"%d\\n\", ret); \/\/ 3      c_exit(0); } <\/code><\/pre>\n<p>\u0421\u0442\u043e\u0438\u0442 \u0437\u0434\u0435\u0441\u044c \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0435 \u0434\u0435\u0442\u0430\u043b\u0438: <\/p>\n<ol>\n<li>\n<p>\u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0442\u0438\u043f int64_t \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>c_printf<\/code>, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 int. \u0421\u0432\u044f\u0437\u0430\u043d\u043e \u044d\u0442\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b <code>c_printf<\/code> \u043d\u0430 <strong>16 \u0441\u0442\u0440\u043e\u0447\u043a\u0435<\/strong> \u043c\u043e\u0433 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u043e\u0448\u0438\u0431\u043a\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0421\u0432\u044f\u0437\u0430\u043d\u043e \u044d\u0442\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e %d \u0432 \u043d\u0430\u0448\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0435\u0441\u0442\u044c \u0447\u0438\u0441\u043b\u043e 64-\u0431\u0438\u0442\u043d\u043e\u0435,<\/p>\n<\/li>\n<li>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 main \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <strong>_start<\/strong>. \u0421\u0432\u044f\u0437\u0430\u043d\u043e \u044d\u0442\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u043e\u043f\u0446\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <code>-nostdlib<\/code> \u043f\u0440\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430 \u0432 \u043b\u0438\u0446\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 main. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0435 \u0432\u0445\u043e\u0434\u0430 _start \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>printf<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0441\u0435\u0445 <strong>\u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u043d\u043d\u044b\u0445<\/strong> \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043d\u0430\u043c\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e <strong>\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445<\/strong> \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 (\u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0441\u043e \u0441\u0442\u0435\u043a\u043e\u043c). \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0435\u0441\u043b\u0438 \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f <code>printf<\/code>, \u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 <strong>= 3<\/strong>, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0431\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 <strong>= 16<\/strong>.<\/p>\n<\/li>\n<\/ol>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c, \u043b\u0438\u043d\u043a\u0443\u0435\u043c, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<pre><code>$ fasm printf.asm &amp;&amp; fasm c_printf.asm &amp;&amp; fasm c_exit.asm flat assembler  version 1.73.31  (16384 kilobytes memory, x64) 6 passes, 1592 bytes. flat assembler  version 1.73.31  (16384 kilobytes memory, x64) 1 passes, 584 bytes. flat assembler  version 1.73.31  (16384 kilobytes memory, x64) 1 passes, 440 bytes. $ gcc -nostdlib -o main printf.o c_printf.o c_exit.o main.c  $ .\/main { hello, 571! } 3<\/code><\/pre>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0418 \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043c\u043e\u0433\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>printf<\/code> \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430 FASM. \u0425\u043e\u0442\u044c \u0434\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0443\u0440\u0435\u0437\u0430\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 printf, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043e\u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u0430 \u0432 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0438 \u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0430 \u043b\u0435\u0433\u043a\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c\u0441\u044f, \u0432\u0431\u0438\u0440\u0430\u044f \u0432 \u0441\u0435\u0431\u044f \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u043f\u0435\u0447\u0430\u0442\u044c \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439, \u0447\u0438\u0441\u0435\u043b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 hex, oct \u0438 \u0442.\u043f. \u0412\u0435\u0441\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434, \u0441 \u0441\u043e\u043f\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 <a href=\"https:\/\/github.com\/number571\/printf\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 Github<\/a>.<\/p>\n<\/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\/766044\/\"> https:\/\/habr.com\/ru\/articles\/766044\/<\/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<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430, \u0438 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0441\u043f\u043e\u043d\u0442\u0430\u043d\u043d\u043e, \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0438\u043a\u043e\u0435 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u0438\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u043e &#171;\u0447\u0442\u043e-\u043b\u0438\u0431\u043e&#187; \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0438 \u0432\u044b\u0448\u0435. \u0422\u0430\u043a \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0430\u043d\u0435\u0435 \u0438\u0437-\u0437\u0430 \u0442\u0430\u043a\u043e\u0433\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u044f \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0442\u0435\u043a\u043e\u0432\u0443\u044e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0433\u043b\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u0431\u0430\u0439\u0442-\u043a\u043e\u0434 \u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c, \u0434\u0430\u043b\u0435\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0433 \u0431\u044b \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044f\u0437\u044b\u043a \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430 \u0432 \u044d\u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u0431\u0430\u0439\u0442-\u043a\u043e\u0434, \u0430 \u043f\u043e\u0441\u043b\u0435 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 <a href=\"https:\/\/habr.com\/ru\/articles\/703036\/\" rel=\"noopener noreferrer nofollow\">LISP-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u044f\u0437\u044b\u043a<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u0440\u0430\u043d\u0435\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b.<\/p>\n<p>\u0418 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043d\u0430 \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0442\u044f\u0433\u0435 \u0436\u0435\u043b\u0430\u043d\u0438\u044f \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0438\u0434\u0435\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u043d\u0443\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>printf<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0434\u0430\u043b\u0435\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043a \u044f\u0437\u044b\u043a\u0443 \u0421\u0438 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0435\u044e \u043d\u0430 \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u0435 \u0431\u0435\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a. \u0418 \u0437\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c\u0441\u044f \u0432\u043f\u043e\u043b\u043d\u0435 \u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c &#8212; \u0437\u0430\u0447\u0435\u043c \u0438 \u0434\u043b\u044f \u0447\u0435\u0433\u043e? \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b \u0434\u0432\u0430 \u043e\u0442\u0432\u0435\u0442\u0430: 1) \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u044b\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e; 2) printf \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u0430\u043c, \u0438\u0437\u0443\u0447\u0430\u044e\u0449\u0438\u043c \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440. <\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u0443\u043d\u043a\u0442 \u0432\u0441\u0451 \u0436\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0439. \u041d\u0430 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u0430\u0445 \u041e\u0410\u0438\u041f (\u043e\u0441\u043d\u043e\u0432\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f) \u0438\u043b\u0438 \u0410\u0410\u0421 (\u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u0440\u0435\u0434\u0441\u0442\u0432) \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u0430\u043c \u0438\u043d\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0430\u0442\u044c \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443. \u0418 \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0438, \u0442\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0438\u043d\u0443\u0442\/\u0447\u0430\u0441\u043e\u0432 \u043d\u0430 \u043f\u043e\u0438\u0441\u043a \u0431\u0430\u0433\u0430. \u0421 \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a\u0430\u043c\u0438 \u043d\u0435 \u0432\u0441\u0435 \u0443\u043c\u0435\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043d\u043e \u0441 \u043f\u0440\u0438\u043d\u0442\u0430\u043c\u0438 \u0432\u0441\u0435 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u043e. \u0418 \u0434\u0430\u043d\u043d\u044b\u0439 printf \u043c\u043e\u0436\u0435\u0442 \u043a\u0430\u043a \u0440\u0430\u0437 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u044d\u0442\u0443 \u0441\u0430\u043c\u0443\u044e \u0440\u043e\u043b\u044c &#8212; \u0447\u0442\u043e\u0431\u044b \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u0430, \u0441\u0442\u0440\u043e\u043a\u0438, \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0435 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0445.<\/p>\n<figure class=\"full-width\"><\/figure>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>\u041d\u0430\u0448 printf \u0431\u0443\u0434\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u044b\u043c \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u043c \u043b\u0438\u0448\u044c \u0442\u0440\u0435\u043c\u044f-\u0447\u0435\u0442\u044b\u0440\u044c\u043c\u044f \u0441\u043f\u0435\u0446-\u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438: <code>%s<\/code>, <code>%c<\/code>, <code>%d<\/code> \u0438 <code>%%<\/code>. \u042f \u043d\u0435 \u0441\u0442\u0430\u043b \u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0438\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 <code>%f<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u0434\u0430\u043b\u0438\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 <code>%x<\/code> (<strong>hex<\/strong>, 16-\u044b\u043c\u0438), <code>%o<\/code> (<strong>oct<\/strong>, 8-\u044b\u043c\u0438) \u0438 <code>%b<\/code> (<strong>bin<\/strong>, 2-\u044b\u043c\u0438) \u0447\u0438\u0441\u043b\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u0438 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c. \u0422\u0430\u043a\u0436\u0435 \u0432\u0435\u0441\u044c \u043d\u0438\u0436\u0435\u0438\u0437\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, \u0441\u043a\u043e\u0440\u0435\u0435 \u0434\u0430\u0436\u0435 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0434\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0441\u0432\u043e\u0435\u0433\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435 \u0441 \u0447\u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043d\u0430\u0447\u0430\u0442\u044c &#8212; \u044d\u0442\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441 \u0441\u0430\u043c\u043e\u0439 \u043f\u0435\u0447\u0430\u0442\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0430 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432. \u0412\u0435\u0441\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043d\u0430 <strong>Linux<\/strong> \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 \u0441 <strong>64-\u0431\u0438\u0442\u043d\u043e\u0439<\/strong> \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043e\u0439. \u041d\u043e \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043f\u0443\u0433\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u0433\u043e \u0444\u0430\u043a\u0442\u0430, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u041e\u0421 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f Linux&#8217;\u043e\u043c. \u0421\u0443\u0442\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u043c\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c \u0432\u044b\u0437\u043e\u0432\u0430\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043b\u0438\u0448\u044c \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043a\u043e\u0434\u0430. \u0412\u0435\u0441\u044c \u0436\u0435 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0439\u0441\u044f \u043a\u043e\u0434 &#8212; \u044d\u0442\u043e \u0447\u0438\u0441\u0442\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u0434 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <strong>Windows<\/strong>, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043b\u0438\u0448\u044c \u044d\u0442\u0443 \u043c\u0430\u043b\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430, \u043d\u0435 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435. <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0435\u0447\u0430\u0442\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u041d\u0430 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u0441\u0435 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0435\u0441\u043b\u0438 \u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0434 \u0434\u0440\u0443\u0433\u0443\u044e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0443, \u0442\u043e \u0432\u0441\u0451 \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c &#8212; \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c <code>print_char<\/code>.<\/p>\n<pre><code class=\"assembly\">section '.print_char' executable ; | input ; rax = char print_char:     push rax     push rdx     push rsi     push rdi      push rax          mov rsi, rsp ; \u043d\u0430\u0447\u0430\u043b\u043e \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0430\u043c\u044f\u0442\u0438     mov rdi, 1   ; 1 \u0431\u0430\u0439\u0442     mov rdx, 1   ; stdout     mov rax, 1   ; write     call do_syscall      pop rax      pop rdi     pop rsi     pop rdx     pop rax     ret  section '.do_syscall' executable do_syscall:     ; syscall rewrite (rcx, r11)     push rcx     push r11       syscall      pop r11      pop rcx      ret <\/code><\/pre>\n<p>\u0412 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 amd64 \u043d\u0435\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u043f\u043e \u043f\u043e\u0434\u043e\u0431\u0438\u044e <strong>pusha \/ popa<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0432 \u0441\u0442\u0435\u043a \u0438 \u0432\u044b\u0433\u0440\u0443\u0437\u0438\u043b\u0438 \u0438\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451 \u0432\u0440\u0443\u0447\u043d\u0443\u044e. \u0414\u0430\u043b\u0435\u0435, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 <strong>rax<\/strong> \u043a\u043b\u0430\u0434\u0451\u0442\u0441\u044f \u0432 \u0441\u0442\u0435\u043a, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b 64-\u0431\u0438\u0442\u043d\u044b\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0441\u043c\u043e\u0433 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0441\u0438\u043c\u0432\u043e\u043b \u0438\u0437 \u0441\u0442\u0435\u043a\u0430. \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043f\u043e\u0434 Linux x86-64 \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f <a href=\"https:\/\/chromium.googlesource.com\/chromiumos\/docs\/+\/master\/constants\/syscalls.md#x86_64-64_bit\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <strong>syscall<\/strong> \u0431\u044b\u043b \u043e\u0431\u0451\u0440\u043d\u0443\u0442 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 <strong>do_syscall<\/strong>. \u0421\u0443\u0442\u044c \u0442\u0430\u043a\u043e\u0433\u043e \u043c\u0430\u043d\u0451\u0432\u0440\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e 64-\u0431\u0438\u0442\u043d\u044b\u0439 syscall \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u043d\u0435\u044f\u0432\u043d\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b <strong>rcx<\/strong> \u0438 <strong>r11<\/strong>, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435. <\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b `print_char`<\/summary>\n<div class=\"spoiler__content\">\n<p><strong>\u041a\u043e\u0434<\/strong><\/p>\n<pre><code class=\"assembly\">; main.asm format ELF64  public _start  section '.text' executable _start:     mov rax, 'h'     call print_char     mov rax, 'e'     call print_char     mov rax, 'l'     call print_char     mov rax, 'l'     call print_char     mov rax, 'o'     call print_char     mov rax, 0xA     call print_char exit:     mov rax, 60     xor rdi, rdi      syscall   section '.print_char' executable ; | input ; rax = char print_char:     push rax     push rdx     push rsi     push rdi      push rax          mov rsi, rsp     mov rdi, 1     mov rdx, 1     mov rax, 1     call do_syscall      pop rax      pop rdi     pop rsi     pop rdx     pop rax     ret  section '.do_syscall' executable do_syscall:     push rcx     push r11       syscall      pop r11      pop rcx      ret <\/code><\/pre>\n<p><strong>\u0417\u0430\u043f\u0443\u0441\u043a<\/strong><\/p>\n<pre><code>$ fasm main.asm &amp;&amp; ld main.o -o main &amp;&amp; .\/main flat assembler  version 1.73.31  (16384 kilobytes memory, x64) 3 passes, 1168 bytes. hello<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0438\u0437 \u043f\u0435\u0447\u0430\u0442\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u043f\u0435\u0447\u0430\u0442\u044c \u0446\u0435\u043b\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. \u0425\u043e\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <strong>write<\/strong> \u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u0441\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u0447\u0442\u043e \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0432\u044b\u0432\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0437 \u043f\u043e\u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0434\u0430\u0451\u0442 \u0434\u0432\u0430 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430: 1) \u0432\u044b\u0432\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c \u043e\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432; 2) \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u0434\u043e\u043f. \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0432 \u043b\u0438\u0446\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 &#8212; \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0447\u0438\u0442\u0430\u0442\u044c \u043b\u0438\u0448\u044c \u0434\u043e \u043d\u0443\u043b\u0435\u0432\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 (\u0441\u0442\u0430\u0440\u044b\u0439 \u0434\u043e\u0431\u0440\u044b\u0439 \u0421\u0438\u0448\u043d\u044b\u0439 \u0441\u0442\u0438\u043b\u044c).<\/p>\n<pre><code class=\"assembly\">section '.print_string' executable ; | input ; rax = string print_string:     push rbx     xor rbx, rbx     .next_iter:         cmp [rax+rbx], byte 0         je .close         push rax          mov rax, [rax+rbx]         call print_char         pop rax          inc rbx         jmp .next_iter     .close:         pop rbx         ret<\/code><\/pre>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b <code>print_string<\/code> \u043a\u0440\u0430\u0439\u043d\u0435 \u043f\u0440\u043e\u0441\u0442:<\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c <strong>i-\u044b\u0439<\/strong> \u0441\u0438\u043c\u0432\u043e\u043b \u0432 \u0441\u0442\u0440\u043e\u043a\u0435,<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 <strong>i-\u044b\u0439<\/strong> \u0441\u0438\u043c\u0432\u043e\u043b \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u0435\u0432\u043e\u043c\u0443, \u0442\u043e\u0433\u0434\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435,<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0441\u0438\u043c\u0432\u043e\u043b (print_char),<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>i<\/strong>,<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u043f\u0443\u043d\u043a\u0442 [1].<\/p>\n<\/li>\n<\/ol>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b `print_string`<\/summary>\n<div class=\"spoiler__content\">\n<p><strong>\u041a\u043e\u0434<\/strong><\/p>\n<pre><code class=\"assembly\">; main.asm format ELF64  public _start  section '.data' writeable     string db \"hello\", 0xA, 0  section '.text' executable _start:     mov rax, string      call print_string exit:     mov rax, 60     xor rdi, rdi      syscall   section '.print_string' executable ; | input ; rax = string print_string:     push rbx     xor rbx, rbx     .next_iter:         cmp [rax+rbx], byte 0         je .close         push rax          mov rax, [rax+rbx]         call print_char         pop rax          inc rbx         jmp .next_iter     .close:         pop rbx         ret  section '.print_char' executable ; | input ; rax = char print_char:     push rax     push rdx     push rsi     push rdi      push rax          mov rsi, rsp     mov rdi, 1     mov rdx, 1     mov rax, 1     call do_syscall      pop rax      pop rdi     pop rsi     pop rdx     pop rax     ret  section '.do_syscall' executable do_syscall:     push rcx     push r11       syscall      pop r11      pop rcx      ret  <\/code><\/pre>\n<p><strong>\u0417\u0430\u043f\u0443\u0441\u043a<\/strong><\/p>\n<pre><code>fasm main.asm &amp;&amp; ld main.o -o main &amp;&amp; .\/main                                               \ue0b2 INT \u2718  flat assembler  version 1.73.31  (16384 kilobytes memory, x64) 4 passes, 1240 bytes. $ hello<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u0443\u0436\u0435 \u0432\u044b\u0432\u043e\u0434 \u0441\u0438\u043c\u0432\u043e\u043b\u0430, \u0432\u044b\u0432\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0448\u044c \u0432\u044b\u0432\u043e\u0434 \u0447\u0438\u0441\u043b\u0430 \u0438 \u043f\u043e\u0441\u043b\u0435 \u0443\u0436\u0435 \u0432\u0441\u0451 \u044d\u0442\u043e \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 printf \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0412\u044b\u0432\u043e\u0434 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u043d\u0443\u0436\u043d\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u043f\u043e\u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e \u0446\u0438\u0444\u0440\u0430-\u0437\u0430-\u0446\u0438\u0444\u0440\u043e\u0439 \u0432\u0441\u0451 \u0447\u0438\u0441\u043b\u043e, \u043d\u043e \u0438 \u0442\u0430\u043a\u0436\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0435 \u0447\u0438\u0441\u043b\u043e &#8212; \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0438\u043b\u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435. <\/p>\n<pre><code class=\"assembly\">section '.print_decimal' executable ; | input: ; rax = number print_decimal:     push rax     push rbx     push rcx     push rdx     xor rcx, rcx     cmp rax, 0     jl .is_minus     jmp .next_iter     .is_minus:         neg rax         push rax         mov rax, '-'         call print_char         pop rax     .next_iter:         mov rbx, 10         xor rdx, rdx         div rbx         push rdx         inc rcx         cmp rax, 0         je .print_iter         jmp .next_iter     .print_iter:         cmp rcx, 0         je .close         pop rax         add rax, '0'         call print_char         dec rcx         jmp .print_iter     .close:         pop rdx         pop rcx         pop rbx         pop rax         ret<\/code><\/pre>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b <code>print_decimal<\/code> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:<\/p>\n<ol>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e <strong>\u043c\u0435\u043d\u044c\u0448\u0435 \u043d\u0443\u043b\u044f<\/strong>, \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0441\u0438\u043c\u0432\u043e\u043b <strong>\u043c\u0438\u043d\u0443\u0441<\/strong>,<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u043d\u0430 <strong>10<\/strong>, \u0432\u0437\u044f\u0442\u044c <strong>\u0447\u0430\u0441\u0442\u043d\u043e\u0435<\/strong> \u0438 <strong>\u043e\u0441\u0442\u0430\u0442\u043e\u043a<\/strong> \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f,<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u043e\u0436\u0438\u0442\u044c <strong>\u043e\u0441\u0442\u0430\u0442\u043e\u043a<\/strong> \u0432 \u0441\u0442\u0435\u043a,<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c <strong>\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/strong> <strong>i<\/strong>,<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 <strong>\u0447\u0430\u0441\u0442\u043d\u043e\u0435<\/strong> \u043d\u0435 \u0440\u0430\u0432\u043d\u043e 0, \u0442\u043e\u0433\u0434\u0430  \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u043f\u0443\u043d\u043a\u0442 [2],<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 <strong>\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 i<\/strong> \u0440\u0430\u0432\u043d\u043e 0, \u0442\u043e\u0433\u0434\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435,<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0438\u0437 \u0441\u0442\u0435\u043a\u0430 (\u043e\u0441\u0442\u0430\u0442\u043e\u043a),<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u043e\u0441\u0442\u0430\u0442\u043a\u0443 <strong>\u0441\u0438\u043c\u0432\u043e\u043b &#8216;0&#8217;<\/strong> (\u0447\u0438\u0441\u043b\u043e 48 \u043f\u043e ASCII),<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u0441\u0438\u043c\u0432\u043e\u043b (print_char),<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c <strong>\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 i<\/strong>,<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u043f\u0443\u043d\u043a\u0442 [6].<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u043e\u0438\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442 &#8212; \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 <code>print_decimal<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 64-\u0431\u0438\u0442\u043d\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438, \u0430 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0430\u043a\u0442\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0448\u044c \u043a\u043e\u0433\u0434\u0430 \u0442\u0430\u043a\u043e\u0432\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 64-\u0431\u0438\u0442\u043d\u044b\u043c. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e 32-\u0431\u0438\u0442\u043d\u043e\u0435 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435, \u0442\u043e \u043e\u043d\u043e \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b 64-\u0431\u0438\u0442\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0430\u043a\u0442\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a <strong>unsigned<\/strong>, \u0442\u043e \u0435\u0441\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0431\u0435\u0437 \u0437\u043d\u0430\u043a\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b `print_decimal`<\/summary>\n<div class=\"spoiler__content\">\n<p><strong>\u041a\u043e\u0434<\/strong><\/p>\n<pre><code class=\"assembly\">; main.asm format ELF64  public _start  section '.text' executable _start:     mov rax, 571      call print_decimal     mov rax, 0xA     call print_char exit:     mov rax, 60     xor rdi, rdi      syscall   section '.print_decimal' executable ; | input: ; rax = number print_decimal:     push rax     push rbx     push rcx     push rdx     xor rcx, rcx     cmp rax, 0     jl .is_minus     jmp .next_iter     .is_minus:         neg rax         push rax         mov rax, '-'         call print_char         pop rax     .next_iter:         mov rbx, 10         xor rdx, rdx         div rbx         add rdx, '0'         push rdx         inc rcx         cmp rax, 0         je .print_iter         jmp .next_iter     .print_iter:         cmp rcx, 0         je .close         pop rax         call print_char         dec rcx         jmp .print_iter     .close:         pop rdx <\/code><\/pre>\n<\/div>\n<\/details>\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-356927","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/356927","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=356927"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/356927\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=356927"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=356927"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=356927"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}