Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12626 Discussions

Nios II DE2-115 containing a Nios II processor

lj4
Beginner
382 Views

hello,

Im writing a code for a project but im encountering errors that i cant solve

Heres the code: 

.global _start
.equ LEDS_BASE_ADDR, 0x10000000
.equ SEVEN_SEG_BASE_ADDR, 0x10000020
.equ PUSH_BUTTONS_ADDR, 0x10000050
.equ SWITCHES_ADDR, 0x10000040
 
.equ START_RESUME_MASK, 0x01
.equ SET_MASK, 0x02
.equ RESET_MASK, 0x04
 
.equ CLK_FREQ, 50000000
.equ CLK_DIV, CLK_FREQ / 100
.equ MAX_TIME, 9999999
 
 .data
    centisecond_counter: .word
    lap_time: .word 
    lap_mode: .byte 
    start_resume_state: .byte 
    set_state: .byte 
    reset_state: .byte 
 
 .data
    .global centisecond_counter
    .global lap_time 
    .global lap_mode
   .global  start_resume_state
    .global set_state
    .global reset_state
 
 
.section .bss
display_hours: .byte 0
display_minutes: .byte 0
display_seconds: .byte 0
display_centiseconds: .byte 0
    
 .text
_start:
    # Initialization
    # Set up IO devices registers
    
main_loop:
    # Clock division
    call clock_division
    
    # Display update
    call display_update
    
    # Button handling
    call button_handling
    
    # Lap time logic
    call lap_time_logic
    
    # Loop back to main loop
    jmp main_loop
 
clock_division:
    movia r2, CLK_DIV
clock_division_loop:
    subi r2, r2, 1
    bne r2, zero, clock_division_loop
    
    ldw r3, (centisecond_counter)
    addi r3, r3, 1
    stw r3, (centisecond_counter)
    
    ret
 
display_update:
    # Convert counters to display format
    # Update 7-segment displays
    # Update LEDs with current count
    
    ldb r4, (reset_state)
    beq r4, zero, display_reset_mode
    
    ldb r4, (lap_mode)
    beq r4, zero, display_lap_mode
    
    ldw r4, (centisecond_counter)
    call display_time
    ret
 
display_reset_mode:
    # Display 'R' on HEX0
    movi r4, 'R'
    sth r4, (SEVEN_SEG_BASE_ADDR)
    ret
    
display_lap_mode:
    # Display 'L' on HEX0
    movi r4, 'L'
    sth r4, (SEVEN_SEG_BASE_ADDR)
    ret
 
display_time:
    # Convert centiseconds to hours, minutes, seconds, and centiseconds
    movi r6, 100 # Centiseconds per second
    movi r7, 60  # Seconds per minute
    movi r8, 60  # Minutes per hour
    
    ldw r5, (centisecond_counter)
    
    # Calculate hours
    mov r9, r5  # Copy centiseconds to r9
    div r9, r5, r8       # r9 = r5 / (60 * 60)
    stb r9, (display_hours) # Store hours
    
    # Calculate minutes
    mov r10, r5  # Copy centiseconds to r10
    div r10, r10, r8  # r10 = r5 / (60 * 60)
    mul r10, r10, r8  # r10 = r10 * (60 * 60)
    sub r9, r5, r10  # r9 = r5 - r10
    div r9, r9, r7       # r9 = r9 / 60
    stb r9, (display_minutes) # Store minutes
    
    # Calculate seconds
    mov r10, r9  # Copy minutes to r10
    div r10, r9, r7  # r10 = r9 / 60
    mul r10, r10, r7  # r10 = r10 * 60
    sub r9, r9, r10  # r9 = r9 - r10
    stb r9, (display_seconds) # Store seconds
    
    # Calculate centiseconds
    div r9, r6, r9  # r9 = r9 / 100
    stb r9, (display_centiseconds) # Store centiseconds
    
    movia r9, SEVEN_SEG_BASE_ADDR
    sth sth display_hours, 0(r9)
    sth display_minutes, 2(r9)
    sth display_seconds, 4(r9)
    sth display_centiseconds, 6(r9)
    
    ret
 
