这段小程序是当初写文件系统时的一个小测试程序,功能是给一个16进制的ASCII数字,转换为数字,相当于STRING TO INT ,只不过它是专门用来进行扇区计算的一个部分,是由其他函数调用的,为了方便测试起见,直接给了一个值进行测试.很简单,就不写注释了
.386p
.8087
.model flat, stdcall
option casemap :none ; case sensitive
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Include 数据
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 数据段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?
hInstance dd ?
hWinMain dd ?
hFile dd ?
back0 dd ?
back1 dd ?
sizeofin dd ?
highPart dd ?
.const
szTable0 db '0123456789abcdefABCDEF',0
szTable1 db 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,10,11,12,13,14,15
sztest db '51b216cde'
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 代码段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
; 主窗口程序
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
GetSect proc uses ebx edi esi
xor ebx,ebx
mov ecx,sizeof sztest
.if ecx>16
xor eax,eax
ret
.endif
mov sizeofin,ecx
sub ecx,9
mov highPart,ecx
xor ecx,ecx
.while ecx<sizeofin
push ecx
shl ebx,4
mov al,byte ptr [sztest+ecx]
mov ecx,22
.while ecx
mov ah,byte ptr [szTable0+ecx-1]
.if al==ah
.break
.endif
dec ecx
.endw
.if ecx==0
xor eax,eax
mov back0,eax
mov back1,eax
pop ecx
ret
.else
or bl,byte ptr [szTable1+ecx-1]
.endif
pop ecx
.if ecx==highPart
mov back1,ebx
.endif
inc ecx
.endw
mov back0,ebx
mov eax,1
ret
GetSect endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 程序开始
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke GetSect
invoke ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end start