亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? c517.txt

?? dsp&c51的編程,從小百合上down的
?? TXT
?? 第 1 頁 / 共 2 頁
字號:
struct sensor_desc sensor_database = { 0x30, 0x50, 0x60, 

                             0xC4, 0x21 } ; 

so that here the structure is created in memory and pre-loaded with values. 

The array case follows a similar form: 

struct sensor_desc sensor_database[4] = {{0x30,0x50,0x60, 

                            0xC4, 0x21 }, 

{ 0x32,0x56,0x56,0xC5,0x28 ; } 

} ; 

6.4.4 Placing Structures At Absolute Addresses 

It is sometimes necessary to place a structure at an absolute address. This 

might occur if, for example, the registers of a memory-mapped real time cloc 

k chip are to be grouped together as a structure. The template in this insta 

nce might be 

Contents Of RTCBYTES.C Module 

    struct RTC { unsigned char seconds ; 

             unsigned char minutes ; 

             unsigned char hours   ; 

             unsigned char days    ; 

} ; 

struct RTC xdata RTC_chip ;  // Create xdata structure 

A trick using the linker is required here so the structure creation must be 

placed in a dedicated module. This module's XDATA segement, containing the R 

TC structure, is then fixed at the required address at link time. 

Using the absolute structure could be: 

/* Structure located at base of RTC Chip */ 

MAIN.C Module 

extern xdata struct RTC_chip ; 

/* Other XDATA Objects */ 

xdata unsigned char time_secs, time_mins ; 

void main(void) { 

time_secs = RTC_chip.seconds ; 

time_mins = RTC_chip.minutes; 

} 

Linker Input File To Locate RTC_chip structure over real RTC Registers is: 

l51 main.obj,rtcbytes.obj XDATA(?XD?RTCBYTES(0h)) 

See section 7.6 for further examples of this placement method. 

6.4.5 Pointers To Structures 

/* Define pointer to structure */ 

Pointers can be used to access structures, just as with simple data items. H 

ere is an example: 

struct sensor_desc *sensor_database ; 

/* Use Pointer To Access Structure Elements */ 

sensor_database->gain = 0x30 ; 

sensor_database->offset = 0x50 ; 

sensor_database->temp_coeff = 0x60 ; 

sensor_database->span = 0xC4 ; 

sensor_database->amp_gain = 0x21 ; 

Note that the '*' which normally indicates a pointer has been replaced by ap 

pending '->' to the pointer name. Thus '*name' and 'name->' are equivalent. 

6.4.6 Passing Structure Pointers To Functions 

A common use for structure pointers is to allow them to be passed to functio 

ns without huge amounts of parameter passing; a typical structure might cont 

ain 20 data bytes and to pass this to a function would require 20 parameters 

 to either be pushed onto the stack or an abnormally large parameter passing 

 area. By using a pointer to the structure, only the two or three bytes that 

 constitute the pointer need be passed. This approach is recommended for C51 

 as the overhead of passing whole structures can tie the poor old 8051 CPU i 

n knots! 

This would be achieved thus: 

struct sensor_desc *sensor_database ; 

sensor_database-> gain = 0x30 ; 

sensor_database-> offset = 0x50  ; 

sensor_database-> temp_coeff = 0x60 ; 

sensor_database-> span = 0xC4 ; 

sensor_ database- >amp_gain = 0x21 ; 

test_function(*struct_pointer) ; 

test_function(struct sensor_desc *received_struct_pointer) { 

   received_struct_pointer->gain = 0x20 ; 

   received_struct_pointer->temp_coef = 0x40 ; 

   } 

Advanced Note: Using a structure pointer will cause the called function to o 

perate directly on the structure rather than on a copy made during the param 

eter passing process. 

6.4.7 Structure Pointers To Absolute Addresses 

It is sometimes necessary to place a structure at an absolute address. This 

might occur if, for example, a memory-mapped real time clock chip is to be h 

andled as a structure. An alternative approach to that given in section 6.4. 

4. is to address the clock chip via a structure pointer. 

