sub cl,'A' - 0ah
来源:互联网 发布:手机淘宝下单流程图 编辑:程序博客网 时间:2024/04/28 03:09
_HexToDec proc
local @szBuffer[512]:byte
invoke GetDlgItemText,hWinMain,IDC_HEX,addr @szBuffer,sizeof @szBuffer
lea esi,@szBuffer
cld
xor eax,eax
mov ebx,16
.while TRUE
movzx ecx,byte ptr [esi]
inc esi
.break .if ! ecx
.if cl > '9'
sub cl,'A' - 0ah
.else
sub cl,'0'
.endif
mul ebx
add eax,ecx
.endw
invoke wsprintf,addr @szBuffer,addr szFmtHexToDec,eax
invoke SetDlgItemText,hWinMain,IDC_DEC,addr @szBuffer
ret
_HexToDec endp
mul ebx 的作用就是 eax * ebx 结果保存到 edx:eax 中. 这段代码应该是把输入框里面的十六进制字符船转换为数值吧, 如 '12EF' -> 12efh 结果通过 wsprintf 函数以十进制显示在另外一个里面
while 循环前置 eax 为 0 是置初始结果为 0.
这里说例子又比较烦了, 假如输入的是 "12EF":
1. while 循环前, 0 -> eax
2. 读入输入的字符 '1' 后, '1'-'0' = 1 -> ecx
eax * ebx = 0 * 10h = 0
eax + ecx = 0 + 1 = 1 -> eax
3. 读入字符 '2', '2' -'0' = 2 -> ecx
eax * ebx = 1 * 10h = 10h
eax + ecx = 10h + 2 = 12h -> eax
4. 读入字符 'E', 'E' - ('A' - 0ah) = 0eh -> ecx
eax * ebx = 12h * 10h = 120h
eax + ecx = 120h + 0eh = 12eh -> eax
5. 读入字符 'F', 'F' - ('A' - 0ah) = 0fh -> ecx
eax * ebx = 12eh * 10h = 12e0h
eax + ecx = 12e0h + 0fh = 12efh -> eax
从上面的 2. - 5. 的循环处理输入的字符后, 结果 eax 中的内容分别是 1, 12h, 12eh, 12efh 这样子看这个算法就比较明白了吧. 这个就是逐次乘进制累加的计算方法了. 如果循环前 eax 不置 0 的话, 后面的结果就会引入一个错乱的数据, 而且, 影响很大, 因为它是被后面乘了好多次 (等于输入的字符个数)
- sub cl,'A' - 0ah
- 汇编 0ah的用法
- cl
- CL
- sub
- Sub
- INT21H的0Ah号功能实现原理
- 汇编--21H里头0ah功能的使用示例
- AH flash
- 802.11ah
- AH大佬
- Ah! I am afraid, and I do tremble, Signor, for I am only a girl
- Sub Array Sum to 0
- 关于nvcc cannot find a supported cl.exe 问题
- VBA里有一个sub a()和一个sub b(),怎样同时运行它们?
- use css modify the sub object of a div
- How To Use An Embedded Resource From A Sub-Folder
- UIImagePickerController as a sub view instead of Modal View
- static_cast 和 reinterpret_cast的区别以及dynamic_cast
- 随想
- 扩充VMWare虚拟机硬盘容量的方法以及扩容后无法启动的修复方式
- 讨论java String中三种加法的区别
- 玩透弹出窗
- sub cl,'A' - 0ah
- "空格的魅力"
- 主流网站开发语言有哪些?
- strtus2 struts.xml的书写规则
- Windows2003 Server下尝试360安全卫士6.0
- css的定义顺序推荐
- 特征码知识(详细篇)
- 从此时此刻,我坚定的相信我的梦想会实现!
- Hibernate初学,实现创建数据库表