-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
I would like to have some program on my 64 bit Windows 7 that takes the current C Runtime Library files that has ASM implementations and get a version in C so I can understand them more (I dont fully get ASM).
Here is an example ASM Code from the CRT that is some stack checking that I need in C:
page ,132
title chkstk - C stack checking routine
.xlist
include vcruntime.inc
.list
; size of a page of memory
_PAGESIZE_ equ 1000h
CODESEG
page
public _alloca_probe
_chkstk proc
_alloca_probe = _chkstk
push ecx
; Calculate new TOS.
lea ecx, [esp] + 8 - 4 ; TOS before entering function + size for ret value
sub ecx, eax ; new TOS
; Handle allocation size that results in wraparound.
; Wraparound will result in StackOverflow exception.
sbb eax, eax ; 0 if CF==0, ~0 if CF==1
not eax ; ~0 if TOS did not wrapped around, 0 otherwise
and ecx, eax ; set to 0 if wraparound
mov eax, esp ; current TOS
and eax, not ( _PAGESIZE_ - 1) ; Round down to current page boundary
cs10:
cmp ecx, eax ; Is new TOS
bnd jb short cs20 ; in probed page?
mov eax, ecx ; yes.
pop ecx
xchg esp, eax ; update esp
mov eax, dword ptr [eax] ; get return address
mov dword ptr [esp], eax ; and put it at new TOS
bnd ret
; Find next lower page and probe
cs20:
sub eax, _PAGESIZE_ ; decrease by PAGESIZE
test dword ptr [eax],eax ; probe page.
jmp short cs10
_chkstk endp
end
So would this work on ASM code like this for my needs?
Metadata
Metadata
Assignees
Labels
No labels