157 /* 158 *PrintFaultAddr: Print fault address 159 *r12: contains address of instruction +4 160 */ 161 PrintFaultAddr: 162 mov r0, r12 163 bl PrintHexWord 164 mrc p15, 0, r0, c6, c0, 0 165 bl PrintHexWord 166 mov pc, lr 167 /* 168 *PrintHexNibble:print the least-significant nibble in r0 as 169 *a hex digit 170 *r0:contains nibble to write as Hex 171 *write to with XXX, modifies r0,r2 172 *TODO:write to with reg ro error handling 173 *Falls through to PrintChar 174 */ 175 PrintHexNibble: 176 adr r2, HEX_TO_ASCII_TABLE 177 and r0, r0, #0xf 178 ldr r0, [r2, r0] 179 b PrintChar 180 181 /* 182 *PrintChar: prints the character in r0 183 *r0 contains the character 184 *writes r0 with XXX, modifies r0,r2 185 *TODO:write r0 with XXX reg ro error hangling 186 */ 187 PrintChar: 188 TXBusy: 189 ldr r2, =rUTRSTAT0 190 ldr r2, [r2] 191 and r2, r2, #(1<<2) 192 tst r2, #(1<<2) 193 beq TXBusy 194 ldr r1, =rUTXH0 195 str r0, [r1] 196 mov pc, lr 197 /* 198 *PrintWord: print the 4 characters in r0 199 *r0 contains the character 200 *writes r0 with XXX, modifies r0,r2 201 *TODO:write r0 with XXX reg ro error hangling 202 */ 203 PrintWord: 204 mov r3, r0 205 mov r4, lr 206 bl PrintChar 207 208 mov r0, r3, lsr #8 209 bl PrintChar 210 211 mov r0, r3, lsr #16 212 bl PrintChar 213 214 mov r0, r3, lsr #24 215 bl PrintChar 216 217 mov r0, #'\r' 218 bl PrintChar 219 220 mov pc, r4 221 222 /* 223 *PrintHexWord : prints the 4 bytes in R0 as 8 hex ascii characters 224 *followed by a newline 225 *r0 contains the binary word 226 *r1 contains the base of the serial port 227 *writes ro with XXX, modifies r0,r2 228 *TODO : write ro with XXX reg to error handling 229 */ 230 PrintHexWord: 231 mov r4, lr 232 mov r3, r0 233 mov r0, r3, LSR #28 234 bl PrintHexNibble 235 mov r0, r3, LSR #24 236 bl PrintHexNibble 237 mov r0, r3, LSR #20 238 bl PrintHexNibble 239 mov r0, r3, LSR #16 240 bl PrintHexNibble 241 mov r0, r3, LSR #12 242 bl PrintHexNibble 243 mov r0, r3, LSR #8 244 bl PrintHexNibble 245 mov r0, r3, LSR #4 246 bl PrintHexNibble 247 mov r0, r3 248 bl PrintHexNibble 249 mov r0, #'\r' 250 bl PrintChar 251 mov r0, #'\n' 252 bl PrintChar 253 mov pc, r4 254 255 .align 2 256 HEX_TO_ASCII_TABLE: 257 .ascii "0123456789ABCDEF" 258 STR_STACK: 259 .ascii "STKP" 260 STR_UNDEF: 261 .ascii "UNDF" 262 STR_SWI: 263 .ascii "SWI " 264 STR_PREFETCH_ABORT: 265 .ascii "PABT" 266 STR_DATA_ABORT: 267 .ascii "DABT" 268 STR_IRQ: 269 .ascii "IRQ " 270 STR_FIQ: 271 .ascii "FIQ" 272 STR_NOT_USED: 273 .ascii "NUSD" 274 .align 2 275 STR_OK: 276 .ascii "OK " 277 STR_FAIL: 278 .ascii "FAIL" 279 STR_CR: 280 .ascii "\r\n"
|