QuestionQuestion

In this assignment you’ll use the bitwise operations, shifts, and rotates to implement the xoroshiro64** pseudo-random number generator.

xoroshiro64 uses 64 bits of internal state, while generating 32-bits of random output per call. It’s internal state is split into two unsigned 32-bit values, s0 and s1. These must be initialized to something other than 0s. To generate the next state in the RNG sequence, we perform the following steps:
tmp = s1 XOR s0
s0 = (s0 ROL 26) XOR tmp XOR (tmp << 9) where ROR is rotate-right.
s1 = s1 ROL 13 where ROL is rotate left
The 32-bit value returned is ((s0 * 0x9E3779BB) ROL 5) * 5.
All arithmetic is performed unsigned, on 32-bit (dword) values. You can find a C/C++ implementation of the algorithm here. Note that because C/C++ do not expose bit rotations as an operation, the authors had to implement it manually as a function!

Here is a scaffold you can use to get started:
;;;;
;;;; xoroshiro64.s
;;;;
section .data

s0:         dd      137546
s1:         dd      729

buffer:    dd      0            

section .text

global _start
_start:

    push rbp
    mov rbp, rsp

.loop:

    call next
    mov dword [buffer], eax ; Return value from next in eax

    mov rax, 1          ; Write syscall
    mov rdi, 1          ; Stdout
    mov rsi, buffer    ; Address
    mov rdx, 4          ; Length
    syscall

    jmp .loop

    pop rbp

    mov rax, 60
    mov rdi, 0
    syscall

next:
    ; Next function here.

    ; Return results in eax.
    ret
You shouldn’t run your executable directly to test it, as it will just print a bunch of garbage to the screen. (Use the command reset to clear the screen if you need to.) Instead, send its output to the RNG_test utility:
./xoroshiro64 | RNG_test stdin

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

.loop:

    call next
    mov dword [buffer], eax ; Return value from next in eax

    mov rax, 1          ; Write syscall
    mov rdi, 1          ; Stdout
    mov rsi, buffer    ; Address
    mov rdx, 4          ; Length
    syscall

    jmp .loop

    pop rbp

    mov rax, 60
    mov rdi, 0
    syscall...
$20.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Assembly Language Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats