Here is the problem, I am trying to write a "readSector()" method. needless to say it is not working.
my code:
Code: Select all
//prototypes
void main(void);
int readSector(char* buf, unsigned long sector);
typedef struct{
unsigned int res_SoDAP;
unsigned int numBlocks;
unsigned int bufferOff;
unsigned int bufferSeg;
unsigned long startABSL;
unsigned long startABSH;
}DAP, *pDAP;
void main(void){
char buffer[512]; //buffer for readSector()
// some other stuff kernel "init()" and what not (all this works).
buffer[0]='t'; // debugging purposes, this should be overwritten by readSector();
readSector(buffer, 30); // a text file is loaded with dd on sector 30.
printString(buffer); // already know this procedure works, "kernel loaded" is displayed on lower left right hand corder after init() stuff is ran.
//prints the " 't' " that i manually loaded, not the message in the text file. (this is the result of the bug i can't find).
// some more stuff, the program "OS" does this stuff so it is making it past the readSector procedure without hanging, but not doing as told.
};
Code: Select all
! 80 readSector(buffer,30);
! Debug: list int = const $1E (used reg = )
mov ax,*$1E
push ax
! Debug: list * char message = S+$246-$243 (used reg = )
lea bx,-$241[bp]
push bx
! Debug: func () int = readSector+0 (used reg = )
call _readSector
add sp,*4
!BCC_EOS
! 81 printString(message);
! Debug: list * char message = S+$244-$243 (used reg = )
lea bx,-$241[bp]
push bx
! Debug: func () int = printString+0 (used reg = )
call _printString
inc sp
inc sp
Code: Select all
int readSector(char* buf, unsigned long sector){
DAP rsDAP;
pDAP prsDAP = &rsDAP;
rsDAP.res_SoDAP = (unsigned int)0x0010;
rsDAP.numBlocks = (unsigned int)0x0001;
rsDAP.bufferOff = (unsigned int)buf;
rsDAP.bufferSeg = (unsigned long)0xFFFF;
rsDAP.startABSL = (unsigned long)sector;
rsDAP.startABSH = (unsigned long)0x00000000;
asm("mov si, -$16[bp]\n\t" \
"mov ah, *$42\n\t" \
"mov dl, *$80\n\t" \
"int *$13");
return 1;
};
Code: Select all
! 229 int readSector(buf,sector)
! 230 # 229 "kernel.c"
! 229 char* buf;
export _readSector
_readSector:
!BCC_EOS
! 230 # 229 "kernel.c"
! 229 unsigned long sector;
!BCC_EOS
! 230 # 229 "kernel.c"
! 229 {
! 230 DAP rsDAP;
!BCC_EOS
! 231 pDAP prsDAP = &rsDAP;
push bp
mov bp,sp
push di
push si
add sp,*-$12
! Debug: eq * struct rsDAP = S+$18-$16 to * struct prsDAP = [S+$18-$18] (used reg = )
lea bx,-$14[bp]
mov -$16[bp],bx
!BCC_EOS
! 232
! 233 rsDAP.res_SoDAP = (unsigned int)0x0010;
! Debug: eq unsigned int = const $10 to unsigned int rsDAP = [S+$18-$16] (used reg = )
mov ax,*$10
mov -$14[bp],ax
!BCC_EOS
! 234 rsDAP.numBlocks = (unsigned int)0x0001;
! Debug: eq unsigned int = const 1 to unsigned int rsDAP = [S+$18-$14] (used reg = )
mov ax,*1
mov -$12[bp],ax
!BCC_EOS
! 235 rsDAP.bufferOff = (unsigned int)buf;
! Debug: eq unsigned int buf = [S+$18+2] to unsigned int rsDAP = [S+$18-$12] (used reg = )
mov ax,4[bp]
mov -$10[bp],ax
!BCC_EOS
! 236 rsDAP.bufferSeg = (unsigned long)0xFFFF;
! Debug: eq unsigned long = const $FFFF to unsigned int rsDAP = [S+$18-$10] (used reg = )
mov ax,#$FFFF
mov -$E[bp],ax
!BCC_EOS
! 237 rsDAP.startABSL = (unsigned long)sector;
! Debug: eq unsigned long sector = [S+$18+4] to unsigned long rsDAP = [S+$18-$E] (used reg = )
mov ax,6[bp]
mov bx,8[bp]
mov -$C[bp],ax
mov -$A[bp],bx
!BCC_EOS
! 238 rsDAP.startABSH = (unsigned long)0x00000000;
! Debug: eq unsigned long = const 0 to unsigned long rsDAP = [S+$18-$A] (used reg = )
xor ax,ax
xor bx,bx
mov -8[bp],ax
mov -6[bp],bx
!BCC_EOS
! 239
! 240 asm("mov si, -$16[bp]\n\tmov ah, *$42\n\tmov dl, *$80\n\tint *$13"
!BCC_ASM
mov si, -$16[bp]
mov ah, *$42
mov dl, *$80
int *$13
! 241
! 242
! 243 );
!BCC_ENDASM
!BCC_EOS
! 244
! 245 return 1;
mov ax,*1
add sp,*$12
pop si
pop di
pop bp
ret
!BCC_EOS
! 246 };
I am just looking for the small detail I missed, Thanks in advance, I have been debugging this one issue for 3 days now and would like to move forward.