How to do timer with Nios II assembly?

Posted by Nick Rosencrantz on Stack Overflow See other posts from Stack Overflow or by Nick Rosencrantz
Published on 2012-10-20T04:58:12Z Indexed on 2012/10/20 5:00 UTC
Read the original article Hit count: 275

Filed under:
|
|
|

I've got an assignment in a computer engineering course that I don't fully understand since it is so large. Anyway I started coding the parts of it and it seems we should make code for some sort of timer. I've started put together the subroutine for snaptime but I'm not sure what I want:

.equ timer, 0x920
.global snaptime

        .text
        .align 2

snaptime:
movia r8,timer  # basadressen till timern
stw r0,12(r8) # sparar 0 till snapl
movi r9,0b0110    # spara 6 i r9
stw r9,16(r8) # spara r9
movi ... ?
andi r10,r10,0xFFFF

The manual for Nios II assembly is here and the C code for what I'm trying to do is:

#define TIMER_1_BASE ((volatile unsigned int*) 0x920)

    int snaptime (void)
    {
    int snaphight;
    int snaplow;
    int snap;

    TIMER_1_BASE[4]=0;
    snaphigh = TIMER_1_BASE[5] & 0xffffff;
    snaplow = TIMER_1_BASE[4] & 0xffffff;

    snap = snaphigh*65536+snaplow;
    return (snap);
    }

Perhaps you can inspect the C which should be properly defined and see how I make it with assembly since the spec says it should be assembly.

© Stack Overflow or respective owner

Related posts about c

    Related posts about assembly