Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .data
- num: .byte 0xa2
- .text
- la x1, num # loads address
- lb x2, 0(x1) # loads data
- # block below performs xor(1, 3, 5, 7, 9, 11)
- mv x3, x2
- srli x4, x3, 1
- srli x5, x3, 3
- srli x6, x3, 4
- srli x7, x3, 6
- xor x3, x3, x4
- xor x3, x3, x5
- xor x3, x3, x6
- xor x3, x3, x7
- andi x10, x3, 1
- # block below performs xor(2, 3, 6, 7, 10, 11)
- mv x3, x2
- srli x4, x3, 2
- srli x5, x3, 3
- srli x6, x3, 5
- srli x7, x3, 6
- xor x3, x3, x4
- xor x3, x3, x5
- xor x3, x3, x6
- xor x3, x3, x7
- andi x3, x3, 1
- slli x3, x3, 1
- or x10, x10, x3 # c1|c0
- # block below performs xor(4, 5, 6, 7, 12)
- mv x3, x2
- srli x4, x3, 1
- srli x5, x3, 2
- srli x6, x3, 3
- srli x7, x3, 7
- xor x3, x5, x4
- xor x3, x3, x6
- xor x3, x3, x7
- andi x3, x3, 1
- slli x3, x3, 3
- or x10, x10, x3 # c2_c1|c0
- # block below performs xor(8, 9, 10, 11, 12)
- mv x3, x2
- srli x4, x3, 4
- srli x5, x3, 5
- srli x6, x3, 6
- srli x7, x3, 7
- xor x3, x5, x4
- xor x3, x3, x6
- xor x3, x3, x7
- andi x3, x3, 1
- slli x3, x3, 7
- or x10, x10, x3 # c3___c2_|c1|c0
- # block below inserts data bits in respective postitions
- andi x4, x2, 1
- slli x4, x4, 2
- or x10, x10, x4 # c3___c2|d0|c1|c0
- andi x4, x2, 0x0e
- slli x4, x4, 3
- or x10, x10, x4 # c3|d3|d2|d1|c2|d0|c1|c0
- andi x4, x2, 0xf0
- slli x4, x4, 4
- or x10, x10, x4 # d7|d6|d5|d4|c3|d3|d2|d1|c2|d0|c1|c0
- sw x10, 4(x1) #stores result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement