Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement