汇编语言 STOS 指令
STOS 指令将数据项从 AL(用于字节-STOSB)、AX(用于字-STOSW)或 EAX(用于双字-STOSD)复制到内存中 ES:DI 指向的目标字符串。
以下实例演示如何使用 LODS 和 STOS 指令将大写字符串转换为小写值:
section .textglobal _start ;must be declared for using gcc_start: ;tell linker entry pointmov ecx, lenmov esi, s1mov edi, s2loop_here:lodsbor al, 20hstosbloop loop_herecldrep movsbmov edx,20 ;message lengthmov ecx,s2 ;message to writemov ebx,1 ;file descriptor (stdout)mov eax,4 ;system call number (sys_write)int 0x80 ;call kernelmov eax,1 ;system call number (sys_exit)int 0x80 ;call kernelsection .datas1 db 'HELLO, WORLD', 0 ;sourcelen equ $-s1section .bsss2 resb 20 ;destination
结果如下:
hello, world