Hi,
I want to insert assembler code in a function. The asm code in my procedure is:
b1,b2,b3,b4 are signed byte variable. ax,bx,cx,dx are register.
push ax
push bx
push cx
push dx
mov dh,b4
mov dl,b3
mov cl,b2
mov bl,b1
mov al,bl
add Al,126
mov bl,al
shl dh,1
rcl dl,1
rcl cl,1
shl dh,1
rcl dl,1
rcl cl,1
shr bl,1
rcr cl,1
rcr dl,1
rcr dh,1
mov b1,dh
mov b2,dl
mov b3,cl
mov b4,bl
pop dx
pop cx
pop bx
pop ax
How can i convert it to gcc asm code ?
Br,
Rainer
Hilscher Gesellschaft für Systemautomation mbH
Hi,
I want to insert assembler code in a function.
Look at http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html, which tells you everything on how to write inline assembler in your C-Source.
The asm code in my procedure is:
b1,b2,b3,b4 are signed byte variable. ax,bx,cx,dx are register.push ax mov dh,b4 mov dl,b3 shl dh,1 rcl dl,1 pop axHow can i convert it to gcc asm code ?
But I don't think your code snippets will work. This is x86 Assembler code that will not work on any ARM based CPU. There is no easy way to "convert" it to gcc syntax. You will need to re-write your code using ARM instructions. If you are compiling your C-File in thumb mode, this is even trickier as not every instruction is available.
Note: Usually it does not make much sense to write things in assembler, as the compilers are usually quite good at optimizing. Maybe you should try to write it in C.
Regards
MT
Andreas Jacob
Hilscher Gesellschaft fuer Systemautomation mbH
Hi Rainer,
please reffer to the GCC documentation.
The keyword you are looking is called inline assembler.
If I am right, is this also used in the VIC example.