+ 1
Well, personally I did it in C instead of assembly, but it might give you an idea.
As an exercise you can translate it to assembly.
Basically I iterate over every pixel and if it's x distance away from the center of the circle draw something at that pixel.
#include <stddef.h>
#include <stdint.h>
#define VIDEO_MEM 0xA0000 // Location of the video ram in graphical mode
#define WIDTH 320 // width depends
#define HEIGHT 200 // height also depends
void* memset( void* dst, int value, size_t size )
{
for( size_t i = 0; i < size; *((unsigned char*)dst + i) = (unsigned char)value, ++i );
return dst;
}
void printAt( int x, int y, char byte )
{
// Some math to find the correct pixel
char* p_video_mem = (char*)(VIDEO_MEM + x + y * WIDTH);
*p_video_mem = byte;
}
// kernel entrance point
void kmain(void)
{
srand( 241 );
const size_t video_mem_size = WIDTH * HEIGHT;
memset( (unsigned char*)VIDEO_MEM, 0, video_mem_size );
int centerX = WIDTH/2, centerY = HEIGHT/2;
for( int y = 0; y < HEIGHT; ++y )
{
for( int x = 0; x < WIDTH; ++x )
{
int distanceX = centerX - x;
int distanceY = centerY - y;
if( distanceX * distanceX + distanceY * distanceY < 5000 ) // Don't have access to sqrt here, luckely it's not needed.
{
char color = rand();
printAt( x, y, color );
}
}
}
while( 1 ); // Just to prevent the rest of the code from running off
}
And the output is:
https://imgur.com/DwhnYpp



