Morning, scan for my changes, also, just for "proper" DOS, I compile:
nasm prog.asm -o prog.com
".COM" files start with all segment registers the equal, carry over for older code/processors which could only access 64K and had no
concept of "segments".
;This program should produce bands of multiple colors, but it doesn't work.
BITS 16 ;Let the NASM compiler know that this is to be compiled as a 16 bit program.
;There is no ORG command here, because it needs to start at offset 0 to be bootable from a floppy, or in this case a disk image.
;If it was 0x100, then the assembler would write its first assembled command to byte# 0x100 in the floppy disk image, but for a
;bootable floppy image, the first byte in the image file, MUST contain the first byte of assembled code, unlike for a COM file,
;which MUST be padded up to byte 0x100 with 0x00 bytes, and have the first byte of compiled code start at exactly file byte# 0x100.
mov ax,0x13 ;Put mode 0x13 (VGA mode) in ax register.
int 0x10 ;Call interupt 0x10 which is BIOS call needed to change video mode.
mov ax,0xA000 ;Put 0xA000 (the address for VGA video-ram) in ax register.
mov es,ax ;Transfer the content of ax register to ds (data segment) register.
mov cx,0FA00h ;I don't like mixing decimal and hex, prefer hex so I
; can see bit activity, I'm also biased towards 0xxxxh format :).
mov di,-1 ;Put -1 in the di register, as it will be incremented as the first step in the coming loop, and 0 should be its first value after INC.
LoopStart:
inc di ;Increment di (destination index)
mov ax,di ;Put the value of di in ax.
;;;;and ax,0xFF ;Make sure that ax stays within the bounds of 0 to 255.
mov [es:di],al ;BYTE AL, ADDED SEGMENT OVERRIDE IN CASE YOUR NOT AWARE OF CAPABILITY
loop LoopStart ;Decrement CX loop if not zero
Plock jmp Plock ;MAKING PROGRAM LOCK, YOU HAD NO TERMINATION
;
; YOU WOULD USE ONE OR OTHER OF BELOW
;
int 20h ;IF ABOVE LINE REMOVED, THIS IS OLD TERMINATE PROGRAM IN DOS
;
mov ax,4C00h ;MORE MODERN EXIT WITH ERROR CODE HELD IN REGISTER AL
int 21h ;
;;;;cmp di,64000 ;Compare the current value of di to 64000.
;;;;jl LoopStart ;If di is less than 64000, then loop back to LoopStart, else continue to the next command.
;There's no next command, but it doesn't matter. If the program crashes at this point, the stuff that was put into VRAM
;will still remain there.