I've put together a first try at making a printA function. Unfortunatly, I can't call it a successful first try, because nothing is displayed. Here's the "main" routine from boot.asm:
Code: Select all
main:
xor ax, ax
mov ds, ax
call mode12h
call clearScreen
mov al, 10
mov dx, 10
mov cx, 10
call printA
jmp $
This is the "printA" function, from graphics.inc:
Code: Select all
extern _printCharA
printA:
call _printCharA
ret
"plotPixel" function:
Code: Select all
global _plotPixel
_plotPixel:
push ebp
mov ebp, esp
mov ah, 0x000c
int 0x0010
leave
ret
This is all the functions in graphics.c:
Code: Select all
void addX(int x){
asm("push %ax");
asm("movw %0, %%ebx" : : "a" (x));
asm("add %bx, %cx");
asm("pop %ax");
}
void addY(int y){
asm("push %ax");
asm("movw %0, %%ebx" : : "a" (y));
asm("add %bx, %dx");
asm("pop %ax");
}
void printCharA(){
int y;
int x;
for(y = 0; y < 8; y++){
for(x = 0; x < 8; x++){
if(aFont[y][x] == 1){
int yLocation = y * 640;
addY(yLocation);
addX(x);
plotPixel();
}
}
}
}
"aFont" is just a two-dimensional integer array, forming an A out of 1s and 0s.
This is assemble.bat:
Code: Select all
@echo off
nasm -f elf "../boot/boot.asm" -o "../temp/boot.elf"
"C:\MinGW\bin\gcc.exe" -c "../boot/graphics.c" -o "../temp/graphics.o"
ld -Ttext 0x7c00 "../temp/boot.elf" "../temp/graphics.o" -o "../temp/boot.o"
objcopy -O binary "../temp/boot.o" "../temp/boot.bin"
pause
And this is what I get running assemble.bat:
Code: Select all
C:\Users\Benjamin\AppData\Local\Temp/ccmsTYSI.s: Assembler messages:
C:\Users\Benjamin\AppData\Local\Temp/ccmsTYSI.s:81: Warning: using `%bx' instead
of `%ebx' due to `w' suffix
C:\Users\Benjamin\AppData\Local\Temp/ccmsTYSI.s:81: Warning: using `%ax' instead
of `%eax' due to `w' suffix
C:\Users\Benjamin\AppData\Local\Temp/ccmsTYSI.s:97: Warning: using `%bx' instead
of `%ebx' due to `w' suffix
C:\Users\Benjamin\AppData\Local\Temp/ccmsTYSI.s:97: Warning: using `%ax' instead
of `%eax' due to `w' suffix
Press any key to continue . . .
I know the code is pretty much pathetic, but it's just to get somewhat like my first A printed in graphics mode.
And as said, the above code doesn't produce any screen output.