inline asm help

This is a forum for discussing the development and testing of alpha MS2/Extra code. Documentation
(Runs on MS2 and Microsquirt)

Moderators: jsmcortina, muythaibxr

Post Reply
oskar
Helpful MS/Extra'er
Posts: 62
Joined: Sun Aug 19, 2007 3:31 pm
Location: Lyons, CO

inline asm help

Post by oskar »

Hi,

I am trying to understand this construct ( ms2_extra_ign_in.c, tooth logger ):


"std 1,Y\n"
:
: "y" (log_offset+ram_data),
"m" (*((unsigned char *)&tooth_diff_this+1)), // byte 3:**2**:1:0
"m" (*((unsigned int *)&tooth_diff_this+1)), // bytes 3:2:**1**:**0**
"m" (synch),
"m" (flagbyte1)

Also, where do I find more info about the MC9S12C opcodes

Thanks
Oskar
vlopsahl
Helpful MS/Extra'er
Posts: 136
Joined: Tue Jul 05, 2005 3:04 pm

Post by vlopsahl »

I cannot explain the tooth logger, but I must show you something interesting I saw the other day. A friend has DTA-engine management and the tuningsoftware has a built in Oscilloscope. It shows the tooth times and the cranking. It also calculates approximately where the missing tooth(s) are and the angle on the second trigger. This would be a nice feature to have with megasquirt as well. I hope Megatunix will support MS2E soon. I guess the tooth logger easily could be developed to something like the DTA Oscilloscope.

http://www.dtafast.co.uk/screenshots/Su ... anking.JPG

Thanks
Vegard
Audi 80Q 2,0 20V Turbo 630cc AEB/ABA/ABF
MS-II V3 MT2.25 MS2 Extra 2.0.1 VAG/Bosch VR 60-2 Waste spark PWM-idle
muythaibxr
Site Admin
Posts: 8230
Joined: Thu Oct 14, 2004 12:48 pm

Re: inline asm help

Post by muythaibxr »

oskar wrote:Hi,

I am trying to understand this construct ( ms2_extra_ign_in.c, tooth logger ):


"std 1,Y\n"
:
: "y" (log_offset+ram_data),
"m" (*((unsigned char *)&tooth_diff_this+1)), // byte 3:**2**:1:0
"m" (*((unsigned int *)&tooth_diff_this+1)), // bytes 3:2:**1**:**0**
"m" (synch),
"m" (flagbyte1)

Also, where do I find more info about the MC9S12C opcodes

Thanks
Oskar
What specifically do you not understand about that construct?

You can download the pdf for the hcs12 opcodes from freescale, I don't have the link though as I found and downloaded the pdf more than a year ago.

Ken
oskar
Helpful MS/Extra'er
Posts: 62
Joined: Sun Aug 19, 2007 3:31 pm
Location: Lyons, CO

Re: inline asm help

Post by oskar »

[quote="muythaibxr"][quote="oskar"]Hi,

I am trying to understand this construct ( ms2_extra_ign_in.c, tooth logger ):


"std 1,Y\n"
:
: "y" (log_offset+ram_data),
"m" (*((unsigned char *)&tooth_diff_this+1)), // byte 3:**2**:1:0
"m" (*((unsigned int *)&tooth_diff_this+1)), // bytes 3:2:**1**:**0**
"m" (synch),
"m" (flagbyte1)

Also, where do I find more info about the MC9S12C opcodes

Thanks
Oskar[/quote]

What specifically do you not understand about that construct?

You can download the pdf for the hcs12 opcodes from freescale, I don't have the link though as I found and downloaded the pdf more than a year ago.

Ken[/quote]

well, here is the whole story:

I am (trying) to compile the source in ICC7. The C code I got compiling just a few modifications with the ISR handlers and memory (tables) at nonstandard location.
In the moment this asm inline stmt does not compile. Too GNU specific, I guess. And I am used to C (win32) but not at all to assembler

the trouble starts with

"std 1,Y\n"

I was thinking std takes one operand, Y is a register, then the statement is closed by a newline ( \n)

Then I cannot figure ( in the GNU compiler docu) what the two : as well as
"y" (log_offset+ram_data). Of course log_offset is an address, ram_data the starting address ..

Anyways, to cut it short: In the moment, I would not even need to understand this codesnippet, it just just would need to compile ( in ICC7)


with the docs, I found something

THX
Oskar
muythaibxr
Site Admin
Posts: 8230
Joined: Thu Oct 14, 2004 12:48 pm

Re: inline asm help

Post by muythaibxr »

oskar wrote:
"std 1,Y\n"
This particular instruction uses indexed addressing.

In the Y register there's already a memory address...

std 1,Y stores whatever's in the "d" register to 1+ the adress in Y.

Ken
oskar
Helpful MS/Extra'er
Posts: 62
Joined: Sun Aug 19, 2007 3:31 pm
Location: Lyons, CO

Re: inline asm help

Post by oskar »

I guess, finally I am getting my fool head to get it :-)

asm ( .....
"std 1,Y\n"
: // no output
: "y" (log_offset+ram_data), // operand nr1, %1 'formatted for register Y
"m" (*((unsigned char *)&tooth_diff_this+1)), // operand nr2, %2
"m" (*((unsigned int *)&tooth_diff_this+1)), // %3
"m" (synch), // %4
"m" (flagbyte1) // %5 , not used

learning is fun, even for a 52 year old

Oskar
jsmcortina
Site Admin
Posts: 39615
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Post by jsmcortina »

I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
Post Reply