oracle.asm 1.3 KB
Newer Older
George Hotz's avatar
George Hotz committed
1 2 3 4 5 6 7
    .section .test, "x"
    .balign 4
    .set    noreorder
    .global test
    .ent    test

# load hash at 0x30001000
George Hotz's avatar
George Hotz committed
8
# 0x47173285 a8d7341e 5e972fc6 77286384 f802f8ef 42a5ec5f 03bbfa25 4cb01fad = "hello world"
George Hotz's avatar
George Hotz committed
9 10 11
test:
  lui $s0, 0x3000
  ori $s0, 0x1000
George Hotz's avatar
George Hotz committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

  lui $t0, 0x4717
  ori $t0, 0x3285
  sw $t0, 0($s0)
  lui $t0, 0xa8d7
  ori $t0, 0x341e
  sw $t0, 4($s0)
  lui $t0, 0x5e97
  ori $t0, 0x2fc6
  sw $t0, 8($s0)
  lui $t0, 0x7728
  ori $t0, 0x6384
  sw $t0, 0xc($s0)
  lui $t0, 0xf802
  ori $t0, 0xf8ef
  sw $t0, 0x10($s0)
  lui $t0, 0x42a5
  ori $t0, 0xec5f
  sw $t0, 0x14($s0)
  lui $t0, 0x03bb
  ori $t0, 0xfa25
  sw $t0, 0x18($s0)
  lui $t0, 0x4cb0
  ori $t0, 0x1fad
  sw $t0, 0x1c($s0)

# syscall 4020 to trigger
  li $v0, 4020
  syscall
George Hotz's avatar
George Hotz committed
41 42 43

# length at 0x31000000
  lui $s1, 0x3100
George Hotz's avatar
George Hotz committed
44
  lw $t0, 0($s1)
George Hotz's avatar
George Hotz committed
45

George Hotz's avatar
George Hotz committed
46 47
# should be len("hello world") == 11
  li $t4, 11
George Hotz's avatar
George Hotz committed
48 49 50 51
  subu $t5, $t0, $t4
  sltiu $v0, $t5, 1 

# data at 0x31000004
52 53 54 55 56 57 58
  lw $t0, 4($s1)
  lui $t4, 0x6865
  ori $t4, 0x6c6c
  subu $t5, $t0, $t4
  sltiu $v1, $t5, 1

  and $v0, $v0, $v1
George Hotz's avatar
George Hotz committed
59 60 61 62 63 64 65 66 67 68 69 70 71 72

# save results
  lui     $s0, 0xbfff         # Load the base address 0xbffffff0
  ori     $s0, 0xfff0
  ori     $s1, $0, 1          # Prepare the 'done' status

  sw      $v0, 8($s0)         # Set the test result
  sw      $s1, 4($s0)         # Set 'done'

$done:
  jr      $ra
  nop

  .end test