【发布时间】:2013-08-26 15:02:24
【问题描述】:
我有这个代码:
section .data
msg3 db 'Enter Two Strings: '
msg3Len equ $ -msg3
section .bss
string1Len resb 1
string1 resb 0
string2Len resb 1
string2 resb 0
section .text
global _start
_start:
mov eax,4
mov ebx,1
mov ecx,msg3
mov edx,msg3Len
int 80h
mov eax,3
mov ebx,1
mov ecx,string1
int 80h
dec al
mov byte [string1Len], al
mov eax,3
mov ebx,1
mov ecx,string2
int 80h
dec al
mov byte [string2Len], al
mov eax,4
mov ebx,1
mov ecx,string1
mov edx,[string1Len]
int 80h
mov eax,4
mov ebx,1
mov ecx,string2
mov edx,[string2Len]
int 80h
mov eax, 0
mov ebx, 1
int 80h
我在打印两个字符串时遇到问题。它打印多余和垃圾字符。此外,当我打印三个字符串时,它会打印出过多的字符。我的代码看起来正确时有什么问题?
【问题讨论】:
-
resb 0保留零字节空间(即根本没有空间)。 -
我应该改变什么?我将所有 resb 0 更改为 resb 1,它仍然打印垃圾字符。
标签: string assembly printing nasm