News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

printing a string

Started by zak100, July 28, 2009, 09:52:11 AM

Previous topic - Next topic

zak100

Hi,
I want to print a string at boot time. I have written the following program but its not working. Can somebody plz help me with this:




;USING INT 10 H for Printing Mesg
;------------------------------------
.model tiny
.data
msg db "We be bootin2'!",0
.code
start:
org 7C00h; starting the program at 7C00H. Address generated at reset

    call overdata    ; Call? WTF? Don't worry, we pop the.
                     ; return address off to get initial IP.
                     ; Note that "call" is longer than

;----------------------------writing a mesg on screen at startup. We cant use int 21h


overdata:
    xor di,di
     mov ds,di
    mov cs,di
   
;----------------------------

   mov bp,offset msg
   mov ah,013h     ; Fn 13h of int 10h writes a whole string on screen
   mov al,00     ; bit 0 determines cursor pos,0->point to start after          ; function call,1->point to last position written
   mov bx,0007h     ; bh -> screen page ie 0,bl = 07 ie white on black
   mov cx,020h     ; Length of string here 32
   mov dx,00000     ; dh->start cursor row,dl->start cursor column
   int 010h     ; call bios interrupt 10h
        ; Return to calling routine

org 510           ; Make the file 512 bytes long
  dw 0AA55h   ; Add the boot signature

end start



Zulfi.


FORTRANS

Hi,

   Well


org 7C00h; starting the program at 7C00H. Address generated at reset


and

    call overdata    ; Call? WTF? Don't worry, we pop the.
                     ; return address off to get initial IP.
                     ; Note that "call" is longer than


   Disagrees with


      23 7C07  8E CF                        mov cs,di
test7.ASM(21): error A2059: Illegal use of CS register


And that generates an error here as well.

And here your data assembles at an address offset of zero as well.


       4                                .model tiny
       5 0000                           .data
       6 0000  57 65 20 62 65 20 62     msg db "We be bootin2'!",0
       7       6F 6F 74 69 6E 32 27
       8       21 00


   This could just be me using an older version of MASM, but it looks bad
here.

Regards,

Steve

dedndave

i dunno why everyone wants to write a boot floppy - lol
but, i have given a great link for it on one of the other threads
all you guys have to do is study the info there
the first thing you need to do is CLI and set the SS:SP to someplace safe
when BIOS relinquishes control to the boot sector, the segment registers are not set up as they are under a running OS
if you really want to know how to write boot code, study the CPU and BIOS

zak100

Hi,
What I have understood from earlier mesg is that this code should generate an error. But I am not getting any syntax error.

D:\masm prog>ml str.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: str.asm

Microsoft (R) Segmented Executable Linker  Version 5.60.339 Dec  5 1994
Copyright (C) Microsoft Corp 1984-1993.  All rights reserved.

Object Modules [.obj]: str.obj /t
Run File [str.com]: "str.com"
List File [nul.map]: NUL
Libraries [.lib]:
Definitions File [nul.def]:

D:\masm prog>dir

I have downloaded this version recently. I have checked that link and I apply it soon. But does this code should need an explicit Stack segment? I mean I am not doing any context swiching.
Right now I have engaged my students in OS development and that's why I am doing this.

Zulfi.

dedndave

here is the link i spoke of...
http://www.geocities.com/thestarman3/asm/mbr/DOS50FDB.htm
study it carefully
if there is something there that you do not understand, it means you need to learn it
if you are going to TEACH OS development, you should have written a boot sector 10 years ago - lol

as for assembling the code - most of us use batch files
use the forum search engine to find them
they show all the right switches needed to assemble console mode or win gui mode apps

zak100

Sorry I couldnt. Courses are not fixed and so the job. Its possible that every semester we get a new course. Whatever I have to do, I have to do in this semester. I have got that link and I am working on it. I am still looking for help on this.

Zulfi.