Character Moving with Arrow Keys

============================================
.MODEL SMALL DATA_SEG SEGMENT 'DATA' CH1 DB (?) CH2 DB (?) Y DB (?) X DB (?) DATA_SEG ENDS CODE_SEG SEGMENT 'CODE' ASSUME CS:CODE_SEG,DS:DATA_SEG START PROC FAR MOV AX,DATA_SEG MOV DS,AX MOV AH,1 INT 21H MOV CH1,AL MOV AH,6 MOV AL,0 MOV BH,07 MOV CH,0 MOV CL,0 MOV DH,50 MOV DL,80 INT 10H MOV AH,2 MOV BH,0 MOV DH,12 MOV DL,40 INT 10H MOV AH,2 MOV DL,CH1 INT 21H MOV Y,12 MOV X,40 AGAIN:

MOV AH,1 INT 21H MOV CH2,AL CMP AL,0 JE CHECK jmp exit CHECK: MOV AH,08 INT 21H MOV CH2,AL CMP AL,72 JE UP CMP AL,80 JE DOWN CMP AL,75 JE JUMP_LEFT CMP AL,77 JE JUMP_CASE4 UP: MOV AH,2 MOV BH,0 MOV DH,Y MOV DL,X INT 10H

MOV AH,2 MOV DL,' ' INT 21H SUB Y,1 CMP Y,0 JE DEC_X MOV MOV MOV MOV AH,2 BH,0 DH,Y DL,X

INT 10H MOV AH,2 MOV DL,CH1 INT 21H JMP AGAIN JUMP_LEFT: JMP LEFT JUMP_CASE4: JMP RIGHT DEC_X: SUB X,1 MOV Y,25 CMP X,0 JE JUMP_PUT_MAX JMP AGAIN

DOWN: MOV AH,2 MOV BH,0 MOV DH,Y MOV DL,X INT 10H

MOV AH,2 MOV DL,' ' INT 21H ADD Y,1 CMP Y,25 JGE INC_X MOV AH,2 MOV BH,0 MOV DH,Y MOV DL,X INT 10H

MOV AH,2 MOV DL,CH1 INT 21H JMP AGAIN INC_X: ADD X,1 MOV Y,0 CMP X,80 JGE JUMP_PUT_ZERO JMP AGAIN JUMP_PUT_MAX: JMP PUT_MAX LEFT: MOV AH,2 MOV BH,0 MOV DH,Y MOV DL,X INT 10H

MOV AH,2 MOV DL,' ' INT 21H SUB X,1 CMP X,0 JE DEC_Y MOV AH,2 MOV BH,0 MOV DH,Y MOV DL,X INT 10H MOV AH,2 MOV DL,CH1 INT 21H JMP AGAIN

JUMP_FAR: JMP AGAIN DEC_Y: SUB Y,1 MOV X,75 CMP Y,0 JE PUT_MAX JMP JUMP_FAR PUT_MAX: MOV X,75 MOV Y,25 MOV AH,6 MOV AL,0 MOV BH,07 MOV CH,0 MOV CL,0 MOV DH,50 MOV DL,80 INT 10H JMP AGAIN JUMP_PUT_ZERO: JMP PUT_ZERO RIGHT: MOV AH,2 MOV BH,0 MOV DH,Y MOV DL,X INT 10H MOV AH,2 MOV DL,' ' INT 21H ADD X,1 CMP X,75 JGE INC_Y MOV AH,2 MOV BH,0

MOV DH,Y MOV DL,X INT 10H MOV AH,2 MOV DL,CH1 INT 21H JMP JUMP_FAR INC_Y: ADD Y,1 MOV X,0 CMP Y,25 JE PUT_ZERO JMP JUMP_FAR PUT_ZERO: MOV X,0 MOV Y,0 MOV AH,6 MOV AL,0 MOV BH,07 MOV CH,0 MOV CL,0 MOV DH,50 MOV DL,80 INT 10H JMP JUMP_FAR EXIT: MOV AH,4CH INT 21H START ENDP CODE_SEG ENDS END START

http://www.ravianeducation.blogspot.com
FARHAN: 03008855006

Sign up to vote on this title
UsefulNot useful