⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fat.lst

📁 Philips LPC2138 Demo Application with Keil C
💻 LST
📖 第 1 页 / 共 5 页
字号:
  514          
  515          euint32 fat_countClustersInChain(FileSystem *fs,euint32 firstcluster)
  516          {
  517   1          ClusterChain cache;
ARM COMPILER V2.42,  fat                                                                   27/03/06  10:45:49  PAGE 9   

  518   1          euint32 c=0;
  519   1          
  520   1          if(firstcluster<=1)return(0);
  521   1          
  522   1          cache.DiscCluster = cache.LogicCluster = cache.LastCluster = cache.Linear = 0;
  523   1          cache.FirstCluster = firstcluster;
  524   1          
  525   1          while(!(fat_LogicToDiscCluster(fs,&cache,c++)));
  526   1          
  527   1          return(c-1);
  528   1      }
  529          
  530          euint32 fat_DiscToLogicCluster(FileSystem *fs,euint32 firstcluster,euint32 disccluster)
  531          {
  532   1          ClusterChain cache;
  533   1          euint32 c=0,r=0;
  534   1          
  535   1          cache.DiscCluster = cache.LogicCluster = cache.LastCluster = cache.Linear = 0;
  536   1          cache.FirstCluster = firstcluster;
  537   1          
  538   1          while(!(fat_LogicToDiscCluster(fs,&cache,c++)) && !r){
  539   2              if(cache.DiscCluster == disccluster){
  540   3                  r = cache.LogicCluster;
  541   3              }
  542   2          }
  543   1          return(r);
  544   1      }
  545          
  546          euint32 fat_countFreeClusters(FileSystem *fs)
  547          {
  548   1          euint32 c=2,fc=0;
  549   1          
  550   1          while(c<=fs->DataClusterCount+1){
  551   2              if(fat_getNextClusterAddress(fs,c,0)==0)fc++;
  552   2              c++;
  553   2          }
  554   1          return(fc);
  555   1      }
ARM COMPILER V2.42,  fat                                                                   27/03/06  10:45:49  PAGE 10  

ASSEMBLY LISTING OF GENERATED OBJECT CODE



*** EXTERNALS:
 EXTERN CODE16 (lpc2000_debug_printf?T)
 EXTERN CODE16 (part_getSect?T)
 EXTERN CODE16 (part_relSect?T)
 EXTERN CODE16 (fs_getLastCluster?T)



*** PUBLICS:
 PUBLIC         fat_getSectorAddressFatEntry?T
 PUBLIC         fat_getNextClusterAddress?T
 PUBLIC         fat_setNextClusterAddress?T
 PUBLIC         fat_isEocMarker?T
 PUBLIC         fat_giveEocMarker?T
 PUBLIC         fat_getNextClusterAddressWBuf?T
 PUBLIC         fat_setNextClusterAddressWBuf?T
 PUBLIC         fat_getNextClusterChain?T
 PUBLIC         fat_LogicToDiscCluster?T
 PUBLIC         fat_allocClusterChain?T
 PUBLIC         fat_unlinkClusterChain?T
 PUBLIC         fat_countClustersInChain?T
 PUBLIC         fat_DiscToLogicCluster?T
 PUBLIC         fat_countFreeClusters?T



*** DATA SEGMENT '?CON?fat':
 00000000          ??S_1:
 00000000            DB          'HARDERROR:::fat_getNextClusterAddress '
 00000026            DB          'READ PAST FAT BOUNDARY',0x0A,0x00

