News:

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

Error with my program..

Started by zafaraj, April 28, 2006, 11:55:16 PM

Previous topic - Next topic

zafaraj

Yes, this is a project for school, but no, I don't need anyone to write it. lol  I was hoping someone can help me understand why my text is not being placed at the right positions when I have this amount of code.  Im using MASM to compile, and everytime I exceed a certain file length, none of my strings seem to go to the positions I encoded.  If you remove the 'ADD AX,BX' and 'ADD CX,DX' which serve no purpose, the program should run fine.  Any help would be MUCH appreciated.

many thanks!

zade

        .MODEL LARGE
        .STACK
   .DATA
INTRO1   DB   'ELET 3105 Project$'
INTRO2   DB   'Submitted by$'
INTRO3   DB   'Zade Faraj$'
INTRO4   DB   'Date: 04/27/2006$'
INTRO5   DB   '(C)ontinue                                (Q)uit$'
INDEX1   DB   'Please choose a program to run$'
INDEX2   DB   '1. Find the nth power of a number$'
INDEX3   DB   '2. Print a pyramid of characters$'
INDEX4   DB   '3. Swap a 3 digit number$'
INDEX5   DB   '(Q)uit$'

   .CODE
        .STARTUP

   MOV AX,0003   ;SET VIDEO MODE
   INT 10H
   MOV DH,06H   ;SET CURSOR POSITION FOR INTRO1
   MOV DL,20H
   MOV AH,02H
   INT 10H
   LEA DX,INTRO1   ;DISPLAY INTRO1'
   MOV AH,09H
   INT 21H
   MOV DH,08H   ;SET CURSOR POSITION FOR INTRO2
   MOV DL,22H
   MOV AH,02H
   INT 10H
   LEA DX,INTRO2   ;DISPLAY INTRO2'
   MOV AH,09H
   INT 21H
   MOV DH,0AH   ;SET CURSOR POSITION FOR INTRO3
   MOV DL,23H
   MOV AH,02H
   INT 10H
   LEA DX,INTRO3   ;DISPLAY INTRO3'
   MOV AH,09H
   INT 21H
   MOV DH,0DH   ;SET CURSOR POSITION FOR INTRO4
   MOV DL,30H
   MOV AH,02H
   INT 10H
   LEA DX,INTRO4   ;DISPLAY INTRO4'
   MOV AH,09H
   INT 21H
   MOV DH,12H   ;SET CURSOR POSITION FOR INTRO5
   MOV DL,10H
   MOV AH,02H
   INT 10H
   LEA DX,INTRO5   ;DISPLAY INTRO5'
   MOV AH,09H
   INT 21H
CHOICE:   MOV AH,08H   ;WAIT FOR KEYBOARD ENTRY
   INT 21H
   CMP AL,'C'   ;CHECK TO SEE IF THE KEY ENTERED IS A 'C'
   JZ  INDEXP   ;IF IT IS, GO TO THE INDEX PAGE
   CMP AL,'c'   ;CHECK TO SEE IF THE KEY ENTERED IS A 'c'
   JZ  INDEXP   ;IF IT IS, GO TO THE INDEX PAGE
   CMP AL,'Q'   ;CHECK TO SEE IF THE KEY ENTERED IS A 'Q'
   JZ  EXITP   ;IF IT IS, EXIT THE PROGRAM
   CMP AL,'q'   ;CHECK TO SEE IF THE KEY ENTERED IS A 'q'
   JZ  EXITP   ;IF IT IS, EXIT THE PROGRAM
        MOV DL,07H
        MOV AH,02H
        INT 21H
        JNZ CHOICE
EXITP:   MOV AX,0003   ;SET VIDEO MODE
   INT 10H
   .EXIT

INDEXP:   MOV AX,0003   ;SET VIDEO MODE
   INT 10H
   MOV DH,06H   ;SET CURSOR POSITION FOR INDEX1
   MOV DL,19H
   MOV AH,02H
   INT 10H
   LEA DX,INDEX1   ;DISPLAY INDEX1'
   MOV AH,09H
   INT 21H
   MOV DH,09H   ;SET CURSOR POSITION FOR INDEX2
   MOV DL,12H
   MOV AH,02H
   INT 10H
   LEA DX,INDEX2   ;DISPLAY INDEX2
   MOV AH,09H
   INT 21H
   MOV DH,0BH   ;SET CURSOR POSITION FOR INDEX3
   MOV DL,12H
   MOV AH,02H
   INT 10H
   LEA DX,INDEX3   ;DISPLAY INDEX3
   MOV AH,09H
   INT 21H
   MOV DH,0DH   ;SET CURSOR POSITION FOR INDEX4
   MOV DL,12H
   MOV AH,02H
   INT 10H
   LEA DX,INDEX4   ;DISPLAY INDEX4
   MOV AH,09H
   INT 21H
   MOV DH,12H   ;SET CURSOR POSITION FOR INDEX5
   MOV DL,3AH
   MOV AH,02H
   INT 10H
   LEA DX,INDEX5   ;DISPLAY INDEX5
   MOV AH,09H
   INT 21H
   MOV AH,08H
   INT 21H
        MOV AH,01H
        INT 21H
        CMP AL,'T'
        ADD AX,BX
        ADD CX,DX
        JMP EXITP

END

MichaelW

The main problem I see is that you are not controlling the value in BH when you call the BIOS Set Cursor Position function, for which BH specifies the display page number. For what you are doing BH should be set to zero.

Also, I think it would be easier to work with the cursor coordinates if you expressed them in decimal instead of hex. And are you aware that you can automate the centering of the strings with code like this:

mov dl,39
sub dl,(SIZEOF INTRO4-1)/2

eschew obfuscation

zafaraj

Yes, I recall I didn't add that in.  Im gonna put them in and see what results I get.  It shouldnt have anything to do with the length of the program should it?  I say this because the only time it ever says anything is when I add past that last CMP statement.  very confusing, but I'll test this out and update the post. 

cheers!

zade

zafaraj

Genious!  It works   :U :U

Thank you so much!  You have saved me life, and the hair on my head.

Have a wonderful day!!