The program is supposed to read numbers from a .txt file and write colors to the screen depending on which number is read. My problem is no numbers are being read from the file. Thank you very much for the time and help!
Code: Cpp
Code:
INCLUDE Irvine16.inc
.data
buffer byte 0
fileName byte "pix.txt",0
fileHandle word ?
y byte ?
x byte ?
.code
main PROC
mov ax,@data
mov ds,ax
mov ah,3dh ;opens the file to read
mov al,0
mov dx,offset fileName
int 21h
jc quit
mov fileHandle,ax
mov x,0
mov y,0
mov ah,3fh ;reads a single byte
mov bx,fileHandle
mov cx,1
mov dx,offset buffer
int 21h
mov al,buffer
begin:
mov ah,02h
mov bh,0
mov dl,x
mov dh,y
int 10h
mov ah,3fh ;reads a single byte
mov bx,fileHandle
mov cx,1
mov dx,offset buffer
int 21h
mov al,buffer
cmp al,2
je greenColor
cmp al,7
je whiteColor
cmp al,6
je yellowColor
cmp al,4
je redColor
cmp al,1
je blueColor
cmp al,0
je blackColor
greenColor:
mov ah,09h ;writes needed color to screen
mov al,' '
mov bh,0
mov bl,10100000b
mov cx,1
int 10h
mov ah,3fh ;reads a single byte
mov bx,fileHandle
mov cx,1
mov dx,offset buffer
int 21h
mov al, buffer
inc x
cmp x,20
je lineJump
jmp begin
whiteColor:
mov ah,09h ;writes needed color to screen
mov al,' '
mov bh,0
mov bl,11110000b
mov cx,1
int 10h
mov ah,3fh ;reads a single byte
mov bx,fileHandle
mov cx,1
mov dx,offset buffer
int 21h
mov al, buffer
inc x
cmp x,20
je lineJump
jmp begin
yellowColor:
mov ah,09h ;writes needed color to screen
mov al,' '
mov bh,0
mov bl,11100000b
mov cx,1
int 10h
mov ah,3fh ;reads a single byte
mov bx,fileHandle
mov cx,1
mov dx,offset buffer
int 21h
mov al, buffer
inc x
cmp x,20
je lineJump
jmp begin
redColor:
mov ah,09h ;writes needed color to screen
mov al,' '
mov bh,0
mov bl,11000000b
mov cx,1
int 10h
mov ah,3fh ;reads a single byte
mov bx,fileHandle
mov cx,1
mov dx,offset buffer
int 21h
mov al, buffer
inc x
cmp x,20
je lineJump
jmp begin
blueColor:
mov ah,09h ;writes needed color to screen
mov al,' '
mov bh,0
mov bl,00010000b
mov cx,1
int 10h
mov ah,3fh ;reads a single byte
mov bx,fileHandle
mov cx,1
mov dx,offset buffer
int 21h
mov al, buffer
inc x
cmp x,20
je lineJump
jmp begin
blackColor:
mov ah,09h ;writes needed color to screen
mov al,' '
mov bh,0
mov bl,00000000b
mov cx,1
int 10h
mov ah,3fh ;reads a single byte
mov bx,fileHandle
mov cx,1
mov dx,offset buffer
int 21h
mov al, buffer
inc x
cmp x,20
je lineJump
jmp begin
lineJump:
call crlf
inc y
mov x,0
cmp y,20
je quit
jne begin
quit:
mov ah,01h
int 21h
mov ah,4ch ; terminate process
mov al,0
int 21h
main ENDP
END main