Skip to content

Instantly share code, notes, and snippets.

@spellancer
Created April 11, 2012 09:15
Show Gist options
  • Save spellancer/2358191 to your computer and use it in GitHub Desktop.
Save spellancer/2358191 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 'IUEATLIGPSGOTFCKSKQOLYSQJHXYFCXCRHBBF',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
public _ADD1
_ADD1 proc
push EBP
mov EBP,ESP
cld
mov esi,[ebp+12]
;lea esi,a
lea edi, a2
mov eax,0
mov edx,0
mov k,0
mov ecx,[ebp+8]
cycle1:
push ecx
push esi
mov al, [esi]
lea edi,a2
mov bl , [edi]
mov ecx,[ebp+8]
repne scasb
je ravno
mov a2[edx], al
lea edi,a2 ;
mov ecx,[ebp+8]
;lea esi,a
mov esi,[ebp+12]
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
ravno:
pop esi
pop ecx
inc esi
quit:
mov nn, edx
loop cycle1
mov EAX,0
lea EAX,x
;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
pop EBP
ret
_ADD1 endp
end
;
; 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