Pages: [1] 2 3 ... 5
Author Topic: What does this line of assembly code mean?  (Read 59281 times)
elRey
Hero Member
*****

Karma: +32/-1
Offline Offline

Posts: 565


« on: March 29, 2012, 04:48:07 PM »

Kind a general thread where one can ask what one or a small set of instructions is doing. NOT for asking what a whole function or several lines is doing. In the spirit of us newbies trying to wrap our heads around assembly language itself, not so much ME7.

I'll start.
Code:
extp    #0E1h, #1
the middle line in:
Code:
mov     r4, #1000h
extp    #0E1h, #1 ; 'ß'
mov     flamsl_w_word_3849F0, r4

So what's going on after r4 is set to 1
and before r4 (now 1) is moved to RAMword_3849F0 (flamsl_w)?

Thanks,
Rey
« Last Edit: March 29, 2012, 04:55:12 PM by elRey » Logged
nyet
Administrator
Hero Member
*****

Karma: +604/-168
Offline Offline

Posts: 12236


WWW
« Reply #1 on: March 29, 2012, 04:54:46 PM »

Not that I know anything about C166 ASM, but from the C166 manual:

Syntax EXTP op1, op2
Operation (count) ← (op2) [1 ≤ op2 ≤ 4]
Disable interrupts and Class A traps
Data_Page = (op1)
DO WHILE ((count) ≠ 0 AND Class_B_trap_condition ≠ TRUE)
Next Instruction
(count) ← (count) - 1
END WHILE
(count) = 0
Data_Page = (DPPx)
Enable interrupts and traps
Description Overrides the standard DPP addressing scheme of the long and
indirect addressing modes for a specified number of instructions.
During their execution both standard/PEC interrupts and class A
hardware traps are locked. The EXTP instruction becomes
immediately active such that no additional NOPs are required.
For any long (‘mem’) or indirect ([…]) address in the EXTP
instruction sequence, the 10-bit page number (address bits A23 -
A14) is not determined by the contents of a DPP register but by the
value of op1 itself. The 14-bit page offset (address bits A13 - A0)
is derived from the long or indirect address as usual. The value of
op2 defines the length of the effected instruction sequence.
Logged

ME7.1 tuning guide (READ FIRST)
ECUx Plot
ME7Sum checksum checker/corrrector for ME7.x

Please do not ask me for tunes. I'm here to help people make their own.

Do not PM me technical questions! Please, ask all questions on the forums! Doing so will ensure the next person with the same issue gets the opportunity to learn from your experience.
elRey
Hero Member
*****

Karma: +32/-1
Offline Offline

Posts: 565


« Reply #2 on: March 29, 2012, 04:56:49 PM »

Yeah, I read that..... Over my head a little. I should add to 1st post 'For Dummies'

What I'm looking for in an answer is something like...

