flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Which Format To Use? |
Author |
|
Tyler 17 Sep 2010, 02:11
"format binary" but remember to specify bitness, it will default to 16bit. You can also use "format binary as "img"" to tell Fasm to use "img" as the extension.
|
|||
17 Sep 2010, 02:11 |
|
nathanpc 17 Sep 2010, 09:36
How to specify the bitness, because I've tried bits 16(like on Nasm) and I got an error. Also, how is the macro declaration at Fasm?
Best Regards |
|||
17 Sep 2010, 09:36 |
|
ManOfSteel 17 Sep 2010, 09:42
|
|||
17 Sep 2010, 09:42 |
|
nathanpc 17 Sep 2010, 15:58
Now I'm having problems on this code:
Code: macro print string { mov si, word string char_loop: lodsb or al, al jz cdone mov ah, 09h mov bl, 19h int 10h jmp char_loop cdone: } Here are the errors: Code: D:\Meus documentos\LeafBoot>fasm write.asm flat assembler version 1.69.24 (1130971 kilobytes memory) kernel.asm [3]: print test stdio.inc [11] print [1]: mov si, word string error: invalid operand. D:\Meus documentos\LeafBoot> |
|||
17 Sep 2010, 15:58 |
|
revolution 17 Sep 2010, 16:04
Are you passing a pointer or a variable?
Code: mov si,string ;passing a pointer mov si,word[string] ;passing a variable |
|||
17 Sep 2010, 16:04 |
|
nathanpc 17 Sep 2010, 17:07
Now it's like this:
Code: flat assembler version 1.69.24 (1076811 kilobytes memory) kernel.asm [3]: print test stdio.inc [11] print [1]: mov si,word[string] ;passing a variable error: reserved word used as symbol. |
|||
17 Sep 2010, 17:07 |
|
LocoDelAssembly 17 Sep 2010, 17:19
You are not showing much code really... But it may be happening that the instruction is passed to the assembling stage as " mov si,word[test]" and of course it doesn't work, because test is an instruction and cannot be a symbol.
|
|||
17 Sep 2010, 17:19 |
|
nathanpc 19 Sep 2010, 19:06
But now I have this:
Code: D:\Meus documentos\LeafBoot>fasm write.asm flat assembler version 1.69.24 (1059063 kilobytes memory) kernel.asm [1]: print tst stdio.inc [13] print [3]: char_loop: error: symbol already defined. D:\Meus documentos\LeafBoot> print is a instruction too? |
|||
19 Sep 2010, 19:06 |
|
LocoDelAssembly 19 Sep 2010, 19:17
No, the problem is that you must used print macro more than once (are you sure you don't prefer some procedure to call instead?)
Anyway, to fix this problem simply do this: Code: macro print string { common local ..char_loop, ..cdone mov si, word string ..char_loop: lodsb or al, al jz cdone mov ah, 09h mov bl, 19h int 10h jmp ..char_loop ..cdone: } |
|||
19 Sep 2010, 19:17 |
|
nathanpc 20 Sep 2010, 00:48
Thanks, I've corrected the jz cdone to jz ..cdone and it's compiling nice now. But when I've tried to emulate it using Bochs, it said that there is no bootable device. Why?
|
|||
20 Sep 2010, 00:48 |
|
LocoDelAssembly 20 Sep 2010, 01:14
You may be generating the image incorrectly. Additionally, make sure it has the AA55 signature at the end of the first sector.
Example I've posted somewhere else but can't search for it: Code: format binary as 'img' org $7c00 xor ax, ax cli mov ss, ax mov sp, $7C00 sti mov ds, ax mov ah, $0E xor bx, bx mov si, msg jmp .loadChar .printChar: int $10 .loadChar: lodsb test al, al jnz .printChar xor ax, ax int $16 int $19 msg db "Hello world ", 13, 10,\ "Now remove the floppy disk and press a key or else you'll see this message again", 13, 10, 0 ; Padding before boot signature rb 512 - 2 + $$ - $ dw $AA55 ; Padding to make the image floppy-sized rb 1440*1024 - 512 - 1 db 0 Try if the above works in Bochs (it works in VirtualPC). |
|||
20 Sep 2010, 01:14 |
|
nathanpc 20 Sep 2010, 09:34
It failed another time
|
|||
20 Sep 2010, 09:34 |
|
DJ Mauretto 20 Sep 2010, 10:00
Try This...
Code: format binary as 'img' org $7c00 jmp @Skip_BPB nop ;====================== ; Bios Parameter Block ; Floppy ;====================== OEM db "nathanpc" Bytes_per_sector dw 512 Sectors_per_cluster db 1 Reserved_sectors dw 1 Number_of_FATs db 2 Root_entries dw 224 Total_sector_count dw 2880 ; 80*2*18 Media_descriptor db $F0 ; Floppy Sectors_per_FAT dw 9 Sectors_per_track db 18 Heads dw 2 Hidden_sectors dd 0 Total_sector_FAT32 dd 0 ; Total sector count for FAT32 (0 for FAT12 and FAT16) BIOS_drive db 0 Unused db 0 Boot_signature db $29 ; Extended boot signature ,IF 29H next 3 fields are present Volume_ID dd 0 Volume_label db " " File_system_type db "FAT12 " @Skip_BPB: xor ax, ax cli mov ss, ax mov sp, $7C00 sti mov ds, ax mov ah, $0E mov bx,$0007 mov si, msg jmp .loadChar .printChar: int $10 .loadChar: lodsb test al, al jnz .printChar xor ax, ax int $16 int $19 msg db "Hello world Very Happy", 13, 10,\ "Now remove the floppy disk and press a key or else you'll see this message again", 13, 10, 0 ; Padding before boot signature rb 510 - ($ - $$) dw $AA55 ; Padding to make the image floppy-sized rb 1440*1024 - 512 - 1 db 0 _________________ Nil Volentibus Arduum |
|||
20 Sep 2010, 10:00 |
|
LocoDelAssembly 20 Sep 2010, 16:12
If DJ Mauretto's code is really needed, I'll be very disappointed at Bochs for terribly bad BIOS emulation (and half-disappointed if the JMP/NOP sequence was the only extra thing needed)
|
|||
20 Sep 2010, 16:12 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.