lecture08 - 0306-250 Assembly Language Programming Lecture...

Info icon This preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
0306-250 Assembly Language Programming Lecture Eight: String/Iteration Examples DB cond Subroutines Stack for Call/Return Stack for Save/Restore
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
String Example One v.2 2 #define LETTERS (26) char Letter; char String[LETTERS]; int8 Index; int8 N = LETTERS; Letter = ‘A’; for (Index=0; Index<N; Index++) { STRING[Index] = Letter++; } ; A: Letter ; X: Pointer to STRING ; B: Index LETTERS: EQU 26 movb #LETTERS,N ldaa #’A’ ldx #String ForInit: clrb ForCond: cmpb N bge ForEnd ForBody: staa b,x inca ForStep: incb bra ForCond ForEnd: ; . . . Done: bra * MyData: SECTION String DS.B 26 N DS.B 1
Image of page 2
String Example Two 3 #define LETTERS (26) char *StrPtr; char *StrPast; char Letter; char String[26]; int8 N = LETTERS; Letter = ‘A’; StrPast = String + N; for (StrPtr = String; StrPtr < StrPast; ) { *(StrPtr++) = Letter++ } ; X: StrPtr ; A: Letter LETTERS: EQU 26 movb #LETTERS,N ldaa #’A’ movw #(String + LETTERS),StrPast ForInit: ldx #String ForCond: cpx StrPast bhs ForEnd ForBody: staa 1,x+ inca bra ForCond ForEnd: ; . . . Done: bra * MyData: SECTION StrPast DS.W 1 String DS.B 26 N DS.B 1
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
DB cond abdxys , Label 4 DBNE : Decrement counter register (A, B, D, X, Y, or S) and branch to label if abdxys 0 To implement n iterations with DBNE initialize counter varaible Dn.W to n DBEQ : Decrement counter register (A, B, D, X, Y, or S) and branch to label if abdxys = 0
Image of page 4
DBNE abdxys , Label 5 S12CPUV2 Reference Manual , p. 56
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern