21,497
社区成员




;
;This Program Compiled Sucess by Masm 6.15
;
assume cs:code,ds:data,ss:stack
data segment
msg1 db 'Enter a digit:$'
buff db 5,0,5 dup (0)
msg2 db 'Result:$'
data ends
stack segment stack
db 64 dup (0)
stack ends
code segment
start:
mov ax,data
mov ds,ax
mov dx,offset msg1
mov ah,9
int 21h
mov dx,offset buff
mov ah,10
int 21h
mov bx,offset buff+2
mov ax,0
mov cl,[bx-1]
s: mov dx,10
mul dx
and byte ptr [bx],0fh
add al,[bx]
adc ah,0
inc bx
loop s
call crlf
mov dx,ax
call disp
mov ah,4ch
int 21h
;
crlf proc uses ax dx
mov ah,2
mov dl,0dh
int 21h
mov dl,0ah
int 21h
ret
crlf endp
disp proc uses dx
mov cx,4
d0: push cx
mov cl,4
rol dx,cl
push dx
and dx,0fh
cmp dl,10
jb d1
add dl,37h
mov ah,2
int 21h
jmp jx
d1: add dl,30h
mov ah,2
int 21h
jx: pop dx
pop cx
loop d0
ret
disp endp
;
code ends
end start
;====================================
;ml /c /coff ustr2dw4.asm
;link /subsystem:windows ustr2dw4.obj
;====================================
.386
.model flat,stdcall
option casemap:none
include windows.inc
include kernel32.inc
include user32.inc
include masm32.inc
includelib kernel32.lib
includelib user32.lib
includelib masm32.lib
.data
;测试数据,将如下串szdw4转成RECT格式的值
szdw4 db " 49 , 129 ,144, 179 ",0
fmt db "%d-%d-%d-%d",0dh,0ah,0 ;//显示分离后的数值数据
sztitle db "Test",0
.data?
buf db 24 dup(?)
dwdata RECT <?>
.code
;#########################################################################
;
; ustr2dw4 - G-Spider 2010
;
; Parameters
; pszString - null-terminated string to be converted
; for example " 94 , 129 , 144, 179 ",0
; pRECT - >RECT struct
; Result
; RECT <= converted number
;
;#########################################################################
ustr2dw4 proc pszString:DWORD,pRECT:DWORD
mov edi,pRECT
assume edi:ptr RECT
mov esi, [pszString]
xor ebx, ebx
@@next:
xor edx, edx
xor eax, eax
jmp @@chkz
@@redo:
sub dl, "0"
mov ecx, eax
add eax, eax
shl ecx, 3
inc esi
add eax, ecx
add eax, edx
@@chkz:
@@:
mov dl, [esi]
inc esi
cmp dl, " "
je @B
dec esi
cmp ebx,3
je @@bottom
cmp dl,","
jne @@redo
inc esi
inc ebx
cmp ebx,2
jl @@left
je @@top
jmp @@right
@@left:
mov [edi].left,eax
jmp @@next
@@top:
mov [edi].top,eax
jmp @@next
@@right:
mov [edi].right,eax
jmp @@next
@@bottom:
test dl,dl
jne @@redo
mov [edi].bottom,eax
assume edi:nothing
xor eax,eax
ret
ustr2dw4 endp
;#########################################################################
start:
invoke ustr2dw4,offset szdw4,offset dwdata
invoke wsprintf,offset buf,offset fmt,\
dwdata.left,dwdata.top,dwdata.right,dwdata.bottom
invoke MessageBox,NULL,offset buf,offset sztitle,0
invoke ExitProcess,0
end start