Calling assembly function that takes an input INSIDE another assembly function

Hello everyone,

For my assignment I have to make two functions: one that converts an 8 bit signed integer into a 16 bit signed one, and one that adds an 8 bit signed int to a 16 bit signed int. This is all in assembly.

I have to call that first function inside the second one, to convert the first 8 bit input into a 16 bit one so I can add them. I am confused, however, on how to call a function that takes in a parameter.

I know I have to do "call ______". Calling my first function should take in r24 as the parameter (right?) and then return r25:r24. I then add the two LSBs, and then add with carry the two MSBs, because they are signed, and then ret.

What I have so far, though, does not even print anything out. Do you have any ideas on what I am doing wrong? Thank you!

I think you are confusing the Arduino "c" with some other programming language. Is there some reason for not showing the code you are using?

Paul

Assembly function (procedure) does not take parameters per se. However if you are on the Intel x86 architecture, there are six registers reserved for parameters (I forgot them). You just need to set the parameters value in those registers, make function call, do magic, set the return value to the reserved return register (rax I think). And voila, you are done.

I know I have to do "call ______". Calling my first function should take in r24 as the parameter (right?) and then return r25:r24.

Yes, that would be compatible with the avr-gcc function calling "binary interface" (ABI) (which is described here: https://www.microchip.com/webdoc/AVRLibcReferenceManual/FAQ_1faq_reg_usage.html

An assembly language function doesn't NEED to be compatible with the C ABI. You could just say "this function accepts an 8bit integer in R1 and returns a 16bit value in r7:r8" (that would be silly, but it is possible.)

What I have so far, though, does not even print anything out.

What you said you're doing sounds fine for the 8 to 16bit add. I didn't see anything about printing anything, though!