Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how i include assembly statements in C language program

Status
Not open for further replies.

quris_terris

Junior Member level 3
Joined
May 29, 2005
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,513
how can i write assembly language code in my C language code in KEIL software for microcontroller
 

#pragma SRC
#pragma SMALL

unsigned int asmfunc1 (
unsigned int arg)
{
#pragma ASM
INC R8
#pragma ENDASM

return (arg);
}



or


int AddUp (
int n,
int near *pTab)
{
__asm { ; open inline-assembly block
mov r2,pTab ; R2:=start of table
mov r3,n
cmp r3,#0
jmp cc_sle,stop ;
shl r3,#1 ; n * 2
add r3,r2 ; R3 := (n*2)+pTab, end of table + 2
mov r4,#0x00 ; clear result

lM: add r4,[r2+] ; add up next value
cmp r2,r3 ; end of table ?
jmp cc_nz,lM ; loop if not eot
ret ; need result in R4
}

stop:
__asm { nop ; single line assembly }
__asm { nop ; another nop }
return (0);
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top