1

When I write custom assembly code using labels, the disassembly is really difficult to read since it starts a new block for each label, for example this code:

    lui t2, %hi(_edata)
    addi t2, t2, %lo(_edata)
.copy_loop:
    bgeu t1, t2, .copy_end
    lw t3, 0(t0)
    sw t3, 0(t1)
    addi t0, t0, 4
    addi t1, t1, 4
    j .copy_loop
.copy_end:

Turns into the following mess in objdump:

 168:   00030313            mv  t1,t1
 16c:   000033b7            lui t2,0x3
 170:   01838393            addi    t2,t2,24 # 3018 <_edata>

00000174 <.copy_loop>:
 174:   /-> 00737c63            bgeu    t1,t2,18c <.copy_end>
 178:   |   0002ae03            lw  t3,0(t0)
 17c:   |   01c32023            sw  t3,0(t1)
 180:   |   00428293            addi    t0,t0,4
 184:   |   00430313            addi    t1,t1,4
 188:   \-- fedff06f            j   174 <.copy_loop>

0000018c <.copy_end>:
 18c:   000032b7            lui t0,0x3
 190:   02028293            addi    t0,t0,32 # 3020 <_irq_reg_save>

But when I disassemble C code generated by GCC, the labels aren't "separated" like that, and the jump arrows are drawn correctly:

 470:          01076713             ori a4,a4,16
 474:          00e7a023             sw  a4,0(a5)
 478:      /-- 01c0006f             j   494 <lcd_puts+0x4c>
 47c:   /--|-> fec42783             lw  a5,-20(s0)
 480:   |  |   00178713             addi    a4,a5,1
 484:   |  |   fee42623             sw  a4,-20(s0)
 488:   |  |   0007c783             lbu a5,0(a5)
 48c:   |  |   00078513             mv  a0,a5
 490:   |  |   dfdff0ef             jal ra,28c <lcd_write_raw>
 494:   |  \-> fec42783             lw  a5,-20(s0)
 498:   |      0007c783             lbu a5,0(a5)
 49c:   \----- fe0790e3             bnez    a5,47c <lcd_puts+0x34>
 4a0:          00000013             nop
 4a4:          00000013             nop

Is there a way to obtain the same result when writing custom assembly code in GNU AS? Am I using labels wrong?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Katharina
  • 243
  • 2
  • 5

0 Answers0