diff src/gba_asm.s @ 0:c84446dfb3f5

initial add
author paulo@localhost
date Fri, 13 Mar 2009 00:39:12 -0700
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/gba_asm.s	Fri Mar 13 00:39:12 2009 -0700
     1.3 @@ -0,0 +1,73 @@
     1.4 +@ fixed fastfmul(fixed x, fixed y)
     1.5 +@ Multiply two 16.16 fixed-point numbers.
     1.6 +
     1.7 +.ARM
     1.8 +.ALIGN
     1.9 +.GLOBL  fastfmul
    1.10 +
    1.11 +fastfmul:
    1.12 +  smull r1,r2,r0,r1
    1.13 +  mov r0,r2,LSL#16
    1.14 +  orr r0,r0,r1,LSR#16
    1.15 +  bx lr
    1.16 +
    1.17 +
    1.18 +@ int dv(int num, int den)
    1.19 +@ Divide two signed integers.
    1.20 +
    1.21 +.THUMB
    1.22 +.THUMB_FUNC
    1.23 +.ALIGN
    1.24 +.GLOBL  dv
    1.25 +
    1.26 +dv:
    1.27 +  cmp r1, #0
    1.28 +  beq 0f
    1.29 +  swi 6
    1.30 +  bx lr
    1.31 +0:
    1.32 +  ldr r0, =0x7fffffff
    1.33 +  bx lr
    1.34 +
    1.35 +
    1.36 +@ int fracmul(signed int x, signed int frac)
    1.37 +@ Multiply by a 0.32 fractional number between -0.5 and 0.5.
    1.38 +@ Used for fast division by a constant.
    1.39 +
    1.40 +.ARM
    1.41 +.ALIGN
    1.42 +.GLOBL  fracmul
    1.43 +
    1.44 +fracmul:
    1.45 +  smull r1,r2,r0,r1
    1.46 +  mov r0, r2
    1.47 +  bx lr
    1.48 +
    1.49 +
    1.50 +@ int fracumul(unsigned int x, unsigned int frac)
    1.51 +@ Multiply by a 0.32 fractional number between 0 and 1.
    1.52 +@ Used for fast division by a constant.
    1.53 +
    1.54 +.ARM
    1.55 +.ALIGN
    1.56 +.GLOBL  fracumul
    1.57 +
    1.58 +fracumul:
    1.59 +  umull r1,r2,r0,r1
    1.60 +  mov r0, r2
    1.61 +  bx lr
    1.62 +
    1.63 +
    1.64 +@ void gblz_unpack(const void *src, void *dst)
    1.65 +@ Unpack GB LZSS format data.
    1.66 +
    1.67 +.THUMB
    1.68 +.THUMB_FUNC
    1.69 +.ALIGN
    1.70 +.GLOBL  _gblz_unpack
    1.71 +
    1.72 +_gblz_unpack:
    1.73 +  swi 0x11  @ LZ77UnCompWRAM
    1.74 +  bx lr
    1.75 +
    1.76 +