gpt4 book ai didi

c - C 中的 Unsigned Long 在 PIC24 汇编语言中是什么样子的?

转载 作者:太空宇宙 更新时间:2023-11-04 02:09:55 24 4
gpt4 key购买 nike

我在 PIC24 上用 C 语言定义了一个变量

假设变量的名称(在 C 文件中)是 The_Number_Of_Bytes

在PIC24的C代码中,是这样定义的....

 unsigned long The_Number_Of_Bytes=0;   // number of bytes in buffer

当名为 DATABUF01 的字节数组将包含 The_Number_Of_Bytes 字节时,我将被调用(抱歉隐含的冗余),我需要确保我准确地执行了那么多字节,然后停止。

我非常有信心这个数字会小于 65535,所以为什么它是 unsigned long 有待其他讨论。现在,我想知道;哪个是高位词,哪个是低位词? (就此而言,long 是 PIC24 C 中的 32 位数字吗?)

有人能告诉我这个例子中的 W2W3 会是什么吗?

    Mov.W   #_The_Number_Of_Bytes, W1       ;From the dispatcher
Mov.W [W1++], W2 ;My question: Hi Order or Low Order ?
Mov.W [W1], W3 ;My question: Hi Order or Low ?

Mov.W #_DATABUF01, W4 ;The Start

Mov.B [W4++], W5 ;First byte...

: ;Whatever
: ;Whatever
: ;Whatever

有人可以确认或纠正我对 unsigned long int 的高/低阶的想法吗?

EDIT 评论者要求这样做。可以回答问题(评论是我的)

请求评论,大小好像是4个字节,从这个...

  45:                 unsigned long i=0;    
0AB6A B80060 mul.uu 0x0000,#0,0x0000 ;make a zero
0AB6C 980710 mov.w 0x0000,[0x001c+2] ;no clue which word
0AB6E 980721 mov.w 0x0002,[0x001c+4] ;aha, if I made it 1 or 2, I'd know
46: unsigned int Fischer;
47:
48: Fischer = sizeof(i);
0AB70 200040 mov.w #0x4,0x0000 ;So it must be 4
0AB72 780F00 mov.w 0x0000,[0x001c] ;okay, it's a 4 byte number
49:

最佳答案

以下是 PIC24 MCU 用户指南的 MPLAB C 编译器的片段:

5.3 DATA REPRESENTATION
Multibyte quantities are stored in “little endian” format, which means:

  • The least significant byte is stored at the lowest address
  • The least significant bit is stored at the lowest-numbered bit position

As an example, the long value of 0x12345678 is stored at address 0x100 as follows:
0x1000x1010x1020x103
 0x78  0x56  0x34  0x12 

As another example, the long value of 0x12345678 is stored in registers w4 and w5:
   w4       w5   
0x56780x1234

关于c - C 中的 Unsigned Long 在 PIC24 汇编语言中是什么样子的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15508199/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com