The Dauug House Wright State University logo
Dauug|36 minicomputer documentation

Code samples for MIX and XIM

Using MIX as a hash function

; Compute hash of 4-word object
unsigned hash word.1 word.2 word.3 word.4

hash = o3THvL`t mix word.1       ; use 36-bit const as initial value
hash = hash mix word.2           ; use progressive words of object
hash = hash mix word.3
hash = hash mix word.4

Using MIX as a pseudorandom number generator

I apologize that this uses the LFSR macro, which remains unimplemented as of 27 June 2023. The dissertation (which says LFSR is an instruction, but it’s actually a one-instruction macro) describes LFSR on pages 162 and 389. The main holdups are (i) ironing out names and semantics for the STUN instructions (which would give us a dependable STUN-based workaround), and (ii) choosing assembler macro semantics and implementing macro support (which would let us use LFSR as shown here).

; Pseudorandom number generator
get_next_rand::                         ; period of PRNG >= (2**36) - 1
    unsigned state1 state2 output
    keep state1 state2 output

    state2 = lfsr state2                ; rekey in just one instruction
    state1 = state1 mix state2          ; new value
    output = state1                     ; keep caller from changing state
    return

main_program::
    get_next_rand::state1 = zRN6x1`t    ; 36-bit seed #1
    get_next_rand::state2 = mPC$TB`t    ; 36-bit seed #2
loop:
    call get_next_rand
    ; do something with that
    jump loop

Using MIX as a block cipher round function

; Toy example cipher - insecure!
encrypt::
    unsigned in out key.1 key.2
    keep in out key.1 key.2

    out =  in mix key.1          ; ECB mode with 36-bit block size
    out = out mix key.2          ; two rounds total
    return

decrypt::
    unsigned in out key.1 key.2
    keep in out key.1 key.2

    out =  in xim key.2          ; "in" here is "out" from encrypt
    out = out xim key.1          ; "unwrap" key in reverse order
    return

main_program::
    encrypt::key.1 = EtdvIv`t    ; bits  0-35 of key
    encrypt::key.2 = yKoM2j`t    ; bits 36-71 of key
    encrypt::in = (a word to encrypt)
    call encrypt

    decrypt::key.1 = EtdvIv`t    ; same key as for encryption
    decrypt::key.2 = yKoM2j`t
    decrypt::in = encrypt::out
    call decrypt

    ; decrypt.out will be the same word as encrypt.in

Marc W. Abel
Computer Science and Engineering
College of Engineering and Computer Science
marc.abel@wright.edu
Without secure hardware, there is no secure software.
937-775-3016