реклама на сайте
подробности

 
 
> Как подключить *.s файл, Компилятор ICC
$ilent
сообщение Sep 28 2006, 12:46
Сообщение #1


Частый гость
**

Группа: Новичок
Сообщений: 116
Регистрация: 14-02-06
Из: Москва. Перово
Пользователь №: 14 296



есть у меня файл написаный не знаю на чём, необходимо подключить его к ICC проекту или превратить в Си. При попытке подключения ругань на всё... АСМ не знаю вообще... Помогите советом...
Код
####################################################################
## File        : asm_codec.s
####################################################################
##
## Version     : 1.0
##
## Written by  : Chaouki ROUAISSIA
##
## Date        : 02-08-2004
##
## Project     : -
##
####################################################################
## Changes     :
####################################################################
## Description : Reads and writes a sample              
##                                                                    
##  Connections between the CODEC and the LC07A :                    
##                                                                    
##                                   MCLK  -->  PB(2)                
##                                   FSYNC -->  PB(0)                
##                                   BCLK  -->  PB(1)                
##                                   SDI   -->  PB(6)                
##                                   SDO   -->  PA(6)                
####################################################################

  .altregsyn  0

  .global Asm_Send_Receive_Sample ;; Function declared in this file


  .text

;******************************************************************;
;* FUNCTION: 'Asm_Send_Receive_Sample'                            *;
;* INPUT: sample to be sent in r3 and r2                          *;
;* OUTPUT: received sample in r3 and r2                           *;
;* DESCRIPTION:                                                   *;
;*  This function sends a 16 bits sample on SDI                   *;
;*  and receives in the mean time a 16 bits sample on SDO         *;
;******************************************************************;
Asm_Send_Receive_Sample:
  
  move    -(i3), ipl
  move    -(i3), iph

loop_wait_sampling_event:       ;;
  move  a,RegEvnEvn              ;
  jzs   loop_wait_sampling_event ; Wait for the sampling event
  move  RegEvn,#0x80            ;;  


; the value we want to send is stored in the i1 register  
  move  i1l, r2                    
  move  i1h, r3                    


  move  r0, RegPBOut   ; Read the status of the Port B
  or    r0, #0x03
  move  RegPBOut,r0    ; Set BCLK and FSYNC

  clrb  r0,#1
  move  RegPBOut,r0    ; Keep FSYNC set and clear BCLK
  
  clrb  r0,#0
  setb  r0,#1          
  move  RegPBOut,r0    ; Clear FSYNC and set BCLK

; in the following loop: first we send and receive the 8 bits of the MSB
;                        then we send and receive the 8 bits of the LSB
  move  i0h,#2   ; Initialize byte counter
loop_msb_lsb:
  move  r2,#0x00 ; By default, the word received on SDO is 00000000

;*****************  Read / Write bit 15 then bit 7 *****************;

  or    r0, #0x42                                ;;
  tstb  i1h,#7                                    ;
  jzc   _write_bit_15                             ;
  clrb  r0,#6                                     ;;  write bit on SDI
_write_bit_15:                                    ;
  move  RegPBOut,r0; update SDI and set BCLK     ;
                                                 ;;
                                                  
  move  a,RegPAIn                                ;;
  tstb  a,#6                                      ;
  jzs   bit_15_zero                               ;; read bit on SDO
  setb  r2,#7                                     ;
bit_15_zero:                                     ;;

  clrb  r0, #1    ; clear BCLK
  move  RegPBOut,r0

;*****************  Read / Write bit 14 then bit 6 *****************;

  or    r0, #0x42                                ;;
  tstb  i1h,#6                                    ;
  jzc   _write_bit_14                             ;
  clrb  r0,#6                                     ;;  write bit on SDI
_write_bit_14:                                    ;
  move  RegPBOut,r0; update SDI and set BCLK     ;
                                                 ;;
                                                  
  move  a,RegPAIn                                ;;
  tstb  a,#6                                      ;
  jzs   bit_14_zero                               ;;  read bit on SDO
  setb  r2,#6                                     ;
bit_14_zero:                                     ;;

  clrb  r0, #1    ; clear BCLK  
  move  RegPBOut,r0

;*****************  Read / Write bit 13 then bit 5 *****************;

  or    r0, #0x42                                ;;
  tstb  i1h,#5                                    ;
  jzc   _write_bit_13                             ;
  clrb  r0,#6                                     ;; write bit on SDI
_write_bit_13:                                    ;
  move  RegPBOut,r0; update SDI and set BCLK     ;
                                                 ;;
                                                  
  move  a,RegPAIn                                ;;
  tstb  a,#6                                      ;
  jzs   bit_13_zero                               ;; read bit on SDO
  setb  r2,#5                                     ;
bit_13_zero:                                     ;;

  clrb  r0, #1    ; clear BCLK
  move  RegPBOut,r0

;*****************  Read / Write bit 12 then bit 4 *****************;

  or    r0, #0x42                                ;;
  tstb  i1h,#4                                    ;
  jzc   _write_bit_12                             ;
  clrb  r0,#6                                     ;; write bit on SDI
_write_bit_12:                                    ;
  move  RegPBOut,r0; update SDI and set BCLK     ;
                                                 ;;
                                                  
  move  a,RegPAIn                                ;;
  tstb  a,#6                                      ;
  jzs   bit_12_zero                               ;; read bit on SDO
  setb  r2,#4                                     ;
bit_12_zero:                                     ;;

  clrb  r0, #1    ; clear BCLK
  move  RegPBOut,r0

;*****************  Read / Write bit 11 then bit 3 *****************;

  or    r0, #0x42                                ;;
  tstb  i1h,#3                                    ;
  jzc   _write_bit_11                             ;
  clrb  r0,#6                                     ;; write bit on SDI
