ant@cmr.ncsl.nist.gov (John Antonishek) (07/06/89)
HELP! I am trying to interface an assembly routine with the printf module contained in the amiga.lib library. According to the "Amiga ROM KERNAL Reference Manual", each argument is contained in a long word "shell" (if I'm reading it correctly). But, the only way I was able to get printf("%c%c%c%c%c\n",'H','e','l','l','o'); to work was: ------------------------------------------------------------------------------- XREF _printf SECTION CODE,CODE LC0: dc.b '%c%c%c%c%c',10,0 EVEN XDEF _main _main: link a6,#0 move.w #111,-(sp) move.w #108,-(sp) move.w #108,-(sp) <=== is there a more efficent way to move.w #101,-(sp) get a char/word on the stack? move.w #72,-(sp) pea LC0 jsr _printf unlk a6 rts end ------------------------------------------------------------------------------- Does this mean that "int's" are 16 bits long and that "char" and "short" are promoted to "int" (at least in the amiga.lib case)? If it matters, I obtained amiga.lib from a Lattice 4.0.2 disk. I am modifying code that will greatly depend on how C arguments are passed on the stack. Is there an accepted convention on the size of "ints" and "shorts"? If "ints" are 4 bytes, then according to C, if I pass a "short" to a function, it will be promtoted to "int" (which is the same size as long). How do Lattice and Manx handle this in their new releases (i.e., are "ints" passed as: "move.w #0,-(sp)" or "move.l #0,-(sp)")? How about "chars" and "shorts"? I need to know as much as possible about the variations in the methods. Another related question: How do I interface this to Lattice's "printf" routine? The "Hello" message appears, but the guru isn't far behind! Does it have something to do with having to set up A4 to point to my data area? Does anyone know how I can get the source code for BLINK? The code would greatly help me in what I am trying to do. Thanks in advance. John Antonishek ant@cmr.ncsl.nist.gov