I stumbled across the code below from emu8086. The final mov goes to
video memory. Is there a map that defines where each video memory
address is on a console screen? For instance, if I wanted to send a
character to row 5, column 18, what video memory address would I use?
Also, what is the purpose of "MOV AX, 0B800h" and "MOV DS, AX" in the
code below? I don't understand why that is there? Thanks.
ORG 100h ; this directive required for a simple 1 segment
..com program.
MOV AX, 0B800h ; set AX to hexadecimal value of B800h.
MOV DS, AX ; copy value of AX to DS.
MOV CL, 'A' ; set CL to ASCII code of 'A', it is 41h.
MOV CH, 1101_1111b ; set CH to binary value.
MOV BX, 15Eh ; set BX to 15Eh.
MOV [BX], CX ; copy contents of CX to memory at B800:015E
RET ; returns to operating system.
|
|
0
|
|
|
|
Reply
|
spamtrap2 (1628)
|
7/30/2006 7:45:06 PM |
|
In article <1154288706.899057.308980@m79g2000cwm.googlegroups.com>,
spamtrap@crayne.org says...
> I stumbled across the code below from emu8086. The final mov goes to
> video memory. Is there a map that defines where each video memory
> address is on a console screen?
Sort of. The first two bytes of video memory are the first character
cell at the TL corner of the screen. The character to display comes
from the first byte, and the display attributes (color possibly
blinking) are in the second byte. The next two bytes are for the next
character cell, and so from left to right and top to bottom.
> For instance, if I wanted to send a
> character to row 5, column 18, what video memory address would I use?
That depends on the display mode you're using, and particularly on
the number of columns in that display mode. Here's some code (MASM
format) to figure an address from a row/column:
; address = base + 2 * (y * columns + x)
; where base =
; b000h for monochrome
; b800h for color
;
mov cx,0b000h
mov ah, 0fh
int 10h
mov columns,ah
cmp al, 7
jz @f
mov cx, 0b800h
@@:
mov es,cx
mov al,y_coord
mov dl,ah
mul dl
mov di,ax
mov al,x_coord
cbw
add di,ax
shl di, 1
--
Later,
Jerry.
The universe is a figment of its own imagination.
|
|
0
|
|
|
|
Reply
|
Jerry
|
7/30/2006 9:43:06 PM
|
|
Sam wrote:
> I stumbled across the code below from emu8086. The final mov goes to
> video memory. Is there a map that defines where each video memory
> address is on a console screen?
Google "VGA programming" or something like that. The standard that
defines how to access video memory is discussed in the VGA
specification, created by IBM. The poster above has given you a good
start to understanding, but if you want to know more (such as how to
use graphics mode) look this up.
> Also, what is the purpose of "MOV AX, 0B800h" and "MOV DS, AX" in the
> code below? I don't understand why that is there? Thanks.
The DS register holds a pointer to the data segment. All memory
references by default are relative to the data segment. The author
needs to explicitly set this up to point to video memory, so that they
can write to it. DS is set to 0xB800. Segments must start on 16 byte
boundaries, which is why the lower four bits are ignored. This is how
a segment start address can be stored in a 16 bit register. The MOV
uses the offset stored in BX, which is 0x15E. This will then do the
MOV to 0xB800:0x15E, which is 0xB815E.
|
|
0
|
|
|
|
Reply
|
MQ
|
7/30/2006 11:50:46 PM
|
|
On 30 Jul 2006 12:45:06 -0700, "Sam" <spamtrap@crayne.org> wrote:
>I stumbled across the code below from emu8086. The final mov goes to
>video memory. Is there a map that defines where each video memory
>address is on a console screen? For instance, if I wanted to send a
>character to row 5, column 18, what video memory address would I use?
>
>Also, what is the purpose of "MOV AX, 0B800h" and "MOV DS, AX" in the
>code below? I don't understand why that is there? Thanks.
>
>ORG 100h ; this directive required for a simple 1 segment
>.com program.
>MOV AX, 0B800h ; set AX to hexadecimal value of B800h.
>MOV DS, AX ; copy value of AX to DS.
>MOV CL, 'A' ; set CL to ASCII code of 'A', it is 41h.
>MOV CH, 1101_1111b ; set CH to binary value.
>MOV BX, 15Eh ; set BX to 15Eh.
>MOV [BX], CX ; copy contents of CX to memory at B800:015E
>RET ; returns to operating system.
>
Note that the above code and the advice in the other posts
are only for *text* mode. Graphics modes don't have the simple
character, attribute, character, attribute layout of test modes.
Different graphics modes have different mappings to get from
data to pixels. Most (EGA, VGA, and above) use A000 as the
start address. Some modes use a byte or word to set the color
of each pixel, but many of the EGA and VGA modes use "bit
planes" where you write a byte with bits set for each of 8 adjacent
pixels. Since color requires more than 1 bit per pixel, you have to
tell the E/VGA hardware what plane you are writing to. With 4
planes you get 4 bits per color, which are use to select one ot
16 colors from a palette of all the possible colors, which depends on
the mode and the video capabilities.
This area can get *extremely* complicated, and everything changes
when you change modes. Oh, and with SVGA there were (are?) a
whole bunch of vendor-specific modes. Despite the complexity of
Windows GDI, it really makes life a lot easier compared to the old
mess.
Best regards,
Bob Masta
dqatechATdaqartaDOTcom
D A Q A R T A
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Home of DaqGen, the FREEWARE signal generator
|
|
0
|
|
|
|
Reply
|
NoSpam
|
7/31/2006 11:58:27 AM
|
|
|
3 Replies
191 Views
(page loaded in 0.034 seconds)
Similiar Articles: How to extract pixel values from a GeoTIFF using an Esri Shapefile ...World Map Shapefile - comp.soft-sys.gis.esri Pixel Data attribute value - comp.protocols.dicom Video Memory Map? - comp.lang.asm.x86 Pixel Data ... extract pixel values ... Texture memory usage - comp.graphics.api.openglmeasuring video memory - comp.graphics.api.opengl There are ways to determine, if a ... -- OpenGL tip #42: How to exactly map texture texels to screen pixels: <http ... Attempt to call constructor image with incorrect letter case ...std::map MyString, MyString > comparison operator? - comp.lang ... Attempt to ... [bochs][nasm][video memory] - comp.lang.asm.x86... give it all in the main nasm module ... Macro to turn on and off add ins - comp.cad.solidworksDebug.Print "" ' Turn off showing of map ... drawing file extension (.slddrw ... [bochs][nasm][video memory] - comp.lang.asm.x86 %macro draw_screen 0 mov ax,09000h mov ... Color depth #3 - comp.unix.solaris... 1600x1200x75 Current resolution setting: 1280x1024x85 Slave Mode: Disabled Video Memory ... The RGB model per se can give you any number of bits of color depth; it maps the ... pbuffers - comp.graphics.api.openglmeasuring video memory - comp.graphics.api.opengl (ie, VRAM > not used by frame buffers ... through my older fixed-function pipeline code that used pbuffers for shadow maps ... Lost Memory in RAM card - comp.sys.hp48One attempt to help and they will have lost money on ... [bochs][nasm][video memory ... with VGA depends not only ... included the color look-up tables ("color map" memory ... CS, DS, and SS Segments Together? - comp.lang.asm.x86I once asked why malloc() did not map 1:1 onto HeapAlloc() and was told that the ... the lower 640K (which is sometimes useful when programming in DPMI) or the video memory ... Image processing the frame buffer under OpenGL - comp.graphics.api ...> Basically I want to be to write real-time video effects ... reading back from the graphics card into the main memory ... Write Depth Map to Depth buffer - comp.graphics.api ... Simple code encryption (xor) problem - comp.lang.asm.x86 ...Sure, interactive video-styled games will benefit if several cores work in ... Like setup memory-maps and distribute the code-parts beside semaphores, signaling, INT ... memory maps - Server Operating Systems Technical ComparisonPC-DOS and MS-DOS memory map; MS-DOS TSR memory map; Mac Plus memory map; Mac Plus video memory locations; Mac Plus sound memory locations; PC-DOS and MS-DOS memory map Memory Map (x86) - OSDev Wiki0x000A0000 0x000FFFFF 384 KiB various (unusable) Video memory, ROM Area ... Use the BIOS function INT 15h, EAX=0xE820 to get a reliable map of Upper Memory. 7/15/2012 7:14:52 AM
|