I use a TM4C123GH6PM board. I've been having issues while debugging assembly code. The code is as following:
void delayMs(unsigned int n) { __asm("Y_LABEL: MOV R1,#4"); __asm("Z_LABEL: SUB R1, #1"); __asm(" CBZ R1, X_LABEL"); __asm(" NOP"); __asm(" B Z_LABEL"); __asm("X_LABEL: SUB R0, #1"); __asm(" CBZ R0, DONE_LABEL"); __asm(" B Y_LABEL"); __asm(" DONE_LABEL:"); }
And I'm getting the errors as: Build target 'Target 1' compiling main.c... main.c(40): warning: #1267-D: Implicit physical register R1 should be defined as a variable __asm("Y_LABEL: MOV R1,#4"); main.c(42): error: #1084: This instruction not permitted in inline assembler __asm(" CBZ R1, X_LABEL"); main.c(45): warning: #1267-D: Implicit physical register R0 should be defined as a variable __asm("X_LABEL: SUB R0, #1"); main.c(46): error: #1084: This instruction not permitted in inline assembler __asm(" CBZ R0, DONE_LABEL"); main.c(59): warning: #1-D: last line of file ends without a newline } main.c: 3 warnings, 2 errors
Could y'all please help to find what is wrong?
void delayMs(unsigned int n) { unsigned int i; __asm { Y_LABEL: MOV i, #4 Z_LABEL: SUBS i, #1 BEQ X_LABEL NOP B Z_LABEL X_LABEL: SUBS n, #1 BNE DONE_LABEL B Y_LABEL DONE_LABEL: } }