TITLE SCORE EXTRN POINTS:WORD, POINTS2:WORD PUBLIC KEEP_SCORE, KEEP_SCORE_2 .MODEL SMALL .CODE KEEP_SCORE PROC ; Input: Points are the number of points player 1 has. ; Points2 are the number of points player 2 has. ; Output score. Player1 and Player2 are updated. ; PUSH AX ;save registers. PUSH BX PUSH DX MOV DX,0204H ;set position for score CALL SETPOS MOV AL,'S' ;set message SCORE: CALL WCHAR MOV AL,'C' CALL WCHAR MOV AL,'O' CALL WCHAR MOV AL,'R' CALL WCHAR MOV AL,'E' CALL WCHAR MOV AL,':' CALL WCHAR MOV AL,' ' CALL WCHAR MOV AX,POINTS ; output score CALL UTXTI POP DX ;restore registers. POP BX POP AX RET ENDP KEEP_SCORE KEEP_SCORE_2 PROC ; Output score is identical to Keep_Score, but is used for player 2. ; Location of score is on right side. PUSH AX ;save registers. PUSH BX PUSH DX MOV DX,0218H ; set position for score CALL SETPOS MOV AL,'S' ; set message SCORE: CALL WCHAR ;write the character. MOV AL,'C' CALL WCHAR MOV AL,'O' CALL WCHAR MOV AL,'R' CALL WCHAR MOV AL,'E' CALL WCHAR MOV AL,':' CALL WCHAR MOV AL,' ' CALL WCHAR MOV AX,POINTS2 ; output score CALL UTXTI POP DX POP BX POP AX RET ENDP KEEP_SCORE_2 WCHAR PROC PUSH AX ; save registers PUSH BX PUSH BP SUB BH,BH ; set page zero MOV AH,14 ; set code for write teletype INT 10H ; write character POP BP ; restore registers POP BX POP AX RET ; return to caller WCHAR ENDP UTXTI PROC PUSH CX ; save registers PUSH DX MOV CX,10 ; divide input argument by 10 SUB DX,DX DIV CX ; ; We have the number / 10 in AX, and number mod 10 in DX. If the ; value in AX is non-zero, we make a recursive call to output it ; OR AX,AX ; test non-zero quotient JZ UTX2 ; jump if zero CALL UTXTI ; else output upper digits ; ; Here we output the remainder from the division as the last digit ; UTX2: MOV AL,DL ; remainder to AL OR AL,'0' ; convert to ASCII CALL WCHAR ; write last digit POP DX ; restore registers POP CX RET ; return to caller UTXTI ENDP SETPOS PROC PUSH AX ; save registers PUSH BX MOV BH,0 ; set cursor MOV AH,2 INT 10H POP BX ; restore registers POP AX RET ; return to caller SETPOS ENDP END