| ECE291 |
Computer Engineering II |
Lockwood, Spring 1999 |
Horizon Web Browser
Goals:
We will implement an x86 assembly program
that can display simple HTML documents from a local NetBIOS
server. The documents will be displayed on an 1024x768x256 SVGA
screen using protected mode to write linear data to the screen.
The browser will use buttons to navigate back and forth, have a
text field to enter hyperlinks, and scrolling through the
document. Our web browser will be complied under NASM and uses
WDOSX for protected mode support.
A web browser has never been attempted in
ECE 291 before, but the most challenging part of our program is
using protected mode to display HTML documents. As far as we
know, no one has ever done 1024x768x256, so we think that doing both
protected mode and high color graphics will challenge our
assembly language knowledge and make the program more useful in
the real world.
Required to run: 80386DX or better
for 32-bit protected mode, 4MB video card, 32MB RAM.
NOTE: You must run the
client and server programs at the same time for Horizon to work
properly.
Implementation:
- The web browser will work in the
following way: SplashScreen will display the
Horizon startup screen and goes right to the web browser
window and calls WaitForInput to wait for the user
to request a file. Two computers with HorizonS (server)
and HorizonC (client) will be running synchronously.
HorizonS will display a "Server Mode" screen to
disable the user interface. When the user requests a file
from the server computer by typing a HTML file and
pressing ENTER, the program will call GetFile to
retrieve the file and put it into [File_Dump].
As a side note, the server will call the serverto wait
and pass files back to HorizonC. HTMLConvert on
the client will then convert the HTML code into Horizon
HTML code ignoring what Horizon cannot display (namely
tables) and place the result into [selector_convert].
HTMLParse will then step through
[selector_convert] sending the proper justification and
ASCII text to ConvertData. If an image is
required, HTMLParse will call GetFile to
retrieve the BMP/PCX image and pass the image data to [File_Dump].
SendRawData is called to write the data header and
image or ASCII data to [base_selector_file] and sends it
to ConvertData]. ConvertData will be called
to display the amount of data that can be currently
displayed on screen. After reaching the end of ConvBuffer,
the display will have all images and text on screen. WaitforInput
will be called to wait for a new input.
- Scrolling will be achieved by moving
the screen BMP either up or down depending on the request
and redisplaying the screen.
- Horizon has two programs: Server and
Horizon. All files used by Horizon are in the server
directory.
Procedures:
Networking: Isaac Sanchez
The web browser will connect to a "web
server" over a session level Netbios connection. The browser
will send a request to the server requesting a file. The server
will then send the file to the client. The client will then pass
the file into a buffer, so that the data can be used by HTMLConvert.
GetFile within Horizon:
Constants:
RESET equ 032h
CANCEL equ 035h
STATUS equ 0B3h
STATUS_WAIT equ 034h
TRACE equ 0F9h
UNLINK equ 070h
ADD_NAME equ 0B0h
ADD_NAME_WAIT equ 030h
ADD_GROUP_NAME equ 0B6h
ADD_GROUP_NAME_WAIT equ 036h
DELETE_NAME equ 0B1h
DELETE_NAME_WAIT equ 031h
CALL_ equ 090h
LISTEN equ 091h
LISTEN_WAIT equ 011h
HANG_UP equ 092h
SEND equ 094h
SEND_WAIT equ 014h
CHAIN_SEND equ 097h
RECEIVE equ 095h
RECIEVE_WAIT equ 015h
RECEIVE_ANY equ 096h
SESSION_STATUS equ 0B4h
SEND_DATAGRAM equ 0A0h
SEND_BCST equ 0A2h
RECEIVE_DATA equ 0A1h
RECEIVE_BCST_DATA equ 0A3h
Structures:
NCB struc
ncb_command db ? ; command code
ncb_retcode db ? ; error return code
ncb_lsn db ? ; session number
ncb_num db ? ; name number
ncb_buf_off dw ? ; ptr to send/receive data offset
ncb_buf_seg dw ? ; ptr to send/receive data segment
ncb_buflen dw ? ; length of data
ncb_callname db 16 dup (?) ; remote name
ncb_name db 16 dup (?) ; local name
ncb_rto db 0 ; receive timeout
ncb_sto db 0 ; send timeout
ncb_post_off dw ? ; async command complete post offset
ncb_post_seg dw ? ; async command complete post segment
ncb_lana_num db ? ; adapter number
ncb_cmd_done db ? ; 0FFh until command completed
ncb_res db 14 dup (?) ; reserved
NCB ends
Inputs:
- EDX: Offset of NULL terminated string
that contains the filename requested.
Outputs:
- EAX: Will return 0 on successful
retrieval, -1 on failure
- File_Dump: Memory allocated to hold
file data willl be overwritten with new file
Modified Variables:
Purpose:
This procedure will be called by the
client when it requires a file from the server. It will
establish a connection, send the filename to the server and
then receive the file. The file will then be written into
File_Dump, which is a 1 megabyte allocation in memory.
Server Program:
Constants:
RESET equ 032h
CANCEL equ 035h
STATUS equ 0B3h
STATUS_WAIT equ 034h
TRACE equ 0F9h
UNLINK equ 070h
ADD_NAME equ 0B0h
ADD_NAME_WAIT equ 030h
ADD_GROUP_NAME equ 0B6h
ADD_GROUP_NAME_WAIT equ 036h
DELETE_NAME equ 0B1h
DELETE_NAME_WAIT equ 031h
CALL_ equ 090h
LISTEN equ 091h
LISTEN_WAIT equ 011h
HANG_UP equ 092h
SEND equ 094h
SEND_WAIT equ 014h
CHAIN_SEND equ 097h
RECEIVE equ 095h
RECIEVE_WAIT equ 015h
RECEIVE_ANY equ 096h
SESSION_STATUS equ 0B4h
SEND_DATAGRAM equ 0A0h
SEND_BCST equ 0A2h
RECEIVE_DATA equ 0A1h
RECEIVE_BCST_DATA equ 0A3h
Structures:
NCB struc
ncb_command db ? ; command code
ncb_retcode db ? ; error return code
ncb_lsn db ? ; session number
ncb_num db ? ; name number
ncb_buf_off dw ? ; ptr to send/receive data offset
ncb_buf_seg dw ? ; ptr to send/receive data segment
ncb_buflen dw ? ; length of data
ncb_callname db 16 dup (?) ; remote name
ncb_name db 16 dup (?) ; local name
ncb_rto db 0 ; receive timeout
ncb_sto db 0 ; send timeout
ncb_post_off dw ? ; async command complete post offset
ncb_post_seg dw ? ; async command complete post segment
ncb_lana_num db ? ; adapter number
ncb_cmd_done db ? ; 0FFh until command completed
ncb_res db 14 dup (?) ; reserved
NCB ends
PPROCEDURES:
MAIN:
Inputs:
Outputs:
Modified Variables:
The ReadIn buffer is used to
temporarily hold data that is readin from the files and
then sent to the client.
Purpose:
The web server will initialize
itself, listen for a connection, and then service
client's requests. The server will open the file,
read in the data into the ReadIn buffer, then send
the data over the network. The procedure will then
close the file and connection, and wait for another
request.
MouseIntsall:
Inputs:
Outputs:
Modified Variables:
Purpose:
Installs the Mouse handler
MouseUninstall:
Inputs:
Outputs:
Modified Variables:
Purpose:
Uninstalls the mouse handler
MouseHandler:
Inputs:
Outputs:
Modified Variables:
Purpose:
Sets the exiting variable to indicate exiting
HTML Conversion: George Neurauter
This part of the program takes the incoming
HTML file from HTMLBuffer and converts the ASCII into a
series of predefined opcodes and ASCII text that will allow HTMLParse
to allow the network to get images and sends palette entries and
ASCII text to the graphic routines for display.
HTMLConvert:
- This function will take a HTML encoded
document and convert it into ASCII text and defined
functions that Horizon will display on the screen. It
will do this by taking the HTML data passed into
[File_Dump] by GetFile and scanning for HTML tags
in either upper or lower case text. Every tag that cannot
be shown or implemented will be ignored. When a tag is
found, the tag is checked to make sure it can be used by
Horizon and, if so, it will scan the data from the tags
and prefix and suffix the data with 'tags' we set (see
below). If plain text is found, it will simply write it
to [selector_convert]. It will go through until the whole
HTML file is scanned.
- Inputs: [File_Dump] - HTML Data
- Outputs: [selector_convert] -
converted data
- External Procedures Used:
SCANHTML, IGNOREHTML, VerifyWord, WriteColor
- HTML Tags used: <BODY>,
<BODY BGCOLOR="#RRGGBB">, <BODY
TEXT="#RRGGBB>, <BODY
BGCOLOR="#RRGGBB" TEXT="#RRGGBB>,
<FONT COLOR="#RRGGBB">, <IMG
SRC="filename">, <A
HREF="#filename> (disabled in our
implementation), <H1>, <H2>, <H3>,
<P>, <BR>, </HTML>, <CENTER>
(disabled in our implementation)
- Constants used to convert HTML
(opcodes that prefix and append ASCII text, hyperlinks,
and other significant data):
BGColor equ 14
ImgSource equ 1
LinkRef equ 2
Head1 equ 3
EndHead1 equ 4
Head2 equ 5
EndHead2 equ 6
Head3 equ 7
EndHead3 equ 8
Paragraph equ 9
EndParagraph equ 10
Break equ 11
FontColor equ 12
EndFontColor equ 13
DefaultFont equ 15
EndHTML equ 16
Center equ 20
EndCenter equ 21
-
HTMLParse:
- This function will be called by the
main function when a HTML document is be processed. It
will iterate through [selector_convert] which is
converted by HTMLConvert to find which tags are
being used. Variables are updated for tags that update
screen colors and justification. If there is text to be
written, the ASCII is written to TextBuffer. If the text
line in TextBuffer is full depending on the size of
FontType, it will call SendRawData to send the line of
text to ConvertData. If an image is to be written,
SendRawData is called with FontType set to 0. Normally,
FontType is set to 1 for text data. It continues to scan
until the EndHTML tag is found.
- Inputs: [selector_convert]
- Outputs: Screen display of HTML
document
- External Procedures Used: SendRawData,
SCANCONV
- Data Header used in
[base_selector_file] when sending data to ConvertData:
;DataHeader db 20 dup(0) ; Header for all
data passed to
; RawBuffer
;The data header to be sent to the screen display
;is defined to be:
;===============
DataType db 1 ;defines data passed
; 0 = BMP
; 1 = Text (default)
LineNumber dd ? ;Current line in RawBuffer
HyperLink db ? ;(text only) - denotes if
; text is hyperlink
; 0 = Not HyperLink
; 1 = Hyperlink (different color)
DefaultFontRGB db 4 dup (0) ;(text only) - gives default font
; color - black by default
; Format - 00(Red)(Green)(Blue) - 00000000 = black by default
; 00000000 = black
; FF000000 = red ,etc.,etc.
FontType db 1 ;(text only) - denotes font size
; passed - 1 default
; 1 = normal(default)
; 2 = Heading 3 (bold?? normal)
; 3 = Heading 2 (2x bold?? normal)
; 4 = Heading 1 (3x bold?? normal)
NumChars db ? ;(text only) - number of chars
; in text packet
BackgroundColor db 0
db 3 dup (0FFh) ; color of background - white by
; default
; 4 bytes reserved
VerifyWord:
- This function is called by HTMLConvert
and tests whether the two consecutive bytes in
[File_Dump:ESI] are equal to the values in AX.
- Inputs: AX = ASCII
values to check
- Outputs: VerifyFlag =
0 if check fails, 1 if check passes
CenterText:
- This function is called by SendRawData
and finds out how many spaces to tab centered text in
when writing the text to [base_selector_file]. The number
of spaces depends on FontType since so many characters of
different font sizes can fit on the screen. It also
depends on NumChars which denotes how many characters
there are in TextBuffer.
- Inputs: FontType,
NumChars
- Outputs: NumSpaces
SCANHTML:
- This function is called by HTMLConvert
and writes HTML data from [File_Dump] to
[selector_convert] until the character in AL is reached.
- Inputs: [File_Dump], AL = character to
scan for
- Outputs: updated [File_Dump] and
[selector_convert] offsets ESI and EDI, ASCII written to
[selector_convert]
SCANCONV:
- This function is called by HTMLParse
and scans [selector_convert] for the character in AL and
returns CX which has the number of bytes scanned until
the character was reached.
- Inputs: [selector_convert], AL = character to scan for
- Outputs: CX = number of bytes scanned
IGNOREHTML:
- This function is called by HTMLConvert
and scans [FIle_Dump] until the character in AL if found.
- Inputs: [File_Dump], AL = character to
scan for
- Outputs: updated [File_Dump] offset
ESI
SendRawData:
Data used to write data buffer:
;DataHeader db 20 dup(0) ; Header for all
data passed to
; RawBuffer
;The data header to be sent to the screen display
;is defined to be:
;===============
DataType db 1 ;defines data passed
; 0 = BMP
; 1 = Text (default)
LineNumber dd ? ;Current line in RawBuffer
HyperLink db ? ;(text only) - denotes if
; text is hyperlink
; 0 = Not HyperLink
; 1 = Hyperlink (different color)
DefaultFontRGB db 4 dup (0) ;(text only) - gives default font
; color - black by default
; Format - 00(Red)(Green)(Blue) - 00000000 = black by default
; 00000000 = black
; FF000000 = red ,etc.,etc.
FontType db 1 ;(text only) - denotes font size
; passed - 1 default
; 1 = normal(default)
; 2 = Heading 3 (bold?? normal)
; 3 = Heading 2 (2x bold?? normal)
; 4 = Heading 1 (3x bold?? normal)
NumChars db ? ;(text only) - number of chars
; in text packet
BackgroundColor db 0
db 3 dup (0FFh) ; color of background - white by
; default
; 4 bytes reserved
WriteColor:
- This function is called by HTMLConvert
and writes the passed in background color or font color
from [File_Dump] and converts the ASCII values to hex
values and writes them to [selector_convert]. A hex value
of zero is added to the front of the data to make the
data accessible bby using double variables
(OverrideFontColor, DefaultColorRGB, BackgroundColor)
- Inputs: [File_dump]
- Outputs: [selector_convert] with hex
values of passed in font/background colors
Graphics, Design, and Program
Implementation: Chris Wissing and Adil Hussain
One task of a web browser is to display
text and graphics on the screen, but to do this in mode 13h the
text would have to be almost one half inch high in order to read,
which would not allow many things to be displayed on the screen.
In order to overcome this limitation we decided to use protected
mode to address more memory and effectively allow us to
display text and graphics at 1024X768x16.7M resolution.
InitVideo:
- This Procedure Initializes
the video to 1024x768x16.7M
- Inputs - Selector
to video memory
- Outputs - None
MakeMem:
- This procedure allocates dos
memory and upper memory
- Inputs - None
- Outputs - Saves
selectors to allocated memory
ConvertData:
- This function is called from
the WaitforInput function. It distinguishes between BMP
and Text for different font sizes.
- Inputs - None
- Outputs - Call
to function to display BMP or display Text. also stores
the pixel location to draw at in variable pixelloc
KillRawBuffer:
- Sets RawBuffer memory to
white color. Basically used to wash screen color.
- Inputs - Selector
to RawBuffer
- Outputs - Sets
RawBuffer variable
ConvertBMP:
- Converts BMP's from the
memory at selector, base_selector_file and stores the
data the the memory at RawBuffer
- Inputs - base_selector_file
which holds text or graphics data to be displayed to the
screen
- Outputs - Memory
at selector RawBuffer is modified so that the BMP or text
will be able to be properly displayed to the screen
FillScreen:
- Writes to the screen in
1024x768x16.7M
- Inputs - Uses
scroll variable to determine where to write to screen
- Outputs - Outputs
directly to the screen in the Linear Frame Buffer through
the base_selector_vid selector
SplashScreen:
- Loads local BMP and Writes
initial splash screen with credits of the programmers and
the top title bar which remains on the screen always.
- Inputs - Selectors
to memory
- Outputs - Modifies
base_selector_file with BMP on local computer and
modifies RawBuffer with converted image data from local
BMP
DeInitVideo:
- Deinitializes the video mode
and returns to text mode
- Inputs - None
- Outputs - Returns
to text mode
PrintURL:
- Displays the characters in
the URL Title Bar at the top of the screen every time a
key is pressed and also cleans them from the bar when the
enter key is pressed.
- Inputs - edi
held the byte number to write . al held the ascii number
for the actual character
- Outputs - Displayed
directly to the screen
TextDisplay1:
- This procedure is called from
the ConvertData procedure. It displays the size 1 text at
the location of variable Pixelloc.
- Inputs - Pixelloc
- Outputs - Displays
to the screen
TextDisplay2:
- This procedure is called from
the ConvertData procedure. It displays the size 2 text at
the location of variable Pixelloc.
- Inputs - Pixelloc
- Outputs - Displays
to the screen
TextDisplay3:
- This procedure is called from
the ConvertData procedure. It displays the size 3 text at
the location of variable Pixelloc.
- Inputs - Pixelloc
- Outputs - Displays
to the screen
TextDisplay4:
- This procedure is called from
the ConvertData procedure. It displays the size 4 text at
the location of variable Pixelloc.
- Inputs - Pixelloc
- Outputs - Displays
to the screen
Initialize:
- Initializes the network and
graphics. Uses 2 DPMI Int 31h calls to initialize the
network with netbios.
- Inputs - Selectors
to registers, network control block, and realmode offsets
to the stored register data and network control block.
- Outputs - Initializes
the network and sets the scroll variable to 0
Load_Font0:
- This procedure stores the
images of characters of text size 0 in the memory
sequentially. This is called from within ConvertData
- Inputs - None
- Outputs - None
Load_Font1:
- This procedure stores the
images of characters of text size 1 in the memory
sequentially. This is called from within ConvertData
- Inputs - None
- Outputs - None
Load_Font2:
- This procedure stores the
images of characters of text size 2 in the memory
sequentially. This is called from within ConvertData
- Inputs - None
- Outputs - None
Load_Font3:
- This procedure stores the
images of characters of text size 3 in the memory
sequentially. This is called from within ConvertData
- Inputs - None
- Outputs - None
Handlers,
Installing/Uninstalling/Loop Functions: Chris Wissing
and Adil Hussain
- These functions will install and
handle mouse and keyboard events within the web browser.
- CREDITS: All of these functions
have been programmed in real mode by each team member
before coding Horizon during the course of this class,
but these are all in protected mode.
WaitForInput:
- Waits for user input from the
mouse and keyboard
- Inputs - new_web_page
holds 1 if new web page should be loaded. ExitFlag holds
value of 1 if the program should exit
- Outputs - new_web_page
is set to 0 when new web page has been gotten.
Scroll_changed is reset to 1 when new web page has been
gotten. pixelloc is changed to 0 when new web page has
been gotten
MouseInstall:
- This Procedure installs the MouseHandler
to be called on mouse events. It also sets the maximum
screen width and height. This function also sets the
initial position of the mouse.
- Inputs - None
- Outputs - None
MouseUnInstall:
- This Procedure restores mouse
driver to its original state
- Inputs - None
- Outputs - None
MouseHandler:
Description - This
routine will be called by MouseInstall. It should process clicks
on the screen.
Inputs -
- AX = event mask (same format as
described in MouseInstall above)
- BX = mouse button status
- Bit 0: LMB activated
Bit 1: RMB activated
Bit 2: MMB activated
Bits 3-15: Unused
- CX = horizontal mouse position
- DX = vertical mouse position
- SI = length of last horizontal mouse
movement
- DI = length of last vertical mouse
movement
- DS = data segment of the mouse driver
- my_saved_ds holds the value of the
data selector
- OldPosition holds value of old mouse
position on screen
- base_selector_vid holds selector to
video memory
- NewMouse holds the 24bit values of the
mouse cursor
Outputs -
- Scroll holds offset of where to draw
in RawBuffer
- Scroll_changed holds 1 if the scroll
variable has been changed
- Mouse_down holds 0 or 1. Left mouse
button up or down respectively.
- Mouse_moved holds 1 if the mouse has
moved
- Mouse_state holds the values of the
button state from bx
- Mouse_ypos holds the mouse vertical
position on screen
- Mouse_xpos holds the mouse horizontal
position on the screen
KeyboardInstall:
- Installs Interrupt 9's (IRQ1's) vector
to the address of KbdHandler.
- Input - none
- Output - OldKBV
variable that holds old vector in interrupt table
KeyboardUninstall:
KeyboardHandler:
- This routine is the Interrupt Service
Routine called when the keyboard hardware reads in the
scan code from the keyboard. By reading the scancode from
the keyboard's hardware register the program can
determine which key was pressed. Our routine should then
translate this scan code into a corresponding ASCII code.
- Input - save_edi holds the
offset in the netfile data array for the filename request
- Output - new_web_page holds
1 if new webpage is requested, Scroll also
modified with offset of where to draw the screen from
RawBuffer. Scroll_changed holds 1 if the scroll variable
changed.
Contact Information:
Chris Wissing - wissing@uiuc.edu
Adil Hussain - ahussai1@uiuc.edu
George Neurauter - neurautr@uiuc.edu
Isaac Sanchez - iisanche@uiuc.edu