The important difference is that in this case no memory is reserved for the 

structure - only an "image" of it appears to be at the address. 

The template in this instance might be: 

/* Define Real Time Clock Structure */ 

struct RTC {char seconds ; 

        char mins ; 

        char hours ; 

        char days ; } ; 

/* Create A Pointer To Structure */ 

struct RTC xdata *rtc_ptr ;  // 'xdata' tells C51 that this 

                     //is a memory-mapped device. 

void main(void) { 

   rtc_ptr = (void xdata *) 0x8000 ;  // Move structure 

                          // pointer to address 

                          //of real time clock at 

                          // 0x8000 in xdata 

    rtc_ptr->seconds = 0 ;  // Operate on elements 

    rtc_ptr->mins = 0x01 ; 

   } 

This general technique can be used in any situation where a pointer-addresse 

d structure needs to be placed over a specific IO device. However it is the 

user's responsibility to make sure that the address given is not likely to b 

e allocated by the linker as general variable RAM! 

To summarize, the procedure is: 

Define template 

Declare structure pointer as normal 

At run time, force pointer to required absolute address in the normal way. 

6.5 Unions 

A union is similar in concept to a structure except that rather than creatin 

g sequential locations to represent each of the items in the template, it pl 

aces each item at the same address. Thus a union of 4 bytes only occupies a 

single byte. A union may consist of a combination of longs, char and ints al 

l based at the same physical address. 

The the number of bytes of RAM used by a union is simply determined by the s 

ize of the largest element, so: 

union test { char x ; 

             int y  ; 

             char a[3] ; 

             long z ; 

} ; 

requires 4 bytes, this being the size of a long. The physical location of ea 

ch element is: 

addr _ 0   x byte  y high byte a[0]  z highest byte 

       +1           y low byte a[1]  z byte 

       +2                      a[2]  z byte 

       +3                      a[3]  z lowest byte 

Non-8051 programmers should see the section on byte ordering in the 8051 if 

they find the idea of the MSB being at the low address odd! 

In embedded C the commonest use of a union is to allow fast access to indivi 

dual bytes of longs or ints.  These might be 16 or 32 bit real time counters 

, as in this example: 

/* Declare Union */ 

union clock {long real_time_count ; // Reserve four byte 

    int real_time_words[2] ;      // Reserve four bytes as 

                        // int array 

    char real_time_bytes[4] ;     // Reserve four bytes as 

                          // char array 

      } ; 

/* Real Time Interrupt */ 

void timer0_int(void) interrupt 1 using 1 { 

    clock.real_time_count++ ;       // Increment clock 

    if(clock.real_time_words[1] == 0x8000) { // Check 

                    // lower word only for value 

    /* Do something! */ 

    } 

    if(clock.real_time_bytes[3] == 0x80) {  // Check most 

                   // significant byte only for value 

    /* Do something! */ 

    } 

    } 

6.6 Generic Pointers 

C51 offers two basic types of pointer, the spaced (memory-specific) and the 

generic. Up to version 3.00 only generic pointers were available. 

As has been mentioned, the 8051 has many physically separate memory spaces, 

each addressed by special assembler instructions. Such characteristics are n 

ot peculiar to the 8051 - for example, the 8086 has data instructions which 

operate on a 16 bit (within segment) and a 20 bit basis. 

For the sake of simplicity, and to hide the real structure of the 8051 from 

the programmer, C51 uses three byte pointers, rather than the single or two 

bytes that might be expected. The end result is that pointers can be used wi 

thout regard to the actual location of the data. 

For example: 

 xdata char buffer[10] ; 

 code char message[] = { "HELLO" } ; 

void main(void) { 

       char *s ; 

       char *d ; 

       s = message ; 

       d = buffer ; 

       while(*s != '\0') { 

          *d++ = *s++ ; 

          } 

   } 

Yields: 

    RSEG  ?XD?T1 

buffer:            DS  10 

    RSEG  ?CO?T1 

message: 

    DB  'H' ,'E' ,'L' ,'L' ,'O' ,000H 

