Homework #3 Due: Sept. 30 9 Am Reading: Chapter 7, 8
Homework #3 Due: Sept. 30 9 Am Reading: Chapter 7, 8
Homework #3 Due: Sept. 30 9 Am Reading: Chapter 7, 8
30 9 am Reading: Chapter 7, 8
Answer the following questions. When code is requested, include actual .s file.
State whether this code has been assembled and run successfully.
1. Write an assembly language program that calls a subroutine which converts all
lower case letters of a string to upper case. Memory location of the string is passed
on the top of the stack. (40)
;***************************************************************
; Leon
; Date
; HW3_Prob 1
; SampleCode.s
; Description of the program SampleCode
;***************************************************************
;***************************************************************
; EQU Directives
; These directives do not allocate memory
;***************************************************************
;SYMBOL DIRECTIVE VALUE COMMENT
;***************************************************************
; Data Section in READWRITE
; Values of the data in this section are not properly initialazed,
; but labels can be used in the program to change the data values.
;***************************************************************
;LABEL DIRECTIVE VALUE COMMENT
;***************************************************************
; Stack Area
;***************************************************************
;SYMBOL DIRECTIVE VALUE COMMENT
;***************************************************************
; Reset Area
;***************************************************************
;LABEL DIRECTIVE VALUE COMMENT
;***************************************************************
; Directives - This Data Section is part of the code
; It is in the read only section so values cannot be changed.
;***************************************************************
;LABEL DIRECTIVE VALUE COMMENT
AREA |.data|, DATA, READONLY
THUMB
MSG1 DCB "ECE251 is cool!"
DCB 0x0D ; New line
DCB 0x04 ; End of
message.
;***************************************************************
; Program section
;***************************************************************
;LABEL DIRECTIVE VALUE COMMENT
start
LDR R0,=output
LDR R1,=MSG1
readchar LDRB R2,[R1] ;Read in
one char in message
STR
R2,[R1] ;Write this char to memory we
want make change
ADD
R0,#1 ;Increse Address
ADD R1,#1
CMP
R2,#0x04 ;Check the end of the String
BNE readchar
LDR R5,=output
BL
OutStr ;Print out Original String
LDR R0,=output
;Reload the register to R0
PUSH {R0} ;Pass
String Address to Stack
BL convert
LDR R5,=output ;Load
Address after converting
BL
OutStr ;Print out the result
END
3. Compared with iterative methods, what are the advantages and disadvantages of
recursive methods? (20)
Advantages: Natural way to solve problems, easy to debug, more conceptual.
Disadvantages: High time and memory overhead and also hard to implement
in some case.