DCPUTeam / DCPUToolchain

[ARCHIVED] The code repository for the DCPU-16 Toolchain.
http://dcputoolcha.in/
MIT License
96 stars 14 forks source link

The following code triggers assertion in aout.c line 361 #171

Closed Laksen closed 11 years ago

Laksen commented 11 years ago
   .section
:_start
   SET SP, _stack_top

   SET I, _bss_start
:__start_loop
   STI [I], 0
   IFA I, _bss_end
   IFE I, _bss_end
   SET PC, __start_loop

   JSR entry

   SET PC, _halt

   .section
:_halt
   SET PC, _halt

   .section
:GetHWN
   HWN A
   SET PC, POP

   .section
:SendHWI
   SET PUSH, A
   SET PUSH, B
   SET PUSH, C
   SET PUSH, X
   SET PUSH, Y
   SET PUSH, Z
   SET PUSH, I
   SET PUSH, J
   SET J, A
   SET I, B

   SET A, [I+0]
   SET B, [I+1]
   SET C, [I+2]
   SET X, [I+3]
   SET Y, [I+4]
   SET Z, [I+5]

   HWI J

   SET J, POP
   SET I, POP
   SET Z, POP
   SET Y, POP
   SET X, POP
   SET C, POP
   SET B, POP
   SET A, POP
   SET PC, POP

   .section
:SendHWQ
   SET PUSH, A
   SET PUSH, B
   SET PUSH, C
   SET PUSH, X
   SET PUSH, Y
   SET PUSH, I
   SET PUSH, J
   SET J, A
   SET I, B

   HWQ J

   SET [I+0], A
   SET [I+1], B
   SET [I+2], C
   SET [I+3], X
   SET [I+4], Y

   SET J, POP
   SET I, POP
   SET Y, POP
   SET X, POP
   SET C, POP
   SET B, POP
   SET A, POP
   SET PC, POP
hach-que commented 11 years ago

My guess is that this is because you're not providing a name for each section, so when it starts adding the section entries into the table, the assertion for whether the name is NULL fails (but it could not be that; I haven't looked).

I'm not sure what you expect each section to do in this case either? The toolchain linker does not pre-define any sections; it's up to the developer to specify what sections they want. Most commonly, the C standard library's bootstrap does .OUTPUT INIT and .OUTPUT CODE so that all of the global initializers are executed before the code starts executing. I think you should probably check the linker and assembler documentation at http://dcputoolcha.in/docs to get an idea of how .SECTION and .OUTPUT work. They are in some ways simpler and in other ways more low-level than your average linker sections.

hach-que commented 11 years ago

This seems to have been fixed.