Skip to content

Instantly share code, notes, and snippets.

@spellancer
Created April 20, 2012 05:55
Show Gist options
  • Save spellancer/2426450 to your computer and use it in GitHub Desktop.
Save spellancer/2426450 to your computer and use it in GitHub Desktop.
laba 5 finish Assembly
; Template for console application
.586
.MODEL flat , c
OPTION CASEMAP:NONE
.CONST
MsgExit DB 13,10,"Press Enter to Exit",0AH,0DH,0
;Задание
;Вариант 11.
;Дана последовательность 37 символов. Определить частоту повторения каждого символа.
.DATA
tex BYTE "Hello from assembler !",10,13,0
;aa byte 'The original string:',13,10,0
;a byte 'IUEATLIGPSGOTFCKSKQOLYSQJHXYFCXCRHBBF',13,10,0
; ytlwermoglfovmagaegofjdkfdjfsdlgserlm
b byte ' ',0
bb byte '=',0
d byte ' ',0
d1 byte '; ',0
n dword 0
nn dword 0
nnn dword 0
kk dword 1
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
externdef print:near
ADD1 proc
push EBP
mov EBP,ESP
cld
mov esi,[ebp+12]
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
push esi
push edi
cld
;add k,48
;mov al,k
;mov b,al
mov b,al
push ecx
mov ecx,1
lea esi,b
lea edi,x
add edi,nnn
rep movsb
add nnn,1
mov ecx,1
lea esi,bb
lea edi,x
add edi,nnn
rep movsb
add nnn,1
pop ecx
pop esi
pop edi
mov a2[edx], al
lea edi,a2
mov ecx,[ebp+8]
mov esi,[ebp+12]
cycle2:
cmp [esi],al
je yes
jmp next
yes:
inc k
next:
inc esi;
loop cycle2
; ввод в строку
push esi
push edi
cld
add k,48
mov al,k
mov b,al
push ecx
mov ecx,1
lea esi,b
lea edi,x
add edi,nnn
rep movsb
mov k,0
add nnn,1
mov ecx,2
lea esi,d1
lea edi,x
add edi,nnn
rep movsb
add nnn,2
pop ecx
pop esi
pop edi
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
cmp ECX,0
sub ecx,1
je exit
jmp cycle1
exit:
mov eax,[ebp+8]
push eax
call print
pop eax
lea eax,x
pop EBP
ret
ADD1 endp
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment