News:

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

help for code

Started by ASMLOVE, May 13, 2009, 11:18:32 AM

Previous topic - Next topic

ASMLOVE

I'M A NEW LEARNER.
I HAVE WRITTEN THIS PROGRAM
TO READ A STRING FROM THE KEYBOARD AND TO DISPLAY IT ON THE SCREEN,BUT I'M NOT GETTING THE OUTPUT.CAN ANY 1 HELP ME?

CODE

.MODEL SMALL
.STACK
.DATA
MSG3 DB "ENTER A WORD:$"
STR DB 20 DUP(?)
.CODE
MOV AX,@DATA
MOV DS,AX
LEA DX,MSG3
MOV AH,09H
INT 21H
LEA DX,STR
MOV AH,0AH
INT 21H

LEA DX,STR
MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H
END

FORTRANS

Hi,

   Look at the "Buffered Input.[solved]" thread in January for
help to use DOS Fn 0AH.

Steve

ASMLOVE

thanks...
here is one more program.i'm getting some garbage value..
this program is to calculate factorial of a number.

CODE

.MODEL SMALL
.STACK
.DATA
NUM DW 4
RESULT DW ?
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AX,01
MOV CX,NUM
CMP CX,00
JE EXIT
MOV BX,CX
CALL FACT
EXIT:MOV RESULT,AX
LEA DX,RESULT
MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H
FACT PROC NEAR
CMP BX,1
JE STOP1
PUSH BX
DEC BX
CALL FACT
POP BX
MUL BX
RET
STOP1:MOV AX,1
RET
FACT ENDP
END

Neil

A quick look & I see a major problem :-

                      CALL FACT  within your proc is messing up the stack.

When you pop BX you are actually popping a return address & not BX

ASMLOVE

THANKS,
WHAT SHOULD I DO NOW?
ANY HINT

Neil

You need to write a LOOP  :bg

ASMLOVE

I TRIED THAT,BUT NOW I GET A BLANK OUTPUT