; 

; 

; xdata char buffer[10] ; 

; code char message[] = { "HELLO" } ; 

; 

;    void main(void) { 

    RSEG  ?PR?main?T1 

    USING    0 

main: 

            ; SOURCE LINE # 6 

; 

;       char *s ; 

;       char *d ; 

; 

;       s = message ; 

            ; SOURCE LINE # 11 

    MOV      s?02,#05H 

    MOV      s?02+01H,#HIGH message 

    MOV      s?02+02H,#LOW message 

;       d = buffer ; 

            ; SOURCE LINE # 12 

    MOV      d?02,#02H 

    MOV      d?02+01H,#HIGH buffer 

    MOV      d?02+02H,#LOW buffer 

?C0001: 

; 

;       while(*s != '\0') { 

            ; SOURCE LINE # 14 

    MOV      R3,s?02 

    MOV      R2,s?02+01H 

    MOV      R1,s?02+02H 

    LCALL    ?C_CLDPTR 

    JZ       ?C0003 

;          *d++ = *s++ ; 

            ; SOURCE LINE # 15 

    INC      s?02+02H 

    MOV      A,s?02+02H 

    JNZ      ?C0004 

    INC      s?02+01H 

?C0004: 

    DEC      A 

    MOV      R1,A 

    LCALL    ?C_CLDPTR 

    MOV      R7,A 

    MOV      R3,d?02 

    INC      d?02+02H 

    MOV      A,d?02+02H 

    MOV      R2,d?02+01H 

    JNZ      ?C0005 

    INC      d?02+01H 

?C0005: 

    DEC      A 

    MOV      R1,A 

    MOV      A,R7 

    LCALL    ?C_CSTPTR 

;          } 

            ; SOURCE LINE # 16 

    SJMP     ?C0001 

;       } 

            ; SOURCE LINE # 17 

?C0003: 

    RET 

; END OF main 

    END 

As can be seen, the pointers '*s' and '*d' are composed of three bytes, not 

two as might be expected. In making *s point at the message in the code spac 

e an '05' is loaded into s ahead of the actual address to be pointed at. In 

the case of *d '02' is loaded. These additional bytes are how C51 knows whic 

h assembler addressing mode to use. The library function C_CLDPTR checks the 

 value of the first byte and loads the data, using the addressing instructio 

ns appropriate to the memory space being used. 

This means that every access via a generic pointer requires this library fun 

ction to be called. The memory space codes used by C51 are: 

CODE  - 05 

XDATA - 02 

PDATA - 03 

DATA  - 05 

IDATA - 01 

6.7 Spaced Pointers In C51 

Considerable run time savings are possible by using spaced pointers. By rest 

ricting a pointer to only being able to point into one of the 8051's memory 

spaces, the need for the memory space "code" byte is eliminated, along with 

the library routines needed to interpret it. 

A spaced pointer is created thus: 

char xdata *ext_ptr ; 

to produce an uncommitted pointer into the XDATA space or 

char code *const_ptr ; 

which gives a pointer solely into the CODE space. Note that in both cases th 

e pointers themselves are located in the memory space given by the current m 

emory model. Thus a pointer to xdata which is to be itself located in PDATA 

would be declared thus: 

pdata char xdata *ext_ptr ; 

   |         | 

location     | 

of pointer   | 

        Memory space pointed into 

        by pointer 

In this example strings are always copied from the CODE area into an XDATA b 

uffer. By customising the library function "strcpy()" to use a CODE source p 

ointer and a XDATA destination pointer, the runtime for the string copy was 

reduced by 50%. The new strcpy has been named strcpy_x_c(). 

The function prototype is: 

extern char xdata *strcpy(char xdata*,char code *) ; Here is the code produc 

ed by the spaced pointer strcpy(): 

