OpenCores
URL https://opencores.org/ocsvn/zipcpu/zipcpu/trunk

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [bench/] [asm/] [testdiv.S] - Rev 43

Go to most recent revision | Compare with Previous | Blame | View Log

entry:
        ; Set up a test program
        MOV     test_div_program(PC),uPC
        MOV     top_of_stack(PC),uSP
        ; Run it in user space
        RTU
        ; Check for how the result came back: R0 = 0 means success
        MOV     uR11,R11
        TST     -1,R11
        HALT.Z
        BUSY

test_div_program:
        SUB     1,SP
        ;
        LDI     1,R11
        LDI     5,R0
        LDI     1,R1
        LDI     5,R2
        LDI     0,R3
        MOV     __HERE__+3(PC),R4
        STO     R4,1(SP)
        BRA     test_divs

        ;
        LDI     2,R11
        LDI     5,R0
        LDI     2,R1
        LDI     2,R2
        LDI     1,R3
        MOV     __HERE__+3(PC),R4
        STO     R4,1(SP)
        BRA     test_divs

        ;
        LDI     3,R11
        LDI     0xb53d0,R0
        LDI     0x2d,R1
        LDI     16496,R2
        LDI     32,R3
        MOV     __HERE__+3(PC),R4
        STO     R4,1(SP)
        BRA     test_divs

        ;
        LDI     4,R11
        LDI     2031890191,R0
        LDI     120193795,R1
        LDI     16,R2
        LDI     108789471,R3
        MOV     __HERE__+3(PC),R4
        STO     R4,1(SP)
        BRA     test_divs

        ;
        LDI     5,R11
        LDI     203553,R0
        LDI     142580994,R1
        LDI     0,R2
        LDI     203553,R3
        MOV     __HERE__+3(PC),R4
        STO     R4,1(SP)
        BRA     test_divs

        ;
        LDI     6,R11
        LDI     142580994,R0
        LDI     203553,R1
        LDI     700,R2
        LDI     93894,R3
        MOV     __HERE__+3(PC),R4
        STO     R4,1(SP)
        BRA     test_divs

        ;
        LDI     7,R11
        LDI     142580994,R0
        LDI     2499,R1
        LDI     57055,R2
        LDI     549,R3
        MOV     __HERE__+3(PC),R4
        STO     R4,1(SP)
        BRA     test_divs

        ;
        LDI     8,R11
        LDI     -142580994,R0
        LDI     2499,R1
        LDI     -57055,R2
        LDI     -549,R3
        MOV     __HERE__+3(PC),R4
        STO     R4,1(SP)
        BRA     test_divs

        ;
        LDI     9,R11
        LDI     142580994,R0
        LDI     -2499,R1
        LDI     -57055,R2
        LDI     549,R3
        MOV     __HERE__+3(PC),R4
        STO     R4,1(SP)
        BRA     test_divs

        ;
        LDI     10,R11
        LDI     -142580994,R0
        LDI     -2499,R1
        LDI     57055,R2
        LDI     -549,R3
        MOV     __HERE__+3(PC),R4
        STO     R4,1(SP)
        BRA     test_divs

        ;
        CLR     R11
        TRAP    0

test_divs:
        ;       R0 = Numerator
        ;       R1 = Denominator
        ;       R2 = Integer result
        ;       R3 = Remainder
        ;       R11= Test failure ID
        SUB     1,SP
        MOV     R2,R4
        MOV     R3,R5
        MOV     __HERE__+3(PC),R2
        STO     R2,1(SP)
        BRA     divs
        CMP     R0,R4
        BNZ     test_failure
        CMP     R1,R5
        BNZ     test_failure
        ADD     1,SP
        RETN
        
test_failure:
        TRAP    0
        NOOP
        BUSY

Go to most recent revision | Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.