Question: TTL ECE362 Lab 06 Exercise Proc Demo ;*************************************************************** ;Descriptive comment header goes here. (What does the program ;do?) ;Name: ;Date: <3> ;Class: ECE 362
TTL "ECE362 Lab 06 Exercise Proc Demo " ;*************************************************************** ;Descriptive comment header goes here. (What does the program ;do?) ;Name:
;************************************** ; vector Table Mapped to Address 0 at Reset ; Linker requries __Vectors to be exported AREA RESET,DATA,READONLY EXPORT __Vectors __Vectors DCD SP_INIT ; stack pointer value when stack is empty DCD Reset_Handler ; reset vector ALIGN ;******************************** ;Program ; linker requries Reset_Handler AREA MyCode, CODE, READONLY ENTRY EXPORT Reset_Handler Reset_Handler Main ;Program code goes here ;disable interrupts
LDR R0, =ICER ; R0 = &ICER MOVS R1, #0 ; R0 = 0 MVNS R1, R1 ; R0 = 0xFFFFFFFF STR R1, [R0, #0] ; icer = 0xFFFFFFFF ; initialize stack pointer LDR R0, =SP_INIT MOV SP, R0
MainLoop NOP ;Load pointer to ConstData to R2 MOV R4,#0; Move 0 to R4 Loop1 ; Load first char (byte) from ConstData (R2) to R0 and point to next char (byte) ; Compare R0 with 0 ; Branch to EXIT if equal ; Branch with Link to IsDigit ; Compare R0 with 1 ; if R0=1, R4=R4 + 1 ; Branch to Loop1
EXIT NOP NOP HERE B HERE
;********************************** ;Procedure of IsDigit ;Input: R0 - ASCII Code Symbol ;Output: R0 - 0, Not a ASCII digit, = 1 a ASCII digit ;Registers used: R0, R1 ;********************************** IsDigit PROC ; Push R1 onto stack ; Move contents of R0 to R1 ; Compare R1 with 0 to check if the symbol <'0' ; Move 0 to R0 if R1<'0'(not a digit) ; Branch to RETURN if R1<'0' ; Compare R1 with 9 check if the symbol >'9' ; Move 0 to R0 if R1 > 9 (not a digit) ; Branch to RETURN if R1 > 9 ; Move 1 to R0 RETURN ; Pop R1 off stack ; Branch and Link to LR with change in instruction format ENDP ALIGN
;****************** AREA MyConst, DATA, READONLY ; Place constant data here ConstData DCB "123abcd0198$ABCD!!!!", 0 ALIGN AREA RAM, DATA, READWRITE ; Allocate system stack SSTACK SPACE SSTACK_SIZE SP_INIT ; PLace variable data here
END
----------------------------------------------------------------
Help needed writing this assembly code
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
