flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > DOS > kant write at boot sector of floppy disk

Author
Thread Post new topic Reply to topic
Hercules



Joined: 09 Nov 2016
Posts: 5
kant write at boot sector of floppy disk
I write a program to data at boot sector of a diskette but my code dont works. Where my error in the code below:

Code:
org 100h
jmp Start

send_controller;
send_check_again
call delay
mov DX3F4h ;
IN ALDX ;
test al,80h
jz send_check_again
call delay ;
mov DX3F5h ;
mov ALBL ;
OUT DXAL 
ret 

delay:
mov si,500
L1:
cmp si,0
jz L2
dec si
jmp L1
L2:
ret

Start:
mov bl,45h              ;COMMAND WRITE SECTOR
call send_controller

mov cl,4
mov al,0
mul cl
mov bl,al               ;DRIVE NUMBER
call send_controller

mov bl,0                ;HEAD
call send_controller

mov bl,0                ;TRACK
call send_controller

mov bl,1                ;SECTOR
call send_controller

mov bl,2                ;512 BYTES PER SECTOR
call send_controller

mov bl,63               ;LAST SECTOR IN TRACK
call send_controller

mov bl,42               ;
call send_controller

mov bl,0ffh            ;RESERVED
call send_controller

ret




Post 09 Nov 2016, 08:45
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14583
Location: Planet Dirt
Which OS are you using?

I don't see where you are sending the sector data to the controller.
Post 09 Nov 2016, 08:48
View user's profile Send private message Visit poster's website Reply with quote
Hercules



Joined: 09 Nov 2016
Posts: 5

revolution wrote:
Which OS are you using?

I don't see where you are sending the sector data to the controller.



Are you so dumb?
Here is the part that send data to sector:
org 100h
jmp Start

send_controller: ;
send_check_again: ;
call delay
mov DX, 3F4h ;
IN AL, DX ;
test al,80h
jz send_check_again
call delay ;
mov DX, 3F5h ;
mov AL, BL ;
OUT DX, AL ;
ret ;

delay:
mov si,500
L1:
cmp si,0
jz L2
dec si
jmp L1
L2:
ret

mov bl,1 ;SECTOR
call send_controller
Post 09 Nov 2016, 08:58
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14583
Location: Planet Dirt
I mean that actual data from memory for each sector. It would be 512 bytes for each sector.
Post 09 Nov 2016, 09:02
View user's profile Send private message Visit poster's website Reply with quote
Hercules



Joined: 09 Nov 2016
Posts: 5

revolution wrote:
I mean that actual data from memory for each sector. It would be 512 bytes for each sector.


Here is: mov bl,2 ;512 BYTES PER SECTOR
call send_controller

2 = 512 butes per sector to floppy disk controller

See that my code is in protected mode only using I/O ports without interrupts
Post 09 Nov 2016, 09:07
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14583
Location: Planet Dirt
You have told it where to write data, and how much to write, but you haven't told it what to write. You will still need to send the 512 bytes that you want placed into the sector.

Perhaps some type of loop that reads a byte from memory and sends it to the controller, and repeats for 512 times.
Post 09 Nov 2016, 09:09
View user's profile Send private message Visit poster's website Reply with quote
Hercules



Joined: 09 Nov 2016
Posts: 5

revolution wrote:
You have told it where to write data, and how much to write, but you haven't told it what to write. You will still need to send the 512 bytes that you want placed into the sector.

Perhaps some type of loop that reads a byte from memory and sends it to the controller, and repeats for 512 times.


Nooooooooooooooooooooooooooooooooooooooooooooooooooo!!!


xmov bl,2 ;512 BYTES PER SECTOR
call send_controller


Last edited by Hercules on 09 Nov 2016, 09:14; edited 1 time in total
Post 09 Nov 2016, 09:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14583
Location: Planet Dirt
But still no data written. Do you want to write 512 bytes of all 0x00, or all 0xff, or something else? You need to tell the controller what bytes to write there.
Post 09 Nov 2016, 09:14
View user's profile Send private message Visit poster's website Reply with quote
Hercules



