vk2acp
vk2acp

Reputation: 1

TMS320 c6000 assembly "hello world" example?

Any one have any TMS320 c6000 assembly only "hello world" examples to share?? Seen plenty of C with inline assembly examples...

regards

AP

Upvotes: 0

Views: 1849

Answers (1)

turboscrew
turboscrew

Reputation: 676

Not the well-known "hello world", but a string copy. Maybe that helps?

; hello.asm
;
;  Created on: 11.12.2013
;      Author: turboscrew
;

         .global _main

         .data
hello_str:
         .string "Hello world!"
         .byte 0

txt_buffer:
         .space 16

         .text

_main:
         mvkl hello_str, b0
         mvkh hello_str, b0 ; string pointer to b0
         mvkl txt_buffer, b1
         mvkh txt_buffer, b1


         ; copy to buffer
c_loop:
         ldb *b0++[1], a0
         nop 4
         stb a0, *b1++[1]
|| [a0]  bnop c_loop, 5 ;

         ; idle loop - end of program
i_loop:
         bnop i_loop, 5

for start-up (modified from TI's example):

; From TI example
;
;  ======== unused ========
;  plug inifinite loop -- with nested branches to
;  disable interrupts -- for all undefined vectors
;
unused  .macro id

        .global unused:id:
unused:id:
        b unused:id:    ; nested branches to block interrupts
        nop 4
        b unused:id:
        nop
        nop
        nop
        nop
        nop

        .endm

        .sect ".vectors"

        .ref _main             ; entry point

        .align  32*8*4          ; must be aligned on 256 word boundary

RESET:                          ; reset vector
        mvkl _main,b0        ; load destination function address to b0
        mvkh _main,b0
        b b0                    ; start branch to destination function
        mvc PCE1,b0             ; address of interrupt vectors
        mvc b0,ISTP             ; set table to point here
        nop 3                   ; fill delay slot
        nop
        nop

        ;
        ;  plug unused interrupts with infinite loops to
        ;  catch stray interrupts
        ;
        unused 1
        unused 2
        unused 3
        unused 4
        unused 5
        unused 6
        unused 7
        unused 8
        unused 9
        unused 10
        unused 11
        unused 12
        unused 13
        unused 14
        unused 15

And a linker control file (CCS-generated + a bit edited):

MEMORY
{
    L2RAM:      o = 0x00800000  l = 0x00200000  /* 2MB L2 Internal SRAM */ 
    L1PRAM:     o = 0x00E00000  l = 0x00008000  /* 32kB L1 Program SRAM/CACHE */ 
    L1DRAM:     o = 0x00F00000  l = 0x00008000  /* 32kB L1 Data SRAM/CACHE */
    EMIFA_CE2:  o = 0xA0000000  l = 0x00800000  /* 8MB EMIFA CE2 */ 
    EMIFA_CE3:  o = 0xB0000000  l = 0x00800000  /* 8MB EMIFA CE2 */ 
    EMIFA_CE4:  o = 0xC0000000  l = 0x00800000  /* 8MB EMIFA CE2 */ 
    EMIFA_CE5:  o = 0xD0000000  l = 0x00800000  /* 8MB EMIFA CE2 */
    DDR2_CE0:   o = 0xE0000000  l = 0x20000000  /* 512MB EMIFB CE0 */ 
} 

SECTIONS
{
    .vectors       >  L2RAM
    .text          >  L2RAM
    .stack         >  L2RAM
    .bss           >  L2RAM
    .cio           >  L2RAM
    .const         >  L2RAM
    .data          >  L2RAM
    .switch        >  L2RAM
    .sysmem        >  L2RAM
    .far           >  L2RAM
    .args          >  L2RAM
    .ppinfo        >  L2RAM
    .ppdata        >  L2RAM

    /* COFF sections */
    .pinit         >  L2RAM
    .cinit         >  L2RAM

    /* EABI sections */
    .binit         >  L2RAM
    .init_array    >  L2RAM
    .neardata      >  L2RAM
    .fardata       >  L2RAM
    .rodata        >  L2RAM
    .c6xabi.exidx  >  L2RAM
    .c6xabi.extab  >  L2RAM
}

Upvotes: 3

Related Questions