【发布时间】:2014-01-01 23:36:59
【问题描述】:
我必须编写一个程序,它读取一个 25 个字符的字符串并返回相同的字符串,每个单词的字母在 asm 语言中颠倒过来
例如:
Input >> Hello world. How are you?
Output >> olleH .dlrow woH era ?uoy
这就是我所做的:
%include "asm_io.inc"
segment .data
prompt1 db "Insert the strin: ", 0 ; don't forget nul terminator
prompt2 db "The string is: ", 0
prompt3 db "The reverse string is: ", 0
segment .bss
vector resb 25
vectorInvert resb 25
aux resb 1
aux2 resb 1
segment .text
global asm_main
asm_main:
mov eax, prompt1 ; print out prompt
call print_string
mov edi, vector ;vetor e do tipo byte
mov ecx, 25
read:
call read_char
stosb
loop read
mov eax, 0
mov edx, 0
mov esi, vector
mov ecx, 25
stack:
mov al, [esi]
cmp al, " "
jz stack2
movzx eax, al
push eax
add eax, 1
add esi, 1
loop stack
stack2:
mov [aux], ecx
mov [aux2], eax
mov ecx, 25
sub ecx, eax
mov edi, vectorInvert
lp:
pop eax
add edx, 1
mov [edi], eax
add edi, 1
loop lp
add eax, 1
add edx, 1
add esi, 1
add edi, 1
mov ecx, [aux]
mov eax, [aux2]
cmp eax, 25
jz out
jnz stack
out:
mov eax, prompt3
call print_string
mov edi, vectorInvert
mov ecx, 25
print:
lodsb
call print_char
loop print
call print_nl
leave
ret
我被困在那里,我不知道如何继续前进。我真的很感激这段代码的一些帮助。 我正在使用这里的库:drpaulcarter.com/pcasm/linux-ex.zip (请注意,我是组装的新手。)
【问题讨论】:
-
这是什么处理器?
-
处理器是英特尔
-
我正在使用这里的库:drpaulcarter.com/pcasm/linux-ex.zip
标签: string assembly nasm reverse