; char xdata *strcpy_x_c(char xdata *s1, char code *s2)  { 

_strcpy_x_c: 

    MOV      s2?10,R4 

    MOV      s2?10+01H,R5 

;__ Variable 's1?10' assigned to Register 'R6/R7' __ 

;   unsigned char i = 0; 

;__ Variable 'i?11' assigned to Register 'R1' __ 

    CLR      A 

    MOV      R1,A 

?C0004: 

; 

;   while ((s1[i++] = *s2++) != 0); 

    INC      s2?10+01H 

    MOV      A,s2?10+01H 

    MOV      R4,s2?10 

    JNZ      ?C0008 

    INC      s2?10 

?C0008: 

    DEC      A 

    MOV      DPL,A 

    MOV      DPH,R4 

    CLR      A 

    MOVC     A,@A+DPTR 

    MOV      R5,A 

    MOV      R4,AR1 

    INC      R1 

    MOV      A,R7 

    ADD      A,R4 

    MOV      DPL,A 

    CLR      A 

    ADDC     A,R6 

    MOV      DPH,A 

    MOV      A,R5 

    MOVX     @DPTR,A 

    JNZ      ?C0004 

?C0005: 

;   return (s1); 

; } 

?C0006: 

    END 

Notice that no library functions are used to determine which memory spaces a 

re intended. The function prototype tells C51 only to look in code fot the s 

tring and xdata for the RAM buffer. 

---------------------------------------------------------------------------- 

---- 

  



-- 

