Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #uneti string,i izracunati procenat alfa numerickih znakova( mala,velika slova i brojevi ),i taj broj ispisati u heksadecimalnom sistemu na ekranu.
- .section .data
- string_max = 200
- string_unos: .fill string_max,1,0
- string_ispis: .fill string_max,1,0
- .section .text
- .globl main
- main:
- unos:
- movl $3, %eax
- movl $0, %ebx
- leal string_unos, %ecx
- movl $string_max, %edx
- int $0x80
- provjera_znaka:
- xorl %esp, %esp
- xorl %esi, %esi
- leal string_unos, %edi
- provjera_znaka_1:
- movb (%edi), %bl
- cmpb $10, %bl
- je racunaj
- cmpb $'0', %bl
- jb nije_alfanum
- cmpb $'9', %bl
- jbe alfanum
- cmpb $'A', %bl
- jb nije_alfanum
- cmpb $'Z', %bl
- jbe alfanum
- cmpb $'a', %bl
- jb nije_alfanum
- cmpb $'z', %bl
- jbe alfanum
- nije_alfanum:
- incl %esp
- incl %edi
- jmp provjera_znaka_1
- alfanum:
- incl %esp
- incl %esi
- incl %edi
- jmp provjera_znaka_1
- racunaj:
- movl $100, %ebp
- movl %esi, %eax
- movl $0, %edx
- mull %ebp
- divl %esp
- konverzija_u_hex:
- xorl %esi, %esi
- xorl %esp, %esp
- leal string_ispis, %esi
- konverzija1:
- xorl %edx, %edx
- movl $16, %ecx
- cmpl $0, %eax
- je obrtanje
- divl %ecx
- cmpl $90, %edx
- ja malo_slovo
- cmpl $9, %edx
- ja veliko_slovo
- jmp broj
- malo_slovo:
- addl $87, %edx
- movl %edx, (%esi)
- incl %esi
- jmp konverzija1
- veliko_slovo:
- addl $55, %edx
- movl %edx, (%esi)
- incl %esi
- jmp konverzija1
- broj:
- addl $'0', %edx
- movl %edx, (%esi)
- incl %esi
- jmp konverzija1
- obrtanje:
- leal string_ispis, %edi
- decl %esi
- movl %esi, %ebp
- obrtanje1:
- movb (%esi), %al
- movb (%edi), %ah
- movb %al, (%edi)
- movb %ah, (%esi)
- incl %edi
- decl %esi
- cmpl %edi, %esi
- jbe ispis
- jmp obrtanje1
- ispis:
- incl %ebp
- movl $10, (%ebp)
- movl $4, %eax
- movl $1, %ebx
- leal string_ispis, %ecx
- movl $string_max, %edx
- int $0x80
- kraj:
- movl $1, %eax
- int $0x80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement