【发布时间】:2018-07-29 14:33:26
【问题描述】:
我想将字符串转换为所有字符都大写的字符串。是什么导致分段错误(核心转储)?分段错误的原因是什么?
OutPut:Enter a Stringsbash: line 1: 9 Segmentation fault (core dumped)
来源:
%macro accept 2
mov eax,3
mov ebx,0
mov ecx,%1
mov edx,%2
int 0x80
%endmacro
%macro display 2
mov eax,4
mov ebx,1
mov ecx,%1
mov edx,%2
int 0x80
%endmacro
section .data
str1 db "Enter a String";
len1 equ $-str1
cnt db 0
section .bss
str2 resb 20
len2 resb 1
c resb 1
section .text
global _start
_start:
display str1,len1
accept str2,2;
dec al;
mov [cnt],al
mov si,[str2]
up:
mov ch,[si]
mov bl,ch
inc si
cmp bl,61
jna up
cmp bl,73
ja up
mov al,20
sub bl,20
mov [si],bl;
mov eax,0
mov ebx,0;
int 0x80
【问题讨论】:
-
在调试器中运行您的代码并找出哪些指令错误。