Quite some time ago I was talking about creating my own toolchain (and later an OS), and well, today is the day that my assembler is released to the public. It's under the GPLv3. It's by far not ready for use, or OS development for that matter (doesn't have the capability to handle numbers bigger than a byte: 255, and some other quirks), but it's coming together very nicely.
So why release it if it's not ready? To test, break, and discover unexpected behavior of course! 3 times hurray!
I'd really appreciate it if you guys could maybe write your own little programs, especially the ones you would expect would break it, but don't be surprised if the instructions you enter don't get assembled into the final binary. Some of them aren't implemented yet.
So how do you write programs?
- Well, I'm glad you asked. It's an assembler, and some, if not most of you, are familiar with assembly language. It has AT&T-esque directives but Intel-esque instructions. It has '.asciz "Hello world!"' but can handle 'mov al, 16' just fine as well.
Using the assembler
First you have to get the source code here. Then, untar it and make it, by simply typing "make".
Now you´ve got to provide it with a source file, 6 so called temporary files and a file to output the binary in.
Code: Select all
./mas86 test.asm temp0 temp1 temp2 temp3 temp4 temp5 out.bin
The directives
.ascii "string" - inserts a ASCII-formatted string into the binary. (implemented)
.asciz "string" - inserts a null-terminated ASCII-formatted string into the binary. (implemented)
.comment 'comment character' - changes the comment character on the fly, it CAN'T be a period ('.'). (implemented)
.dec x - inserts a decimal-represented value into the binary. (half-implemented)
.fill x y - puts the value of 'y' 'x' times in the binary, no matter the size. (implemented)
.hex x - inserts a hexadecimal-represented value into the binary. (half-implemented)
.include "file path"- includes a separate assembly source file. (not implemented)
.incbin "file path" - includes a separate binary file. (not implemented)
.size x y - makes the binary up to that point the size of 'x' in bytes and 'y' is the value it uses to fill the void. (not implemented)
Comment characters
The standard comment character is an exclamation mark ('!'), but the comment characters are completely changeable on the fly, as you might have seen when you read the directives part.
So, now that that is out of the way: a sample:
Code: Select all
.comment ';' ; A comment is now a ';', like with NASM. Probably makes it more readable for you guys ;-)
; Bootsector that makes a cool effect on the screen.
main:
mov ah, 00 ; Set the video mode.
mov al, 141 ; Set the video mode to 320x200, 256 colors (13h), with 128 added to it, so it doesn't clear the screen. Creates a cool effect.
int 16 ; Call the BIOS.
cli ; Clear interrupts.
hlt ; Halt.
.fill 502 0 ; Fill it up with 502x0.
.hex 0x55 ; Boot signature.
.hex 0xAA ; Boot signature.
~SoLDMG