x86-32 NASM汇编编程实现将小写字母自动转化成大写字母

先说一下编译和运行环境: 汇编器是NASM 2.12.01 链接器是LD 2.28 操作系统是DEBIAN 9.13 STRETCH 备注:此小程序功能

先说一下编译和运行环境:

汇编器是NASM 2.12.01

链接器是LD 2.28

操作系统是DEBIAN 9.13 STRETCH

备注:此小程序功能单一,主要目的是为了向初学者展示汇编语言编程的基本步骤。

代码如下:

section .bss
Buff resb 1
section .data
section .text
global _start:
_start:

Read:
xor eax,eax
xor ebx,ebx
xor ecx,ecx
xor edx,edx
mov eax,0x3
mov ebx,0
mov ecx,Buff
mov edx,1
int 0x80

cmp eax,0
je Exit

cmp BYTE [Buff],0x61
jb Write
cmp BYTE [Buff],0x7a
ja Write
sub BYTE [Buff],20h

Write:
mov eax,4
mov ebx,1
mov ecx,Buff
mov edx,1
int 80h
mov eax,4
mov ebx,1
mov [Buff],BYTE 10
mov ecx,Buff
mov edx,1
int 80h

Exit:
xor eax,eax
mov eax,1
xor ebx,ebx
mov ebx,0
int 0x80

makefile 编译配置文件内容:

test:test.o

ld -o test -m elf_i386  test.o

test.o:test.s

nasm -o test.o -f elf -g -F stabs test.s