![AFA-GBG2001 [www.motkraft.net/gbg2001]](http://www.motkraft.net/gbg2001/banner/banner02.gif)
assembling bootloader with tasm 4.1
Anyone know of any way to get tasm 4.1 to accept 7c00h as initial entry address? Or perhaps just some sort of workaround...
/Mikael Jacobson
![AFA-GBG2001 [www.motkraft.net/gbg2001]](http://www.motkraft.net/gbg2001/banner/banner02.gif)
that post of mine might have been a bit confusing, my problem is that there are lots of sources of info on this subject, and none are the same...
btw org 7c00h won''t work, tasm complains...
btw org 7c00h won''t work, tasm complains...
![AFA-GBG2001 [www.motkraft.net/gbg2001]](http://www.motkraft.net/gbg2001/banner/banner02.gif)
if "org 7C00h" does not work, which i presume it should, or did when i used it about 4-5 years ago. you are assembling it as a "COM program (TINY model)", correct?. what you CAN do is create an empty data segment of (7C00h) size at the beginning of the file. next i also assume that you wrote a program to manually write the bootloader to the first sector of the diskette? when you are copying the program simply exclude the first 7C00h (which is just an empty data segment). it''s just a work around, but it will work.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
ummm I can''t remeber the exact way to do it but it was something like this....
mov ax,07c0h
push ax
mov ax,nextinstuction
push ax
retf
nextinstruction: ;update the other segment regs
I think thats it I can''t remeber for shure... I haven''t used tasm for a while so.... =)
mov ax,07c0h
push ax
mov ax,nextinstuction
push ax
retf
nextinstruction: ;update the other segment regs
I think thats it I can''t remeber for shure... I haven''t used tasm for a while so.... =)
The Great Milenko"Don't stick a pretzel up your ass, it might get stuck in there.""Computer Programming is findding the right wrench to hammer in the correct screw."
O one more thing... probably guessed it on your own but... this needs to come before you do much... far jumps, call inturupts, reference data, ect... basicaly before you do anything that involves a segment register... if I remeber right your segment registers will be 0x0000 so that would return you to somewhere bad =)
The Great Milenko"Don't stick a pretzel up your ass, it might get stuck in there.""Computer Programming is findding the right wrench to hammer in the correct screw."
Thanks for all the help, but I somehow got it working with:
Now I just need to figure out how to get DS to work properly...
/Mikael Jacobson
.MODEL TINY .CODE ORG 100hstart: blablabla blablabla ORG 766d ; decimal dw 055AAh end start
Now I just need to figure out how to get DS to work properly...
/Mikael Jacobson
![AFA-GBG2001 [www.motkraft.net/gbg2001]](http://www.motkraft.net/gbg2001/banner/banner02.gif)
Ok, since I''m a complete retard, I can''t figure out how to read memory that I have allocated, so someone please tell me.
This is how part of my code looks like:
I have tried modifying this code in a number of ways, none of which have worked, so I am now at your mercy, someone please help me!
/Mikael Jacobson (do I suck at x86 asm or what?)
This is how part of my code looks like:
.MODEL TINY .CODE ORG 100hmain: jmp short start nopstart: call ResetFloppy ; unimportant call InitStack ; same here mov ax,OFFSET Message mov ds,ax call PrintMsg ; prints ASCIIZ string that begins at [ds] jmp done include routines.inc ; contains the different routines called Message DB ''This is a test'',0 ; ASCIIZ stringdone: ORG 766d dw 055AAhend main
I have tried modifying this code in a number of ways, none of which have worked, so I am now at your mercy, someone please help me!
/Mikael Jacobson (do I suck at x86 asm or what?)
![AFA-GBG2001 [www.motkraft.net/gbg2001]](http://www.motkraft.net/gbg2001/banner/banner02.gif)
Use NASM. It is what most people use to write their OSes.
If you still want to use TASM there are three ways go about it:
1) Try using this as the first line of your code:
jmp far 07B0:0105 ;assuming that the next instruction is located at 07C0:0005
This should set the code segment register properly.
2) Use relative addressing and short jumps.
3) Forget all about fancy text and error handling in the boot loader. Just load the next sector to any address you like (at offset 100h) and jump.
If you still want to use TASM there are three ways go about it:
1) Try using this as the first line of your code:
jmp far 07B0:0105 ;assuming that the next instruction is located at 07C0:0005
This should set the code segment register properly.
2) Use relative addressing and short jumps.
3) Forget all about fancy text and error handling in the boot loader. Just load the next sector to any address you like (at offset 100h) and jump.
Here is what I did/used for bootstrap, but i compiled with nasm. Made from multiple sources.
And instead of screwing around with partition programs, I suggest using Hex Workshop and then opening the phsyical disk because it shows sector 0, the logical disk shows sector 63 as 0 (Windows) which is the first sector logically.
START:
MOV AX,0x0003
;Write 0003 to AX reg
;AH - Function number (00h, video)
;AL - Video Mode (03, 80x25x16)
INT 0x10 ;Access Video Card
PRINT_STRING:
MOV AX,0x1301
;Write 1301 to AX reg
;AH - Function number (13h: print string)
;AL - Write Mode (01h: string is characters only attribute BL, cursor moved)
MOV BX,0x0007
;Write 0007 to BX reg; BH - Video Page number (00h)
;BL - Attributes of characters (07h)
MOV CX,0x23 ;Write 23 to CX reg
;CX - Length of string, excluding any attributes (23h = 35 characters)
MOV BP,MSG
;BP - ES:BP must point to the string, since a boot sector starts at 07C00, we add that
;to BP after we loaded it. You could also set the entry point of the program to
;07C00, or change the data segment register to point to 07C00, but since it''s just
;one instruction, this is fine for now.
ADD BP,0x7C00
INT 0x10 ;Access Video Card
WAIT_FOR_KEY_PRESS:
MOV AH,0x00
;AH - 00, Read keyboard buffer, wait till full if not already.
;The buffer will be empty since the computer didn''t get time to put anything into it yet.
INT 0x16
REBOOT:
DB 0xEA
DW 0x0000
DW 0xFFFF
;We reboot the computer by simply jumping to 0000:FFFF:
;This looks a bit weird but it''s actualy quite simple. When declaring "variables" in
;assembly, the assembler simply puts the value into a memory location. Usually you
;use interrupts or something to point to them in order to use and manipulate them, but we
;could also put code there. This is what we''re doing here. If you get a Hex to Mnemonix
;chart you will notice that EA is a Far Jump. So we put that into memory, followed by
;the location to jump to.
MSG DB ''Press any key to Reboot'',13,10,''Sp%K'',0
TIMES 510-($-$$) DB 0 ;Fill remaining memory with "Null" data.
SIGNATURE DW 0xAA55 ;Add the BootStrap signature "AA55" to the end of the sector
And instead of screwing around with partition programs, I suggest using Hex Workshop and then opening the phsyical disk because it shows sector 0, the logical disk shows sector 63 as 0 (Windows) which is the first sector logically.
START:
MOV AX,0x0003
;Write 0003 to AX reg
;AH - Function number (00h, video)
;AL - Video Mode (03, 80x25x16)
INT 0x10 ;Access Video Card
PRINT_STRING:
MOV AX,0x1301
;Write 1301 to AX reg
;AH - Function number (13h: print string)
;AL - Write Mode (01h: string is characters only attribute BL, cursor moved)
MOV BX,0x0007
;Write 0007 to BX reg; BH - Video Page number (00h)
;BL - Attributes of characters (07h)
MOV CX,0x23 ;Write 23 to CX reg
;CX - Length of string, excluding any attributes (23h = 35 characters)
MOV BP,MSG
;BP - ES:BP must point to the string, since a boot sector starts at 07C00, we add that
;to BP after we loaded it. You could also set the entry point of the program to
;07C00, or change the data segment register to point to 07C00, but since it''s just
;one instruction, this is fine for now.
ADD BP,0x7C00
INT 0x10 ;Access Video Card
WAIT_FOR_KEY_PRESS:
MOV AH,0x00
;AH - 00, Read keyboard buffer, wait till full if not already.
;The buffer will be empty since the computer didn''t get time to put anything into it yet.
INT 0x16
REBOOT:
DB 0xEA
DW 0x0000
DW 0xFFFF
;We reboot the computer by simply jumping to 0000:FFFF:
;This looks a bit weird but it''s actualy quite simple. When declaring "variables" in
;assembly, the assembler simply puts the value into a memory location. Usually you
;use interrupts or something to point to them in order to use and manipulate them, but we
;could also put code there. This is what we''re doing here. If you get a Hex to Mnemonix
;chart you will notice that EA is a Far Jump. So we put that into memory, followed by
;the location to jump to.
MSG DB ''Press any key to Reboot'',13,10,''Sp%K'',0
TIMES 510-($-$$) DB 0 ;Fill remaining memory with "Null" data.
SIGNATURE DW 0xAA55 ;Add the BootStrap signature "AA55" to the end of the sector
You think... Therefore, I'm right!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement