flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > My first ever bootloader for x86 |
Author |
|
sinsi 07 Aug 2021, 05:27
Code: start: mov al,72 ; "H" call print mov al,105 ; "i" call print int 10h ret You might want to change that "ret" since you don't know where it returns to. For something like this test, I usually use "jmp $" |
|||
07 Aug 2021, 05:27 |
|
FlierMate 07 Aug 2021, 07:30
sinsi wrote:
Good advice. Although the result is the same but it make more sense to use "jmp $". Thank you. |
|||
07 Aug 2021, 07:30 |
|
macomics 07 Aug 2021, 12:02
Quote:
After returning from the second call of the print function, the value of AH will be restored, so the subsequent int 10h will try to set the 105 (not correct) screen mode and the call will return an error. Last edited by macomics on 07 Aug 2021, 12:48; edited 2 times in total |
|||
07 Aug 2021, 12:02 |
|
FlierMate 07 Aug 2021, 12:43
macomics wrote:
Yeah, you are right. The redundant "int 10h" was there by mistake as I did not remove it. Thank you for the detailed analysis. |
|||
07 Aug 2021, 12:43 |
|
revolution 07 Aug 2021, 19:45
fasm can use the ASCII codes directly. No need to convert to decimal.
Code: mov al,"H" call print mov al,"i" call print |
|||
07 Aug 2021, 19:45 |
|
FlierMate 08 Aug 2021, 20:52
revolution wrote: fasm can use the ASCII codes directly. No need to convert to decimal. I didn't know that. This will make my life easier, if I need to customize the message. Thank you , revolution! |
|||
08 Aug 2021, 20:52 |
|
FlierMate 08 Aug 2021, 20:58
May I ask something, out of curiosity, when I disassemble the boot.img file, I notice there are no mention of "org 7c00h"??
Please refer to screenshot, the disasembly of hex dump has no where mentioning the offset 7c00h? Code: 00000000 31 C0 8E D8 8E C0 8E D0 BC 00 7C 50 68 10 7C CB 1.........|Ph.|. 00000010 B0 48 E8 07 00 B0 69 E8 02 00 EB FE 60 BB 07 00 .H....i.....`... 00000020 B4 0E CD 10 61 C3 ....a. Sorry for my ignorance. And one more question, why do I need to copy the boot.img to a 8GB FAT partition in USB flash drive, but not a 32GB FAT32 partition? When I copied boot.img to a 32GB USB flash drive, it didn't show my "Hi" message, just prints "Missing operating system". But after I create a 8GB small partition in 32GB USB flash drive, then it works like a charm again. Can someone explain ?
|
||||||||||
08 Aug 2021, 20:58 |
|
revolution 08 Aug 2021, 21:16
org affects the offset used. In your code you don't have any offsets so it makes no difference.
Code: org 0x7c00 my_string db 'Hello world!$' mov bx, my_string ; <--- bx = 0x7c00 |
|||
08 Aug 2021, 21:16 |
|
FlierMate 08 Aug 2021, 22:40
revolution wrote: org affects the offset used. In your code you don't have any offsets so it makes no difference. From your explanation, I found this: Code: push start is actually... Code: push 0x7c10 So I see now why the "org 7c00h" is needed. Thank you once again! |
|||
08 Aug 2021, 22:40 |
|
revolution 08 Aug 2021, 22:53
Thanks for the correction.
|
|||
08 Aug 2021, 22:53 |
|
FlierMate 08 Aug 2021, 23:44
revolution wrote: Thanks for the correction. My bad, I should have set base address as 0x7c00 in the online disassembler.
|
||||||||||
08 Aug 2021, 23:44 |
|
revolution 08 Aug 2021, 23:51
call is relative. The generated code is not affected by org.
Same for jmp, and jcc. |
|||
08 Aug 2021, 23:51 |
|
macomics 09 Aug 2021, 08:50
Quote:
Check the USB/HDD settings in the BIOS/EFI on your computer. The details depend on the version and manufacturer of your equipment, but it is worth looking in this direction. |
|||
09 Aug 2021, 08:50 |
|
FlierMate 09 Oct 2021, 16:20
I should have added these two lines at the bottom of the source file:
Code: rb 7C00h+510-$ dw 0AA55h So now I can attach it to VM.
|
||||||||||
09 Oct 2021, 16:20 |
|
macomics 09 Oct 2021, 20:54
Slightly more versatile design
Code: define BytesPerSector 512 ; Not all media sectors have the same size. Two signatures are required for such media: by offset 510 in the sector and at the end of the sector if $$ + 510 + $ > 0 rb $$ + 510 + $ else if $$ + 510 + $ < 0 err ; code out of sector bounds! end if dw 0AA55h if BytesPerSector > 512 rb $$ + BytesPerSector - 2 - $ dw 0AA55h end if |
|||
09 Oct 2021, 20:54 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.