It jump to address 0E1+1000 (address 10E1) and runs one line of code (#1) then jumps back and continues.

Obviously that's not it, but explained liked that, please.
« Last Edit: March 29, 2012, 05:01:11 PM by elRey » Logged
nyet
Administrator
Hero Member
*****

Karma: +604/-168
Offline Offline

Posts: 12236


WWW
« Reply #3 on: March 29, 2012, 04:58:23 PM »

So

EXTP #0E1h, #1

means

"ignore dpp for one (1) instruction following this EXP, and use page 0xe1 instead"

Logged

ME7.1 tuning guide (READ FIRST)
ECUx Plot
ME7Sum checksum checker/corrrector for ME7.x

Please do not ask me for tunes. I'm here to help people make their own.

Do not PM me technical questions! Please, ask all questions on the forums! Doing so will ensure the next person with the same issue gets the opportunity to learn from your experience.
nyet
Administrator
Hero Member
*****

Karma: +604/-168
Offline Offline

Posts: 12236


WWW
« Reply #4 on: March 29, 2012, 05:00:31 PM »

In other words, I know the exact address is

flamsl_w_word_3849F0 | (0xe1 << 14)

and not

flamsl_w_word_3849F0 | (dpp << 14)
Logged

ME7.1 tuning guide (READ FIRST)
ECUx Plot
ME7Sum checksum checker/corrrector for ME7.x

Please do not ask me for tunes. I'm here to help people make their own.

Do not PM me technical questions! Please, ask all questions on the forums! Doing so will ensure the next person with the same issue gets the opportunity to learn from your experience.
nyet
Administrator
Hero Member
*****

Karma: +604/-168
Offline Offline

Posts: 12236


WWW
« Reply #5 on: March 29, 2012, 05:09:44 PM »

You're telling the cpu that this is a location that is definitely not in the current page pointed to by dpp (but you know exactly where it is, since its a constant absolute, not relative, location)

If you're an x86 programmer, this is basically a "far" pointer deference (update both the segment and offset).

on the C166, you can do this in one fell swoop (protected atomically) w/o have to save/restore the segment.
Logged

ME7.1 tuning guide (READ FIRST)
ECUx Plot
ME7Sum checksum checker/corrrector for ME7.x

Please do not ask me for tunes. I'm here to help people make their own.

Do not PM me technical questions! Please, ask all questions on the forums! Doing so will ensure the next person with the same issue gets the opportunity to learn from your experience.
elRey
Hero Member
*****

Karma: +32/-1
Offline Offline

Posts: 565


« Reply #6 on: March 29, 2012, 05:10:31 PM »

Thank you.
Logged
elRey
Hero Member
*****

Karma: +32/-1
Offline Offline

Posts: 565


« Reply #7 on: May 09, 2012, 07:18:33 PM »

Trying to figure out relative locations...

Starting @ address 8B41A:
Code:
mov     r12, #2148h
mov     r13, #206h
movbz   r14, byte_F89C
movbz   r15, byte_380A61
calls   83h, LookupM_833f24 ; KFLDRXO Lookup

What address does the first line refer to? (#2148h = what address?  xx148)

From another file starting @ address 8E398:
Code:
mov     r12, #19BAh
mov     r13, #206h
movbz   r14, byte_F89C
movbz   r15, byte_380A5F
calls   82h, LookupM_825eac ; KFLDRXO Lookup

I know the first line refers to address 199BA (#19BAh = 199BA)

When I see address references like this, how can I figure out what absolute address they are pointing to?

I don't understand the #1xxx vs #2xxx part.

Thanks,
Rey
« Last Edit: May 09, 2012, 07:22:56 PM by elRey » Logged
nyet
Administrator
Hero Member
*****

Karma: +604/-168
Offline Offline

Posts: 12236


WWW
« Reply #8 on: May 09, 2012, 07:32:17 PM »

i dont understand what you mean by #1xxx and #2xxx. that makes no sense :/

#19BAh is 0x19BA
#206h is 0x0206

the upper bits of the actual address are whatever is in the appropriate DPP register.

Logged

ME7.1 tuning guide (READ FIRST)
ECUx Plot
ME7Sum checksum checker/corrrector for ME7.x

Please do not ask me for tunes. I'm here to help people make their own.

Do not PM me technical questions! Please, ask all questions on the forums! Doing so will ensure the next person with the same issue gets the opportunity to learn from your experience.
nyet
Administrator
Hero Member
*****

Karma: +604/-168
Offline Offline

Posts: 12236


WWW
« Reply #9 on: May 09, 2012, 07:39:24 PM »

I know the first line refers to address 199BA (#19BAh = 199BA)

the bottom 14 bits of 0x199BA is 0x199BA & 0x0x3fff = 0x19ba
the upper bits of 0x199BA is 0x18000>>14 = 6

So dpp is 6.

so dpp | 0x206 is 6<<14 | 0x206 = 0x18000 | 0x206 = 0x18206
Logged

ME7.1 tuning guide (READ FIRST)
ECUx Plot
ME7Sum checksum checker/corrrector for ME7.x

Please do not ask me for tunes. I'm here to help people make their own.

Do not PM me technical questions! Please, ask all questions on the forums! Doing so will ensure the next person with the same issue gets the opportunity to learn from your experience.
elRey
Hero Member
*****

Karma: +32/-1
Offline Offline

Posts: 565


« Reply #10 on: May 09, 2012, 07:48:49 PM »

i dont understand what you mean by #1xxx and #2xxx. that makes no sense :/

sorry. b/c of my lack of understanding.

comparing the first line of the two files:

mov     r12, #2148h
vs
mov     r12, #19BAh

I know the 2nd (#19BAh) = 199BAH because I've mapped that file.
But the 1st (#2148h) I can't figure out.

Seemed to me that only the last 3 digits were part of the absolute address (148 and 9BA). I can't figure out the #1 and #2 that each begins with.


the bottom 14 bits of 0x199BA is 0x199BA & 0x0x3fff = 0x19ba

Can you explain this using #2148h please?
« Last Edit: May 09, 2012, 07:53:49 PM by elRey » Logged
nyet
Administrator
Hero Member
*****

Karma: +604/-168
Offline Offline

Posts: 12236


WWW
« Reply #11 on: May 09, 2012, 09:34:56 PM »

#1 and #2 doesn't mean what you think it does.

ignore the #

it just means its a constant.

dpp | 0x2148 is 6<<14 | 0x2148 = 0x18000 | 0x2148 = 0x1a148

14 bits is halfway through that digit. You can't do it by digits.

8|2 = 10 = 0xa
Logged

ME7.1 tuning guide (READ FIRST)
ECUx Plot
ME7Sum checksum checker/corrrector for ME7.x

Please do not ask me for tunes. I'm here to help people make their own.

Do not PM me technical questions! Please, ask all questions on the forums! Doing so will ensure the next person with the same issue gets the opportunity to learn from your experience.
matchew
Hero Member
*****

Karma: +47/-22
Offline Offline

Posts: 503


« Reply #12 on: May 09, 2012, 09:39:51 PM »


But the 1st (#2148h) I can't figure out.


0x1A148

The clue is in the 2nd line down in both examples. R12 and R13 are both used to describe an address outside of the current data page.
« Last Edit: May 09, 2012, 09:43:11 PM by matchew » Logged
rajivc666
Full Member
***

Karma: +23/-2
Offline Offline

Posts: 127



« Reply #13 on: May 09, 2012, 11:22:19 PM »

Ideally You will have to reverse the two functions that are called (calls   83h, LookupM_833f24 & calls   82h, LookupM_825eac) to understand which memory address they are referring to. But as matchew said it is most likely going to be 206H * 4000H + #2148h =  8, 1a148h in the first case and similar in the second.
Logged
nyet
Administrator
Hero Member
*****

Karma: +604/-168
Offline Offline

Posts: 12236


WWW
« Reply #14 on: May 14, 2012, 01:27:30 PM »

Also, you have to figure out what data segment each subroutine thinks they sit in, and keep an eye out for anything that modifies the segment register(s) (for this processor, the dpp registers)

Otherwise, you'll have no prayer at figuring out what a near pointer is actually pointing to.
Logged

ME7.1 tuning guide (READ FIRST)
ECUx Plot
ME7Sum checksum checker/corrrector for ME7.x

Please do not ask me for tunes. I'm here to help people make their own.

Do not PM me technical questions! Please, ask all questions on the forums! Doing so will ensure the next person with the same issue gets the opportunity to learn from your experience.
Pages: [1] 2 3 ... 5
  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Page created in 0.022 seconds with 16 queries. (Pretty URLs adds 0.001s, 0q)