For instruction :NEG,it has one usage:NEG oprx8,X.I don't know how to use it in fact.

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

For instruction :NEG,it has one usage:NEG oprx8,X.I don't know how to use it in fact.

跳至解决方案
1,166 次查看
100asong
Contributor I

I don't know what means oprx8.

In datasheet,oprx8 is "Any label or expression that evaluates to an unsigned 8-bit value, used for indexed addressing".

Could you please give me an sample.

Thanks.:smileytongue:

标签 (1)
0 项奖励
回复
1 解答
905 次查看
peg
Senior Contributor IV

Hello Tom,

 

PTAD, I presume is 0. What's happening here is the assembler is optimising this to the faster IX addressing mode which uses an implied zero base. It shouldn't happen for a non-zero base.

 

在原帖中查看解决方案

0 项奖励
回复
5 回复数
905 次查看
rocco
Senior Contributor II

Hi Tom,

 

I assume you are talking about a MC9S08 family MCU. If so, then you need to get the HCS08 Family Reference Manual and read section 6.3 to learn about the addressing modes in the S08.

 

But to answer your question:

 

        neg     n,X     ;negate the a value in memory

 

"n" is an 8 bit offset, contained in the assembled instruction, which is added to the contents  of the H:X register to determine the address in memory to be negated.

0 项奖励
回复
905 次查看
peg
Senior Contributor IV

Hello Tom,

 

Not clear what you are saying here. There are many addressing modes available with this instruction

The limitation you allude to here occurs with many instructions in this addressing mode.

It means that the base value that you index from must be in the "zero page" or the first 256 bytes of RAM.

0 项奖励
回复
905 次查看
100asong
Contributor I

Thanks for your help.

Now I know how to use it:smileysurprised:prx8 is a base address value and X index register is offset.

I meet a new question: the machine code is 60 00,I want to know what the asm sentenct  is.

I try to write the code: NEG 0,X or NEG PTAD,X. But the corresponding hex is 70.I can not get 60 00 object binary.

Please help me about it.Thanks.

0 项奖励
回复
906 次查看
peg
Senior Contributor IV

Hello Tom,

 

PTAD, I presume is 0. What's happening here is the assembler is optimising this to the faster IX addressing mode which uses an implied zero base. It shouldn't happen for a non-zero base.

 

0 项奖励
回复
905 次查看
100asong
Contributor I

Okay,I know now.It should be code space.

0 项奖励
回复