



Error: attempt to move .org backwards
by dabing on Jun 21, 2013 |
dabing
Posts: 8 Joined: Apr 25, 2011 Last seen: May 22, 2014 |
||
I compile bootrom.S using "or32-elf-as bootrom.S -o boot.elf", it turns out :
bootrom.S: Assembler messages:
bootrom.S:1: Error: attempt to move .org backwards
It seems that ".org 0xf0001000" is wrong. AS I use jump instructions in the bootrom.S and I want that the jump destination is in the rom,namely 0xf0001xxx, not 0x00001xxx in the ram, So I have to locate the programm from adrress 0xf0001000. How can I solve that? Thank YOU!
the content of bootrom.S is as follows:
.org 0xf0001000
reset:
l.nop 0x0
l.nop 0x0
l.j main
main:
#l.addi r3,r0,0x1b #divisor is 27
l.jal uart_init
l.nop 0x0
#uart_print_str("ROM")
l.addi r3,r0,0x52
l.jal uart_putc
l.nop 0x0
l.addi r3,r0,0x4f
l.jal uart_putc
l.nop 0x0
l.addi r3,r0,0x4d
l.jal uart_putc
l.nop 0x0
/*unsigned int num = uart_getw();*/
l.jal uart_getw /*return value is put in r11*/
l.nop 0x0
l.or r3,r0,r11
l.or r6,r0,r11 /*put num in r6*/
l.jal uart_print_int
l.nop 0x0
/*for(i=0, p=(unsigned int *)0; i> 8) & 0x000000ff;*/
l.movhi r2,0x9000
l.ori r2,r2,0x1 /*DLM*/
l.addi r3,r0,0x1b /*divisor 27*/
l.srai r3,r3,0x8
l.andi r3,r3,0xff
l.sb 0x0(r2),r3
/*REG8(UART_BASE_ADR + UART_LCR) &= ~(UART_LCR_DLAB);*/
l.movhi r2,0x9000
l.ori r2,r2,0x3 /*LCR*/
l.movhi r3,0x9000
l.ori r3,r3,0x3 /*LCR*/
l.lbz r3,0x0(r3)
l.andi r3,r3,0xff
l.andi r3,r3,0x7f
l.andi r3,r3,0xff
l.sb 0x0(r2),r3
l.jr r9
l.nop 0x0
uart_putc:
/*WAIT_FOR_THRE(core);*/
/*do { \ */
/* lsr = REG8(UART_BASE_ADR + UART_LSR); \ */
/*} while ((lsr & UART_LSR_THRE) != UART_LSR_THRE) */
wait_for_thre:
l.movhi r2,0x9000
l.ori r2,r2,0x5
l.lbz r2,0x0(r2)
l.andi r2,r2,0x20
l.sfeqi r2,0x0
l.bf wait_for_thre
l.nop 0x0
/*REG8(UART_BASE_ADR + UART_TX) = c;*/
l.movhi r2,0x9000
l.ori r2,r2,0x0
l.sb 0x0(r2),r3
/*WAIT_FOR_XMITR(core);*/
/*do { \ */
/* lsr = REG8(UART_BASE_ADR + UART_LSR); \ */
/*} while ((lsr & BOTH_EMPTY) != BOTH_EMPTY) */
wait_for_xmitr:
l.movhi r2,0x9000
l.ori r2,r2,0x5
l.andi r2,r2,0x60
l.sfnei r2,0x60
l.bf wait_for_xmitr
l.nop 0x0
l.jr r9
uart_getc:
/*WAIT_FOR_CHAR(core);*/
/*do { \ */
/* lsr = REG8(UART_BASE_ADR + UART_LSR); \ */
/*} while ((lsr & UART_LSR_DR) != UART_LSR_DR) */
wait_for_char:
l.movhi r2,0x9000
l.ori r2,r2,0x5
l.andi r2,r2,0x1
l.sfeqi r2,0x0
l.bf wait_for_char
l.nop 0x0
/*c = REG8(UART_BASE_ADR + UART_RX);*/
l.movhi r2,0x9000
l.ori r2,r2,0x0
l.lbz r2,0x0(r2)
l.andi r2,r2,0xff
l.ori r11,r2,0x0
l.jr r9
l.nop 0x0
uart_print_int:
l.add r13,r0,r9 /*put return pc r9 to r13*/
l.add r4,r0,r3 /*r4=int n*/
l.srli r3,r4,0x1c /*buf[0] = ( (n >> 28) & 0xf ) + '0';*/
l.andi r3,r3,0xf
l.addi r3,r3,0x30
l.jal uart_putc
l.nop 0x0
l.srli r3,r4,0x18 /*buf[1] = ( (n >> 24) & 0xf ) + '0';*/
l.addi r3,r3,0x30
l.andi r3,r3,0xf
l.jal uart_putc
l.nop 0x0
l.srli r3,r4,0x14 /*buf[2] = ( (n >> 20) & 0xf ) + '0';*/
l.addi r3,r3,0x30
l.andi r3,r3,0xf
l.jal uart_putc
l.nop 0x0
l.srli r3,r4,0x10 /*buf[3] = ( (n >> 16) & 0xf ) + '0';*/
l.addi r3,r3,0x30
l.andi r3,r3,0xf
l.jal uart_putc
l.nop 0x0
l.srli r3,r4,0xc /*buf[4] = ( (n >> 12) & 0xf ) + '0';*/
l.addi r3,r3,0x30
l.andi r3,r3,0xf
l.jal uart_putc
l.nop 0x0
l.srli r3,r4,0x8 /*buf[5] = ( (n >> 8) & 0xf ) + '0';*/
l.addi r3,r3,0x30
l.andi r3,r3,0xf
l.jal uart_putc
l.nop 0x0
l.srli r3,r4,0x4 /*buf[6] = ( (n >> 4) & 0xf ) + '0';*/
l.addi r3,r3,0x30
l.andi r3,r3,0xf
l.jal uart_putc
l.nop 0x0
l.srli r3,r4,0x4 /*buf[7] = ( (n >> 0) & 0xf ) + '0';*/
l.addi r3,r3,0x30
l.andi r3,r3,0xf
l.jal uart_putc
l.nop 0x0
l.add r9,r0,r13
l.jr r9
l.nop 0x0
uart_getw:
l.add r13,r0,r9 /*put return pc r9 to r13*/
/*unsigned int w=0;*/
l.addi r12,r0,0x0 /*return value is temporaly put in r11*/
/*w |= (unsigned int) (uart_getc())
|
RE: Error: attempt to move .org backwards
by dabing on Jun 21, 2013 |
dabing
Posts: 8 Joined: Apr 25, 2011 Last seen: May 22, 2014 |
||
I compile bootrom.S using "or32-elf-as bootrom.S -o boot.elf",
it turns out : bootrom.S: Assembler messages: bootrom.S:1: Error: attempt to move .org backwards It seems that ".org 0xf0001000" is wrong. AS I use jump instructions in the bootrom.S and I want that the jump destination is in the rom,namely 0xf0001xxx, not 0x00001xxx in the ram, So I have to locate the programm from adrress 0xf0001000. How can I solve that? Thank YOU! The content of bootrom.S is as follows: .org 0xf0001000 reset: l.nop 0x0 l.nop 0x0 l.j main |



