CODE	SEGMENT
	ASSUME	CS:CODE,DS:CODE,ES:CODE,SS:CODE
	ORG	100H
START:
	MOV	DI,OFFSET BUF
	CLD
	MOV	BP,1111H
	MOV	BX,1112H
	MOV	CX,1
MAIN2:
	MOV	DX,120FH
MAIN1:
	DEC	DX
	JS	MAIN2
	MOV	SI,OFFSET STREND
	PUSH	SI
	PUSH	CX
	JPO	NEXTM
	JE	FIZBUZ
	MOV	CL,(OFFSET BUF - OFFSET STREND) / 2
	ADD	SI,CX
	SHR	DH,1
	JC	NEXT
NEXTM:
	SUB	SI,CX
NEXT:
	REP	MOVSB
	MOV	AX,0A0DH
	STOSW
	CMP	DI,OFFSET BUF + 8192
	JB	NOFLS
FLUSH:
	PUSH	BX
	PUSH	DX
	MOV	DX,OFFSET BUF
	MOV	CX,DI
	SUB	CX,DX
	MOV	DI,DX
	MOV	BX,1
	MOV	AH,40H
	INT	21H
	POP	DX
	POP	BX
NOFLS:
	POP	CX
	JCXZ	ENDPRG
	POP	SI
NEXT1:
	DEC	SI
NEXT2:
	INC	BYTE PTR [SI]
	CMP	BYTE PTR [SI],'9'+1
	JB	MAIN1
	MOV	BYTE PTR [SI],'0'
	JE	NEXT1
	INC	CX
	JMP	NEXT2
FIZBUZ:
	MOV	CL,OFFSET BUF - OFFSET STREND
	DEC	BP
	JNE	NEXT
	DEC	BX
	JNE	NEXT
	PUSH	BX
	JMP	FLUSH
ENDPRG:
	MOV	AX,4C00H
	INT	21H
	DB	'AAAAAAAAA1'
STREND	LABEL	BYTE
	DB	'FizzBuzz'
BUF	LABEL	BYTE
CODE	ENDS
	END	START
