ASSEMBLER HELP
ASSEMBLER HELP
i learnd assembler now but just the bassics,
i am at the very beginning of my kernel so don't kill for saying or asking something stupid. when i load my program that should be my kernel it doesn't work but in windows it does what's wrong, interupts don't they work either in the creation of a kernel
ex: INT 21h
i trying to read the input of the keybourd with that int
please help ???
i am at the very beginning of my kernel so don't kill for saying or asking something stupid. when i load my program that should be my kernel it doesn't work but in windows it does what's wrong, interupts don't they work either in the creation of a kernel
ex: INT 21h
i trying to read the input of the keybourd with that int
please help ???
Re:ASSEMBLER HELP
int 21h is a DOS interrupt. So unless you're loading your kernel inside DOS then it won't be there. This is why it works in windows and not from your bootloader. Without DOS you'll have to restrict yourself to the BIOS interrupts.
Just a guess here but I think it's likely this is the BIOS interrupt you're looking for (Information is from one of the numerous BIOS references around the web):
Hope that helps.
Curufir
Just a guess here but I think it's likely this is the BIOS interrupt you're looking for (Information is from one of the numerous BIOS references around the web):
The alternative is to emulate the behaviour of the DOS int 21h in your code and load it's reference into the IVT/IDT. That sounds like entirely too much hassle to me, but you may have a different opinion.Int 16h, function 00h : read a character
INPUT
AH 00h
OUTPUT
AL = 0 Extended keyboard code : AH is the extended keyboard code.
AL <> 0 AL is the ASCII code of the key
AH is the keyboard code of the key
DESCRIPTION :
This function reads a character from the keyboard buffer. If there is no character available, it waits until one is. The character is removed from the buffer once it has been read.
The content of the registers CX, DX, SI, DI, BP and the segment registers aren't modified by this function. All other registers may have been altered.
Hope that helps.
Curufir
Re:ASSEMBLER HELP
i'm beginnning to understand how to wright an os.
if a understand all correctly i can wright a kernel in assembler but only by using to bios interupts wright ???
i need somewhere to start guis help me.
i can't make the os in it's total in ones i need to know what to wright first HELP ME PLEASE
if a understand all correctly i can wright a kernel in assembler but only by using to bios interupts wright ???
i need somewhere to start guis help me.
i can't make the os in it's total in ones i need to know what to wright first HELP ME PLEASE
Re:ASSEMBLER HELP
lo!
I suggest the following kernel versions. Start with the first and then extend your kernel to the next versions.
1. Kernel:
This kernel only boots from disk and does nothing. If you build up a kernel that boots, but the PC doesn't reboot, you have your first kernel.
2. Kernel:
This kernel uses BIOS-Functions to print something on the screen. (INT 10h ; ah=0Eh ; al=ascii-code ; bx = 0007h). First you can only print one letter but later on you should try to print hole strings.
3. Kernel:
This kernel should also read strings with a BIOS-Function(int 16h ; ah=00h ; after the int returns al= ASCII-Code of the typed character).
4. Kernel:
Now you can try to build a kernel that has a small shell. This shell could read a command and then call the function that handles this command.
All this kernels can be writen in asm and run in real-mode. After you have build this kernels you can try to write a kernel in protected mode which is even harder because you couldn't use BIOS-Interrupts anymore.
I think that the 3. and 4. Kernel would get to big to fit in the bootsector. So you have to load (within the bootsector) another file that is the actual kernel. Good luck! (And not to many reboots)
I suggest the following kernel versions. Start with the first and then extend your kernel to the next versions.
1. Kernel:
This kernel only boots from disk and does nothing. If you build up a kernel that boots, but the PC doesn't reboot, you have your first kernel.
2. Kernel:
This kernel uses BIOS-Functions to print something on the screen. (INT 10h ; ah=0Eh ; al=ascii-code ; bx = 0007h). First you can only print one letter but later on you should try to print hole strings.
3. Kernel:
This kernel should also read strings with a BIOS-Function(int 16h ; ah=00h ; after the int returns al= ASCII-Code of the typed character).
4. Kernel:
Now you can try to build a kernel that has a small shell. This shell could read a command and then call the function that handles this command.
All this kernels can be writen in asm and run in real-mode. After you have build this kernels you can try to write a kernel in protected mode which is even harder because you couldn't use BIOS-Interrupts anymore.
I think that the 3. and 4. Kernel would get to big to fit in the bootsector. So you have to load (within the bootsector) another file that is the actual kernel. Good luck! (And not to many reboots)
Re:ASSEMBLER HELP
since the title is correct, i'll place a question here. ;D
How would one go about assigning a string variable the contents of another string variable in assembly?
How would one go about assigning a string variable the contents of another string variable in assembly?
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:ASSEMBLER HELP
just with rep movsb ...
(if what you want is a copy of the content...)
otherwise, it's just moving the string's address from one dword to another (mov eax,[src] ; mov [dst],eax) ... but then you just copied the pointer )
did i make myself clear ?
(if what you want is a copy of the content...)
otherwise, it's just moving the string's address from one dword to another (mov eax,[src] ; mov [dst],eax) ... but then you just copied the pointer )
did i make myself clear ?
Re:ASSEMBLER HELP
It's the same as pass by reference and pass by value in C. Pype's explanation should make that clear.
Difference here is that the assembler doesn't know/care about the length of the string. So you'll have to decide on a string format to use before you start copying by value (Eg 0 terminated) so that you know how many bytes to move. Of course if you already know the length of the string then that particular problem won't arise.
Curufir
Difference here is that the assembler doesn't know/care about the length of the string. So you'll have to decide on a string format to use before you start copying by value (Eg 0 terminated) so that you know how many bytes to move. Of course if you already know the length of the string then that particular problem won't arise.
Curufir
Re:ASSEMBLER HELP
yes, the error i'm getting is "operating size not specified" i tried with the rep movsb and the same error occurd. I also get the same error message when i try to compare the keyboard buffer with strings containing the command name.
Re:ASSEMBLER HELP
I copied the pointer over and no more error message. how about comparing two strings? or a buffer and a string? ???
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:ASSEMBLER HELP
the comparison can be performed with rep cmpsb iirc.
the prelude to this is
you also might wish a dynamic length detection ...
it's the smaller i can do, but i can't promise this is the faster (though i hope the processor is smart enough to do cmpsb at least as fast as mov al,[esi] ; cmp al,[edi] ; jne out ; inc esi ; inc edi ...
to be checked ...
the prelude to this is
Code: Select all
mov esi, <string 1 address>
mov edi, <string 2 address>
mov ecx,<maximum string length>
repne cmpsb
;; if ecx == 0, your strings were identical.
Code: Select all
mov esi, <string 1>
mov edi, <string 2>
here:
cmp byte [esi], byte 0
je out
cmp byte [edi], byte 0
je out
cmpsb
je here
;; strings were different
out:
;; strings were same.
to be checked ...
Re:ASSEMBLER HELP
Hi,
I wana ask. What's diference:
Label: db 08h
Label2: equ 08h
And when I use in C:
struct examp {
unsigned char A;
unsigned char B;
}
It shows in ASM like this:
db 00h
db 00h
I wana ask. What's diference:
Label: db 08h
Label2: equ 08h
And when I use in C:
struct examp {
unsigned char A;
unsigned char B;
}
It shows in ASM like this:
db 00h
db 00h
Re:ASSEMBLER HELP
This reserves 1 byte of memory and assigns it a value of 8h.Unexpected wrote: Hi,
I wana ask. What's diference:
Label: db 08h
This makes Label2 a constant value you can use later in your code instead of the value. Generally used for legibility or to do some assemble/compile time memory calculations.Label2: equ 08h
As it should. An unsigned char in ansi C is 1 byte in length. Apparently whichever compiler you're using also takes the precaution of initialising them to zero if you don't specifiy an initial value yourself. Not all compilers do this, which from a personal point of view has meant some seriously hard to find bugs in the past .And when I use in C:
struct examp {
unsigned char A;
unsigned char B;
}
It shows in ASM like this:
db 00h
db 00h
Re:ASSEMBLER HELP
Now i have another problem...
Source:
I compiling this in AOUT format, then linking with C kernel.
LD linker shows this:
Test.o(.text+0x842): relocation truncated to fit: 16 .text
Whats wrong with DW IDT_Unused?
Why I can't create a pointer?
Source:
Code: Select all
...
DW IDT_Unused
DW CodeSel
DB 0x00
DB 0x8e
DW 0x0000
IDT_Unused:
IRET
...
LD linker shows this:
Test.o(.text+0x842): relocation truncated to fit: 16 .text
Whats wrong with DW IDT_Unused?
Why I can't create a pointer?