Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INT13h, AH=02h

Status
Not open for further replies.

5888

Programmer
Apr 27, 2003
16
0
0
MY
I tried to write a program that reads the boot sector from floppy drive A and store it at a variable called Sector. I am having problem with my code but I do not know where to debug, please help. Thank you. The following is my code for MASM:

.model small
.stack

.data
Sector db 512 dup(0)

.code
Start:

mov ax, @data
mov ds, ax

mov ax, 0201h
mov cx, 0001h
mov dx, 0000h
mov bx, 0000h
int 13h

mov cx, 512
mov si, 0000h
lea di, Sector
cld
rep movsb

mov cx, 512
mov ax, 0200h
mov bx, 0000h
Loop1:
inc bx
mov dl, [bx]
int 21h
loop loop1
mov ax, 4c00h
int 21h
end Start
 
Various problems
(1) I am a bit concerned about your setting up of data and stack segments.
(2) Int 013h ah=02h needs to know where to put the data it reads (address goes in es:bx) You haven't set es, so at the moment it's reading to a random place. This should make it unnecessary to copy the data elsewhere after loading...


 
How to set up the ES?
 
I don't know if this can help, try it

.model small
.stack

.data
Sector db 512 dup(0)

.code
Start:
mov ax, @data
mov ds, ax
les bx, Sector

mov ax, 0201h
mov cx, 0001h
mov dx, 0000h
mov bx, 0000h
int 13h

mov ax, 4c00h
int 21h
end Start

-- AirCon --
 
There are two very common ways to put a value in es.
(1) Very often you want to set es to the value of ds (string movements within the data segment, or things like this). You can push ds, then pop es.
(2) "les reg, something" loads a pointer whose value is in memory location refered to by "something" into es:reg. This is the sort of instruction that is most useful in linked lists, where each list has a data element ("something") that holds the address of the next element in the list. Hence les di, es:[di + thingy] is one of my favourites, taking an address at offset thingy in a linked-list element, and putting it in es:di so I can then read the data refered to by the linked list element, data which might well be the next element in the list....
Good luck
 
Hi ppl! i'm not sure code by AirCon will work - les bx, Sector will load some undetermined far pointer, is not that? - see the above lionelhill comment
major point is that is it going to be an exe or com style program?? for com there is no need to bother about segments, as CS=DS=ES=SS at the load time, so the near pointer is enough
in any way, the simplest solution will be to target the int13 service to Sector..
i believe it should be helpful to have a glance at disassembly of an MBR or Boot Rec
regards, oleksii
 
hi oleksii,

You right, it will give you 0:0
My mistake. Well.. I hope he didn't follow my code :-D

Regards

-- AirCon --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top