../src/csd_asm.S: Assembler messages:
../src/csd_asm.S:26: Error: Macro `uart_init' was already defined
../src/csd_asm.S:26: Error: symbol `print_menu' is already defined
../src/csd_asm.S:26: Error: symbol `pop_reg' is already defined
../src/csd_asm.S:26: Error: symbol `print_reg' is already defined
../src/csd_asm.S:26: Error: symbol `print_nzcv' is already defined
../src/csd_asm.S:26: Error: symbol `print_eaift' is already defined
../src/csd_asm.S:26: Error: symbol `fill' is already defined
../src/csd_asm.S:26: Error: symbol `print_mode' is already defined
../src/csd_asm.S:26: Error: symbol `string1' is already defined
../src/csd_asm.S:26: Error: symbol `string2' is already defined
../src/csd_asm.S:26: Error: symbol `string3' is already defined
../src/csd_asm.S:26: Error: symbol `string4' is already defined
../src/csd_asm.S:26: Error: symbol `string5' is already defined
../src/csd_asm.S:26: Error: symbol `end' is already defined
This is the message I get when calling my custom debugging macro second time. Seems like I cannot reuse the macro because of the labels inside the macro. Can anyone help me out?
main:
ldr r0, =Input_data
ldr r1, =Output_data
my_debugging_message
mov r2, #31
mov r3, #0
my_debugging_message
below is my macro file I am working on zedboard-zynq7000 using xilinx sdk I am pretty sure that I have to use local labels, but is adding . to the label not enough? It's not working for me
.macro my_debugging_message
#include "uart_regs.h"
#include "uart_init.s"
//use stack
stmdb r13!, {r0 - r12} // push 13 registers to stack
mrs r2, cpsr // read cpsr to r2
add r3, r13, #52 // save base address of stack pointer to r3 (4X13 decremented, so we add 52)
mov r4, r14 // save link regiester to r4
sub r5, r15, #24 // save original address of program counter to r5 (pc has been incremented 6 times)
stmia r3, {r3 - r5} // save sp, lr, pc after r12 (post-incremental store)
ldr r9, =string1 // string1 to be displayed on screen
mov r10, #0 // index for loop - pop_reg
UART_init // UART Initialization
bl pop_reg // branch with link to pop_reg
bl print_menu // branch with link to print_menu
and r7, r2, #0xf0000000 // copy only the nzcv part of cpsr to r
mov r7, r7, LSR#28 // remove seven 0s in hex
bl print_nzcv // branch with link to print_nzcv
bl print_eaift // branch with link to print_eaift
bl print_menu // branch with link to print_menu
bl print_mode // branch with link to print_mode
bl print_menu // branch with link to print_menu
b end
print_menu:
ldr r0, =uart_TX_RX_FIFO0
ldr r1, =uart_Channel_sts_reg0
// --------- Check to see if the Tx FIFO is empty ------------------------------
ldr r3, [r1] // read Channel Status Register
and r3, r3, #0x8 // read Transmit Buffer Empty bit(bit[3])
cmp r3, #0x8 // check if TxFIFO is empty and ready to receive new data
bne print_menu // if TxFIFO is NOT empty, keep checking until it is empty
//------------------------------------------------------------------------------
ldrb r7, [r9], #1 // load one byte of string
strb r7, [r0] // fill the TxFIFO with 0x48
cmp r7, #0x00
bne print_menu
mov pc, lr
pop_reg:
mov r12, r14 // lr to r12
bl print_menu // print string1
mov r14, r12 // r14 back to original value
ldr r6, [r13], #4 // load one register addr to r6 and increase sp
bl print_reg // branch with link to print_reg
mov r14, r12 // lr back to original value
add r10, r10, #1 // increment index
cmp r10, #16 // 16 registers printed
moveq pc, r14 // go back to my_debug_macro
bne pop_reg // keep pop and print regs
print_reg:
ldr r0, =uart_TX_RX_FIFO0
ldr r1, =uart_Channel_sts_reg0
// --------- Check to see if the Tx FIFO is empty ------------------------------
ldr r3, [r1] // read Channel Status Register
and r3, r3, #0x8 // read Transmit Buffer Empty bit(bit[3])
cmp r3, #0x8 // check if TxFIFO is empty and ready to receive new data
bne print_reg // if TxFIFO is NOT empty, keep checking until it is empty
//------------------------------------------------------------------------------
mov r7, #48 // ascii code for '0'
str r7, [r0] // TX FIFO now filled with '0'
mov r7, #120 // ascii code for 'x'
str r7, [r0] // TX FIFO now filled with 'x'
mov r7, r6
and r7, r7, #0xf0000000 // get first digit
mov r7, r7, LSR#28 // remove seven '0's
cmp r7, #10
addlt r7, r7, #48 // if digit is smaller than 10 add 48 to make the digit an ascii code
strlt r7, [r0] // TX FIFO filled with hexa code
addge r7, r7, #87 // if digit is greater than or equal to 10 add 87 to make the digit an ascii code(a-f)
strge r7, [r0] // TX FIFO filled with hexa code
mov r7, r6
and r7, r7, #0x0f000000 // get second digit
mov r7, r7, LSR#24 // remove six '0's
cmp r7, #10
addlt r7, r7, #48 // if digit is smaller than 10 add 48 to make the digit an ascii code
strlt r7, [r0] // TX FIFO filled with hexa code
addge r7, r7, #87 // if digit is greater than or equal to 10 add 87 to make the digit an ascii code(a-f)
strge r7, [r0] // TX FIFO filled with hexa code
mov r7, r6
and r7, r7, #0x00f00000 // get third digit
mov r7, r7, LSR#20 // remove five '0's
cmp r7, #10
addlt r7, r7, #48 // if digit is smaller than 10 add 48 to make the digit an ascii code
strlt r7, [r0] // TX FIFO filled with hexa code
addge r7, r7, #87 // if digit is greater than or equal to 10 add 87 to make the digit an ascii code(a-f)
strge r7, [r0] // TX FIFO filled with hexa code
mov r7, r6
and r7, r7, #0x000f0000 // get fourth digit
mov r7, r7, LSR#16 // remove five '0's
cmp r7, #10
addlt r7, r7, #48 // if digit is smaller than 10 add 48 to make the digit an ascii code
strlt r7, [r0] // TX FIFO filled with hexa code
addge r7, r7, #87 // if digit is greater than or equal to 10 add 87 to make the digit an ascii code(a-f)
strge r7, [r0] // TX FIFO filled with hexa code
mov r7, #95 //print '_'
str r7, [r0]
mov r7, r6
and r7, r7, #0x0000f000 // get fifth digit
mov r7, r7, LSR#12 // remove three '0's
cmp r7, #10
addlt r7, r7, #48 // if digit is smaller than 10 add 48 to make the digit an ascii code
strlt r7, [r0] // TX FIFO filled with hexa code
addge r7, r7, #87 // if digit is greater than or equal to 10 add 87 to make the digit an ascii code(a-f)
strge r7, [r0] // TX FIFO filled with hexa code
mov r7, r6
and r7, r7, #0x00000f00 // get sixth digit
mov r7, r7, LSR#8 // remove two '0's
cmp r7, #10
addlt r7, r7, #48 // if digit is smaller than 10 add 48 to make the digit an ascii code
strlt r7, [r0] // TX FIFO filled with hexa code
addge r7, r7, #87 // if digit is greater than or equal to 10 add 87 to make the digit an ascii code(a-f)
strge r7, [r0] // TX FIFO filled with hexa code
mov r7, r6
and r7, r7, #0x000000f0 // get seventh digit
mov r7, r7, LSR#4 // remove one '0's
cmp r7, #10
addlt r7, r7, #48 // if digit is smaller than 10 add 48 to make the digit an ascii code
strlt r7, [r0] // TX FIFO filled with hexa code
addge r7, r7, #87 // if digit is greater than or equal to 10 add 87 to make the digit an ascii code(a-f)
strge r7, [r0] // TX FIFO filled with hexa code
mov r7, r6
and r7, r7, #0x0000000f // get eigth digit
cmp r7, #10
addlt r7, r7, #48 // if digit is smaller than 10 add 48 to make the digit an ascii code
strlt r7, [r0] // TX FIFO filled with hexa code
addge r7, r7, #87 // if digit is greater than or equal to 10 add 87 to make the digit an ascii code(a-f)
strge r7, [r0] // TX FIFO filled with hexa code
mov r7, #32 // print ' '
str r7, [r0]
mov pc, lr
print_nzcv:
ldr r0, =uart_TX_RX_FIFO0
ldr r1, =uart_Channel_sts_reg0
// --------- Check to see if the Tx FIFO is empty ------------------------------
ldr r3, [r1] // read Channel Status Register
and r3, r3, #0x8 // read Transmit Buffer Empty bit(bit[3])
cmp r3, #0x8 // check if TxFIFO is empty and ready to receive new data
bne print_nzcv // if TxFIFO is NOT empty, keep checking until it is empty
//------------------------------------------------------------------------------
and r8, r7, #0b1000
cmp r8, #0
moveq r8, #110 // print 'n' if false
streq r8, [r0]
movne r8, #78 //print 'N' if true
strne r8, [r0]
and r8, r7, #0b0100
cmp r8, #0
moveq r8, #122 // print 'z' if false
streq r8, [r0]
movne r8, #90 //print 'Z' if true
strne r8, [r0]
and r8, r7, #0b0010
cmp r8, #0
moveq r8, #99 // print 'c' if false
streq r8, [r0]
movne r8, #67 //print 'C' if true
strne r8, [r0]
and r8, r7, #0b0001
cmp r8, #0
moveq r8, #118 // print 'v' if false
streq r8, [r0]
movne r8, #86 //print 'V' if true
strne r8, [r0]
mov pc, lr
print_eaift:
ldr r0, =uart_TX_RX_FIFO0
ldr r1, =uart_Channel_sts_reg0
// --------- Check to see if the Tx FIFO is empty ------------------------------
ldr r3, [r1] // read Channel Status Register
and r3, r3, #0x8 // read Transmit Buffer Empty bit(bit[3])
cmp r3, #0x8 // check if TxFIFO is empty and ready to receive new data
bne print_eaift // if TxFIFO is NOT empty, keep checking until it is empty
//------------------------------------------------------------------------------
mov r8, #44 // print ','
str r8, [r0]
mov r8, #32 // print ' '
str r8, [r0]
and r7, r2, #0b1000000000 //'E' register
cmp r7, #0
movne r8, #69 //if 'E' register is set
strne r8, [r0] //print 'E'
and r7, r2, #0b100000000 //'A' register
cmp r7, #0
movne r8, #65 //if 'A' register is set
strne r8, [r0] //print 'A'
and r7, r2, #0b10000000 //'I' register
cmp r7, #0
movne r8, #73 //if 'I' register is set
strne r8, [r0] //print 'I'
and r7, r2, #0b1000000 //'F' register
cmp r7, #0
movne r8, #70 //if 'F' register is set
strne r8, [r0] //print 'F'
and r7, r2, #0b100000 //'T' register
cmp r7, #0
movne r8, #84 //if 'T' register is set
strne r8, [r0] //print 'T'
mov r8, #44 // print ','
str r8, [r0]
mov r8, #32 //print ' '
str r8, [r0]
and r8, r2, #0x1000000 // leave J bit
and r10, r2, #0b100000 //leave T bit
mov r8, r8, lsr#23
mov r10, r10, lsr#5
add r8, r10, r8 //make J T for mode comparison
cmp r8, #0
ldreq r11, =string2 //print "ARM mode"
cmp r8, #0b01
ldreq r11, =string3 //print "Thumb mode"
cmp r8, #0b10
ldreq r11, =string4 //print "Jazelle mode"
cmp r8, #0b11
ldreq r11, =string5 //print "ThumbEE mode"
fill:
ldrb r7, [r11], #1
strb r7, [r0] //fill Tx FIFO with byte in r7
cmp r7, #0x00
bne fill
mov pc, lr
print_mode:
and r7, r2, #0x1f // M[4:0] for mode
cmp r7, #0b10000 // print 'USR' for user mode
moveq r7, #85
streq r7, [r0]
moveq r7, #83
streq r7, [r0]
moveq r7, #82
streq r7, [r0]
cmp r7, #0b10001 //print "FIQ" fiq mode
moveq r7, #70
streq r7, [r0]
moveq r7, #73
streq r7, [r0]
moveq r7, #81
streq r7, [r0]
cmp r7, #0b10010 //print "IRQ" irq mode
moveq r7, #73
streq r7, [r0]
moveq r7, #82
streq r7, [r0]
moveq r7, #81
streq r7, [r0]
cmp r7, #0b10011 //print "SVC" supervisor mode
moveq r7, #82
streq r7, [r0]
moveq r7, #86
streq r7, [r0]
moveq r7, #67
streq r7, [r0]
cmp r7, #0b10110 //print "MON" monitor mode
moveq r7, #77
streq r7, [r0]
moveq r7, #79
streq r7, [r0]
moveq r7, #78
streq r7, [r0]
cmp r7, #0b10111 //print "ABT" abort mode
moveq r7, #65
streq r7, [r0]
moveq r7, #66
streq r7, [r0]
moveq r7, #84
streq r7, [r0]
cmp r7, #0b11010 //print "HYP" hyp mode
moveq r7, #72
streq r7, [r0]
moveq r7, #89
streq r7, [r0]
moveq r7, #80
streq r7, [r0]
cmp r7, #0b11011 //print "UND" undefined mode
moveq r7, #85
streq r7, [r0]
moveq r7, #78
streq r7, [r0]
moveq r7, #68
streq r7, [r0]
cmp r7, #0b11111 //print "SYS" system mode
moveq r7, #83
streq r7, [r0]
moveq r7, #89
streq r7, [r0]
moveq r7, #83
streq r7, [r0]
mov r7, #32 //print ' '
str r7, [r0]
mov r7, #40 //print '('
str r7, [r0]
mov r7, #32 //print ' '
str r7, [r0]
mov r7, #61 //print '='
str r7, [r0]
mov r7, #48 //print '0'
str r7, [r0]
mov r7, #120 //print 'x'
str r7, [r0]
mov r7, r2
and r7, r7, #0xf0000000 // get first digit
mov r7, r7, LSR#28 // remove seven '0's
cmp r7, #10
addlt r7, r7, #48 // if digit is smaller than 10 add 48 to make the digit an ascii code
strlt r7, [r0] // TX FIFO filled with hexa code
addge r7, r7, #87 // if digit is greater than or equal to 10 add 87 to make the digit an ascii code(a-f)
strge r7, [r0] // TX FIFO filled with hexa code
mov r7, r2
and r7, r7, #0x0f000000 // get second digit
mov r7, r7, LSR#24 // remove six '0's
cmp r7, #10
addlt r7, r7, #48 // if digit is smaller than 10 add 48 to make the digit an ascii code
strlt r7, [r0] // TX FIFO filled with hexa code
addge r7, r7, #87 // if digit is greater than or equal to 10 add 87 to make the digit an ascii code(a-f)
strge r7, [r0] // TX FIFO filled with hexa code
mov r7, r2
and r7, r7, #0x00f00000 // get third digit
mov r7, r7, LSR#20 // remove five '0's
cmp r7, #10
addlt r7, r7, #48 // if digit is smaller than 10 add 48 to make the digit an ascii code
strlt r7, [r0] // TX FIFO filled with hexa code
addge r7, r7, #87 // if digit is greater than or equal to 10 add 87 to make the digit an ascii code(a-f)
strge r7, [r0] // TX FIFO filled with hexa code
mov r7, #95 //print '_'
str r7, [r0]
mov r7, r2
and r7, r7, #0x000f0000 // get fourth digit
mov r7, r7, LSR#16 // remove five '0's
cmp r7, #10
addlt r7, r7, #48 // if digit is smaller than 10 add 48 to make the digit an ascii code
strlt r7, [r0] // TX FIFO filled with hexa code
addge r7, r7, #87 // if digit is greater than or equal to 10 add 87 to make the digit an ascii code(a-f)
strge r7, [r0] // TX FIFO filled with hexa code
mov r7, r2
and r7, r7, #0x0000f000 // get fifth digit
mov r7, r7, LSR#12 // remove three '0's
cmp r7, #10
addlt r7, r7, #48 // if digit is smaller than 10 add 48 to make the digit an ascii code
strlt r7, [r0] // TX FIFO filled with hexa code
addge r7, r7, #87 // if digit is greater than or equal to 10 add 87 to make the digit an ascii code(a-f)
strge r7, [r0] // TX FIFO filled with hexa code
mov r7, r2
and r7, r7, #0x00000f00 // get sixth digit
mov r7, r7, LSR#8 // remove two '0's
cmp r7, #10
addlt r7, r7, #48 // if digit is smaller than 10 add 48 to make the digit an ascii code
strlt r7, [r0] // TX FIFO filled with hexa code
addge r7, r7, #87 // if digit is greater than or equal to 10 add 87 to make the digit an ascii code(a-f)
strge r7, [r0] // TX FIFO filled with hexa code
mov r7, r2
and r7, r7, #0x000000f0 // get seventh digit
mov r7, r7, LSR#4 // remove one '0's
cmp r7, #10
addlt r7, r7, #48 // if digit is smaller than 10 add 48 to make the digit an ascii code
strlt r7, [r0] // TX FIFO filled with hexa code
addge r7, r7, #87 // if digit is greater than or equal to 10 add 87 to make the digit an ascii code(a-f)
strge r7, [r0] // TX FIFO filled with hexa code
mov r7, r2
and r7, r7, #0x0000000f // get eigth digit
cmp r7, #10
addlt r7, r7, #48 // if digit is smaller than 10 add 48 to make the digit an ascii code
strlt r7, [r0] // TX FIFO filled with hexa code
addge r7, r7, #87 // if digit is greater than or equal to 10 add 87 to make the digit an ascii code(a-f)
strge r7, [r0] // TX FIFO filled with hexa code
mov r7, #41 //print ')'
str r7, [r0]
mov pc, lr
.data
//string to be displayed on UART terminal
string1:
.ascii "-----------------------------------------------------------------------------------------------------"
.byte 0x0D
.byte 0x0A
.ascii "r0 = "
.byte 0x00
.ascii ", r1 = "
.byte 0x00
.ascii ", r2 = "
.byte 0x00
.ascii ", r3 = "
.byte 0x00
.byte 0x0D
.byte 0x0A
.ascii "r4 = "
.byte 0x00
.ascii ", r5 = "
.byte 0x00
.ascii ", r6 = "
.byte 0x00
.ascii ", r7 = "
.byte 0x00
.byte 0x0D
.byte 0x0A
.ascii "r8 = "
.byte 0x00
.ascii ", r9 = "
.byte 0x00
.ascii ", r10 = "
.byte 0x00
.ascii ", r11 = "
.byte 0x00
.byte 0x0D
.byte 0x0A
.ascii "r12 = "
.byte 0x00
.ascii ", r13 = "
.byte 0x00
.ascii ", r14 = "
.byte 0x00
.ascii ", r15 = "
.byte 0x00
.byte 0x0D
.byte 0x0A
.ascii "cpsr = "
.byte 0x00
.ascii ", current mode = "
.byte 0x00
.byte 0x0D
.byte 0x0A
.ascii "----------------------------------------------------------------------------------------"
.byte 0x0D
.byte 0x0A
.byte 0x00
string2:
.ascii "ARM mode"
.byte 0x00
string3:
.ascii "Thumb mode"
.byte 0x00
string4:
.ascii "Jazelle mode"
.byte 0x00
string5:
.ascii "ThumbEE mode"
.byte 0x00
.text
end:
.endm
User contributions licensed under CC BY-SA 3.0