This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

from armasm to gnu arm assembler


Hello !
I have tried to translate a boot code from armasm to gnu arm assembler.
Then, I have written a simple HelloWorld program in c. Eventually, I have
linked both.
Here are the commands I used : 

$arm-elf-as -gdwarf -o boot_code3.o -mcpu=arm7tdmi boot_code3.s
$arm-elf-gcc hello.c -c
$arm-elf-ld -o hello.x --no-gc-sections --entry 0x0 --Ttext 0x0 
boot_code3.o hello.o
 
The problem is that when I try to use hello.x with a tool called seamless
cve, nothing happens : I make a loop "Resethandler - SWI handler -
AbortHandler"

I think the problem comes from the translated boot code.
If someone could give me an idea, I would be very grateful.
-----------------------------------------------------------
Here is the boot-code after translation : 

.extern main	

.equ SVC_MODE, 0x13
.equ IRQ_MODE, 0x12
.equ FIQ_MODE, 0x11

.macro proc_SwitchMode mode, stack_pointer        
    MRS     R0, CPSR
    MOV     R1, R0
    AND     R1, R1, #0x1F       
    BIC     R0, R0, #0x1F       
    ORR     R0, R0, #\mode      
    MSR     CPSR_csfx, R0       
    LDR     R13,=\stack_pointer 
    BIC     R0, R0, #0x1F       
    ORR     R0, R0, R1          
    MSR     CPSR_csfx, R0        
.endm

.section EXCEPTION_VECTORS
.code 32

    B    ResetHandler
    B    UndefinedHandler    
    B    SWIHandler    
    B    PrefetchHandler
    B    AbortHandler
    NOP
    B    IRQHandler
    B    FIQHandler

.global ResetHandler
ResetHandler:
    proc_SwitchMode FIQ_MODE, FIQ_STACK_TOP
    proc_SwitchMode IRQ_MODE, IRQ_STACK_TOP
    LDR    R13, =SVC_STACK_TOP
    
.global Start
Start:    
    BL  main
	
.global TestEnd
TestEnd:
    B   TestEnd

.global UndefinedHandler
UndefinedHandler:
    B   UndefinedHandler

.global SWIHandler
SWIHandler:
    B   SWIHandler

.global PrefetchHandler
PrefetchHandler:
    B   PrefetchHandler

.global AbortHandler
AbortHandler:
    B   AbortHandler

.global IRQHandler
IRQHandler:
    STMDB   R13!,{R0-R1}
    LDR     R0, =NumberOfIRQs
    LDR     R1, [R0]
    ADD     R1, R1, #0x1
    STR     R1, [R0]
    LDMIA   R13!,{R0-R1}
    SUBS    PC, R14, #0x4

.global FIQHandler
FIQHandler:
    STMDB   R13!,{R0-R1}
    LDR     R0, =NumberOfFIQs
    LDR     R1, [R0]
    ADD     R1, R1, #0x1
    STR     R1, [R0]
    LDMIA   R13!,{R0-R1}
    SUBS    PC, R14, #0x4

.section DSEG, "w"

    .global MemoryErrors
    .global MemoryWordErrors
    .global MemoryHWordErrors
    .global MemoryByteErrors
    .global NumberOfIRQs
    .global NumberOfFIQs

     MemoryErrors: .word 0
     MemoryWordErrors: .word 0
     MemoryHWordErrors: .word 0
     MemoryByteErrors: .word 0
     NumberOfIRQs: .word 0
     NumberOfFIQs: .word 0

    .space    232

.section SVC_STACK, "w"
    .space    256
    .global SVC_STACK_TOP
SVC_STACK_TOP:

.section IRQ_STACK, "w" 
    .space    256
    .global IRQ_STACK_TOP
IRQ_STACK_TOP:

.section FIQ_STACK, "w"
    .space    256
    .global FIQ_STACK_TOP
FIQ_STACK_TOP: 

.end
-------------------------------------------------------------------------------
Here is my helloWorld code : 

#include <stdio.h>
#include "conf_defs.h"


void scr_Display (char *str);

// Main.
int main (void) {
    
    scr_Display("Hello ....");
	return 1;
}


void scr_Display(char *str) {

    char *pScreen = (char *) SCREEN;
    unsigned char char_counter = 0;
    
    while (str[char_counter]) {
        *pScreen = str[char_counter];
        char_counter++;
    }
}
-----------------------------------------
and here is the conf_defs.h file : 

#ifndef __ARM_CONF_DEFS_H__
#define __ARM_CONF_DEFS_H__

/* Type definitions */
typedef enum {IRQ, FIQ} t_Interrupt;
typedef enum {IRQ_ENABLE = 0, IRQ_DISABLE} t_IRQ_MASK;
typedef enum {FIQ_ENABLE = 0, FIQ_DISABLE} t_FIQ_MASK;


/* Design constants.*/
#define LOW_SEAMLESS_MEMORY_START   0x40000000
#define LOW_SEAMLESS_MEMORY_LIMIT   0x3FFF
#define LOW_HW_MEMORY_START         0x8000
#define LOW_HW_MEMORY_LIMIT         0x19
#define HIGH_SEAMLESS_MEMORY_START  0xFFFF0000
#define HIGH_SEAMLESS_MEMORY_LIMIT  0x3FFF
#define HIGH_HW_MEMORY_START        0xFFFF8000
#define HIGH_HW_MEMORY_LIMIT        0x19

#ifndef __ARM_BIG_ENDIAN__
/* Set everything to run in Little endian format */
#define PROCESSOR_CONF_REGISTER         0xFFFFFF20
#define INTERRUPT_GENERATOR             0xFFFFFF10
#define SCREEN                          0xFFFF8020
#else
/* Set everything to run in Big endian format */
#define PROCESSOR_CONF_REGISTER         0xFFFFFF2F
#define INTERRUPT_GENERATOR             0xFFFFFF1F
#define SCREEN                          0xFFFF8023
#endif /* __ARM_BIG_ENDIAN__ */

#endif /* __ARM_CONF_DEFS_H__ */



Thank you in advance !
-- 
View this message in context: http://www.nabble.com/from-armasm-to-gnu-arm-assembler-tf3686669.html#a10305511
Sent from the gcc - cross compiler mailing list archive at Nabble.com.


--
For unsubscribe information see http://sourceware.org/lists.html#faq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]