汇编(NASM)64X-将字符串中的字母转换为字母订单号
我需要将字符串的字母转换为字母中的相应顺序(例如:a - > 1,b - > 2等)
。 em>“ mostra os objetos e os morfismos” ,我尝试了很多事情,但没有任何效果。好像我得到了字符的ASCII值,但是当我在字符串上添加它时,它会打印到ASCII中的相应的最后2个DEC数字,例如:( M,在DEC中为0155 prints-(在ASCII中为55)
)是我的代码:
SYS_EXIT equ 1
SYS_WRITE equ 4
STDIN equ 0
STDOUT equ 1
global _start
section .text
_start:
qe:
mov eax, SYS_WRITE ;
mov ebx, STDOUT ;
mov ecx, e ;
mov edx, len ;
int 0x80 ;
mov rdi, string ;
mov rdx, string_e ;
mov r9, 0 ;
jmp loop_e
next:
mov [rdx], esp ; write single character
inc rdx ; advance pointer to next cell to write
inc rdi ; advance pointer to next cell to write
inc r9 ; "count" number so far on
cmp r9, len_string ; did we reach the number of stars for this line?
jne loop_e ; not yet, keep writing on this line
jmp result_e
loop_e:
mov esp, [rdi]
cmp byte [rdi], ' '
je next
xor esp, 40H
mov [rdx], esp ; write single character
inc rdx ; advance pointer to next cell to write
inc rdi ; advance pointer to next cell to write
inc r9 ; "count" number so far on line
cmp r9, len_string ; did we reach the number of stars for this line?
jne loop_e ; not yet, keep writing on this line
jmp result_e
result_e:
mov eax, SYS_WRITE ; system call number for write (SYS_WRITE)
mov ebx, STDOUT ; system call number for file handle (STDOUT)
mov ecx, string ; address of string to output
mov edx, len_string ; number of bytes
int 0x80
mov eax, SYS_WRITE ; system call number for write (SYS_WRITE)
mov ebx, STDOUT ; system call number for file handle (STDOUT)
mov ecx, lbreak ; address of string to output
mov edx, 1 ; number of bytes
int 0x80
mov eax, SYS_WRITE ; system call number for write (SYS_WRITE)
mov ebx, STDOUT ; system call number for file handle (STDOUT)
mov ecx, string_e ; address of string to output
mov edx, len_string ; number of bytes
int 0x80
mov eax, SYS_WRITE ; system call number for write (SYS_WRITE)
mov ebx, STDOUT ; system call number for file handle (STDOUT)
mov ecx, lbreak ; address of string to output
mov edx, 1 ; number of bytes
int 0x80
jmp _finish
_finish:
mov eax,SYS_EXIT ;system call number (SYS_EXIT)
int 0x80 ;call kernel
ret
section .data
e: db "e.", 0xA,0xD
len equ $ - e
string: db "mostra os objetos e os morfismos", 0
lbreak: db 0xA,0xD
section .bss
string: resb 44
string_e: resb 44
zero equ 0
len_string equ 32
我的输出:
e.
mostra os objetos e os morfismos
-/342! /3 /"*%4/3 % /3 -/2&)3-/3
我期望的:
e.
mostra os objetos e os morfismos
13151920181 1519 152105201519 5 1519 1315186919131519
I'm in need to convert the letters of a string to the corresponding order in alphabet, (ex: A -> 1, B -> 2, etc.)
In this example, the string I have to convert is: "mostra os objetos e os morfismos", I tried a lot of things, but nothing worked. It seems like I get the ascii value of the char, but when I add it back on the string it prints the corresponding last 2 dec digits in ascii, ex: (m which in dec is 0155 prints - that is 55 in ascii)
here is my code:
SYS_EXIT equ 1
SYS_WRITE equ 4
STDIN equ 0
STDOUT equ 1
global _start
section .text
_start:
qe:
mov eax, SYS_WRITE ;
mov ebx, STDOUT ;
mov ecx, e ;
mov edx, len ;
int 0x80 ;
mov rdi, string ;
mov rdx, string_e ;
mov r9, 0 ;
jmp loop_e
next:
mov [rdx], esp ; write single character
inc rdx ; advance pointer to next cell to write
inc rdi ; advance pointer to next cell to write
inc r9 ; "count" number so far on
cmp r9, len_string ; did we reach the number of stars for this line?
jne loop_e ; not yet, keep writing on this line
jmp result_e
loop_e:
mov esp, [rdi]
cmp byte [rdi], ' '
je next
xor esp, 40H
mov [rdx], esp ; write single character
inc rdx ; advance pointer to next cell to write
inc rdi ; advance pointer to next cell to write
inc r9 ; "count" number so far on line
cmp r9, len_string ; did we reach the number of stars for this line?
jne loop_e ; not yet, keep writing on this line
jmp result_e
result_e:
mov eax, SYS_WRITE ; system call number for write (SYS_WRITE)
mov ebx, STDOUT ; system call number for file handle (STDOUT)
mov ecx, string ; address of string to output
mov edx, len_string ; number of bytes
int 0x80
mov eax, SYS_WRITE ; system call number for write (SYS_WRITE)
mov ebx, STDOUT ; system call number for file handle (STDOUT)
mov ecx, lbreak ; address of string to output
mov edx, 1 ; number of bytes
int 0x80
mov eax, SYS_WRITE ; system call number for write (SYS_WRITE)
mov ebx, STDOUT ; system call number for file handle (STDOUT)
mov ecx, string_e ; address of string to output
mov edx, len_string ; number of bytes
int 0x80
mov eax, SYS_WRITE ; system call number for write (SYS_WRITE)
mov ebx, STDOUT ; system call number for file handle (STDOUT)
mov ecx, lbreak ; address of string to output
mov edx, 1 ; number of bytes
int 0x80
jmp _finish
_finish:
mov eax,SYS_EXIT ;system call number (SYS_EXIT)
int 0x80 ;call kernel
ret
section .data
e: db "e.", 0xA,0xD
len equ $ - e
string: db "mostra os objetos e os morfismos", 0
lbreak: db 0xA,0xD
section .bss
string: resb 44
string_e: resb 44
zero equ 0
len_string equ 32
my output:
e.
mostra os objetos e os morfismos
-/342! /3 /"*%4/3 % /3 -/2&)3-/3
what I expect:
e.
mostra os objetos e os morfismos
13151920181 1519 152105201519 5 1519 1315186919131519
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论