Problem with db (define bite)

I couldnt compile with "MOV SKIP,1" and "MOV ROW,1" I dont know what's wrong with it. Is it because I didnt define it right or it just cannot use MOV SKIP,1? Someone please help me . Thank you

Here is my code:
ORG 140H
;Program XYDRAW.ASM: Draw simple figures on a color 25 by 80 screen.
;

ROW DB 12 ;initial cursor position
COL DB 40
COLOR DB 2 ;start with green
SKIP DB 1 ;start with skip true (no drawing)
HELP DB 'D: Draw, S: Skip, Move: Arrow Keys, ',0DH, 0AH, 0;
DB 'R/G/B: Set Color, Q: Quit $',0DH, 0AH, 0;
; .CODE
; .STARTUP
MOV AH,0 ;set video mode
MOV AL,3 ;80 x 25 color
INT 10H ;video BIOS call
MOV AH,2 ;set cursor position
MOV BH,0 ;display page number
MOV DH,24 ;bottom row
MOV DL,7 ;column number
INT 10H ;video BIOS call
MOV DX,HELP ;set up pointer to help message
MOV AH,9 ;display string
INT 21H ;DOS call
MOV AH,2 ;set cursor position
MOV BH,0 ;display page number
MOV DH,ROW ;row number
MOV DL,COL ;column number
INT 10H ;video BIOS call
READKEY: MOV AH,0 ;read keyboard
INT 16H ;BIOS call
CMP AL,0 ;check scan code?
JZ CSC
CMP AL,'a' ;test for lower case
JC NOLC
CMP AL,'z'+1
JNC NOLC
AND AL,0DFH ;convert to upper case
NOLC: CMP AL,'Q' ;quit?
JNZ X1
JMP EXIT
X1: CMP AL,'S' ;skip?
JZ SETSKIP
CMP AL,'D' ;draw?
JZ SETDRAW
JMP READKEY
SETSKIP:
MOV SKIP,1 ;skip is true
JMP READKEY
SETDRAW: MOV SKIP,0 ;skip is false
JMP READKEY
CSC: CMP AH,48H ;up arrow?
JZ GOUP
CMP AH,50H ;down arrow?
JZ GODOWN
CMP AH,4BH ;left arrow?
JZ GOLEFT
CMP AH,4DH ;right arrow?
JZ GORIGHT
JMP READKEY ;did not get a valid input
GOUP: ; CMP ROW,0 ;ignore if first row
JNZ GOUP2
JMP READKEY
GOUP2: ;SUB ROW,1
JMP SETCUR ;reposition cursor
GODOWN: ;CMP ROW,23 ;ignore if last row
JNZ GODOWN2
JMP READKEY
GODOWN2: ; ADD ROW,1
JMP SETCUR
GOLEFT: ; CMP COL,0 ;ignore if first column
JNZ GOLEFT2
JMP READKEY
GOLEFT2: ;SUB COL,1
JMP SETCUR
GORIGHT: ;CMP COL,79 ;ignore if last column
JNZ GORIGHT2
JMP READKEY
GORIGHT2: ;ADD COL,1
SETCUR: MOV AH,2 ;set cursor position
MOV BH,0 ;display page number
MOV DH,ROW ;row number
MOV DL,COL ;column number
INT 10H ;video BIOS call
CMP SKIP,1 ;skip if true
JZ NOC
MOV AL,'*' ;write colored * to screen
MOV BL,COLOR
MOV CX,1
MOV AH,9
INT 10H ;video BIOS call
NOC: JMP READKEY
EXIT: RET

END