*** CODE SEGMENT '?PR?fat_getSectorAddressFatEntry?T?fat':
   33: euint32 fat_getSectorAddressFatEntry(FileSystem *fs,euint32 cluster_addr)
 00000000  B430      PUSH        {R4-R5}
 00000002  ---- Variable 'cluster_addr' assigned to Register 'R1' ----
 00000002  1C04      MOV         R4,R0 ; fs
 00000004  ---- Variable 'fs' assigned to Register 'R4' ----
 00000004  ---- Variable 'res' assigned to Register 'R2' ----
   34: { 
 00000004            ; SCOPE-START
   35:     euint32 base = fs->volumeId.ReservedSectorCount,res;
 00000004  1C20      MOV         R0,R4 ; fs
 00000006  8900      LDRH        R0,[R0,#0x8]
 00000008  1C03      MOV         R3,R0
 0000000A  ---- Variable 'base' assigned to Register 'R3' ----
   37:     switch(fs->type){
 0000000A  1C20      MOV         R0,R4 ; fs
 0000000C  303C      ADD         R0,#0x3C
 0000000E  7800      LDRB        R0,[R0,#0x0]
 00000010  2802      CMP         R0,#0x2
 00000012  D012      BEQ         L_3  ; T=0x0000003A
 00000014  2803      CMP         R0,#0x3
 00000016  D01D      BEQ         L_4  ; T=0x00000054
 00000018  2801      CMP         R0,#0x1
 0000001A  D128      BNE         L_1  ; T=0x0000006E
   38:         case FAT12:
 0000001C          L_2:
   39:             res=(cluster_addr*3/1024);
 0000001C  1C0A      MOV         R2,R1 ; cluster_addr
 0000001E  2003      MOV         R0,#0x3
 00000020  4342      MUL         R2,R0
 00000022  0A92      LSR         R2,R2,#0xA
   40:             if(res>=fs->FatSectorCount){
 00000024  1C20      MOV         R0,R4 ; fs
 00000026  6A45      LDR         R5,[R0,#0x24]
 00000028  1C10      MOV         R0,R2 ; res
 0000002A  42A8      CMP         R0,R5 ; res
 0000002C  D301      BCC         L_5  ; T=0x00000032
ARM COMPILER V2.42,  fat                                                                   27/03/06  10:45:49  PAGE 11  

   41:                 return(0);
 0000002E  2000      MOV         R0,#0x0
 00000030  E01E      B           L_6  ; T=0x00000070
   42:             }else{
 00000032          L_5:
   43:                 return(base+res);
 00000032  1C15      MOV         R5,R2 ; res
 00000034  1C18      MOV         R0,R3 ; base
 00000036  1940      ADD         R0,R5 ; base
 00000038  E01A      B           L_6  ; T=0x00000070
   46:         case FAT16:
 0000003A          L_3:
   47:             res=cluster_addr/256;
 0000003A  1C0A      MOV         R2,R1 ; cluster_addr
 0000003C  0A12      LSR         R2,R2,#0x8 ; cluster_addr
   48:             if(res>=fs->FatSectorCount){
 0000003E  1C20      MOV         R0,R4 ; fs
 00000040  6A45      LDR         R5,[R0,#0x24]
 00000042  1C10      MOV         R0,R2 ; res
 00000044  42A8      CMP         R0,R5 ; res
 00000046  D301      BCC         L_8  ; T=0x0000004C
   49:                 return(0);
 00000048  2000      MOV         R0,#0x0
 0000004A  E011      B           L_6  ; T=0x00000070
   50:             }else{
 0000004C          L_8:
   51:                 return(base+res);
 0000004C  1C15      MOV         R5,R2 ; res
 0000004E  1C18      MOV         R0,R3 ; base
 00000050  1940      ADD         R0,R5 ; base
 00000052  E00D      B           L_6  ; T=0x00000070
   54:         case FAT32:
 00000054          L_4:
   55:             res=cluster_addr/128;
 00000054  1C0A      MOV         R2,R1 ; cluster_addr
 00000056  09D2      LSR         R2,R2,#0x7 ; cluster_addr
   56:             if(res>=fs->FatSectorCount){
 00000058  1C20      MOV         R0,R4 ; fs
 0000005A  6A41      LDR         R1,[R0,#0x24]
 0000005C  1C10      MOV         R0,R2 ; res
 0000005E  4288      CMP         R0,R1 ; res
 00000060  D301      BCC         L_10  ; T=0x00000066
   57:                 return(0);
 00000062  2000      MOV         R0,#0x0
 00000064  E004      B           L_6  ; T=0x00000070
   58:             }else{
 00000066          L_10:
   59:                 return(base+res);
 00000066  1C11      MOV         R1,R2 ; res
 00000068  1C18      MOV         R0,R3 ; base
 0000006A  1840      ADD         R0,R1 ; base
 0000006C  E000      B           L_6  ; T=0x00000070
   62:     }
 0000006E          L_1:
   63:     return(0);
 0000006E  2000      MOV         R0,#0x0
 00000070            ; SCOPE-END
   64: }
 00000070          L_6:
 00000070  BC30      POP         {R4-R5}
 00000072  4770      BX          R14
 00000074          ENDP ; 'fat_getSectorAddressFatEntry?T'


*** CODE SEGMENT '?PR?fat_getNextClusterAddress?T?fat':
   75: euint32 fat_getNextClusterAddress(FileSystem *fs,euint32 cluster_addr,euint16 *linear)
 00000000  B5F0      PUSH        {R4-R7,LR}
 00000002  1C0F      MOV         R7,R1 ; cluster_addr
ARM COMPILER V2.42,  fat                                                                   27/03/06  10:45:49  PAGE 12  

 00000004  ---- Variable 'cluster_addr' assigned to Register 'R7' ----
 00000004  1C06      MOV         R6,R0 ; fs
 00000006  ---- Variable 'fs' assigned to Register 'R6' ----
 00000006  B084      SUB         R13,#0x10
 00000008  ---- Variable 'offset' assigned to Register 'R4' ----
   76: {
 00000008            ; SCOPE-START
   81:     euint32 nextcluster=0;
 00000008  2000      MOV         R0,#0x0
 0000000A  9003      STR         R0,[R13,#0xC] ; nextcluster
   83:     sector=fat_getSectorAddressFatEntry(fs,cluster_addr);
 0000000C  1C30      MOV         R0,R6 ; fs
 0000000E  1C39      MOV         R1,R7 ; cluster_addr
 00000010  F7FF      BL          fat_getSectorAddressFatEntry?T  ; T=0x0001  (1)
 00000012  FFF6      BL          fat_getSectorAddressFatEntry?T  ; T=0x0001  (2)
 00000014  9002      STR         R0,[R13,#0x8] ; sector
   84:     if( (fs->FatSectorCount <= (sector-fs->volumeId.ReservedSectorCount)) || sector==0 )
 00000016  1C30      MOV         R0,R6 ; fs
 00000018  8900      LDRH        R0,[R0,#0x8]
 0000001A  9902      LDR         R1,[R13,#0x8] ; sector
 0000001C  1A0A      SUB         R2,R1,R0
 0000001E  1C30      MOV         R0,R6 ; fs
 00000020  6A40      LDR         R0,[R0,#0x24]
 00000022  4290      CMP         R0,R2
 00000024  D901      BLS         L_13  ; T=0x0000002A
 00000026  2900      CMP         R1,#0x0
 00000028  D101      BNE         L_12  ; T=0x0000002E
 0000002A          L_13:
   86:         return(0);
 0000002A  2000      MOV         R0,#0x0
 0000002C  E075      B           L_14  ; T=0x0000011A
   87:     }
 0000002E          L_12:
   89:     buf=part_getSect(fs->part,sector,IOM_MODE_READONLY);
 0000002E  1C30      MOV         R0,R6 ; fs
 00000030  6800      LDR         R0,[R0,#0x0] ; fs
 00000032  2201      MOV         R2,#0x1
 00000034  F7FF      BL          part_getSect?T  ; T=0x0001  (1)
 00000036  FFE4      BL          part_getSect?T  ; T=0x0001  (2)
 00000038  1C05      MOV         R5,R0 ; buf
 0000003A  ---- Variable 'buf' assigned to Register 'R5' ----
   91:     switch(fs->type)
 0000003A  1C30      MOV         R0,R6 ; fs
 0000003C  303C      ADD         R0,#0x3C
 0000003E  7800      LDRB        R0,[R0,#0x0]
 00000040  2802      CMP         R0,#0x2
 00000042  D04B      BEQ         L_17  ; T=0x000000DC
 00000044  2803      CMP         R0,#0x3
 00000046  D056      BEQ         L_18  ; T=0x000000F6
 00000048  2801      CMP         R0,#0x1
 0000004A  D160      BNE         L_15  ; T=0x0000010E
   93:         case FAT12:
 0000004C          L_16:
   94:             offset = ((cluster_addr%1024)*3/2)%512;
 0000004C  1C3C      MOV         R4,R7 ; cluster_addr
 0000004E  4800      LDR         R0,=0x3FF
 00000050  4004      AND         R4,R0
 00000052  2003      MOV         R0,#0x3
 00000054  4344      MUL         R4,R0
 00000056  0864      LSR         R4,R4,#0x1
 00000058  4800      LDR         R0,=0x1FF
 0000005A  4004      AND         R4,R0
 0000005C  0424      LSL         R4,R4,#0x10
 0000005E  0C24      LSR         R4,R4,#0x10
   95:             hb = buf[offset];
 00000060  1C20      MOV         R0,R4 ; offset
ARM COMPILER V2.42,  fat                                                                   27/03/06  10:45:49  PAGE 13  

 00000062  0401      LSL         R1,R0,#0x10 ; offset
 00000064  0C09      LSR         R1,R1,#0x10
 00000066  1C28      MOV         R0,R5 ; buf
 00000068  5C41      LDRB        R1,[R0,R1]
 0000006A  A800      ADD         R0,R13,#0x0
 0000006C  7001      STRB        R1,[R0,#0x0] ; hb
   96:             if(offset == 511){
 0000006E  1C20      MOV         R0,R4 ; offset
 00000070  0400      LSL         R0,R0,#0x10 ; offset
 00000072  0C00      LSR         R0,R0,#0x10
 00000074  4800      LDR         R1,=0x1FF
 00000076  4288      CMP         R0,R1

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -