Author Topic: Int 10h Problem when string in memory  (Read 9799 times)

nobody

  • Guest
Int 10h Problem when string in memory
« on: February 08, 2008, 10:15:07 AM »
Hi,

I'm new on this board and still new to assembly.  So forgive my newbness if this seems a straightforward thing to fix but I don't know how to get around it.

Basically, I am writing a 16 bit boot sector to a floppy (code stating at 0x00, padded with 0xAA55 at 510) and it works fine.  The bios boots it up and runs the code.  But because I am not using DOS, I am using BIOS commands directly, I am having a problem printing a simple string.  

I can use 10h to print a constant character, but not to print a character in a variable, and not print a string in memory.

Here is my code below...  If anyone has any explanations, they would be much appreciated.

-----------------------------------------------
[BITS 16]    ; 16 bit code generation

mymsg db 'B'     ; A single byte char variable

main:       ; Main program label

;Call the bios interrupt 10h to print a char to screen...(Works OK)
mov bh,0x00   ; Page number
mov bl,0x07   ; Text attribute (white)
mov al,'A'      ; Print an 'A'
mov ah,0x0e     ; Print char function of 10h
int 0x10        ; Execute 10h

;Call the bios interrupt 10h to print a char to screen from memory...(Not working?)
; PS, I know that I don't need to repeat a lot of these instructions, this is just for example.
mov bh,0x00   ; Page number
mov bl,0x07   ; Text attribute (white)
mov al,[mymsg]  ; Print a 'B'from variable - Does nothing or prints garbage
mov ah,0x0e     ; Print char function of 10h
int 0x10        ; Execute 10h

; So, I tried this....
mov bh,0x00   ; Page number
mov bl,0x07   ; Text attribute (white)
mov al,byte [mymsg]  ; Print an 'B' - Does nothing or prints garbage
mov ah,0x0e     ; Print char function of 10h
int 0x10        ; Execute 10h

; And this....
mov bh,0x00   ; Page number
mov bl,0x07   ; Text attribute (white)
mov al,[byte mymsg]  ; Print an 'B' - Does nothing or prints garbage
mov ah,0x0e     ; Print char function of 10h
int 0x10        ; Execute 10h

; And even this....
mov bh,0x00   ; Page number
mov bl,0x07   ; Text attribute (white)
mov si,[mymsg]  ;
mov al,[si]     ; Print an 'B' - Does nothing or prints garbage
mov ah,0x0e     ; Print char function of 10h
int 0x10        ; Execute 10h

; It only work when a constant is moved into al.  Confused.

; Keep looping here to keep things on screen...
infiniteloop:
jmp infiniteloop

times 510-($-$$) db 0      ; Fill the rest of the sector with zeros
dw 0xAA55         ; Boot signature at 511-512

times 1474560-($-$$) db 0   ; Pad rest with 0's to create 1.44mb bootable floppy image

nobody

  • Guest
Re: Int 10h Problem when string in memory
« Reply #1 on: February 08, 2008, 10:28:06 AM »
Agh! Wrong section of forum...

I'll move this.

Thanks

nobody

  • Guest
Re: Int 10h Problem when string in memory
« Reply #2 on: August 28, 2008, 09:25:21 AM »
Why you dont use:

http://www.ctyme.com/intr/rb-0210.htm

instead of:

http://www.ctyme.com/intr/rb-0106.htm

A good reference on interrupts:

http://www.ctyme.com/intr/int.htm

Also you can write characters directly to screen:

Hexadecimal address B800 for color in text mode
Hexadecimal adresss B000 for B/N in text mode

Hexadecimal address A000 for graphics mode

address b800: 0000 and next 0000 is offset 0001 0002 0003..

Remember that one byte is for character and other for attribute.

http://support.microsoft.com/kb/44412

nobody

  • Guest
Re: Int 10h Problem when string in memory
« Reply #3 on: November 23, 2008, 01:35:14 PM »
Sorry for double posting. I intended to post in this forum....

Seems like no one has used (or uses) the 13h service routine of INT 10h yet. I am using DOS on Windows XP platform. The following is my code snippet.

main:
msg db "Hello World\n", 0
msglen equ $-msg

xor bp, bp
mov es, bp
mov ax, [msg]
mov [es:bp], ax
xor ax, ax
mov ah, 0x13
mov al, 01h
mov bh, 00h
mov bl, 0Ah
mov cx, msglen
xor dx, dx
int 10h

It yielded garbage..