我需要将“h4ppy c0d1ng”转换为“H4PPY C0D1NG”。 我是这种语言的初学者,但这是我的尝试(ubuntu i386 VirtualBox Mac)。我认为int 21h是错误的,除了程序不会完成,也不会在执行时打印字符串:
sdnorm <- function(x, mean=0, sd=1, lambda=1){lambda*dnorm(x, mean=mean, sd=sd)}
答案 0 :(得分:3)
一些小的改动,它应该运行:
section .text
GLOBAL _start
_start: mov ecx, string
call toUpper
call print
mov eax,1
mov ebx,0
int 80h
toUpper:
mov al,[ecx] ; ecx is the pointer, so [ecx] the current char
cmp al,0x0
je done
cmp al,'a'
jb next_please
cmp al,'z'
ja next_please
sub al,0x20 ; move AL upper case and
mov [ecx],al ; write it back to string
next_please:
inc ecx ; not al, that's the character. ecx has to
; be increased, to point to next char
jmp toUpper
done: ret
print: mov ecx, string ; what to print
mov edx, len ; length of string to be printed
mov ebx, 1
mov eax, 4
int 80h
ret
section .data
string: db "h4ppy c0d1ng",10,0
len: equ $-string
编辑:
更新&#34;打印&#34;工作,
修复大写的bugfix:al保存char,而不是cl
添加符号来确定字符串的长度
在我的linux机箱上测试,而不是它的工作