_write_bit_11:                                    ;
  move  RegPBOut,r0; update SDI and set BCLK     ;
                                                 ;;
                                                  
  move  a,RegPAIn                                ;;
  tstb  a,#6                                      ;
  jzs   bit_11_zero                               ;; read bit on SDO
  setb  r2,#3                                     ;
bit_11_zero:                                     ;;

  clrb  r0, #1    ; clear BCLK  
  move  RegPBOut,r0

;*****************  Read / Write bit 10 then bit 2 *****************;

  or    r0, #0x42                                ;;
  tstb  i1h,#2                                    ;
  jzc   _write_bit_10                             ;
  clrb  r0,#6                                     ;; write bit on SDI
_write_bit_10:                                    ;
  move  RegPBOut,r0; update SDI and set BCLK     ;
                                                 ;;
                                                  
  move  a,RegPAIn                                ;;
  tstb  a,#6                                      ;
  jzs   bit_10_zero                               ;; read bit on SDO
  setb  r2,#2                                     ;
bit_10_zero:                                     ;;

  clrb  r0, #1    ; clear BCLK  
  move  RegPBOut,r0

;*****************  Read / Write bit 9 then bit 1 *****************;

  or    r0, #0x42                                ;;
  tstb  i1h,#1                                    ;
  jzc   _write_bit_9                              ;
  clrb  r0,#6                                     ;; write bit on SDI
_write_bit_9:                                     ;
  move  RegPBOut,r0; update SDI and set BCLK     ;
                                                 ;;
                                                  
  move  a,RegPAIn                                ;;
  tstb  a,#6                                      ;
  jzs   bit_9_zero                                ;; read bit on SDO
  setb  r2,#1                                     ;
bit_9_zero:                                      ;;

  clrb  r0, #1    ; clear BCLK  
  move  RegPBOut,r0

;*****************  Read / Write bit 8 then bit 0 *****************;

  or    r0, #0x42                                ;;
  tstb  i1h,#0                                    ;
  jzc   _write_bit_8                              ;
  clrb  r0,#6                                     ;; write bit on SDI
_write_bit_8:                                     ;
  move  RegPBOut,r0; update SDI and set BCLK     ;
                                                 ;;
                                                  
  move  a,RegPAIn                                ;;
  tstb  a,#6                                      ;
  jzs   bit_8_zero                                ;; read bit on SDO
  setb  r2,#0                                     ;
bit_8_zero:                                      ;;

  clrb  r0, #1    ; clear BCLK  
  move  RegPBOut,r0

; Test to check if we have to send the LSB
  dec   i0h
  jzs   end
  
  move  r3,r2   ; Rotate SDI and SDO registers
  move  i1h,i1l ;

  jump  loop_msb_lsb
  
  end:
  move  iph, (i3)+
  move  ipl, (i3)+
  
  jump  ip
;*********************************************************************;
;*              END OF 'Asm_Send_Receive_Sample' FUNCTION            *;
;*********************************************************************;
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
kamedi_clab
сообщение Oct 6 2006, 07:35
Сообщение #2


Местный
***

Группа: Новичок
Сообщений: 239
Регистрация: 5-10-06
Пользователь №: 21 004



в ICC подробнейший хелп и примеры - посмотрите, там все это есть.
Go to the top of the page
 
+Quote Post
$ilent
сообщение Oct 6 2006, 08:04
Сообщение #3


Частый гость
**

Группа: Новичок
Сообщений: 116
Регистрация: 14-02-06
Из: Москва. Перово
Пользователь №: 14 296



Цитата(kamedi_clab @ Oct 6 2006, 11:35) *
в ICC подробнейший хелп и примеры - посмотрите, там все это есть.

как всегда стандартный ответ... angry.gif
я жен не спрашиваю есть ли ответ на мой вопрос в ИСС...
вот что там есть...
Код
Your program may need to address absolute memory locations. For example, external IO peripherals are usually mapped to specific memory locations. These may include LCD interface and dual port SRAM. Currently, you can use inline asm or a separate assembler file to declare data that are located in specific memory addresses. In a later release of the compiler, we may provide this capability in C.
In the following examples, assume there is a two-byte LCD control register at location 0x1000 and a two-byte LCD data register at the following location (0x1002), and there is a 100 byte dual port SRAM located at 0x2000.

Using an Assembler Module
In an assembler file, put the following:

.area memory(abs)
.org 0x1000
_LCD_control_register::    .blkw 1

_LCD_data_register:: .blkw 1

.org 0x2000

_dual_port_SRAM::    .blkb 100

In your C file, you must then declare them as:

extern unsigned int LCD_control_register, LCD_data_register;

extern char dual_port_SRAM[100];

Note the interface convention of prefixing an external variable names with an '_' in the assembler file and the use of two colons to define them as global variables.

Using Inline Asm

Inline asm is really just the same as regular assembler syntax, except that it is enclosed in the pseudo-function asm(). In a C file, the above assembly code becomes the following:

asm(".area memory(abs)\n"
    ".org 0x1000\n"
    "_LCD_control_register:: .blkw 1\n"
    "_LCD_data_register:: .blkw 1");

asm(".org 0x2000\n"
    "_dual_port_SRAM:: .blkb 100");

Note that the use of \n to separate the lines. You still need to declare these as "extern" in C (as above), just as in the case of using a separate assembler file, since the C compiler does not really know what's inside the asm statements.

но понять в этом ни чего не могу...
Go to the top of the page
 
+Quote Post



Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 19th July 2025 - 23:19
Рейтинг@Mail.ru


Страница сгенерированна за 0.10624 секунд с 7
ELECTRONIX ©2004-2016