汇编32位无符号整数转字符串输出.docVIP

  • 68
  • 0
  • 约2.77千字
  • 约 3页
  • 2017-06-08 发布于重庆
  • 举报
汇编32位无符号整数转字符串输出

字体放大即可看清源代码,缩小是为了排版 .386 .model flat, stdcall option casemap :none include \masm32\include\kernel32.inc include \masm32\include\masm32.inc include \masm32\macros\macros.asm includelib \masm32\lib\masm32.lib includelib \masm32\lib\kernel32.lib .data buffer db 256 dup ? ; message db value overflow,please check code,0; message1 db The unsigned 32bit value ,0; message2 db represented by decimal string is ,0; number_of_32bit dd 1座机电话号码h ;You can change the value of unsigned number in here. .code int_to_string proc value:DWORD ;Design a function that exchange unsigned 32bit number to string and output mov edi,offset buffer; ;Transmit the address of buffer to edi; mov eax,value; ;Transmit unsigned 32bit number to eax xor ecx,ecx; ;Reset the ecx mov ebx,10; ;Transmit 10 to ebx and ebx used to be divisor again: xor edx,edx; ;Reset the edx div ebx; ;eax/ebx,The quotient is transmited to eax and remainder is transmited to edx jo overflow; ;check overflow push edx; ;push the edx remainder into stack inc ecx; ;ecx ecx+1 test eax,0ffffffffh; ;cmp eax,0 je output; ;if eax 0,goto output jmp again; ;circulate overflow: print ADDR message; ;Handle overflow interrupt:jmp interrupt; ;drop-dead halt,express message to user and wait user to handle; output: pop edx; ;pop data to edx; add edx,30h; ;Exchange edx to string exploit the ASCII mov [edi],edx; ;Move edx to memory address edi inc edi; ;address+1 loop output; ;if ecx 0,circulate print ADDR message1; ;Print message print ADDR buffer; print ADDR message2; print ADDR buffer; jmp interrupt; ;Goto drop-dead halt,express message to user and wait user to handle; ret; int_to_string endp; start: invoke int_to_string,number_of_32bit; invoke ExitProcess,0; end start; Lab1-Report My application does’nt support input the unsigned 32-bit number from keybored.But you can change the value by modify source ,it’s so easy. It’s a pity ,my source code only can pass the compile in masm32,I try compile it in masm5.0 and masm611,But there are many e

文档评论(0)

1亿VIP精品文档

相关文档