首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

学 Win32 汇编[19]: 查看二进制等相干函数

2012-09-19 
学 Win32 汇编[19]: 查看二进制等相关函数在 masm32.inc 中有这样几个函数的声明: byt2bin_exPROTO :BYTE,

学 Win32 汇编[19]: 查看二进制等相关函数

在 masm32.inc 中有这样几个函数的声明:

byt2bin_ex  PROTO :BYTE, :DWORDwrd2bin_ex  PROTO :WORD, :DWORDdw2bin_ex   PROTO :DWORD, :DWORDdw2hex_ex   PROTO :DWORD, :DWORDbin2byte_ex PROTO :DWORD


byt2bin_ex: 从 Byte 数到二进制字符串

; Test19_1.asm.386.model flat, stdcallinclude    windows.incinclude    kernel32.incinclude    masm32.incinclude    debug.incincludelib kernel32.libincludelib masm32.libincludelib debug.lib.data?   szBin db 8 dup(0), 0  ;这是接收二进制字符串的缓冲区?   bVal  db 3.codemain proc    ;查看数字的二进制信息?   invoke byt2bin_ex, 2, addr szBin?   PrintString szBin ;00000010?       ;查看变量 bVal 的二进制信息?   invoke byt2bin_ex, bVal, addr szBin?   PrintString szBin ;00000011?       ;查看寄存器 al 的二进制信息?   mov al, 0feh?   invoke byt2bin_ex, al, addr szBin?   PrintString szBin ;11111110?   retmain endpend main


wrd2bin_ex: 从 Word 数到二进制字符串

; Test19_2.asm.386.model flat, stdcallinclude    windows.incinclude    kernel32.incinclude    masm32.incinclude    debug.incincludelib kernel32.libincludelib masm32.libincludelib debug.lib.data?   szBin db 16 dup(0), 0  ;这是接收二进制字符串的缓冲区?   wVal  dw 3.codemain proc    ;查看数字的二进制信息?   invoke wrd2bin_ex, 2, addr szBin?   PrintString szBin ;0000000000000010?       ;查看变量 wVal 的二进制信息?   invoke wrd2bin_ex, wVal, addr szBin?   PrintString szBin ;0000000000000011?       ;查看寄存器 ax 的二进制信息?   mov ax, 0fffeh?   invoke wrd2bin_ex, ax, addr szBin?   PrintString szBin ;1111111111111110?   retmain endpend main


dw2bin_ex: 从 DWord 数到二进制字符串

; Test19_3.asm.386.model flat, stdcallinclude    windows.incinclude    kernel32.incinclude    masm32.incinclude    debug.incincludelib kernel32.libincludelib masm32.libincludelib debug.lib.data?   szBin db 32 dup(0), 0  ;这是接收二进制字符串的缓冲区?   dwVal dd 3.codemain proc    ;查看数字的二进制信息?   invoke dw2bin_ex, 2, addr szBin?   PrintString szBin ;00000000000000000000000000000010?       ;查看变量 dwVal 的二进制信息?   invoke dw2bin_ex, dwVal, addr szBin?   PrintString szBin ;00000000000000000000000000000011?       ;查看寄存器 eax 的二进制信息?   mov eax, 0fffffffeh?   invoke dw2bin_ex, eax, addr szBin?   PrintString szBin ;11111111111111111111111111111110?   retmain endpend main


dw2hex_ex: 从 DWord 数到十六进制字符串

; Test19_4.asm.386.model flat, stdcallinclude    windows.incinclude    kernel32.incinclude    masm32.incinclude    debug.incincludelib kernel32.libincludelib masm32.libincludelib debug.lib.data?   szHex db 8 dup(0), 0  ;这是接收十六进制字符串的缓冲区?   dwVal dd 255.codemain proc    ;查看数字的十六进制信息?   invoke dw2hex_ex, 16, addr szHex?   PrintString szHex ;00000010?       ;查看变量 dwVal 的十六进制信息?   invoke dw2hex_ex, dwVal, addr szHex?   PrintString szHex ;000000FF?       ;查看寄存器 eax 的十六进制信息?   mov eax, 2694881440?   invoke dw2hex_ex, eax, addr szHex?   PrintString szHex ;A0A0A0A0?   retmain endpend main


bin2byte_ex: 从字符串(必须有 8 个 '0' 或 '1' 组成)到字节

; Test19_5.asm.386.model flat, stdcallinclude    windows.incinclude    kernel32.incinclude    masm32.incinclude    debug.incincludelib kernel32.libincludelib masm32.libincludelib debug.lib.data?   szTxt1 db '00000010', 0?   szTxt2 db '01111011', 0?   szTxt3 db '11111111', 0.codemain proc?   invoke bin2byte_ex, addr szTxt1?   PrintDec eax  ;2?   ?   invoke bin2byte_ex, addr szTxt2?   PrintDec eax  ;123?   ?   invoke bin2byte_ex, addr szTxt3?   PrintDec eax  ;255?   retmain endpend main


学习查看二进制是为了看到 EFLAGS 中的二进制位的变化:

; Test19_6.asm.386.model flat, stdcallinclude    windows.incinclude    kernel32.incinclude    masm32.incinclude    debug.incincludelib kernel32.libincludelib masm32.libincludelib debug.lib.data?   szBin db 8 dup(?), 0.codemain proc?   lahf  ;LAHF 指令是把 EFLAGS 寄存器的低字节读入 AH?   invoke byt2bin_ex, ah, addr szBin?   PrintString szBin  ;01000110?   retmain endpend main

热点排行