Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #CZWARTEK 12.30
- .data
- occurences:
- .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- .text
- .type check_tab, @function
- .global check_tab
- #tab->n->max
- check_tab:
- PUSH %rbx
- XOR %rbx, %rbx
- XOR %rax, %rax
- XOR %r8, %r8
- XOR %r9, %r9
- XOR %rcx, %rcx
- MOV $0, %ecx
- clear:
- MOVL $0, occurences(, %ecx, 4)
- INC %ecx
- CMP $64, %ecx
- JNE clear
- XOR %ecx, %ecx
- MOV %rdi, %r9
- loop:
- CMP $0, %rsi
- JE afterLoop
- CMPB $0, (%rdi)
- JL afterHashing
- CMPB $63, (%rdi)
- JG afterHashing
- MOV (%rdi), %eax
- MOV occurences(, %eax, 4), %ebx
- INC %ebx
- MOV %ebx, occurences(, %eax, 4)
- afterHashing:
- ADD $4, %rdi
- DEC %rsi
- JMP loop
- afterLoop:
- MOV $63, %ecx
- XOR %rax, %rax
- XOR %rbx, %rbx
- MOV $0, %r8
- loop2:
- XOR %rbx, %rbx
- MOVL occurences(, %ecx, 4), %ebx
- CMP %r8, %rbx
- JG swapMax
- afterSwap:
- SHL $1, %rax
- CMP $0, %ebx
- JE afterModifing
- ADD $1, %rax
- afterModifing:
- DEC %ecx
- CMP $0,%ecx
- JGE loop2
- MOV %r8,%rbx
- MOVL %ebx, (%rdx)
- MOV %r9, %rdi
- POP %rbx
- RET
- swapMax:
- MOV %rbx, %r8
- JMP afterSwap
- #PIĄTEK 8.00
- .text
- .type fun, @function
- .global fun
- #a - rdi
- #b - rsi
- #pcs - rdx
- #count - rcx
- fun:
- PUSH %rbx
- PUSH %rdx
- XOR %rbx, %rbx
- XOR %r9, %r9
- XOR %r10, %r10
- XOR %rax, %rax
- MOV $1, %rbx # (i+1)
- MOV $0, %r9 # how Many 1
- CMP $1, %rsi # which bit
- JE sum
- CMP $2, %rsi
- JE mul
- JMP nothing
- loop:
- PUSH %rdi
- AND $1, %rdi
- JMP count
- afterCount:
- CMP $0, %rsi
- JE afterOp
- PUSH %rax
- MOV %rdi, %rax
- XOR %rdx, %rdx
- MUL %rbx
- MOV %rax, %r8
- POP %rax
- CMP $1, %rsi
- JE sumOp
- CMP $2, %rsi
- JE mulOp
- afterOp:
- POP %rdi
- INC %rbx
- SHR $1, %rdi
- CMP $64, %rbx
- JNE loop
- afterLoop:
- POP %rdx
- POP %rbx
- MOVL %r9d, (%rcx)
- MOVL %r10d, (%rdx)
- RET
- sum:
- MOV $0, %rax #starting value
- JMP loop
- mul:
- MOV $1, %rax #starting value
- JMP loop
- nothing:
- MOV $0, %rax
- JMP loop
- sumOp:
- ADD %r8, %rax #xi in rax
- JMP afterOp
- mulOp:
- CMP $0, %r8
- JE afterOp
- XOR %rdx, %rdx
- MUL %r8 #xi in rax
- JMP afterOp
- count:
- CMP $0, %rdi
- JE afterCount
- INC %r9
- MOV %rbx, %r10
- JMP afterCount
- #PIĄTEK 9.30
- .data
- mask:
- .long 0,0,0,0,0,0,0,0,0,0
- .text
- .type encode, %function
- .global encode
- #rdi - buf
- #rsi - maska
- #rdx - operacja
- #rcx - character
- encode:
- PUSH %rbx
- PUSH %rdi
- PUSH %rsi
- MOV $0, %rbx
- createMask:
- PUSH %rsi
- AND $1, %rsi
- CMP $1, %rsi
- JE changeMask
- MOVL $0, mask(, %rbx, 4)
- maskChanged:
- POP %rsi
- SHR $1, %rsi
- INC %rbx
- CMP $10, %rbx
- JNE createMask
- XOR %r8, %r8
- MOV %rdi, %rax
- MOV %rdi, %r8
- mainLoop:
- CMPB $0, (%rdi)
- JE afterLoop
- CMPB $'0', (%rdi)
- JL noOperation
- CMPB $'9', (%rdi)
- JG noOperation
- CMP $1, %rdx
- JE deleteNumber
- CMP $2, %rdx
- JE transposition
- CMP $3, %rdx
- JE substitute
- JMP noOperation
- afterLoop:
- MOV (%rdi), %r9
- MOV %r9, (%r8)
- POP %rsi
- POP %rdi
- POP %rbx
- RET
- changeMask:
- MOVL $1, mask(, %rbx, 4)
- JMP maskChanged
- noOperation:
- XOR %r10, %r10
- MOVB (%rdi), %r10b
- MOVB %r10b, (%r8)
- INC %rdi
- INC %r8
- JMP mainLoop
- deleteNumber:
- XOR %r10, %r10
- MOVB (%rdi), %r10b
- SUBB $'0', %r10b
- CMP $0, mask(,%r10d,4)
- JE noOperation
- INC %rdi
- JMP mainLoop
- transposition:
- XOR %r10, %r10
- MOVB (%rdi), %r10b
- SUBB $'0', %r10b
- CMP $0, mask(,%r10d,4)
- JE noOperation
- MOV $9, %r11
- SUB %r10, %r11
- ADD $'0', %r11
- MOVB %r11b, (%r8)
- INC %rdi
- INC %r8
- JMP mainLoop
- substitute:
- XOR %r10, %r10
- MOVB (%rdi), %r10b
- SUBB $'0', %r10b
- CMP $0, mask(,%r10d,4)
- JE noOperation
- MOVB %cl, (%r8)
- INC %rdi
- INC %r8
- JMP mainLoop
- #MAX_IND (POPRAWKA)
- .text
- .type max_1_ind, @function
- .global max_1_ind
- #rdi -tab
- #rsi - n
- #rdx - even_count
- #rcx - neg-count
- max_1_ind:
- PUSH %rbx
- PUSH %rdx
- PUSH %rdi
- MOV $0, %r10 # even_count
- MOVB $0, (%rcx)
- MOV $0, %rbx #max 1 counter
- MOV %rsi, %r8
- loop:
- MOVQ (%rdi), %rax
- CMP $0, %rax
- JL negative
- afterNeg:
- MOVQ (%rdi), %rax
- XOR %rdx, %rdx
- XOR %r12, %r12
- MOV $2, %r12
- IDIV %r12d
- CMP $0, %rdx
- JE even
- afterEven:
- XOR %rax, %rax
- MOV (%rdi), %rax
- JMP count1
- afterCount:
- DEC %rsi
- ADD $8, %rdi
- CMP $0, %rsi
- JNE loop
- POP %rdi
- POP %rdx
- POP %rbx
- MOV %r11, %rax
- MOVQ %r10, (%rdx)
- RET
- negative:
- XOR %r12, %r12
- MOVQ (%rcx), %r12
- INC %r12
- MOVQ %r12, (%rcx)
- JMP afterNeg
- even:
- INC %r10
- JMP afterEven
- count1:
- XOR %r9, %r9
- XOR %r12, %r12
- MOV $0, %r9
- MOV $0, %r12 # how many 1
- countLoop:
- PUSH %rax
- AND $1, %rax
- CMP $0, %rax
- JE zero
- INC %r12
- zero:
- POP %rax
- SHR $1, %rax
- INC %r9
- CMP $64, %r9
- JNE countLoop
- CMP %r12, %rbx
- JG afterCount
- MOV %r12, %rbx
- MOVQ (%rdi), %r11
- JMP afterCount
- #GENERATE_STRING
- .data
- s:
- .byte 0
- .type generate_str,@function
- .global generate_str
- #rdi->rsi->rdx->rcx
- generate_str:
- MOV %rdi, s
- CMP $0, %rcx
- JE theSameLetter
- JMP changeLetter
- theSameLetter:
- CMP $0, %rdx
- JE exit
- MOV %rsi, (%rdi)
- INC %rdi
- DEC %rdx
- JMP theSameLetter
- changeLetter
- CMP $0, %rdx
- JE exit
- MOV %rsi, (%rdi)
- INC %rsi
- INC %rdi
- DEC %rdx
- JMP changeLetter
- exit:
- MOV s, %rax
- RET
- #NA ZMIANE LITERY
- .data
- buf:
- .byte 0
- .text
- .type fun,@function
- .global fun
- #rdi - pierwszy argument
- #rsi - drugi argument
- #rdx - trzeci argument
- fun:
- MOV %rdi, buf
- takeFromFirst:
- MOVB (%rsi), %al
- CMPB $0, %al
- JE isEndOfSecond
- MOV %al, (%rdi)
- INC %rdi
- INC %rsi
- JMP takeFromSecond
- takeFromSecond:
- MOVB (%rdx), %al
- CMPB $0, %al
- JE isEndOfFirst
- MOV %al, (%rdi)
- INC %rdi
- INC %rdx
- JMP takeFromFirst
- isEndOfFirst:
- MOV (%rsi),%al
- CMPB $0, %al
- JE exit
- JMP takeFromFirst
- isEndOfSecond:
- MOV (%rdx),%al
- CMPB $0, %al
- JE exit
- JMP takeFromSecond
- exit:
- MOV buf, %rax
- RET
- #USUWANIE SPACJI
- .text
- .type transform, @function
- .global transform
- #rdi - string pointer
- #rsi - change
- #0 - no space
- #1 - space found
- transform:
- MOV %rdi, %r10 #beginning
- MOV %rdi, %r9 #second pointer
- MOV $0, %r11
- loop:
- CMP $' ', (%rdi)
- JE space
- MOV $0, %r11
- CMP $1, %rsi
- JE transformToUpperCase
- rewrite:
- MOV (%rdi), %al
- MOV %al, (%r9)
- INC %r9
- afterSpace:
- INC %rdi
- CMP $0, (%rdi)
- JNE loop
- MOV %r10, %rax
- RET
- space:
- CMP $0, %r11
- JE moveSpace
- JMP afterSpace
- moveSpace:
- MOV $1, %r11
- JMP rewrite
- transformToUpperCase:
- CMPB $'a', (%rdi)
- JB rewrite
- CMPB $'z', (%rdi)
- JA rewrite
- MOV (%rdi), %al
- SUB $32, %al
- MOV %al, (%r9)
- INC %r9
- JMP afterSpace
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement