📄 libasm.asm
字号:
.file "libasm.asm"
.text
;********************************
; DoHash: used in ncpp.c
;********************************
.globl _DoHash
_DoHash:
pushl %esi
xor %eax,%eax
movl %eax,%edx
movl 8(%esp),%ecx
movl 12(%esp),%esi
_$DoHash1:
lodsb
add %eax,%edx
loop _$DoHash1
mov %edx,%eax
pop %esi
ret
.align 2
;********************************
; cpplookup: Used in ncpp.c
;********************************
.globl _cpplookup
_cpplookup:
pushl %ebp
movl %esp,%ebp
pushl %edi
pushl %esi
pushl %ebx
movl 8(%ebp),%eax
movl 12(%eax),%esi
movl %esi,%ebx
movl 8(%eax),%ecx
movl %ecx,%edi
xor %eax,%eax
mov %eax,%edx
orl %ecx,%ecx
je _$1700
; Add all characters of the token:
; Entry conditions:
; %esi contains the character string to search
; %eax is zeroed
; %edx (result) is zero
_$1701:
lodsb
add %eax,%edx
decl %ecx
jne _$1701
; index the nlist variable wth %edx modulo 1024
andl $1023,%edx
movl _nlist(,%edx,4),%esi
jmp _$1705
_$1704:
; Find matching char string.
; %esi contains the current token in the list
; %edi contains its length
; %ebx is the string to compare with
cmpl 4(%esi),%edi
jne _$1707
movl %edi,%ecx
leal 28(%esi),%edx
_$comparestrings:
movb -1(%edx,%ecx),%al
cmpb -1(%ebx,%ecx),%al
jne _$1707
decl %ecx
jne _$comparestrings
jmp _$1706
_$1707:
movl (,%esi),%esi
_$1705:
or %esi,%esi
jne _$1704
_$1706:
movl %esi,%eax
_$1700:
popl %ebx
popl %esi
popl %edi
popl %ebp
ret
.align 2
;**********************************
; is_dnrange: used in asm.c
;**********************************
.globl _is_dnrange
_is_dnrange:
movl 4(%esp),%ecx
movl 8(%esp),%edx
xor %eax,%eax
or %ecx,%ecx
je _$exitDn_Range
_$loopDnRange:
movl 4(%ecx),%ecx
cmpl %edx,%ecx
sete %al
je _$exitDn_Range
or %ecx,%ecx
jne _$loopDnRange
_$exitDn_Range:
ret
.align 2
;***********************************
; sametree: used in win32.c
;***********************************
.globl _sametree
_sametree:
pushl %esi
pushl %edi
movl 12(%esp),%edi
movl 16(%esp),%esi
_$00sametree:
xor %eax,%eax
or %edi,%edi
jne _$2126
or %esi,%esi
sete %al
je _$2121
_$2126:
movw (,%edi),%cx
cmpw (,%esi),%cx
jne _$2121
movl 4(%edi),%ecx
cmpl 4(%esi),%ecx
jne _$2121
pushl 16(%esi)
pushl 16(%edi)
call _sametree
add $8,%esp
or %eax,%eax
je _$2121
movl 20(%edi),%edi
movl 20(%esi),%esi
jmp _$00sametree
_$2121:
popl %edi
popl %esi
ret
.align 2
;***********************************
; DoRead: called from ncpp.c
;***********************************
.globl _DoRead
_DoRead:
pushl %ebp
movl %esp,%ebp
subl $20,%esp
pushl %esi
pushl %edi
xor %eax,%eax
movl %eax,-12(%ebp)
pushl %eax
leal -12(%ebp),%edx
pushl %edx
pushl 16(%ebp)
pushl 12(%ebp)
pushl 8(%ebp)
call _ReadFile@20
movl -12(%ebp),%ecx
addl %ecx,_CharsRead
movl 12(%ebp),%edi
movl %edi,%esi
incl %ecx
_$DoReadLoop:
dec %ecx
je _$DoReadEndLoop
lodsb
stosb
cmpb $13,%al
jne _$DoReadLoop
dec %edi
jmp _$DoReadLoop
_$DoReadEndLoop:
cmpb $26,%al
je _$zapCtrlZ
_$DoReadOut:
mov -12(%ebp),%eax
sub %edi,%esi
sub %esi,%eax
popl %edi
popl %esi
leave
ret
_$zapCtrlZ:
dec %edi
jmp _$DoReadOut
.align 4,0x90
;**************************************
; allocate called from alloc.c
; This function is called more than 200.000 times in compiles of large
; files. It tests quickly if a cheap allocation (without calling malloc)
; can be done.
;**************************************
.globl _allocate
.type _allocate,function
_allocate:
movl 4(%esp),%eax
; roundup size of block to be allocated
addl $7,%eax
andl $0xfffffff8,%eax
movl 8(%esp),%edx
movl _arena(,%edx,4),%ecx
movl 8(%ecx),%edx
leal (%edx,%eax),%edx
; test if space available
cmpl 4(%ecx),%edx
ja _$allocateFail
; Test OK. add to ap->avail and return the old value
xadd %eax,8(,%ecx)
ret
.align 2,0x90
_$allocateFail:
; No more space available. Call allocate slow for searching the free
; blocks list and (eventually) call malloc
movl %eax,4(%esp)
jmp _allocateslow
.align 2,0x90
; Parse the table RegisterNames, containing the first 4 characters of
; a register name.
.globl _parse_register
.type _parse_register,function
_parse_register:
movl 4(%esp),%eax
; zero 4 bytes to contain the given name that is copied from the value
; pointed by eax
xor %edx,%edx
push %edx
; ignore the first character
incl %eax
; destination: edx, source eax
movl %esp,%edx
; copy two first bytes
movw (,%eax),%cx
movw %cx,(,%edx)
incl %eax
incl %edx
incl %eax
incl %edx
movzbl (,%eax),%ecx
cmpb $0,_register_chars(,%ecx)
je _$ParseRegBeginLoop
movb %cl,(,%edx)
incl %eax
incl %edx
movzbl (,%eax),%ecx
cmpb $0,_register_chars(,%ecx)
je _$ParseRegBeginLoop
movb %cl,(,%edx)
_$ParseRegBeginLoop:
pop %eax
leal _RegisterNames,%ecx
xor %edx,%edx
_$ParseRegLoop:
cmpl %eax,(%ecx,%edx,4)
je _$ParseRegEqual
incl %edx
cmpb $58,%dl
jb _$ParseRegLoop
xor %eax,%eax
ret
.align 2,0x90
_$ParseRegEqual:
imul $12,%edx,%eax
leal _i386_regtab(,%eax),%eax
ret
.extern _register_chars
.extern _RegisterNames
.extern _i386_regtab
.extern _allocateslow
.extern _arena
.extern _ReadFile@20
.extern _GetTickCount@0
.bss
.extern _CharsRead
.extern _ReadTime
.data
.extern _nlist
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -