Hi i am new to assembly programming and i want to develop my own language and macros first. I do not like prewritten code or others macros for anything, i want to learn assembly the real deal like how it was originally used. I have read a few books on assembly so far and know enough to know what you are talking about in responing, i know the basics like what the command do, i read assembly language 8086 and other books. What my problem is none of these books or any material i can find details, the old school assembly way to make graphics, i know that with assembly commands you can make graphics, for in the disassembler it all goes into assembly every program. so i just need to know how to do basic 2d graphics with it, nothing prewritten, just how to make a fricking green dot on the screen, i am die for it, it is so stupid these toutorial writers all think we only want to use api,s the whole reason i got into assembly is full control over the code. so f any of you could tell me in strict aassembly no api's i don't wanna program in apis but the and or xor type stuff the actual assembly language how to make a dot appear on the screen by assembly code of some colour  i would really appreciate it. Thank you or a place whwere there is a toutorial on that stuff, plus i failed geography and shit and dropped out but was an a student in math and totally get this stuff easy it is like second knowledge please help i am dieing to just write my first dot of colour on the screen.
Posted on 2011-08-03 20:56:37 by Boo-dadli_gi
Doesn't matter what you're doing, you're never going to get away from API's so I suggest you get used to it. The BIOS services themselves are just another form of API. That being said, I think what you're looking for is something like this.

That link should give you a good starting point. Basically you're just plotting a color code to video memory. In the above example, it uses a hard coded pixel point, if you do anything dynamic you might want to come up with a quick plotting formula.

I used to use the old offset = (Y<<8) + (Y<< 6) + X formula, but again that was a long time ago.

plot_pixel:
; ax = Y coordinate
; bx = X coordinate
; cx = color code

mov dx, 0xA0000000
mov es, dx

; Calculate X,Y position in memory using
; the formula:
; offset = (Y<<8) + (Y<<6) + X

mov dx, ax
shl ax, 8
shl dx, 6
add ax, dx
add ax, bx

; Draw the color in CL into memory.

mov es:, cl
ret


That should work for plotting a pixel to video memory. As a note, you should probably play with that, then immediately stop using it (or at least port it to use any memory location instead of hard-coding 0xA0000000 so you can use a double buffering method as shown in that lecture).

Anyway, I'm sure other people might have better words of wisdom on this subject. I've not actually done VGA stuff in many, many, MANY, years.

Regards,
Bryant Keller
Posted on 2011-08-03 22:27:43 by Synfire

That should work for plotting a pixel to video memory.


Yes, but let me point out that you should first switch to the VGA 320x200 mode, else it won't work, which is mode 13h:

; Set videomode
mov ah, 0
mov al, 13h
int 10h


After all, the whole (Y << 8 ) + (Y << 6) + X formula is basically this:
Y * (2^8) + Y * (2^6) + X = Y * 256 + Y * 64 + X = Y * (256+64) + X = Y * 320 + X.

In other words: you assume that you have pixels of 1 byte size (256 colour palette mode), and a scanline is 320 pixels wide.
You also assume that the linear framebuffer starts at segment 0xA000.
Mode 13h fits these criteria. For other graphics modes, you may need to modify the segment and the pixel addressing.

Note also that although int 10h is an API, it is a BIOS function, not an OS function. It is supplied by the BIOS of the VGA card itself, so technically you're still programming the hardware directly.
Posted on 2011-08-04 01:39:37 by Scali

mov dx, 0xA0000000


Wot? Surely:


mov dx, 0xA000


Mode 13h is pretty "chunky" these days. Not very useful in a "real" (that is, "protected") OS. Either use the APIs, or do without an OS... In a multi-tasking, multi-user system, you wouldn't want to do this even if you could - it might not be "your turn"!

Best,
Frank

Posted on 2011-08-04 06:48:01 by fbkotler
Yes, but let me point out that you should first switch to the VGA 320x200 mode, else it won't work, which is mode 13h:

; Set videomode
mov ah, 0
mov al, 13h
int 10h


After all, the whole (Y << 8 ) + (Y << 6) + X formula is basically this:
Y * (2^8) + Y * (2^6) + X = Y * 256 + Y * 64 + X = Y * (256+64) + X = Y * 320 + X.

In other words: you assume that you have pixels of 1 byte size (256 colour palette mode), and a scanline is 320 pixels wide.
You also assume that the linear framebuffer starts at segment 0xA000.
Mode 13h fits these criteria. For other graphics modes, you may need to modify the segment and the pixel addressing.

Note also that although int 10h is an API, it is a BIOS function, not an OS function. It is supplied by the BIOS of the VGA card itself, so technically you're still programming the hardware directly.


Yeah, I was assuming VGA 320x200 mode as is discussed in the link I was referencing. I guess I could have made that more clear in my post, but I figured a link would be just as easy. :)



mov dx, 0xA0000000


Wot? Surely:


mov dx, 0xA000



Heh, yeah. I'm too used to dword registers. :P Sorry for the (multiple) typos.
Posted on 2011-08-05 01:12:35 by Synfire