muta...@gmail.com
2023-04-01 17:09:19 UTC
Does this code look wrong?
edx appears to be used to contain the cluster number:
andl $-16, %edx
From the AND here:
cluster = (buf[offset]
| ((unsigned long)buf[offset + 1] << 8)
| ((unsigned long)buf[offset + 2] << 16)
| ((unsigned long)buf[offset + 3] << 24))
& 0x0fffffff;
But this code wipes the value:
xorl %edx, %edx
And the value would have been corrupt anyway because of this:
movb _buf.8+3(%edx), %dl
This is my version of gcc 3.2.3, but as far as I know, I
didn't change the code generation logic.
C source code is here:
https://sourceforge.net/p/pdos/gitcode/ci/master/tree/src/fat.c
and it is being built with this:
https://sourceforge.net/p/pdos/gitcode/ci/master/tree/src/comp5w.bat
using gcc386.exe available from http://pdos.org/customb.zip
It is the fatNuke() function.
Thanks. Paul.
L665:
subl $8, %esp
pushl %ebx
pushl %edi
call _fatEndCluster
addl $16, %esp
testl %eax, %eax
jne L689
movl 92(%edi), %eax
cmpl $16, %eax
je L690
cmpl $12, %eax
je L691
L671:
cmpl $32, %eax
jne L665
xorl %edx, %edx
leal 0(,%ebx,4), %eax
movl 16(%edi), %ecx
divl %ecx
movl %eax, %esi
addl 48(%edi), %esi
cmpl %esi, -16(%ebp)
je L681
movl -16(%ebp), %eax
testl %eax, %eax
jne L692
L682:
pushl %eax
pushl $_buf.8
pushl %esi
pushl %edi
call _fatReadLogical
movl %esi, -16(%ebp)
addl $16, %esp
movl 16(%edi), %ecx
L681:
leal 0(,%ebx,4), %eax
xorl %edx, %edx
divl %ecx
movzbl _buf.8+1(%edx), %eax
movzbl _buf.8(%edx), %ebx
sall $8, %eax
orl %eax, %ebx
movzbl _buf.8+2(%edx), %eax
movl %edx, %ecx
sall $16, %eax
movb _buf.8+3(%edx), %dl
orl %eax, %ebx
movl %edx, %eax
sall $24, %eax
orl %eax, %ebx
andl $-16, %edx
andl $268435455, %ebx
movb $0, _buf.8(%ecx)
movb $0, _buf.8+1(%ecx)
movb $0, _buf.8+2(%ecx)
movb %dl, _buf.8+3(%ecx)
incl -24(%ebp)
jmp L665
edx appears to be used to contain the cluster number:
andl $-16, %edx
From the AND here:
cluster = (buf[offset]
| ((unsigned long)buf[offset + 1] << 8)
| ((unsigned long)buf[offset + 2] << 16)
| ((unsigned long)buf[offset + 3] << 24))
& 0x0fffffff;
But this code wipes the value:
xorl %edx, %edx
And the value would have been corrupt anyway because of this:
movb _buf.8+3(%edx), %dl
This is my version of gcc 3.2.3, but as far as I know, I
didn't change the code generation logic.
C source code is here:
https://sourceforge.net/p/pdos/gitcode/ci/master/tree/src/fat.c
and it is being built with this:
https://sourceforge.net/p/pdos/gitcode/ci/master/tree/src/comp5w.bat
using gcc386.exe available from http://pdos.org/customb.zip
It is the fatNuke() function.
Thanks. Paul.
L665:
subl $8, %esp
pushl %ebx
pushl %edi
call _fatEndCluster
addl $16, %esp
testl %eax, %eax
jne L689
movl 92(%edi), %eax
cmpl $16, %eax
je L690
cmpl $12, %eax
je L691
L671:
cmpl $32, %eax
jne L665
xorl %edx, %edx
leal 0(,%ebx,4), %eax
movl 16(%edi), %ecx
divl %ecx
movl %eax, %esi
addl 48(%edi), %esi
cmpl %esi, -16(%ebp)
je L681
movl -16(%ebp), %eax
testl %eax, %eax
jne L692
L682:
pushl %eax
pushl $_buf.8
pushl %esi
pushl %edi
call _fatReadLogical
movl %esi, -16(%ebp)
addl $16, %esp
movl 16(%edi), %ecx
L681:
leal 0(,%ebx,4), %eax
xorl %edx, %edx
divl %ecx
movzbl _buf.8+1(%edx), %eax
movzbl _buf.8(%edx), %ebx
sall $8, %eax
orl %eax, %ebx
movzbl _buf.8+2(%edx), %eax
movl %edx, %ecx
sall $16, %eax
movb _buf.8+3(%edx), %dl
orl %eax, %ebx
movl %edx, %eax
sall $24, %eax
orl %eax, %ebx
andl $-16, %edx
andl $268435455, %ebx
movb $0, _buf.8(%ecx)
movb $0, _buf.8+1(%ecx)
movb $0, _buf.8+2(%ecx)
movb %dl, _buf.8+3(%ecx)
incl -24(%ebp)
jmp L665