Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

. syntax unified . cpu cortex - m 3 AREA | . text | , CODE, READONLY ; Define an area named ' . text'

.syntax unified
.cpu cortex-m3
AREA |.text|, CODE, READONLY ; Define an area named '.text'
SVC_NUM EQU 006 ; Define SVC_NUM as 006
; Define the SVC_Handler as a global symbol
THUMB
EXPORT SVC_Handler
SVC_Handler
TST lr, #4 ; Test whether LR indicates MSP or PSP
ITE EQ
MRSEQ r0, msp ; If EQ, set r0 to MSP
MRSNE r0, psp ; If not EQ, set r0 to PSP
MOV r1, r0 ; Copy the stack pointer to r1
LDRB r0,[r1, #-2] ; Load the SVC instruction
AND r0, r0, #0xFF ; Mask to extract the SVC number
CMP r0, #SVC_NUM ; Compare with SVC_NUM
BNE not_matched ; Branch if not equal to SVC_NUM
; SVC number matches BITS ID, perform addition
LDR r2,=84006 ; Load BITS ID last 5 digits
LDR r3,=84006 ; Load BITS ID last 5 digits
ADD r0, r2, r3 ; Perform addition
B svc_done ; Branch to svc_done
not_matched
; SVC number doesn't match BITS ID, perform subtraction
LDR r2,=84006 ; Load BITS ID last 5 digits
LDR r3,=84006 ; Load BITS ID last 5 digits
SUB r0, r2, r3 ; Perform subtraction
svc_done
; Return from SVC handler, restoring original stack and returning to application
TST lr, #4 ; Test whether LR indicates MSP or PSP
ITE EQ
MRSEQ r1, msp ; If EQ, set r1 to MSP
MRSNE r1, psp ; If not EQ, set r1 to PSP
LDMIA r1!,{r0-r3} ; Restore context
MOV lr, r3 ; Restore LR
BX lr ; Return to the application
Above code in ARM is throwing 4 errors as below, Unable to rectify, I am using ARM Architecture and LPC2378 from nxp on Keil version. Please help resolve the errors so tha i can run the program
Error Message as below
*** Using Compiler 'V5.06 update 6(build 750)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Rebuild target 'Target 1'
assembling Q3.s...
Q3.s(1): error: A1137E: Unexpected characters at end of line
Q3.s(2): error: A1137E: Unexpected characters at end of line
Q3.s(4): error: A1163E: Unknown opcode |.text|,, expecting opcode or Macro
Q3.s(9): error: A1355U: A Label was found which was in no AREA
".\Objects\Q3.axf" -4 Error(s),0 Warning(s).
Target not created.
Build Time Elapsed: 00:00:00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions