A89: Difficulty inserting assembly into C code
[Prev][Next][Index][Thread]
A89: Difficulty inserting assembly into C code
l'm having trouble getting the assembly code in this program to work. As a
test, l copied the idle_loop() source code, and am trying to have it
assembled with my program. When l compile the C program, l get about 3
errors per line from the Assembler. l know it has something to do with the
stuff in the asm(" ") braces, or all of it.
#include <romcalls.h> // include file for rom calls
#define clr_scr graphlib__0005 // any library calls used in the
#define idle_loop userlib__0000 // program have to be defined
int get_key();
int _ti89; // compiles for TI-89
_main() // start of code
{
char str[6];
int key;
clr_scr();
DrawLine(14,99,54,29,2);
DrawLine(145,99,105,29,2);
key = get_key();
sprintf(str,"%d",key);
DrawStr(100,0,str,0);
clr_scr();
};
get_key()
{
asm("
movem.l a0-a6/d1-d7,-(a7)
\idle_start
move.l APD_INIT,APD_TIMER ; reset APD timer
clr.w APD_FLAG ; reset APD flag
\wait_idle
tst.w APD_FLAG ; time for APD?
beq \no_apd ; no -- do not shut down
\do_apd
trap #4
bra \idle_start
\no_apd
tst.w (doorsos::kb_vars+$1C) ; has a key been pressed?
beq \wait_idle
move.l APD_INIT,APD_TIMER ; reset APD timer (1)
move.w (doorsos::MaxHandles+$1E),d0
clr.w (doorsos::kb_vars+$1C) ; clear key buffer
\try_key_off
cmp.w #KEY_DIAMOND+$10B,d0 ;press of diamond+On
beq \do_apd ;->off
\not_key_off
movem.l (a7)+,a0-a6/d1-d7
rts
");
};
Follow-Ups: