2012年7月4日星期三

show_register.asm


;把eax等寄存器的内容以二进制的形式显示出来。
;made in 2009.1.4
;ml /coff test.asm /link /subsystem:windows
.386
.model flat,stdcall
Option casemap:none
include windows.inc
include user32.inc
includelib user32.lib
.data
correy byte "made by correy.QQ:112426112.you eax=",0
;想想此处若不加零,结果会如何。
.data?
buffer byte 32 dup (?)
.code
start:
                mov ecx,32
                xor ebx,ebx
                mov eax,0c090702h
          again:test eax,10000000000000000000000000000000b
                jnz one
                mov [buffer]+ebx,48
                jmp next
            one:mov [buffer]+ebx,49
           next:shl eax,1
                inc ebx
                sub ecx,1
                cmp ecx,0
                jnz again
                invoke MessageBox,NULL,addr buffer,addr correy,0
                ret
end             start
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;把eax等寄存器的内容以十六进制的形式显示出来。
;made in 2009.1.5
;ml /coff test.asm /link /subsystem:windows
.386
.model flat,stdcall
Option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
includelib user32.lib
includelib kernel32.lib
.data
correy byte "made by correy.QQ:112426112.you eax=",0
Digit db '0123456789ABCDEF'
.data?
buffer byte 9 dup (?)
.code
start:
mov eax,0c090701h ;要显示的一个数。
mov ebx,offset Digit
mov ecx,8
mov edx,offset buffer
xor esi,esi
again:
rol eax,4
push eax
and eax,0Fh
mov dl,byte ptr [ebx+eax]
mov [buffer+esi],dl
inc esi
dec ecx
cmp ecx,0
pop eax
jne again
   invoke MessageBox,NULL,offset buffer,addr correy,0
   invoke ExitProcess, eax
end start
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;把eax等寄存器的内容以十六进制的形式显示出来。
;made in 2009.1.11
;ml /coff test.asm /link /subsystem:windows
.386
.model flat,stdcall
Option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
includelib user32.lib
includelib kernel32.lib
.data
correy byte "made by correy.QQ:112426112.you eax=",0
.data?
buffer byte 8 dup (?)
.code
start:
mov eax,0c090701h
mov ecx,8
xor esi,esi
again:
dec ecx
rol eax,4
push eax
and eax,0Fh
cmp eax,9
jg big
add eax,30h         
mov [buffer+esi],al
pop eax
inc esi
cmp ecx,0
jne again
je show
big:
add eax,37h         
mov [buffer+esi],al
pop eax
inc esi
cmp ecx,0
jne again
show:invoke MessageBox,NULL,offset buffer,addr correy,0
   invoke ExitProcess, eax
end start
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
showeax proc
local buffer[8]:byte
;local correy[15]:byte
mov ecx,8
xor esi,esi
againp:
dec ecx
rol eax,4
push eax
and eax,0Fh
cmp eax,9
jg big
add eax,30h         
mov [buffer+esi],al
pop eax
inc esi
cmp ecx,0
jne againp
je showp
big:
add eax,37h         
mov [buffer+esi],al
pop eax
inc esi
cmp ecx,0
jne again
showp:invoke MessageBox,NULL,addr buffer,0,0
ret
showeax endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.386
.model flat, stdcall
option casemap :none
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
ICO_MAIN equ 1000h ;图标
.data
sztitle db "made by correy",0
sz db "eax=%08xh eax=%08d",0dh,0ah,"ebx=%08xh ebx=%08d",0dh,0ah,"ecx=%08xh ecx=%08d",0dh,0ah,"edx=%08xh edx=%08d",0dh,0ah,"esi=%08xh esi=%08d",0dh,0ah,"edi=%08xh edi=%08d",0dh,0ah,"esp=%08xh esp=%08d",0dh,0ah,"ebp=%08xh ebp=%08d",0dh,0ah,"es=%08xh es=%08d",0dh,0ah,"cs=%08xh cs=%08d",0dh,0ah,"ss=%08xh ss=%08d",0dh,0ah,"ds=%08xh ds=%08d",0dh,0ah,"fs=%08xh fs=%08d",0dh,0ah,"fs=%08xh fs=%08d",0dh,0ah,0
sz2 db "gdtr=%012xh gdtr=%019d",0dh,0ah,"idtr=%012xh idtr=%019d",0dh,0ah,"msw=%012xh msw=%019d",0dh,0ah,0
   .data?
szBuffer db 1024 dup (?)
szBuffer2 db 1024 dup (?)
szsgdt db 6 dup (?)
szsidt db 6 dup (?)
szsmsw db 6 dup (?)
   .code
start:
invoke wsprintf,addr szBuffer,addr sz,eax,eax,ebx,ebx,ecx,ecx,edx,edx,esi,esi,edi,edi,esp,esp,ebp,ebp,es,es,cs,cs,ss,ss,ds,ds,fs,fs,gs,gs
invoke MessageBox,NULL,offset szBuffer,offset sztitle,MB_OK
SGDT    QWORD PTR szsgdt
SIDT    QWORD PTR szsidt
;SMSW    QWORD PTR eax
invoke wsprintf,addr szBuffer2,addr sz2,szsgdt,szsgdt,szsidt,szsidt;,eax,eax
invoke MessageBox,NULL,offset szBuffer2,offset sztitle,MB_OK
invoke ExitProcess,NULL
end start
;cro,
;cr1-no used
;cr2
;cr3
;gdtr
;idtr
;ldtr
;tr6 tr7
;dr0,dr1,drw,dr3,dr6,dr7
;为啥十六进制与十进制显示的不一样呢?

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;把一个八位的十六进制的字符转换成数字,存放在eax中。
;编程比较混乱,敬请指导。
.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
include comctl32.inc
includelib comctl32.lib
includelib user32.lib
includelib kernel32.lib
.data
template db "123456E8",0
.code
mulit proc m:dword
mov ecx,m
.if ecx==1
mov ebx,1
ret
.endif
mov ebx,1
mul10:
   imul ebx,16
   dec ecx
   cmp ecx,1
jne mul10
ret
mulit endp
String2Dword proc uses ecx edi edx esi String:DWORD
LOCAL Result:DWORD
mov Result,0
mov edi,String

mov ecx,8
calc:
      mov bl,byte ptr [edi]
      movzx ebx,bl
    .if bl >= "A" && bl <= "F"
      sub bl,"A"
      add bl,10
    .elseif
      sub bl,"0"
    .endif
     
      push ecx
     
      push ebx
      invoke mulit,ecx
      mov eax,ebx
      pop ebx
     
      imul eax,ebx
      add Result,eax
   
    pop ecx
   
inc edi
dec ecx
cmp ecx,0
jne calc

;mov edx,0
mov eax,Result
;mov ebx,10
;div ebx

ret
String2Dword endp
start:
invoke String2Dword,addr template
ret
end start
;made at 2010.10.27

没有评论:

发表评论