Ours is essentially a tragic age, so we refuse to take it tragically. 

  

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色哟哟欧美精品| 久久久久久久性| 久久这里只精品最新地址| 亚洲同性gay激情无套| 精品在线你懂的| 欧美伦理影视网| 亚洲婷婷综合色高清在线| 黄色成人免费在线| 欧美三级电影精品| 国产精品私人影院| 国产麻豆日韩欧美久久| 欧美片在线播放| 一区二区三区毛片| 处破女av一区二区| 日日夜夜精品免费视频| 亚洲女女做受ⅹxx高潮| 国产一区二区三区久久久| 欧美日韩午夜精品| 亚洲视频免费观看| 99麻豆久久久国产精品免费| 久久久综合激的五月天| 麻豆成人av在线| 欧美福利视频一区| 日韩在线卡一卡二| 欧美日韩国产高清一区二区三区 | 韩国精品主播一区二区在线观看| 欧美日韩一级黄| 亚洲综合网站在线观看| 色天天综合久久久久综合片| 欧美国产日本韩| 国产福利一区二区三区在线视频| 久久久精品黄色| 国产馆精品极品| 日本一区二区不卡视频| 丁香一区二区三区| 中文字幕一区二区三区乱码在线| av在线综合网| 综合网在线视频| 日本丶国产丶欧美色综合| 亚洲欧美成人一区二区三区| 在线欧美一区二区| 婷婷开心久久网| 日韩小视频在线观看专区| 免费成人av在线| 久久久三级国产网站| jizzjizzjizz欧美| 亚洲国产日韩a在线播放| 欧美高清视频一二三区| 精品一区免费av| 国产拍欧美日韩视频二区| 91亚洲精品一区二区乱码| 香蕉久久夜色精品国产使用方法| 欧美一区日韩一区| 国产成人久久精品77777最新版本| 中文字幕亚洲不卡| 欧美高清www午色夜在线视频| 久久精品国产久精国产爱| 国产精品色呦呦| 5858s免费视频成人| 国产综合色在线视频区| 国产精品国产自产拍高清av| 欧美日韩一区二区在线视频| 国产在线看一区| 一区二区高清免费观看影视大全| 69久久99精品久久久久婷婷| 国产酒店精品激情| 亚洲日本一区二区三区| 欧美精品第1页| 国产一区二区三区久久久| 中文字幕在线不卡| 欧美日本在线一区| 成人黄色一级视频| 亚洲国产成人porn| 中文字幕免费一区| 欧美日韩精品欧美日韩精品一综合| 麻豆精品在线看| 国产日韩精品一区二区三区 | 天使萌一区二区三区免费观看| 欧美高清视频不卡网| 美女在线视频一区| 中文字幕视频一区| 欧美剧情片在线观看| 精品中文av资源站在线观看| 亚洲国产精品影院| 久久综合一区二区| 欧美亚洲国产一区二区三区| 精品影视av免费| 亚洲午夜免费电影| 国产精品久久久久精k8| 欧美一三区三区四区免费在线看| 蜜臀av性久久久久蜜臀aⅴ流畅 | 国产日韩欧美高清在线| 日本大香伊一区二区三区| 韩国欧美国产一区| 亚洲一区二区视频| 日韩欧美一区在线| 色综合久久久久综合| 国产1区2区3区精品美女| 日日摸夜夜添夜夜添亚洲女人| 日韩一区欧美小说| 久久久美女艺术照精彩视频福利播放| 在线视频你懂得一区二区三区| 成人理论电影网| 国产一区二区三区久久悠悠色av| 午夜精品久久久久久久99水蜜桃 | 久久伊99综合婷婷久久伊| 97se狠狠狠综合亚洲狠狠| 国产成人一区在线| 精品一区精品二区高清| 日韩在线观看一区二区| 综合激情成人伊人| 国产精品丝袜黑色高跟| 久久影院午夜片一区| 欧美一区二区三区婷婷月色| 91免费视频网| 不卡一二三区首页| 国产福利一区二区三区在线视频| 麻豆国产精品官网| 日本sm残虐另类| 免费在线一区观看| 亚洲一区欧美一区| 亚洲一卡二卡三卡四卡五卡| 国产精品不卡视频| 中文字幕永久在线不卡| 国产精品久久久久久久久免费相片 | 亚洲影视在线播放| 亚洲图片另类小说| 亚洲男女毛片无遮挡| 1024成人网| 亚洲视频1区2区| 一区二区三区日韩精品| 一区二区视频免费在线观看| 高清不卡一区二区| 亚洲欧洲av在线| 国产精品久久久久一区二区三区共| 国产精品女主播在线观看| 国产精品免费av| 亚洲女爱视频在线| 午夜精品福利一区二区蜜股av| 亚洲国产日韩精品| 男人的天堂久久精品| 国产福利一区在线观看| aaa国产一区| 日本高清成人免费播放| 欧美日本一区二区在线观看| 91精品国产一区二区| 欧美成人精品高清在线播放| 91精品国产乱码| 中文字幕中文字幕一区二区| 亚洲丝袜另类动漫二区| 日韩黄色片在线观看| 日本亚洲三级在线| 99在线精品视频| 欧美三级日韩在线| 在线综合亚洲欧美在线视频| 久久婷婷国产综合国色天香| 国产精品久久久久影院亚瑟| 琪琪久久久久日韩精品| 国产激情一区二区三区四区| 欧美三片在线视频观看| 亚洲精品一区二区三区影院| 亚洲免费av高清| 日本视频一区二区三区| 成人免费视频一区二区| 欧美日韩一区在线观看| 欧美经典一区二区| 麻豆精品国产传媒mv男同| 国内成人精品2018免费看| 成人aaaa免费全部观看| 欧美一区二区三区视频| 亚洲欧美日韩成人高清在线一区| 久久精品国产99国产| 99riav一区二区三区| 日本一区二区三区久久久久久久久不| 亚洲精品国产一区二区精华液 | 久久精品国产在热久久| av一区二区三区| 久久亚洲一级片| 日本视频在线一区| 欧美精品亚洲二区| 日韩毛片在线免费观看| 成人不卡免费av| 777亚洲妇女| 夜夜嗨av一区二区三区网页| 成人av动漫网站| 精品国产乱码91久久久久久网站| 午夜伦欧美伦电影理论片| 99久久婷婷国产综合精品电影| 26uuu精品一区二区在线观看| 午夜a成v人精品| 欧美日韩精品一区二区| 国产欧美精品一区aⅴ影院 | 日日骚欧美日韩| 韩国v欧美v日本v亚洲v| 精品剧情在线观看| 亚洲综合视频在线观看| 94色蜜桃网一区二区三区| 国产精品萝li| 成人免费视频app| 久久久精品蜜桃|