Fragment 1:
B Main
ExampleString ; start of packed string
DCD #0x ; ‘S’=0x53 ‘Y’=0x59 ‘S’=0x53 ‘C’=0x43
DCD #0x
DCD #0x ; 1st 00 is the null-terminator, 2nd 00 is just padding to fill the word
Main
; R0 = address of the packed string
LEA R0, [ ExampleString ]
; R1 = index o...
fragment 1 b main examplestring start of packed string dcd 0x53595343 ‘s’0x53 ‘y’0x59 ‘s’0x53 ‘c’0x43 dcd 0x20333030 dcd 0x36210000 1st 00 is the null te
DCD #0x36210000 ; 1st 00 is the null-terminator, 2nd 00 is just padding to fill the word
Main
; R0 = address of the packed string
m
er as
LEA R0, [ ExampleString ]
co
eH w
; R1 = index of the character in the packed string ... test with several values
o.
MOV R1, #5
rs e
; the following code puts the indexed character into the least significant byte of R0,
ou urc
; and clears the remainder of R0
o
; ---- start of block to copy into Fragment 2 ----
aC s
; R2 = offset to word containing indexed character
vi y re
LSR R2, R1, #2 ; divide index by 4
; R3 = word containing indexed character
ed d
LDR R3, [ R0, R2 ]
ar stu
; R1 = digit offset of indexed character in R3 (digit offset = 0, 1, 2 or 3)
AND R1, R1, #3
sh is
; need to shift character from current position to least significant byte
Th
; need to shift 8 bits for each digit position
; R1 = number of digit shifts needed
MOV R4, #3
SUB R1, R4, R1
BEQ DoneShiftLoop ; if 0 shifts needed, then done shifting
; shift character into least significant byte
ShiftLoop
This study source was downloaded by 100000850872992 from CourseHero.com on 03-24-2023 01:11:09 GMT -05:00
https://www.coursehero.com/file/14306242/lab8syscpdf/
DCD #0x36210000 ; 1st 00 is the null-terminator, 2nd 00 is just padding to fill the word
ar stu
; char CharAt ( &( PackedString[] ), uint charIndex )
sh is
; accepts R0 = address of PackedString[] (by reference),
Th
; R1 = charIndex (by value)
; returns R0 = PackedString[ charIndex ]
CharAt
PUSH {R1,R2,R3,R4,R14} ; save registers (SYSC 3006 Register Preservation convention)
; ---- start of block copied from Fragment 1 ----
This study source was downloaded by 100000850872992 from CourseHero.com on 03-24-2023 01:11:09 GMT -05:00
https://www.coursehero.com/file/14306242/lab8syscpdf/
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller ExamsConnoisseur. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $7.99. You're not tied to anything after your purchase.