So Lab1
So Lab1
a Moldovei
Facultatea Calculatoare, Informatică și Microelectronică
Report
for laboratory work Nr. 1
in the course "Operational Systems"
Elaborated:
Procopii Maria , st. gr. FAF-212
Verified:
Rostislav Calin
Chişinău - 2023
Subject: Printing text using int 10H Video Services
Tasks:
1. ALL possible methods should be used in order to print text.
(update):
- M1: Write character as TTY
- M2: Write character
- M3: Write character/attribute
- M4: Display character + attribute
- M5: Display character + attribute & update cursor
- M6: Display string
- M7: Display string & update cursor
- M8(optional): Print directly to video memory
2. Compiled program should be used in order to create a floppy image and it
should be bootable. Use this image to boot the OS in a VirtualBox VM and the
text which you intended to print should appear on the screen.
3. You can use any assembly compiler.
4. Students should be able to modify the code, to recompile it and to boot the
VM with a new version of the program.
5. In order to use documentation from TechHelp/XView DOS application,
students can install DosBox.
The result of performing the tasks:
Method 1: Write character as TTY:
org 7c00H
section .text
global start
start:
The result:
jmp $
The second program writes character “B” using the 0Ah function. It also
has a CX which is the repeat count.
The result:
start:
mov AH, 09h
mov AL, "B"
mov BL, 04H
mov CX, 1
int 10H
jmp $
times 510-($-$$) db 0
dw 0xAA55
The third program writes the character “B” using the 09h function. It also
has a BL register to specify the attribute for the character. For my code, it is the
red background color.
The result:
Figure 3 – Write character/attribute
M4: Display character + attribute:
org 7c00H
section .text
global start
start:
jmp $
times 510-($-$$) db 0
dw 0xAA55
The result:
Figure 4 – Display character + attribute
The method described above sets with the first two lines the Data
Segment value to the Segment Address, this ensures that we are pointing at the
right address of the buffer. Next we ensure that the page number is 0, as the
default one, then the number of characters that should be displayed on the
screen, i.e the string length, is set. The xor dx, dx sets the row and column
where the string will be displayed. Then we are passing the buffer, and choose
the 1302H BIOS interrupt from the 10H family.
M5: Display character + attribute & update cursor:
org 7c00H
section .text
global start
start:
call clear_window
jmp $
times 510-($-$$) db 0
dw 0xAA55
The result:
section .text
global start
start:
call clear_window
jmp $
char: db "Maria"
times 510-($-$$) db 0
dw 0xAA55
The result:
Figure 6 – Display string
M7: Display string & update cursor:
org 7c00H
section .text
global start
start:
call clear_window
jmp $
char: db "Maria"
times 510-($-$$) db 0
dw 0xAA55
The result:
Figure 7 – Display string & update cursor
The programs 6 and 7 display string “Maria” using the 1300h and 1301h
functions, differ by the fact that 1301h updates the cursor. For these functions it
is necessary to enter ES:BP, which is the address of start of text to write. In the
code, in BP we add offset address of the buffer, BL- the color red for the
characters, DX - row, column for string displacement, CX - the amount of
characters to be written. in the end we call the display string interrupt.
M8(optional): Print directly to video memory:
org 7c00H
section .text
global start
start:
call clear
mov ax, 0B800H
mov ds, ax
mov bx, 0
mov al, 'M'
mov ah, 0aH
mov [bx], ax
add bx, 2
mov al, 'A'
mov ah, 0cH
mov [bx], ax
add bx, 2
mov al, 'R'
mov ah, 0aH
mov [bx], ax
add bx, 2
mov al, 'I'
mov ah, 0cH
mov [bx], ax
add bx, 2
mov al, 'A'
mov ah, 0aH
mov [bx], ax
jmp $
jmp $
char: db "Maria"
times 510-($-$$) db 0
dw 0xAA55
The result:
Figure 8 – Print directly to video memory
The program 8 prints the word “Maria” directly to video memory using
the 0xB800 instruction. It sets the AX register to the video memory segment.
Then, mov DS, AX sets the data segment (DS) to the video memory segment,
making it the default segment for memory operations. After this setup, the code
uses mov [BX], AX to write the content of the AX register (which holds the
character and attribute) directly to the memory location pointed to by BX. The
add BX, 2 instructions increment the BX register by 2, ensuring that each
character is written to the next memory location in the video memory, allowing
to display multiple characters on the screen.
clean:
@echo "${bold}${green}[INFO]${reset} Cleaning"
@rm -rfv bin/*.bin
@echo "${bold}${green}[INFO]${reset} Cleaned."
Conclusion:
In this laboratory work I had the possibility to study the assembly
functions to display characters and strings. I learned how to change colors,
position of the text and cursor updates. I had the possibility to print characters
directly to the video memory and I got hands-on experience on how a
bootloader works, what dick is considerred a bootable one, how to work with
BIOD interrupts.