General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 22nd, 2009, 05:51 PM
Armnewbie87 Armnewbie87 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2009
Posts: 1 Armnewbie87 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 44 sec
Reputation Power: 0
Project Help Please? Urgent

I'm working on a project and I'm writing a code that performs these 7 subroutines:

· uart_init initializes the user UART for use.
· output_character transmits a character from the UART to HyperTerminal.
· read_string reads a string entered in HyperTerminal and stores it as a null-terminated string in memory. The user terminates the string by hitting Enter.
· output_string transmits a null-terminated string to be displayed in HyperTerminal.
· read_character reads a character which is received by the UART from HyperTerminal.
· convert_2_lowercase is the subroutine which converts all the characters in the string to lowercase.
· sort orders the characters in the word alphabetically.


So far, I've written this:

Code:
AREA Serial, CODE, READONLY
EXPORT lab3

SER EQU 0x04 ; Serial Port
USTAT0 EQU 0x08 ; UART Status Register
TRANS EQU 0x0C ; Transmit Register
RECEIV EQU 0x10 ; Receive Register
BAUD EQU 0x14 ;

string = "--------------------",0
prompt = " Enter a string up to 20 characters long:", 0

ALIGN

lab3

STMFD SP!,{lr} ; Store register lr on stack

BL uart_init ; Branch to uart_init

LDR r10, =prompt ; Prompts user
BL output_string
LDR r8, =string ; Loads string into r8

MOV r9, r8
BL read_string


BL convert_2_lowercase

BL sort


;-----------------------------------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------------------------------------------------


uart_init ; INITIALIZE UART

STMFD SP!,{lr} ; Store register lr on stack

LDR r1, =0x03FFD000 ; Load base address into r1
MOV r2, #0 ; Turn off serial port
STR r2, [r1, #SER] ; Contents of 0x3FFD004, stored into r2

LDR r1, =0x03FFD000 ; Load base address into r1
MOV r2, #3 ; Set port for 8 bits, 1 stop, 0 parity
STR r2, [r1] ; Store the value 3 into memory address 0x3FFD000

LDR r1, =0x03FFD000 ; Load base address into r1
MOV r2, #9 ; Turn on serial port
STR r2, [r1, #SER] ; Store the value 9 into memory address 0x3FFD004

LDR r1, =0x03FFD000 ; Load base address into r1
MOV r2, #162 ; Set to 9600 baud
MOV r2, r2, LSL #4 ; Left shift value 162 stored in r2 by
; 4 spots, and recopy into r2
STR r2, [r1, #BAUD] ; Store left shifted value in r2 into
; memory address 0x3FFD014

LDMFD SP!, {lr} ; Restore register lr from stack
MOV pc, lr

;-----------------------------------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------------------------------------------------

read_string ; READ STRING ENTERED BY USER UNTIL
; ENTER KEY IS REACHED

STMFD SP!,{lr} ; Store register lr on stack

STORE BL read_character
STRB r0, [r9] ; Store the byte
ADD r9, r9, #1
BL output_character ; Display the contents of each byte
CMP r0, #13 ; Finish when the Enter key is pressed
BNE STORE
MOV r0, #0
STRB r0, [r9]

LDMFD SP!, {lr} ; Restore register lr from stack
MOV pc, lr

;-----------------------------------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------------------------------------------------

read_character

STMFD SP!,{lr} ; Store register lr on stack

LOOP LDR r1, =0x03FFD000
LDR r2, [r1, #USTAT0]
TST r2, #32
BEQ LOOP
LDR r0, [r1, #RECEIV]

LDMFD SP!, {lr} ; Restore register lr from stack
MOV pc, lr

;-----------------------------------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------------------------------------------------

output_character

STMFD SP!,{lr} ; Store register lr on stack

LOOP2 LDR r1, =0x03FFD000 ; Load memory address 0x03FFD000 into r1
LDR r2, [r1, #USTAT0] ; Load 0x03FFD004 into r2
TST r2, #64 ; Clear bit 6
BEQ LOOP2
STR r0, [r1, #TRANS] ; Store contents of 0x03FFD004 into r1

LDMFD SP!, {lr} ; Restore register lr from stack
MOV pc, lr

;-----------------------------------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------------------------------------------------

output_string ; SHOW STRING IN HYPERTERMINAL
; UNTIL IT REACH END

STMFD SP!,{lr} ; Store register lr on stack

DISPLAY
LDRB r0, [r10], #1 ; Load the byte from address in r10 into r0
; and post-index r10 by 1
CMP r0, #0 ; Finish when the string comes to a 0
BEQ DONE2
BL output_character
B DISPLAY

DONE2 ; Branch here if null character is reached

LDMFD SP!, {lr} ; Restore register lr from stack
MOV pc, lr



;-----------------------------------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------------------------------------------------

convert_2_lowercase ; CONVERTS VALUES ENTERED TO THEIR
; LOWERCASE FORM

MOV r5, #65 ; r5 holds ascii value for capital A
MOV r6, #90 ; r6 holds ascii value for capital Z

LDR r11, string ; load address for string into r11
MOV r3, #0 ; move #0 into r0

LOOPZ MOV r12, r11 ; move value in r11 to r12
LDRB r3, [r12] ; load byte content from r12 into r0

CMP r3, #13 ; Compare contents of r3 to ascii value for SPACE
BEQ LOOPE ; If equal to SPACE, Branch to LOOPE and immediately increment

LOOPX CMP r3, r6 ; Compare r0 to Z
BLE LOOPY ; Branch to LOOPY if r0 < Z
B DONE ; Otherwise, Branch to DONE

LOOPY CMP r3, r5 ; Compare r0 to A
BLT DONE ; Branch to DONE if r0 < A

ADD r3, r3, #32 ; Add 32 to acsii value in r3 and copy back to r3
LOOPE STRB r3, [r12], #1 ; store value in r3 into memory address r12 - Post index by 1
CMP r12, #0 ; Compare post indexed r12 address to NULL
BEQ output_string ; Branch to DONE if r12=0
B LOOPZ ; If unequal, unconditional branch to LOOPZ

DONE ; Done

;-----------------------------------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------------------------------------------------


STMFD SP!,{lr} ; Store register lr on stack

sort
LDR r7, =string
MOV r0, #0
LDRB r0, [r7]
MOV r8, r7

sort2
ADD r4, r7, r0
MOV r1, #0
ADD r8, r8, #1

after
LDRB r2, [r4], #-1
LDRB R3, [r4]
CMP r2, r3
BCC skip

STRB r2, [r4], #1
STRB r3, [r4]
ADD r1, r1, #1
SUB r4, r4, #1

skip
CMP r4, r8
BHI after
CMP r1, #0
BNE sort2

DONE3

LDMFD SP!, {lr} ; Restore register lr from stack
MOV pc, lr


;-----------------------------------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------------------------------------------------

LDMFD SP!, {lr} ; Restore register lr from stack
MOV pc, lr
END





The code prompts the user fine, and it reads and transmits the string perfectly as well. However, I can't seem to figure out how to Branch and Link my program from the "main" part to my convert_2_lowercase and sort programs so that they function as well.

I appreciate any and all the help I can get. I'm honestly lost at this point.

Thank you

btw, this is for an ARM7TDMI processor.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Project Help Please? Urgent


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 11 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek