Welcome to HardwareForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

how memory maps to monitor screen

 
   Hardware Problem Solving Community! (Home) -> General RSS
Next:  Help: ECS KN1 LSI AMD64 cannot get Cool'n'quiet t..  
Author Message
Allan Adler

External


Since: Nov 12, 2007
Posts: 2



(Msg. 1) Posted: Mon Nov 12, 2007 9:51 am
Post subject: how memory maps to monitor screen
Archived from groups: comp>sys>ibm>pc>hardware>video (more info?)

At various places on the web one can find an article by Krishnakumar
entitled "Writing your own Toy OS". In Part I of this article, he has
an assembly language program boot.s and a C program write.c which are
pretty simple. The assembly language program boot.s is assembled under
Linux using as86 and linked with ld86 to produce a file named boot. The
C program writes boot to the boot sector of a floppy and also places
0x55 and 0xAA respectively at bytes 510 and 511 of the boot sector. This
is just a proof of concept: booting from the floppy causes the machine,
during bootup, to write the letter A in blue to the upper left corner of
the monitor screen and then hang in an infinite loop. I've tried it and it
works fine. Here is the code for boot.s:

entry start
start:
mov ax,#0xb800
mov es,ax
seg es
mov [0],#0x41
seg es
mov [1],#0x1f
loop1: jmp loop1

I decided to modify the code to write two blue letters (A and B) instead of
one and obtained:

entry start
start:
mov ax,#0xb800
mov es,ax
seg es
mov [0],#0x41
seg es
mov [1],#0x1f
add ax,#0x2
mov es,ax
seg es
mov [0],0x42
seg es
mov [1],#0x1f
loop1: jmp loop1

I assembled and linked this with as86 and ld86 and wrote it to the boot
sector of a floppy. When I booted the floppy, the blue A and blue B did
appear on the screen. The A was in the upper left corner and the B was
16 spaces to the right of it. In another version of the program, I had
it write 256 characters in what I thought would be consecutive positions
and, instead, they got written in 5 equally spaced columns with 25 characters
in a column, so some where apparently not on the screen.

Anyway, this shows that I don't understand how the relevant part of memory
gets written to the monitor screen. Can someone please explain how I have
to modify the program I wrote in order to get the B to appear immediately
to the right of the A, and more generally to the i-th position in the j-th
row? Also, in the case of the 256 characters at allegedly consecutive
positions, as described above, what happened to the remaining 256-125=131
characters that didn't appear?
--
Ignorantly,
Allan Adler <ara DeleteThis @zurich.csail.mit.edu>
* Disclaimer: I am a guest and *not* a member of the MIT CSAIL. My actions and
* comments do not reflect in any way on MIT. Also, I am nowhere near Boston.

 >> Stay informed about: how memory maps to monitor screen 
Back to top
Login to vote
Allan Adler

External


Since: Nov 12, 2007
Posts: 2



(Msg. 2) Posted: Tue Nov 13, 2007 1:38 am
Post subject: Re: how memory maps to monitor screen [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Allan Adler <ara.RemoveThis@nestle.csail.mit.edu> writes:

> I decided to modify the code to write two blue letters (A and B) instead of
> one and obtained:
>
> entry start
> start:
> mov ax,#0xb800
> mov es,ax
> seg es
> mov [0],#0x41
> seg es
> mov [1],#0x1f
> add ax,#0x2
> mov es,ax
> seg es
> mov [0],0x42
> seg es
> mov [1],#0x1f
> loop1: jmp loop1
>
> I assembled and linked this with as86 and ld86 and wrote it to the boot
> sector of a floppy. When I booted the floppy, the blue A and blue B did
> appear on the screen.

I figured out what was wrong: the ax register is copied to es, which only
defines the segment. Increments in ax amount to adding 16 to the address,
not 1. Leaving ax alone and simply writing to [2] and [3] for the B made
the characters adjacent on the screen.

> Anyway, this shows that I don't understand how the relevant part of memory
> gets written to the monitor screen. Can someone please explain how I have
> to modify the program I wrote in order to get the B to appear immediately
> to the right of the A, and more generally to the i-th position in the j-th
> row? Also, in the case of the 256 characters at allegedly consecutive
> positions, as described above, what happened to the remaining 256-125=131
> characters that didn't appear?

By writing 128 A's, 128 B's and 128 C's and examining the screen carefully,
I figured this out too. The screen is 25 lines of 80 characters each, each
character requiring a byte for the ascii code and a byte to say it is blue.
So the screen corresponds to 4000 bytes located, in this case, at address
B800:0000h. These 4000 bytes constitute the screen buffer in this mode.

Now that that problem is solved, I'm trying to capture those 4000 bytes
and write them to 8 sectors on the floppy using interrupt 13h with AH=3.
For some reason that isn't working.
--
Ignorantly,
Allan Adler <ara.RemoveThis@zurich.csail.mit.edu>
* Disclaimer: I am a guest and *not* a member of the MIT CSAIL. My actions and
* comments do not reflect in any way on MIT. Also, I am nowhere near Boston.

 >> Stay informed about: how memory maps to monitor screen 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Monitor Vs big screen Lcd tv - I am planning on upgrading all my equipment an am stuck whether to buy a Vizio like the Vizio L32 32" Widescreen HD-Ready Flat-Panel LCD TV and hook it to the HDMI port on my graphics card OR just buy a 22" lcd screen from Tigerdirect. If I ...

Scratch on 21" monitor screen? - I have an older 21" CRT monitor, an IBM P202. It has great image quality, but there's a small scratch in the screen. It seems like there's some kind of special layer or coating, and that's what the scratch is in, either that or the screen is just ...

Monitor screen goes black but computer still going fine - I have had this problem for about 3 weeks. I am on the PC and my monitor goes black. For about a month the monitor would flicker for maybe once every 2-3 hours. Then the black out started. I have changed the video card and changed to another PC. I..

flat screen comp monitor for television - I am looking to buy a new lcd flat screen monitor (~19"), so I can get my desk back. I am also interested in one I can watch television on. I currently have a cable internet connection. What is the best way to go about this (or the best..

monitor problem (disturbing lines appear on screen) - hey guys i am using samsung syncmaster 795MB it appears a lot of disturbing lines on the screen? why is it? wat should i do? http://server2.uploadit.org/files/ltsenc-DSCN3538.JPG sorry for my poor engllish thank you in advance[/img]
   Hardware Problem Solving Community! (Home) -> General All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]