Matija:
MT> I am writing a little operating, but i have a little problem. When i
MT> try to execute this
I did too, pretty cool looking core dump on my machine!
First, change the end of string character to a 'NULL', ASCII
character 0. Then you can use this routine as a general purpose string
output routine. This is known as an ASCIIZ string:
BootMsg db 'Loading OS...', 0
MT> MsgLoop: MOV DX,[SI]
This line can confuse the assembler, but not yield an error. Use
the explicit form:
MsgLoop: MOV DL, byte ptr [SI]
Then look for the end of the string:
MT> CMP DX,'0'
CMP DL, 0
Make sure that you can SEE the attribute
MT> MOV DH,7
MOV DH, 2
Then continue to be explicit, with the added note that this will
write to the upper corner of the screen in CGA text modes only:
MT> MOV ES:[BX],DX
MOV word ptr ES:[BX], DX
So the whole deal should look like:
seg_a segment byte public
assume cs:seg_a; ds:seg_a
org 100h
main: jmp start
b_msg db 'Loading OS...', 0
start: mov ax, 0B800h ; Point to CGA screen
mov es, ax
mov si, offset b_msg ; Point to b_msg string
xor bx, bx ; Clear BX
msg_l: mov dl, byte ptr [si] ; Get a character
cmp dl, 0 ; See if it is NULL
je msg_e ; If it is, end
mov dh, 2 ; I think green is cool
mov word ptr es:[bx], dx ; Send the char/attr pair
inc si ; Increment the pointers
inc bx
inc bx
jmp msg_l ; Next character
msg_e: ret
seg_a ends
end main
You could expand on this routine and offer users of the OS a
wide range of screen functions... Sort of like DOS, but don't make them
so bad to use!
Ron Avery
... Real programmers confuse XMAS & Halloween: DEC 25=OCT 31!
--- Blue Wave v2.12 [NR]
---------------
* Origin: BEAVER KEEPER BBS (1:244/442)
|