|
From: zak100 <zul...@ya...> - 2009-07-10 18:05:17
|
Hi,
The changes for jump code lies here:
GiveControlToOS: ; PROC
LEA AX,[szDone]
Call PrintMessage
CALL GetKey
; db 0e9h ;Far JMP op code.
; dw 512 ;JMP 512 bytes ahead
;jmp 0:7E00h;-----------------------------------At this point we are
going to Kernel code; for including C prog:test_kernel2.asm
;jmp 7D0h:100h
jmp 0:7D00h
; POP AX ;//Another why to make
;the CPU jump to a new place.
; POP AX
; Push 7E0h ;Push New CS address.
; Push 0 ;Push New IP address.
;The address that comes out is 7E00:0000.
; comment does not match code!
;(512 bytes Higher from were BIOS Put us.)
retf
; you'd want "retf" here.
;GiveControlToOS EndP
The changes for ..start lie here
..start:
extern _K_main
;--- test kernel.bin---
; push cs
; push cs
; pop ds
; pop es
mov ax, 7E0H
mov ds,ax
mov es,ax
mov si, msg
mov ah, 0Eh
mov bx, 7
top:
lodsb
cmp al, 0
jz blackhole
int 10h
jmp short top
blackhole:
mov cx,1000
Delay: Loop Delay
call _K_main; this is in main.c
hlt
jmp blackhole
msg db 'Welcome to the Kernel!', 0
times 0x200-($-$$) db 0
Kindly help me with this.
Zulfi.
Frank Kotler-3 wrote:
>
> zak100 wrote:
>> Hi,
>> I am able to make the binary using alink. partcopy was giving prob but it
>> was handled as done previously.
>>
>> The steps are provided below:
>> D:\nasm prog>nasm -f bin -o boot.bin BLKernelT.asm
>>
>> D:\NASMPR~1>nasm -f bin -o writeit.com writeit.asm
>>
>> D:\NASMPR~1>writeit
>>
>> D:\NASMPR~1>del test_kernel2.onj
>> Could Not Find D:\NASMPR~1\test_kernel2.onj
>>
>> D:\NASMPR~1>del test_kernel2.obj
>>
>> D:\NASMPR~1>nasm -f obj test_kernel2.asm
>>
>> D:\NASMPR~1>dir t*.obj
>> Volume in drive D is New Volume
>> Volume Serial Number is 70FD-1D2C
>>
>> Directory of D:\NASMPR~1
>>
>> 07/10/2009 10:55 AM 642 test_kernel2.obj
>> 1 File(s) 642 bytes
>> 0 Dir(s) 22,656,360,448 bytes free
>>
>> D:\NASMPR~1>alink -o kernel.bin test_kernel2.obj main1.o
>> ALINK v1.6 (C) Copyright 1998-9 Anthony A.J. Williams.
>> All Rights Reserved
>>
>> Loading file test_kernel2.obj
>> Loading file main1.o
>> matched Externs
>> matched ComDefs
>> Warning, no entry point specified
>
> You can fix this by adding a "..start:" label where you want your
> entrypoint.
>
>> Warning - no stack
>
> segment stack stack
> resb ???? ; how big do you want? C uses a lot of stack, I understand.
>
> The first "stack" is just a name - could be anything. The second "stack"
> is necessary to let Nasm know what we want. I've been ignoring the
> warning, and "let the OS take care of the stack". We set up a stack in
> the bootsector which should be "okay for now". When you get to task
> switching/multitasking, you'll want to swap stacks for each process (I
> imagine).
>
>> D:\NASMPR~1>alink -o kernel.exe test_kernel2.obj main1.o
>> ALINK v1.6 (C) Copyright 1998-9 Anthony A.J. Williams.
>> All Rights Reserved
>>
>> Loading file test_kernel2.obj
>> Loading file main1.o
>> matched Externs
>> matched ComDefs
>> Warning, no entry point specified
>> Warning - no stack
>>
>> D:\NASMPR~1>del kernel.bin
>>
>> D:\NASMPR~1>exe2bin kernel.exe kernel.bin
>
> Good. This produces a .com file (no matter what we call it) which
> expects to be loaded at 100h into... whatever segment.
>
>> D:\NASMPR~1>partcopy kernel.bin 0 200 -f0 200
>> Failed to read source at offset 144
>> D:\NASMPR~1>partcopy kernel.bin 0 144 -f0 200
>>
>> D:\NASMPR~1>
>> -----------------------------------
>>
>> But when I rebooted , I got boot sector statment but I am not seeing the
>> "welcome....." kernel message.
>> Can somebody plz guide me??
>
> Try jumping to 7D0h:100h (assuming that you're writing this to 7E00h).
>
> I haven't done anything further with this. I've downloaded source (in
> assembly) for an exe2bin clone, thinking we might be able to modify it
> to produce a binary at "org 0", or perhaps create a loader for MZ to be
> included in our code. Only just begun to look at it.
>
> Tyler mentioned using bochs for testing. That would speed up development
> a *lot* (especially for me, since I don't like rebooting). I've
> downloaded bochs a couple of times, but never tried it. I've seen too
> many posts about "my bootsector works in bochs, but not in a real
> machine" (or vise versa), and "bochs is giving me this error message,
> what the heck does it mean?"... suggesting that bochs doesn't accurately
> reflect "real hardware" (can't match *all* of 'em, of course), and has a
> "learning curve" to it...
>
> Any tips, Tyler? Is bochs going to insist on seeing a full 1.44M image
> before it'll boot from a "fake floppy"? Well, I'll figure it out (or
> not), if and when I get around to trying it...
>
> Best,
> Frank
>
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full
> prize
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> Nasm-users mailing list
> Nas...@li...
> https://lists.sourceforge.net/lists/listinfo/nasm-users
>
>
--
View this message in context: http://www.nabble.com/calling-%27C%27-functions-tp24404865p24432173.html
Sent from the nasm-users mailing list archive at Nabble.com.
|