flat assembler
Message board for the users of flat assembler.

Index > DOS > kant write at boot sector of floppy disk

Author
Thread Post new topic Reply to topic
Hercules



Joined: 09 Nov 2016
Posts: 5
Hercules 09 Nov 2016, 08:45
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 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

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: 20685
Location: In your JS exploiting you and your system
revolution 09 Nov 2016, 08:48
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
Hercules 09 Nov 2016, 08:58
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: 20685
Location: In your JS exploiting you and your system
revolution 09 Nov 2016, 09:02
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
Hercules 09 Nov 2016, 09:07
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: 20685
Location: In your JS exploiting you and your system
revolution 09 Nov 2016, 09:09
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
Hercules 09 Nov 2016, 09:12
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: 20685
Location: In your JS exploiting you and your system
revolution 09 Nov 2016, 09:14
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
Hercules 09 Nov 2016, 09:16
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: 20685
Location: In your JS exploiting you and your system
revolution 09 Nov 2016, 09:20
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: 507
Location: New Zealand
neville 09 Nov 2016, 10:01
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: 20685
Location: In your JS exploiting you and your system
revolution 09 Nov 2016, 10:03
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: 507
Location: New Zealand
neville 09 Nov 2016, 18:58
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: 20685
Location: In your JS exploiting you and your system
revolution 09 Nov 2016, 22:20
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: 507
Location: New Zealand
neville 10 Nov 2016, 00:34
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: 20685
Location: In your JS exploiting you and your system
revolution 10 Nov 2016, 00:47
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: 507
Location: New Zealand
neville 10 Nov 2016, 03:03
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


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.