I had something in my mind to spice up the code that draw the pixels on the screen about what if I can make a condition that change the variable (dl register/data stack) value by 1, 2 and 5, then make the code to increase/decrease value by variable.
add dx, dl ; something like that, the assembler gave me an error: incorrect/illegal combination of opcodes and operands
Here's the full code, modified by me (OG code from the video):
bits 16
org 0x7c00
start:
cli
push 0x0A000
pop es
xor di, di
xor ax, ax
mov ax, 0x13
int 0x10
jmp payload
payload:
add dl, 1
cmp dl, 3
jg condition
mov ah, 0x0c
add al, 1
mov bh, 0x00
add cx, 1
add dx, [dl] ; from reference, the assembler said: invalid 16-bit effective address
int 0x10
jmp payload
condition:
mov dl, 0
jmp payload
times 510 - ($-$$) db 0
dw 0xaa55
Waiting for your answers and feedback.
P.S. For those who are confused, I'll rephrase the code part I want to add in a C syntax (may be some inaccuracies, you can always fix me):
byte reg1;
byte reg2 = 1;
int main() {
reg1 += ®2;
if (reg2 == 1) {
reg2 = 2;
} else if (reg2 == 2) {
reg2 = 5;
} else if (reg2 == 5) {
reg2 = 1;
};
return 0;
}
As for my config: I compile the code into .img (floppy disk) file.
I tried to figure out what's wrong and fixed the question to be more understandable. I asked my question because I want to follow the DRY (Don't Repeat Yourself) coding principle to reduce the CPU overhead if there's no use to apply the dl register, then I could use the other unit that can hold the value compatible with DX, otherwise, give me a verdict if that's possible or not.
Thank you.