button_handling:
  
    ldw r10, (PUSH_BUTTONS_ADDR)
    
    andi r11, r10, START_RESUME_MASK
    beq r11, zero, start_resume_pressed
    
    andi r11, r10, SET_MASK
    beq r11, zero, set_pressed
    
    andi r11, r10, RESET_MASK
    beq r11, zero, reset_pressed
    
    ret
 
start_resume_pressed:
    ldb r11, 0(start_resume_state)
    beq r11, zero, start_stopwatch
    ret
    
start_stopwatch:
    movi r11, 1
    stb r11, (start_resume_state)
    ret
 
set_pressed:
    ldb r11, (lap_mode)
    xori r11, r11, 1
    stb r11, (lap_mode)
    ret
 
reset_pressed:
    movi r11, 0
    stw r11, (centisecond_counter)
    stb r11, (lap_mode)
    stb r11, (start_resume_state)
    stb r11, (set_state)
    movi r11, 1
    stb r11, (reset_state)
    ret
 
lap_time_logic:
    ret
 
These are the errors im getting after attempting to compile: 
work/asm9kvLzB.s: Assembler messages: work/asm9kvLzB.s:57: Error: unknown register main_loop
work/asm9kvLzB.s:65: Error: unknown register centisecond_counter
work/asm9kvLzB.s:67: Error: unknown register centisecond_counter
work/asm9kvLzB.s:76: Error: unknown register reset_state
work/asm9kvLzB.s:79: Error: unknown register lap_mode
work/asm9kvLzB.s:82: Error: unknown register centisecond_counter
work/asm9kvLzB.s:89: Error: unknown register SEVEN_SEG_BASE_ADDR
work/asm9kvLzB.s:95: Error: unknown register SEVEN_SEG_BASE_ADDR work/asm9kvLzB.s:104: Error: unknown register centisecond_counter
work/asm9kvLzB.s:109: Error: unknown register display_hours
work/asm9kvLzB.s:117: Error: unknown register display_minutes
work/asm9kvLzB.s:124: Error: unknown register display_seconds
work/asm9kvLzB.s:128: Error: unknown register display_centiseconds
work/asm9kvLzB.s:132: Error: unknown register sth display_hours
work/asm9kvLzB.s:133: Error: unknown register display_minutes
work/asm9kvLzB.s:134: Error: unknown register display_seconds
work/asm9kvLzB.s:135: Error: unknown register display_centiseconds
work/asm9kvLzB.s:144: Error: unknown register PUSH_BUTTONS_ADDR
work/asm9kvLzB.s:158: Error: unknown register start_resume_state
work/asm9kvLzB.s:164: Error: unknown register start_resume_state
work/asm9kvLzB.s:168: Error: unknown register lap_mode
work/asm9kvLzB.s:170: Error: unknown register lap_mode
work/asm9kvLzB.s:175: Error: unknown register centisecond_counter
work/asm9kvLzB.s:176: Error: unknown register lap_mode
work/asm9kvLzB.s:177: Error: unknown register start_resume_state
work/asm9kvLzB.s:178: Error: unknown register set_state
work/asm9kvLzB.s:180: Error: unknown register reset_state Compile failed.
 
any help will be greatly appreciated.
0 Kudos
4 Replies
khtan
Employee
317 Views

Hi,

Thanks for using Intel Forums. Do allow us some time to go through your program and get back to you later.

 

Thanks

Regards

Kian

0 Kudos
aikeu
Employee
290 Views

Hi lj4,


May I know where you get the reference document to run the design in the first place?


Thanks.

Regards,

Aik Eu


0 Kudos
aikeu
Employee
240 Views

Hi lj4,


Any follow up on the previous comment?


Thanks.

Regards,

Aik Eu


0 Kudos
aikeu
Employee
215 Views

Hi lj4,


As we do not receive any response from you on the previous question/reply/answer that we have provided. Please login to ‘https://supporttickets.intel.com’, view details of the desire request, and post a feed/response within the next 15 days to allow me to continue to support you. After 15 days, this thread will be transitioned to community support. The community users will be able to help you on your follow-up questions.


Thanks.

Regards,

Aik Eu


0 Kudos
Reply