Update toolchain to use GCC 8.1.
[n64chain.git] / libn64 / rcp / vi.c
1 //
2 // libn64/rcp/vi.c: VI helper functions.
3 //
4 // n64chain: A (free) open-source N64 development toolchain.
5 // Copyright 2014-16 Tyler J. Stachecki <stachecki.tyler@gmail.com>
6 //
7 // This file is subject to the terms and conditions defined in
8 // 'LICENSE', which is part of this source code package.
9 //
10
11 #include <rcp/vi.h>
12
13 void vi_flush_state(const vi_state_t *state) {
14 uint32_t vi_region = 0xA4400000U;
15 uint32_t data, end_ptr;
16
17 __asm__ __volatile__(
18 ".set noreorder\n\t"
19 ".set gp=64\n\t"
20 "addiu %[end_ptr], %[vi_region], 0x30\n"
21
22 "1:\n\t"
23 "ld %[data], 0x30(%[state])\n\t"
24 "addiu %[state], %[state], -0x8\n\t"
25 "sw %[data], 0x4(%[end_ptr])\n\t"
26 "dsrl32 %[data], %[data], 0x0\n\t"
27 "sw %[data], 0x0(%[end_ptr])\n\t"
28 "bne %[vi_region], %[end_ptr], 1b\n\t"
29 "addiu %[end_ptr], %[end_ptr], -0x8\n\t"
30 ".set gp=default\n\t"
31 ".set reorder\n\t"
32
33 : [state] "=&r" (state), [data] "=&r" (data),
34 [end_ptr] "=&r" (end_ptr), [vi_region] "=&r" (vi_region)
35 : "0" (state), "3" (vi_region)
36 );
37 }
38