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++

Debugging asm code in IDE

Altera_Forum
Honored Contributor II
1,159 Views

Hi, 

 

I'm trying to debug assembler code, but the debugger never jumps into the asm code like it does with c code. 

It just ignores the breakpoint set on the asm line.  

 

Cheers
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
430 Views

Have you tried using the Disassembly View Mode button?  

 

It’s the button that looks like an upside down stack of gold blocks, when in debug mode.
0 Kudos
Altera_Forum
Honored Contributor II
430 Views

I had the same problem,  

try to set a breakpoint in C/C++ Perspective, in the tree view, at the function 

name,your assembly routine (right click, add breakpoint). 

the debugger stops then at the beginning of the assembly routine, from  

then on breakpoints also work in asm code.
0 Kudos
Altera_Forum
Honored Contributor II
430 Views

 

--- Quote Start ---  

originally posted by fischer@Jul 27 2004, 03:43 PM 

i had the same problem,  

try to set a breakpoint in c/c++ perspective, in the tree view, at the function 

name,your assembly routine (right click, add breakpoint). 

the debugger stops then at the beginning of the assembly routine, from  

then on breakpoints also work in asm code. 

--- Quote End ---  

 

Hm, doesn't work for me. The self written assembly code is missing any debug information. So there is no function name in the tree to set a break point on it. 

How do I write asm code to "convince" the compiler/assembler to add debug code? 

 

Here is my tiny example "call_asm.S": 

.align 2 

.global call_asm 

 

 

call_asm: 

addi r2, r4, 1 

ret 

 

I used to debug using "ddd" and this works fine with this asm code. 

 

Cheers
0 Kudos
Altera_Forum
Honored Contributor II
430 Views

Hi, here is an asm sample, where I could set breakpoints 

also I have enabled in menu  

"Window->preferences->C/C++->Debug" 

check mark "Disassembly option" "Automatically switch to disassembly mode" 

 

perhaps this helps 

 

 

# .section .text# .align 3 

 

.section .text 

 

.globl main 

.type main,@function 

 

.globl sample 

.type sample,@function 

.globl testasm 

.type testasm,@function 

 

coeff:  

.short 3*2,-11*2,-11*2,53*2,12*2,-156*2,32*2,362*2,-210*2,-805*2,951*2,3876*2,  

3876*2,951*2,-805*2,-210*2,362*2,32*2,-156*2,12*2,53*2,-11*2,-11*2,3*2 

 

 

.section .data  

.globl dindex 

.globl firdata 

dindex: 

.int 0 

 

firdata: 

.short 0,0,0,0,0,0,0,0,0,0,0,0  

0,0,0,0,0,0,0,0,0,0,0,0  

 

 

.section .text 

 

main: 

 

start_loop: 

br start_loop 

 

 

sample: 

addi sp, sp, -48 

 

stw r16, 36(sp) 

stw r17, 32(sp) 

stw r18, 28(sp)# stw r19, 24(sp)# stw r20, 20(sp)# stw r21, 16(sp)# stw r22, 12(sp)# stw r23, 8(sp) 

stw fp, 4(sp) 

stw ra, 0(sp)  

 

 

# here we start 

 

movia r16,firdata 

ldhu r17,44(r16) 

sth r17,46(r16) 

 

ldhu r17,42(r16) 

sth r17,44(r16) 

 

ldhu r17,40(r16) 

sth r17,44(r16) 

 

ldhu r17,38(r16) 

sth r17,44(r16) 

 

ldhu r17,36(r16) 

sth r17,44(r16) 

 

ldhu r17,34(r16) 

sth r17,44(r16) 

 

 

 

ldw r16, 36(sp) 

ldw r17, 32(sp) 

ldw r18, 28(sp)# ldw r19, 24(sp)# ldw r20, 20(sp)# ldw r21, 16(sp)# ldw r22, 12(sp)# ldw r23, 8(sp) 

ldw fp, 4(sp) 

ldw ea, 0(sp) 

 

addi sp, sp, 48 

 

ret 

 

 

 

 

testasm: 

 

addi sp, sp, -48 

 

stw r16, 36(sp) 

stw r17, 32(sp) 

stw r18, 28(sp) 

stw r19, 24(sp) 

stw r20, 20(sp) 

stw r21, 16(sp) 

stw r22, 12(sp) 

stw r23, 8(sp) 

stw fp, 4(sp) 

stw ra, 0(sp)  

 

 

# here we start 

movia r16,firdata 

movi r17,5 

sth r17,0(r16) 

movi r17,12 

sth r17,2(r16) 

 

movia r16,coeff 

ldhu r17,0(r16) 

ldhu r17,2(r16)  

ldhu r17,2(r16)  

 

 

movi r16,-3 

movi r17,4 

custom 1,r18,r16,r17 

movi r16,2 

movi r17,6 

custom 129,r18,r16,r17 

 

 

movi r16,-3 

movi r17,4 

custom 0,r18,r16,r17 

movi r16,5 

movi r17,7 

custom 128,r18,r16,r17 

 

 

 

 

ldw r16, 36(sp) 

ldw r17, 32(sp) 

ldw r18, 28(sp) 

ldw r19, 24(sp) 

ldw r20, 20(sp) 

ldw r21, 16(sp) 

ldw r22, 12(sp) 

ldw r23, 8(sp) 

ldw fp, 4(sp) 

ldw ea, 0(sp) 

 

addi sp, sp, 48 

 

ret
0 Kudos
Reply