1

I'm trying to understand a program in assembly code which should be compiled with COSMIC compiler to run on STM8 controller.

At the beginning of the program, there are a couple of xref and xdef and then comes a .dcall statement or command. Here it is:

.dcall "2,0,__checksum16"

I searched the compiler's manual, the controller's programming manual and the internet in general but couldn't find what does this line mean.

Could someone please explain what does it mean and what are these comma-seperated entries mean?

glts
  • 21,808
  • 12
  • 73
  • 94
Salahuddin
  • 1,617
  • 3
  • 23
  • 37
  • Did you try to ask Cosmic Software? What did they say? Presumably it defines a call to `checksum16` so that symbolic debuggers and/or linkers can show some more context information. A quick run of `strings /CXSTM8_EVAL/castm8.exe` reveals more of those pseudo instructions. – the busybee Jul 05 '19 at 20:24
  • 1
    I know nothing about this, but I noticed in the header of this file the developer tried to describe part of what they learned from Cosmic Software: http://e3ft.ddns.net/vvcdtapublic/dtapublic/to_be_filed/uculib01/src/stm8/cosmic/modx0/bas16absdiffboundedrxx/src/bas16absdiffboundedrxx.s?limit_changes=0&diff_format=l&view=markup&sortby=rev&pathrev=30 . Not sure if it is helpful to you or not. – Michael Petch Jul 06 '19 at 02:20
  • The line seems to be some debugging entry which is used to perform a stack requirement analysis after linking. If the document described by Michael Petch is right, the 2 means that a function call requires 2 bytes of stack (the return address) and the 0 means that the function does not access parameters that have been pushed by the calling function. – Martin Rosenau Jul 06 '19 at 05:41

1 Answers1

3

It is an assembler directive marking the entry point, symbol name and stack usage of a function.

According to this:

[...] the first integer is the stack space used by the call instruction plus any automatic storage used by the function. The second integer is the number of bytes stacked by the caller.

I suggest that given its name and function that it causes debug information to be inserted into the object file for use by the ZAP symbolic debugger. I am not familiar with the Cosmic tool chain, but it is also possibly used to perform stack depth analysis within the call graph by the linker.

Clifford
  • 88,407
  • 13
  • 85
  • 165