News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

I need some help with this

Started by Narray, October 15, 2011, 03:17:40 AM

Previous topic - Next topic

Narray

OK, long story. I am taking a Assembly, and I've already gotten a 0 on project 13, and turned in project 17.  So you're not helping me cheat!   

We're working with a ROR and bit counting, but i don't think that is the problem. i am using VS2010,
project 13 and 17 are almost exactly alike.
project 13
"Using your last name (Capitalize the first letter of your last name) determine whether each character, taken one at a time, has either an even or odd numbner of bits set.  Move all of the even characters to a buffer area called "even" and move all of the odd characters to a buffer area called "odd". Print out your last name and each of the buffer areas."
project 17
"Using your full first name (Capitalize the first letter of your first name) determine whether each character, taken one at a time, has either an even or odd number of bits set.  Move all of the even characters to a buffer area called "even" and move all of the odd characters to a buffer area called "odd". Print out your last name and each of the buffer areas"
I got Project 17 working like a charm.  Afterwards i decided to retry 13 due to it being the same but with different names, and i cannot get it to work...

//////////////////////////code deleted ///////////////////////


i don't know what's going on here.  i copied and pasted  the entire program from 17 to 13. as i said 17 works, 13 doesn't.

dedndave

the forum has a no homework rule
however, you have put in a lot of effort, so i can give you a couple ideas

it sounds like you got the instructions mixed up a little bit...
Quoteproject 13
"Using your last name (Capitalize the first letter of your last name) determine whether each character, taken one at a time, has either an even or odd numbner of bits set.  Move all of the even characters to a buffer area called "even" and move all of the odd characters to a buffer area called "odd". Print out your last name and each of the buffer areas."
project 17
"Using your full first name (Capitalize the first letter of your first name) determine whether each character, taken one at a time, has either an even or odd number of bits set.  Move all of the even characters to a buffer area called "even" and move all of the odd characters to a buffer area called "odd". Print out your last name and each of the buffer areas"

at any rate, you can easily test the "odd/even-ness" of a byte value by using the JPO or JPE branch instructions
with the byte in AL, an OR AL,AL instruction will set the Parity flag according to how many bits in AL are set
you can then use JPE or JPO to branch

        mov     al,SomeByte
        or      al,al
        jpe     ParityIsEven

ParityIsOdd:
;some code
        jmp     Continue

ParityIsEven:
;some code

Continue:

dedndave

here is a snag in your code
   OddLetter:                           
      mov edi,countOdd                  ; loads odd counter             
      mov odds[edi],al                         ; saves letter in string
      inc edi                      ; inc odd counter
      mov countOdd,edi                  ; stores odd counter
      inc esi                           ; moves to next letter
      LOOP letterLoop

   EvenLetter:
      mov edi,countEven                  ; loads even counter
      mov evens[edi],al                  ; saves letter in string
      inc edi                           ; inc even counter
      mov countEven,edi                  ; stores even counter
      inc esi                           ; moves to next letter
      LOOP letterLoop

      XOR EDX,EDX

if the last letter is odd, the letterLoop falls through to EvenLetter
add something like this
   OddLetter:                           
      mov edi,countOdd                  ; loads odd counter             
      mov odds[edi],al                         ; saves letter in string
      inc edi                      ; inc odd counter
      mov countOdd,edi                  ; stores odd counter
      inc esi                           ; moves to next letter
      LOOP letterLoop

      jmp Continue

   EvenLetter:
      mov edi,countEven                  ; loads even counter
      mov evens[edi],al                  ; saves letter in string
      inc edi                           ; inc even counter
      mov countEven,edi                  ; stores even counter
      inc esi                           ; moves to next letter
      LOOP letterLoop

Continue:
      XOR EDX,EDX

Narray

hey, thanks  guys!  it work just fine.  as i said i already got a 0  on 13 anyway it was more for me than any thing else
thanks again.

dedndave

maybe you got a 0 for writing down the problems incorrectly   :P

Narray

na dave,  have 2 kids and a wife. who wouldn't leave me alone to write programs...  the assignments are copied and pasted from the homework, any problems are the teachers.