Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 减去“a”;char";在汇编代码at&;t语法_Assembly_X86 - Fatal编程技术网

Assembly 减去“a”;char";在汇编代码at&;t语法

Assembly 减去“a”;char";在汇编代码at&;t语法,assembly,x86,Assembly,X86,我试图找出一个汇编示例,即at&t语法。该代码用于查找字符串的小写字母。在第26行和第28行中,距离是什么意思?我知道这里的$'a'有点像ascii,但是距离是多少?我们为什么不把$bl和'a'和'z'比较一下,看看它是否是低成本的呢 1 .data 2 x: .string "c92jemc82ne<824j8vcm92jq3.,.u" 3 counts: 4 .rept 26 5 .byte 0 6 .endr 7 .text 8 .globl _start 9 _star

我试图找出一个汇编示例,即at&t语法。该代码用于查找字符串的小写字母。在第26行和第28行中,距离是什么意思?我知道这里的$'a'有点像ascii,但是距离是多少?我们为什么不把$bl和'a'和'z'比较一下,看看它是否是低成本的呢

1 .data
2 x: .string "c92jemc82ne<824j8vcm92jq3.,.u"
3 counts:
4   .rept 26
5   .byte 0
6   .endr
7 .text
8 .globl _start
9 _start:
10   # EAX will always point to the current character to be tallied
11   movl $x, %eax
12 top:
13   # need to zero out all of EBX for later use (see subl)
14   movl $0, %ebx
15   # get the character to be tallied
16   movb (%eax), %bl
17   # check for end of string
18   cmpb $0, %bl
19   jz done
20   # check to see if in range ’a’-’z’
21   cmpb $’a’, %bl
22   js nextchar
23   cmpb $’z’+1, %bl
24   jge nextchar
25   # find distance past counts where we will increment
26   subl $’a’,%ebx
27   # add that distance to counts to get address of place to increment
28   addl $counts, %ebx
29   # now increment
30   incb (%ebx)
31   # OK, ready to go to the next character in the string
32 nextchar:
33   addl $1, %eax
34   jmp top
35 done: movl %edx, %edx`
1.数据
2 x:.字符串“c92jemc82ne
我知道这里的$'a'有点像ascii,但是距离是多少

不是“类似的东西”,它是
'a'
的ASCII码。这里的距离是指它离
a
ASCII码有多远,也就是说,从“a”码中减去它的码

我们为什么不把$bl和'a'和'z'比较一下,看看它是否是低成本的呢

他们已经在这样做了:

20   # check to see if in range ’a’-’z’
21   cmpb $’a’, %bl
22   js nextchar
23   cmpb $’z’+1, %bl
24   jge nextchar

是的,我知道他们将$bl与'a'和'z'进行比较,但是为什么我们仍然需要找到距离?因为代码不仅仅是要找到字符串是否是小写的。