Clan x86
Technical (Development, Security, etc.) => General Programming => Operating System Development => Topic started by: Nate on July 11, 2006, 07:27:44 pm
-
[BITS 16]
[ORG 0x7c00]
main:
xor ax, ax ;Sets ax = 0
mov cs, ax ;All I know is that ds needs
mov ds, ax ;to be offset to 0x00 but Joe did
mov es, ax ;them all so i followed his lead,
mov fs, ax ;bad idea i know.
mov si, Helloworld ;Moves the location of Helloworld to SI
Call putSTR
jmp $ ;big ass loop, how do i get to the next stage?
PutSTR:
mov ah, 0x0E ;Set TTY mode, no idea what 0x10 is in Joe's
mov bh, 0x00 ;sets page = 0
mov bl, 0x09 ;blue screen, white text iirc
.next ;label to get to next character
lodsb ;Pretty much mov al, si
int 0x10 ;Runs BIOS video interrupt
or al, al ;Determines if al = 0
jz .end ;GoTo label .end if al = 0
jmp .next ;GoTo .next
.end ;Label to bypass loop if end of STR
ret ;Return to main
;Data
Helloworld db 'Hello World', 13, 10, 0
times 510-($-$$) db 0
dw 0xAA55
May be some suggestions or you could completely rip it apart if im not even close that would also be helpful.
-
Depending on what you want to do, you could play around with write string (ah = 0x13 for int 10). I wrote this and I'm not sure if its included anywhere else but I'll paste it here just because.
putString:
mov bp, sp
inc [putStringRow]
mov dh, [putStringRow] ;row
mov dl, 0 ;column
mov al, 0 ;mode
mov bl, 0x0f ;display attribute
mov ah, 0x13 ;Write String
mov cx, [bp+4] ;String length
mov bp, [bp+2] ;String
int 0x10
retn
loadingString db 'Zorms OS Loading...', 13, 10
putStringRow db 0
and then its called like:
push 21 ;String length
push loadingString
call putString
I was just looking over what I have and I don't remember what I was doing in a lot of places. Also this snippet may prove useful:
emptySpace = 510 - ($ - $$)
times emptySpace db 0
dw 0xAA55
You could then output emptySpace to know how much space you have left to use.
-
Well everyone of his comments pretty much says he copied and pasted out of an AIM convo. SO anyways is it right? And what do i do next? Ive just been kind of reading up on more x86 assembly and NASM.
-
mov cx, [bp+4] ;String length
mov bp, [bp+2] ;String
If the function is called as putString(word length, LPCSTR string), and you're pushing those elements to the stack, couldn't you use this code?
pop cx
pop bp
-
I'd refrain from using the stack at all before PMode. Once you're in PMode you just make a descriptor to protect the stack and give it an address, not too hard. Realmode is something you don't want to linger in. Most of it's usefulness can be done in either vm86 mode or with PMode port reading/writing (Talking about detecting 386, 486 and detecting the presence of 'cpuid'). Realmode is there for legacy compatability, don't use it much.
-
Come to think about it, what is a two-byte pointer to a CString called? PCSTR?
-
Come to think about it, what is a two-byte pointer to a CString called? PCSTR?
??? We wouldn't use a two-byte pointer..... we use four-byte pointers. Even in real mode, addressing is done by segment:offset. Anything you're coding in C/C++ won't use a segment:offset addressing mode, though. Not nowadays.
If you're talking about a length-prefixed string, since C doesn't do them, I don't know why you'd make a data type alias for them.
-
I'm talking about 16 bit processors.
-
In a 16-bit processor, all of the pointers will be 16-bit. Why would you have a special name for it?
-
Because LPCSTR is a long pointer, right? Or is sizeof(long) processor dependant?
-
Because LPCSTR is a long pointer, right? Or is sizeof(long) processor dependant?
LP does mean "long pointer," but on a 64-bit architecture, LPCSTR refers to a 64-bit pointer. Pointer sizes are processor-dependent and are always the size of the machine word.