Comments

  • : I couldnt compile with "MOV SKIP,1" and "MOV ROW,1" I dont know
    : what's wrong with it. Is it because I didnt define it right or it
    : just cannot use MOV SKIP,1? Someone please help me . Thank you
    :
    : Here is my code:
    : ORG 140H
    : ;Program XYDRAW.ASM: Draw simple figures on a color 25 by 80 screen.
    : ;
    : [code]
    : ROW DB 12 ;initial cursor position
    : COL DB 40
    : COLOR DB 2 ;start with green
    : SKIP DB 1 ;start with skip true (no drawing)
    : HELP DB 'D: Draw, S: Skip, Move: Arrow Keys, ',0DH, 0AH, 0;
    : DB 'R/G/B: Set Color, Q: Quit $',0DH, 0AH, 0;
    : ; .CODE
    : ; .STARTUP
    : MOV AH,0 ;set video mode
    : MOV AL,3 ;80 x 25 color
    : INT 10H ;video BIOS call
    : MOV AH,2 ;set cursor position
    : MOV BH,0 ;display page number
    : MOV DH,24 ;bottom row
    : MOV DL,7 ;column number
    : INT 10H ;video BIOS call
    : MOV DX,HELP ;set up pointer to help message
    : MOV AH,9 ;display string
    : INT 21H ;DOS call
    : MOV AH,2 ;set cursor position
    : MOV BH,0 ;display page number
    : MOV DH,ROW ;row number
    : MOV DL,COL ;column number
    : INT 10H ;video BIOS call
    : READKEY: MOV AH,0 ;read keyboard
    : INT 16H ;BIOS call
    : CMP AL,0 ;check scan code?
    : JZ CSC
    : CMP AL,'a' ;test for lower case
    : JC NOLC
    : CMP AL,'z'+1
    : JNC NOLC
    : AND AL,0DFH ;convert to upper case
    : NOLC: CMP AL,'Q' ;quit?
    : JNZ X1
    : JMP EXIT
    : X1: CMP AL,'S' ;skip?
    : JZ SETSKIP
    : CMP AL,'D' ;draw?
    : JZ SETDRAW
    : JMP READKEY
    : SETSKIP:
    : MOV SKIP,1 ;skip is true
    : JMP READKEY
    : SETDRAW: MOV SKIP,0 ;skip is false
    : JMP READKEY
    : CSC: CMP AH,48H ;up arrow?
    : JZ GOUP
    : CMP AH,50H ;down arrow?
    : JZ GODOWN
    : CMP AH,4BH ;left arrow?
    : JZ GOLEFT
    : CMP AH,4DH ;right arrow?
    : JZ GORIGHT
    : JMP READKEY ;did not get a valid input
    : GOUP: ; CMP ROW,0 ;ignore if first row
    : JNZ GOUP2
    : JMP READKEY
    : GOUP2: ;SUB ROW,1
    : JMP SETCUR ;reposition cursor
    : GODOWN: ;CMP ROW,23 ;ignore if last row
    : JNZ GODOWN2
    : JMP READKEY
    : GODOWN2: ; ADD ROW,1
    : JMP SETCUR
    : GOLEFT: ; CMP COL,0 ;ignore if first column
    : JNZ GOLEFT2
    : JMP READKEY
    : GOLEFT2: ;SUB COL,1
    : JMP SETCUR
    : GORIGHT: ;CMP COL,79 ;ignore if last column
    : JNZ GORIGHT2
    : JMP READKEY
    : GORIGHT2: ;ADD COL,1
    : SETCUR: MOV AH,2 ;set cursor position
    : MOV BH,0 ;display page number
    : MOV DH,ROW ;row number
    : MOV DL,COL ;column number
    : INT 10H ;video BIOS call
    : CMP SKIP,1 ;skip if true
    : JZ NOC
    : MOV AL,'*' ;write colored * to screen
    : MOV BL,COLOR
    : MOV CX,1
    : MOV AH,9
    : INT 10H ;video BIOS call
    : NOC: JMP READKEY
    : EXIT: RET
    :
    : END
    :
    [/code]
    [color=Blue]
    Ah...! That's much better! Now I can read it! :-)

    Try "MOV BYTE PTR ROW,1".
    If that will not compile, you have to use some register to put the value in, like this:
    [code]
    MOV AL, 1
    MOV ROW, AL
    [/code]
    However, this may be not so good, if you have all registers busy with other work. In that case use a macro, which preserves a register. Besides, with macros, you can read your code better:
    [code]
    MACRO STORE_BYTE mem_byte, value
    PUSH AX
    MOV AL, value
    MOV mem_byte, AL
    POP AX
    ENDM
    [/code]
    Now, you can safely use the macro, without worrying about the contents of AX - it will be preserved every time you use the macro:
    [code]
    STORE_BYTE ROW, 5
    ...
    STORE_BYTE SKIP, 1
    [/code]
    [/color]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion