Re: Help, it's my first ASM homework

spamtrap_at_crayne.org
Date: 11/09/04

  • Next message: Tim Roberts : "Re: Help, it's my first ASM homework"
    Date: Tue, 9 Nov 2004 07:12:06 +0000 (UTC)
    
    

    In article <2v6mkhF2ih2esU1@uni-berlin.de>
               spamtrap@crayne.org "Jesse Woo " writes:

    > Hi, my first post here. I am really confused why my program does not
    > run correctly, it's my first assignment that counts the digits and
    > letters in the string you input. Could someone point out the bug?
    > thanks. (compiled by MASM5.1 in FreeDOS in Bochs)

    The main problem is that you are using LOOP to count off the
    characters in the input string, and in all but one case skipping
    past the LOOP hence not decrementing CX properly. See below for
    a suggestion.

    > === code start here ===
    [snip]
    > CODE SEGMENT
    > ASSUME DS:DATA, SS:STACK, CS:CODE

    [snip]

    > MAIN: INC SI
    > MOV AL, [SI]
    > MOV BL, 30H
    > MOV BH, 3AH
    > CMP AL, BL
    > JS OTHER
    > CMP AL, BH
    > JNS CAP
    > INC BUF_B

    -> JMP MORE

    > CAP: MOV BL, 41H
    > MOV BH, 5BH
    > CMP AL, BL
    > JS OTHER
    > CMP AL, BH
    > JNS LOWER
    > INC BUF_C

    -> JMP MORE

    > LOWER: MOV BL, 61H
    > MOV BH, 7BH
    > CMP AL, BL
    > JS OTHER
    > CMP AL, BH
    > JNS OTHER
    > INC BUF_D

    -> JMP MORE

    > OTHER: INC BUF_E

    -> MORE: LOOP MAIN

    > ;;
    > PRINT: MOV BL, 0AH
    > MOV AH, 0

    [snip rest]

    I made those changes here and it seemed to work -- at least it
    gave the right answers on the two input strings I tested :-)

    Keep at it,
    Pete

    -- 
       "We have not inherited the earth from our ancestors,
        we have borrowed it from our descendants."
    

  • Next message: Tim Roberts : "Re: Help, it's my first ASM homework"

    Relevant Pages

    • Re: substring finding problem!
      ... banono going right to left without overlap ... <snip naming dropping rant> ... the string. ... something at which C programmers suck because C sucks at it. ...
      (comp.lang.c)
    • Re: Efficency and the standard library
      ... could represent this as a negative string length. ... Heathfield labors mightily to stay inside the Game: ... And so the Combatants turn once more to their game of reading C. ...
      (comp.lang.c)
    • Re: The Philosophy of Programming?
      ... less trivial to ensure that the string length has not been altered. ... > lowers psychological complexity for most intelligent readers. ... For most intelligent programmers, the laziness principal applies. ...
      (comp.programming)
    • Re: A C++ Whishlist
      ... > people from inclusion in a standard. ... > creating their own string class. ... >>don't want an ever increasing size of exception specification on each ...
      (comp.lang.cpp)
    • Re: Hash functions (was: Maximum String size in Java?)
      ... snip ... ... Inserted with sx31hsh and ssfh_ph in 0.385 secs ... your string library has problems with them speaks for itself. ... published your SFH code with the shifted and undersized ints. ...
      (comp.programming)