Re: Help, it's my first ASM homework
spamtrap_at_crayne.org
Date: 11/09/04
- Previous message: Chip: "Re: Buffer Overflow Exploits"
- In reply to: Jesse Woo : "Help, it's my first ASM homework"
- Next in thread: Tim Roberts : "Re: Help, it's my first ASM homework"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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."
- Previous message: Chip: "Re: Buffer Overflow Exploits"
- In reply to: Jesse Woo : "Help, it's my first ASM homework"
- Next in thread: Tim Roberts : "Re: Help, it's my first ASM homework"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|