3

I'm new to whole assembly FASM

I have implement WriteString via this tutorial

INT 10h / AH = 13h - write string.

    input:
    AL = write mode:
        bit 0: update cursor after writing;
        bit 1: string contains attributes.
    BH = page number.
    BL = attribute if string contains only characters (bit 1 of AL is zero).
    CX = number of characters in string (attributes are not counted).
    DL,DH = column, row at which to start writing.
    ES:BP points to string to be printed. 

Like that

include 'proc32.inc'
org 0x7c00

mov ax,ds
mov es,ax

jmp start
start:

ccall puts,message,0x000c,attribute,0x02,0x00,0x00,0x00

stop:
jmp stop

attribute db 0x0F
message db 'hello world!','$'

proc puts,string,length,attribute,mode,page,row,column
 mov al,byte [mode]
 mov bh,byte [page]
 mov bl,byte [attribute]
 mov dl,byte [column]
 mov dh,byte [row]
 mov cx,word [length]
 lea bp,[string]
 mov ah,0x13
 int 0x10
 ret
endp

Problem:
FASM gives NO errors, but Procedure doesn't return or work !

Ahmed Ghoneim
  • 6,834
  • 9
  • 49
  • 79
  • This is a program which is intended to run as a BIOS (org 0x7c00). But you are using BIOS interrupts, which will be not available if you write your own BIOS (which you most likely didn't want to do). Try writing an simnple executable first. – Gunther Piez Jun 03 '12 at 09:22
  • No, I'm writing my own mini OS and I used to flash the output binary of FASM to USB key which used as the main VMDK for a virtual box machine :) – Ahmed Ghoneim Jun 03 '12 at 09:30
  • have you tried running this under a remote debugger? something like GDB + bochs: http://www.cs.princeton.edu/courses/archive/fall09/cos318/precepts/bochs_gdb.html – Necrolis Jun 03 '12 at 10:23

1 Answers1

1

The simple answer is that proc32.inc is for 32 bit protected mode code (which won't work with the 16 bit real mode bootsector code). Note also that the proc macro uses ebp as a frame pointer and the BIOS function 13h also uses bp.

The happy answer is that there is a wealth of information and help at the flat assembler OS Construction forum.

Mike Gonta
  • 644
  • 6
  • 11