Ok, here's a question/problem to the DOS guys (yet another one). I wrote myself a small program that does a raw write to a floppy using the BIOS functions. Very simple, it should just load my image (which is less than 64kb so I don't have to play around with segments that much yet) and write it to the very begging of the floppy, which is head 0, track 0, sector 1. I'm getting an error nr 4 which is "Request sector not found". What could go wrong ?
.intel_syntax noprefix.code16.macro FAR_MEMCPY SRC, DST, SIZE, DST_SEG PUSHA MOV CX, \SIZE MOV SI, \SRC MOV DI, \DST MOV AX, \DST_SEG MOV ES, AX CLD REP MOVSB POPA.endm.globl _start_start: MOV DX, offset WELCOME_STR CALL PRINT_STRING#; READ THE ARGUMENT, WHICH WILL BE THE FILE NAME XOR BX, BX MOV BL, BYTE PTR [0x80] CMP BL, 126 JA NO_ARGUMENTS#; ADD TERMINATING 0 MOV BYTE PTR [BX + 0x81], 0 #; OPEN THE FILE MOV AH, 0x3D MOV AL, 0x00 MOV DX, 0x82 INT 0x21 JC OPEN_FILE_FAIL MOV WORD PTR [FILE_HANDLE], AX#; MOVE THE FILE POINTER TO THE END OF OPENED FILE MOV BX, WORD PTR [FILE_HANDLE] MOV AH, 0x42 MOV AL, 0x02 XOR CX, CX XOR DX, DX INT 0x21 JC OPEN_FILE_FAIL#; NOW WHE HAVE THE SIZE OF THE FILE IN DX:AX (32BIT)#; WE ONLY NEED THE AX, AS THIS PROGRAM CAN ONLY WRITE#; 64KB IMAGES (RIGHT NOW) MOV WORD PTR [FILE_SIZE], AX PUSH AX MOV DX, offset FILE_SIZE_STR CALL PRINT_STRING POP AX CALL PRINT_WORD MOV DL, '\r' CALL PRINT_CHAR MOV DL, '\n' CALL PRINT_CHAR #; NOW MOVE THE FILE POINTER BACK TO THE BEGGINING MOV AH, 0x42 XOR AL, AL XOR CX, CX XOR DX, DX INT 0x21 JC OPEN_FILE_FAIL#; LOAD THE FILE INTO MEMORY MOV BX, WORD PTR [FILE_HANDLE] MOV AH, 0x3F MOV CX, WORD PTR [FILE_SIZE] MOV DX, 0x1000 INT 0x21 JC READ_FILE_FAIL#; COPY THE READ FILE TO AN ADDRESS THAT IS#; ALLIGN TO 64KB... MOV AX, WORD PTR [FILE_SIZE] FAR_MEMCPY 0x1000, 0, AX, 0x1000#; WRITE THE READ FILE TO FLOPPY MOV AX, WORD PTR [FILE_SIZE] SHR AX, 9 MOV AH, 3 MOV CH, 0 MOV CL, 1 MOV DH, 0 MOV DL, 0 MOV BX, 0x1000 INT 0x13#; CHECK IF WE FLOPPY WRITE WAS SUCCESSFUL JC FLOPPY_WRITE_FAIL PUSH AX MOV DX, offset SECTORS_WRITEN_STR CALL PRINT_STRING POP AX CALL PRINT_BYTE#; CLOSE THE FILE#; WE DON'T HAVE TO CLOSE THE FILE,#; EXIT TO DOS WILL DO IT FOR US JMP EXIT NO_ARGUMENTS: MOV DX, offset NO_ARG_STR CALL PRINT_STRING JMP EXIT OPEN_FILE_FAIL: MOVZX BX, BYTE PTR [0x80] MOV BYTE PTR [BX + 0x81], '$' MOV DX, 0x82 CALL PRINT_STRING MOV DX, offset CANT_OPEN_FILE_STR CALL PRINT_STRING JMP EXITREAD_FILE_FAIL: MOVZX BX, BYTE PTR [0x80] MOV BYTE PTR [BX + 0x81], '$' MOV DX, 0x82 CALL PRINT_STRING MOV DX, offset CANT_READ_FILE_STR CALL PRINT_STRING JMP EXITFLOPPY_WRITE_FAIL: PUSH AX MOV DX, offset CANT_WRITE_FLOPPY_STR CALL PRINT_STRING POP AX MOV AL, AH CALL PRINT_BYTE EXIT: MOV AX, 0x4C MOV AL, 0 INT 0x21.globl PRINT_STRING.type PRINT_STRING, @functionPRINT_STRING: PUSH AX MOV AH, 0x09 INT 0x21 POP AX RET .globl PRINT_CHAR.type PRINT_CHAR, @functionPRINT_CHAR: PUSH AX MOV AH, 0x02 INT 0x21 POP AX RET.globl PRINT_BYTE.type PRINT_BYTE, @functionPRINT_BYTE: PUSH AX MOV AH, AL SHR AL, 4 CMP AL, 10 JAE 1f ADD AL, '0' JMP 2f1: ADD AL, 0x372: MOV DL, AL CALL PRINT_CHAR AND AH, 0x0F CMP AH, 10 JAE 3f ADD AH, '0' JMP 4f3: ADD AH, 0x374: MOV DL, AH CALL PRINT_CHAR POP AX RET.globl PRINT_WORD.type PRINT_WORD, @functionPRINT_WORD: PUSH AX MOV AL, AH CALL PRINT_BYTE POP AX CALL PRINT_BYTE RET FILE_HANDLE:.word 0FILE_SIZE:.word 0WELCOME_STR:.ascii "REAL RAW WRITE\r\n$"NO_ARG_STR:.ascii "GIVE ME FILE NAME TO WRITE\r\n$"CANT_OPEN_FILE_STR:.ascii " - CAN'T OPEN THIS FILE\r\n$"CANT_READ_FILE_STR:.ascii " - CAN'T READ THIS FILE\r\n$"FILE_SIZE_STR:.ascii "FILE SIZE : $"SECTORS_WRITEN_STR:.ascii "h SECTORS WRITEN\r\n$"CANT_WRITE_FLOPPY_STR:.ascii "CAN'T WRITE TO FLOPPY, ERROR CODE : \r\n$"