汇编宏

; A macro with two parameters
; Implements the write system call
   %macro write_string 2 
      mov   eax, 4
      mov   ebx, 1
      mov   ecx, %1
      mov   edx, %2
      int   80h
   %endmacro

section    .text
   global _start            ;must be declared for using gcc

_start:                     ;tell linker entry point
   write_string msg1, len1               
   write_string msg2, len2    
   write_string msg3, len3  

   mov eax,1                ;system call number (sys_exit)
   int 0x80                 ;call kernel

section    .data
msg1 db    'Hello, programmers!',0xA,0xD     
len1 equ $ - msg1            

msg2 db 'Welcome to the world of,', 0xA,0xD 
len2 equ $- msg2 

msg3 db 'Linux assembly programming! '
len3 equ $- msg3

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/264646.html

(0)
上一篇 2022年6月7日
下一篇 2022年6月7日

相关推荐

发表回复

登录后才能评论