Joined: 09 Nov 2016
Posts: 5

revolution wrote:
But still no data written. Do you want to write 512 bytes of all 0x00, or all 0xff, or something else? You need to tell the controller what bytes to write there.



No! I give up!
Aaarrggghhh! I am having a hysterical attack
Post 09 Nov 2016, 09:16
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14583
Location: Planet Dirt
The "mov bl,2 ;512 BYTES PER SECTOR" only tells it you want to write 512 bytes, it doesn't tell it what those bytes will be. Write a loop to send the 512 bytes that will be written into the sector.

Father: Tell a 512 word message to the neighbour.
Son: Okay.
... time passes ...
Son: Um dad, so what are the actual 512 words you want me to say?
Father: Oh yeah, here they are: blah blah blah ...
Post 09 Nov 2016, 09:20
View user's profile Send private message Visit poster's website Reply with quote
neville



Joined: 13 Jul 2008
Posts: 501
Location: New Zealand
revo I suppose you should be congratulated for your patience and tolerance of abuse!!

It would seem Hercules has a lot to learn: not only in programming but also in manners and basic civility.

Although admittedly your "Which OS..." question may have been a little bit infuriating...

_________________
FAMOS - the first memory operating system
Post 09 Nov 2016, 10:01
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14583
Location: Planet Dirt

neville wrote:
Although admittedly your "Which OS..." question may have been a little bit infuriating...

Two reasons: 1) I wanted to move it to the proper place, and 2) just in case the OS doesn't support 16-bit code, or requires admin privileges to allow direct access to the disc controller.

Edit: Moved to DOS. It is clearly DOS code, but we still don't know if the OP is running it Windows (or maybe Linux Shocked)
Post 09 Nov 2016, 10:03
View user's profile Send private message Visit poster's website Reply with quote
neville



Joined: 13 Jul 2008
Posts: 501
Location: New Zealand

revolution wrote:
It is clearly DOS code

Really? I don't see a single INT21h or any other OS-specific code. Perhaps "OS Construction" would have been a better call... But Hercules probably doesn't understand why a little more context would have been helpful.

_________________
FAMOS - the first memory operating system
Post 09 Nov 2016, 18:58
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14583
Location: Planet Dirt

neville wrote:

revolution wrote:
It is clearly DOS code

Really? I don't see a single INT21h or any other OS-specific code.

I used the "org 100h" as my guiding line. Makes a .com file by default. And somehow I doubt that the OP has written an OS and is now struggling to make this code work.
Post 09 Nov 2016, 22:20
View user's profile Send private message Visit poster's website Reply with quote
neville



Joined: 13 Jul 2008
Posts: 501
Location: New Zealand

revolution wrote:
I used the "org 100h" as my guiding line. Makes a .com file by default.

To be more precise, it makes a flat binary starting from offset 100h, which DOS happens to support and calls a com file. But Hercules could still be trying to make an OS (also a possible explanation for why on earth he's trying to write to a floppy disk these days).

In the early days of developing FAMOS I adopted ORG 0100H for most of my code modules (kernel, drivers, global subroutines and applications) simply because I could also test and debug them in DOS. (Later I developed resident debuggers and a fasm-based IDE in FAMOS so I don't need "DOS compatibility" any more)

_________________
FAMOS - the first memory operating system
Post 10 Nov 2016, 00:34
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14583
Location: Planet Dirt
Fairy Nuff. So when the OP has recovered from the hysterical attack perhaps they can enlighten us as to the actual intended use for this code.

If the error message and/or the observed behaviour was given (rather than the vague "my code dont works") then we could have narrowed down some things faster.
Post 10 Nov 2016, 00:47
View user's profile Send private message Visit poster's website Reply with quote
neville



Joined: 13 Jul 2008
Posts: 501
Location: New Zealand
Exactly.

Nuff said? I suspect it was a random programming exercise given to a hapless IT student.

_________________
FAMOS - the first memory operating system
Post 10 Nov 2016, 03:03
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.