Skip to content

Instantly share code, notes, and snippets.

@spellancer
Created March 21, 2012 05:02
Show Gist options
  • Save spellancer/2144552 to your computer and use it in GitHub Desktop.
Save spellancer/2144552 to your computer and use it in GitHub Desktop.
; Template for console application
.586
.MODEL flat, stdcall
OPTION CASEMAP:NONE
Include kernel32.inc
Include masm32.inc
IncludeLib kernel32.lib
IncludeLib masm32.lib
.CONST
MsgExit DB 13,10,"Press Enter to Exit",0AH,0DH,0
;Çàäàíèå
;Âàðèàíò 11.
;Äàíà ïîñëåäîâàòåëüíîñòü 37 ñèìâîëîâ. Îïðåäåëèòü ÷àñòîòó ïîâòîðåíèÿ êàæäîãî ñèìâîëà.
.DATA
aa byte 'The original string:',13,10,0
a byte 'ytlwermoglfovmagaegofjdkfdjfsdlgserlm',13,10,0
; ytlwermoglfovmagaegofjdkfdjfsdlgserlm
b byte ' '
bb byte ' = ',0
d byte ' ',0
d1 byte '/37 ',0
n dword 0
nn dword 0
result byte 13,10,'Result:',13,10,0
.DATA?
inbuf DB 100 DUP (?)
Buffer DB 10 DUP (?)
x byte 37 dup (?)
a2 byte 40 dup (?)
k byte ?
.CODE
Start:
cld
lea esi,a
lea edi, a2
mov eax,0
mov edx,0
mov k,0
mov ecx,37
cycle1:
push ecx
push esi
;push edi
;lea esi,a
;lea edi,a2
mov al, [esi]
lea edi,a2 ;
mov bl , [edi]
mov ecx,37
repne scasb
je ravno
mov a2[edx], al
lea edi,a2 ;
mov ecx,37
lea esi,a
cycle2:
cmp [esi],al
je yes
jmp next
yes:
inc k
next:
inc esi;
loop cycle2
mov al,k
mov x[edx],al
mov k,0
pop esi
pop ecx
inc esi
inc edx
inc edi
jmp quit
;inc edi
ravno:
pop esi
pop ecx
inc esi
quit:
mov nn, edx
loop cycle1
Invoke StdOut,ADDR aa
Invoke StdOut,ADDR a
Invoke StdOut,ADDR result
; Âûâîä
cld
mov ebx,0
mov eax,0
lea esi,a
lea edi,a2
mov ecx, nn
mov ebx,0
cycle3:
push ebx
push ecx
push edi
mov al , [edi]
mov b , al
Invoke StdOut,ADDR b
mov al , x[ebx]
movzx eax,AL
mov n , eax
Invoke dwtoa,n,ADDR d
Invoke StdOut,ADDR d
Invoke StdOut,ADDR d1
pop edi
pop ecx
pop ebx
inc ebx
inc esi
inc edi
loop cycle3
;
; Add you statements
;
XOR EAX,EAX
Invoke StdOut,ADDR MsgExit
Invoke StdIn,ADDR inbuf,LengthOf inbuf
Invoke ExitProcess,0
End Start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment