;Fail to add  ←  function,why?
WINWIDTH=60       
WINTOP=10           
WINLEFT=10          
WINBOTTOM=20      
WINRIGHT=WINLEFT+WINWIDTH-1  
COLOR=54H
PAGEN=0                     
CTRL_C=03H                  

CSEG   SEGMENT
       ASSUME CS:CSEG
START:  
      
      

       MOV   AL,PAGEN       
       MOV   AH,5
       INT   10H
;
        MOV   CH,WINTOP       
        MOV   CL,WINLEFT
        MOV   DH,WINBOTTOM
        MOV   DL,WINRIGHT
        MOV   BH,COLOR
        MOV   AL,0
        MOV   AH,6
        INT   10H
;
        MOV   BH,PAGEN       
        MOV   DH,WINTOP
        MOV   DL,WINLEFT
        MOV   AH,2
        INT   10H
;
NEXT:   MOV   AH,0           
        INT   16H
        CMP   AL,CTRL_C     
        JZ    EXIT          
;
cmp  al,0dh
jne  bb
inc  dh
cmp    dh,WINBOTTOM+1
jne  ee
call  roll_up
ee:          
MOV   DL,WINLEFT
jmp   SETCUR
bb: 
cmp  ah,072
jne  aa
dec  dh
;dec  dl
cmp  dh,WINTOP-1
jne  SETCUR
        MOV   CH,WINTOP      
        MOV   CL,WINLEFT     
        MOV   DH,WINBOTTOM
        MOV   DL,WINRIGHT
        MOV   BH,COLOR
        MOV   AL,1
        MOV   AH,7
        INT   10H
       MOV   DL,WINLEFT     
       MOV   dh,WINTOP
jmp   SETCUR
aa:
cmp  ah,080
jne  cc
inc  dh
cmp    dh,WINBOTTOM+1
jne  ee2
call  roll_up
ee2:         
jmp   SETCUR

cc:
;cmp  ah,075;Fail to add this  function,why?;●  
;jne  dd
;dec  dl
;dd:       
 
        MOV   BH,PAGEN       
        MOV   CX,1        
        MOV   AH,0AH
        INT   10H

        INC   DL
        CMP   DL,WINRIGHT+1  
        JNE   SETCUR        

INC   Dh
MOV   DL,WINLEFT     
cmp    dh,WINBOTTOM+1
jne    SETCUR
call   roll_up
SETCUR: MOV   BH,PAGEN       
        MOV   AH,2
        INT   10H
        JMP   NEXT         
roll_up  proc
        MOV   CH,WINTOP     
        MOV   CL,WINLEFT     
        MOV   DH,WINBOTTOM
        MOV   DL,WINRIGHT
        MOV   BH,COLOR
        MOV   AL,1
        MOV   AH,6
        INT   10H
        MOV   DL,WINLEFT     
        ret
        roll_up  endp


EXIT:   MOV   AX,4C00H
        INT   21H            
CSEG    ENDS
        END   START

Edited 7 Years Ago by John A: added code tags

You did NOT listen!!!
I posted on your other two posts to properly post your code. It is assembly language and is WAY too big to make simple prognosis!

I had some time to spare this morning so I did what I told you to do but you didn't! I formatted and commented your code! Once I did your problem was VERY apparent! If you had done what I had said you would have most likely found the problem yourself!

If you want advice FOLLOW THE ADVICE YOU ARE GIVEN!!!!

Okay now that I've digressed, here is your problem!!!

WINWIDTH=60 
	WINTOP=10 
	WINLEFT=10 
	WINBOTTOM=20 
	WINRIGHT=WINLEFT+WINWIDTH-1 
	COLOR=54H
	PAGEN=0 
	CTRL_C=03H 

	CSEG SEGMENT
	ASSUME CS:CSEG


START:
		;	Set Active Page#0 
	MOV AL,PAGEN 
	MOV AH,5
	INT 10H			; BIOS - Video Interrupt

	;
	MOV CH,WINTOP 
	MOV CL,WINLEFT
	MOV DH,WINBOTTOM
	MOV DL,WINRIGHT


		;	Scroll up window
	MOV BH,COLOR
	MOV AL,0
	MOV AH,6
	INT 10H

		;	Set Cursor Position
	MOV BH,PAGEN 
	MOV DH,WINTOP
	MOV DL,WINLEFT
	MOV AH,2
	INT 10H

	;	Keyboard polling loop

NEXT: MOV AH,0 
	INT 16H
		; ah=scan code, al=ASCII

	CMP AL,CTRL_C 		; Quit
	JZ EXIT 

	;
	cmp al,0dh			; Is key a <CR>?
	jne bb

		; Carriage Return

;<---   You scroll screen down, advance Y axis, Force left margin
;<-- How does this affect your scroll up?

	inc dh				; Next line down
	cmp dh,WINBOTTOM+1
	jne ee				; Jump if not last line of page!

	call roll_up		; Bottom of screen, scroll it!

ee: 
	MOV DL,WINLEFT
	jmp SETCUR


	; Is Keyscan code a Up Arrow Key? 48h (72)
bb: 
	cmp ah,072		; <-- Becareful with those leading zeros!
	jne aa

	dec dh					; Y up
	;dec dl
	cmp dh,WINTOP-1
	jne SETCUR				; reach the top yet?

	MOV CH,WINTOP 
	MOV CL,WINLEFT 
	MOV DH,WINBOTTOM
	MOV DL,WINRIGHT


		; Scroll Down Window 1 line
	MOV BH,COLOR
	MOV AL,1
	MOV AH,7
	INT 10H				; BIOS - Video 



	MOV DL,WINLEFT 
	MOV dh,WINTOP
	jmp SETCUR


	; Is Keyscan code a Down Arrow? 50h (80)
aa:
	cmp ah,080
	jne cc

	inc dh
	cmp dh,WINBOTTOM+1
	jne ee2
	call roll_up

ee2: 
	jmp SETCUR


	; Is Keyscan code a Left Arrow? 4bh (75)
cc:
;	cmp ah,075			;Fail to add this function,why?;? 
;	jne dd
;
;	dec dl

		; BL=color 
		; Write character CX times at cursor position

;;;; <-- VERY BAD
;
;	db	1	byte
;	dw	2	word
;	dd	4	dword
;	dq	8	qword
;	do	16	oword

;dd: 
	MOV BH,PAGEN 
	MOV CX,1 
	MOV AH,0AH
	INT 10H

	INC DL
	CMP DL,WINRIGHT+1 
	JNE SETCUR			; Reach right margin? 

		;	At screen right margin
	INC Dh				; Wrap onto next line down...
	MOV DL,WINLEFT		; ...Left Edge 
	cmp dh,WINBOTTOM+1	; <---   Are you really sure this is what you meant?
	jne SETCUR

	call roll_up

	; dh=row, dl=col
	;	Set Cursor position
SETCUR: MOV BH,PAGEN 
	MOV AH,2
	INT 10H

	JMP NEXT 


roll_up proc
		; Set vars for last row, 1st column
	MOV CH,WINTOP 
	MOV CL,WINLEFT 
	MOV DH,WINBOTTOM
	MOV DL,WINRIGHT

		;	Scroll Up window 1 line
	MOV BH,COLOR
	MOV AL,1
	MOV AH,6
	INT 10H
	MOV DL,WINLEFT 
	ret
roll_up endp


	;	Terminate program

EXIT: MOV AX,4C00H
	INT 21H 


	CSEG ENDS
	END START

See the problem now?

This isn't the dark ages of assembly language programming where your variables had to be one to a maximum of eight characters long! Use nice verbose labels. Or use local labels!

This article has been dead for over six months. Start a new discussion instead.