Solar Assembler: Difference between revisions
[unchecked revision] | [unchecked revision] |
m (added Original features section.) |
(use cite extension) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{In Progress}} |
{{In Progress}} |
||
Solar Assembler (aka Sol_Asm) is a multipass macro assembler written by Bogdan Ontanu. It supports HLL primitives, like procedures, structures/unions, .IF/.ENDIF, .WHILE/.ENDWHILE, .REPEAT/.UNTIL, etc. Sol_Asm can produce binary files, PE executables (32/64-bit), COFF object files (32/64-bit), ELF object files (32-bit |
Solar Assembler (aka Sol_Asm) is a multipass macro assembler written by Bogdan Ontanu. It supports HLL primitives, like procedures, structures/unions, .IF/.ENDIF, .WHILE/.ENDWHILE, .REPEAT/.UNTIL, etc. Sol_Asm can produce binary files, PE executables (32/64-bit), COFF object files (32/64-bit), ELF object files (32/64-bit) and Mach-O object files (32-bit only). |
||
==Sol_Asm syntax== |
==Sol_Asm syntax== |
||
Line 18: | Line 18: | ||
|- |
|- |
||
| Procedures |
| Procedures |
||
| < |
| <syntaxhighlight lang="asm"> |
||
PROC TestProc |
PROC TestProc |
||
USES eax, ebx |
USES eax, ebx |
||
Line 26: | Line 26: | ||
... |
... |
||
ENDP |
ENDP |
||
⚫ | |||
</source>{{ref|1}} |
|||
| < |
| <syntaxhighlight lang="asm"> |
||
TestProc PROC |
TestProc PROC |
||
USES eax, ebx |
USES eax, ebx |
||
Line 35: | Line 35: | ||
... |
... |
||
ENDP |
ENDP |
||
</syntaxhighlight> |
|||
</source> |
|||
| < |
| <syntaxhighlight lang="asm"> |
||
TestProc PROC \ |
TestProc PROC \ |
||
USES eax, ebx \ |
USES eax, ebx \ |
||
Line 44: | Line 44: | ||
... |
... |
||
TestProc ENDP |
TestProc ENDP |
||
</syntaxhighlight> |
|||
</source> |
|||
| < |
| <syntaxhighlight lang="asm"> |
||
proc TestProc \ |
proc TestProc \ |
||
USES eax ebx \ |
USES eax ebx \ |
||
Line 53: | Line 53: | ||
... |
... |
||
endp |
endp |
||
</syntaxhighlight> |
|||
</source> |
|||
|- |
|- |
||
| Structures |
| Structures |
||
| < |
| <syntaxhighlight lang="asm"> |
||
STRUC StructTest |
STRUC StructTest |
||
Var1 db ? |
Var1 db ? |
||
Line 62: | Line 62: | ||
Var3 dd ? |
Var3 dd ? |
||
ENDS |
ENDS |
||
</syntaxhighlight> |
|||
</source> |
|||
| < |
| <syntaxhighlight lang="asm"> |
||
StructTest STRUC |
StructTest STRUC |
||
Var1: db ? |
Var1: db ? |
||
Line 69: | Line 69: | ||
Var3: dd ? |
Var3: dd ? |
||
ENDS |
ENDS |
||
</syntaxhighlight> |
|||
</source> |
|||
| < |
| <syntaxhighlight lang="asm"> |
||
StructTest STRUC |
StructTest STRUC |
||
Var1: db ? |
Var1: db ? |
||
Line 76: | Line 76: | ||
Var3: dd ? |
Var3: dd ? |
||
StrucTTest ENDS |
StrucTTest ENDS |
||
</syntaxhighlight> |
|||
</source> |
|||
| < |
| <syntaxhighlight lang="asm"> |
||
struct StructTest |
struct StructTest |
||
Var1: db ? |
Var1: db ? |
||
Line 83: | Line 83: | ||
Var3: dd ? |
Var3: dd ? |
||
ends |
ends |
||
</syntaxhighlight> |
|||
</source> |
|||
|- |
|- |
||
| Reserve non initialized data |
| Reserve non initialized data |
||
| < |
| <syntaxhighlight lang="asm"> |
||
Buffer: rb 256 |
Buffer: rb 256 |
||
</syntaxhighlight> |
|||
</source> |
|||
| < |
| <syntaxhighlight lang="asm"> |
||
Buffer: db 256 dup(?) |
Buffer: db 256 dup(?) |
||
</syntaxhighlight> |
|||
</source> |
|||
| < |
| <syntaxhighlight lang="asm"> |
||
Buffer: db 256 dup(?) |
Buffer: db 256 dup(?) |
||
</syntaxhighlight> |
|||
</source> |
|||
| < |
| <syntaxhighlight lang="asm"> |
||
Buffer: db 256 dup(?) |
Buffer: db 256 dup(?) |
||
or |
or |
||
Buffer: rb 256 |
Buffer: rb 256 |
||
</syntaxhighlight> |
|||
</source> |
|||
|- |
|- |
||
| I/O ports |
| I/O ports |
||
| < |
| <syntaxhighlight lang="asm"> |
||
in al, [92h] |
in al, [92h] |
||
or al, 02h |
or al, 02h |
||
out [92h], al |
out [92h], al |
||
</syntaxhighlight> |
|||
</source> |
|||
| < |
| <syntaxhighlight lang="asm"> |
||
in al, 92h |
in al, 92h |
||
or al, 02h |
or al, 02h |
||
out 92h, al |
out 92h, al |
||
</syntaxhighlight> |
|||
</source> |
|||
| < |
| <syntaxhighlight lang="asm"> |
||
in al, 92h |
in al, 92h |
||
or al, 02h |
or al, 02h |
||
out 92h, al |
out 92h, al |
||
</syntaxhighlight> |
|||
</source> |
|||
| < |
| <syntaxhighlight lang="asm"> |
||
in al, 92h |
in al, 92h |
||
or al, 02h |
or al, 02h |
||
out 92h, al |
out 92h, al |
||
</syntaxhighlight> |
|||
</source> |
|||
|- |
|- |
||
| .IF/.ENDIF |
| .IF/.ENDIF |
||
| < |
| <syntaxhighlight lang="asm"> |
||
.IF ( eax == 2 .or. ebx != 3 ) |
.IF ( eax == 2 .or. ebx != 3 ) |
||
; something... |
; something... |
||
.ENDIF |
.ENDIF |
||
</syntaxhighlight> |
|||
</source> |
|||
| < |
| <syntaxhighlight lang="asm"> |
||
.IF (eax == 2 or ebx != 3) |
.IF (eax == 2 or ebx != 3) |
||
; something... |
; something... |
||
.ENDIF |
.ENDIF |
||
</syntaxhighlight> |
|||
</source> |
|||
| < |
| <syntaxhighlight lang="asm"> |
||
.IF (eax == 2 or ebx != 3) |
.IF (eax == 2 or ebx != 3) |
||
; something... |
; something... |
||
.ENDIF |
.ENDIF |
||
</syntaxhighlight> |
|||
</source> |
|||
| < |
| <syntaxhighlight lang="asm"> |
||
.if (eax == 2 or ebx != 3) |
.if (eax == 2 or ebx != 3) |
||
; something... |
; something... |
||
.endif |
.endif |
||
</syntaxhighlight> |
|||
</source> |
|||
|} |
|} |
||
==Original features== |
==Original features== |
||
Sol_Asm also implements some original features. |
|||
===ENUMs=== |
===ENUMs=== |
||
It is possible to define some constants like C language with the ENUM keyword. |
It is possible to define some constants like C language with the ENUM keyword. |
||
This little example will generate: TASK_ZOMBIE equ 0, TASK_READY equ 1, TASK_RUNNING equ 2, etc. |
This little example will generate: TASK_ZOMBIE equ 0, TASK_READY equ 1, TASK_RUNNING equ 2, etc. |
||
< |
<syntaxhighlight lang="asm"> |
||
ENUM TASK, 0, 4 |
ENUM TASK, 0, 4 |
||
TASK_ZOMBIE |
TASK_ZOMBIE |
||
Line 160: | Line 160: | ||
TASK_SLEEPING |
TASK_SLEEPING |
||
ENDE |
ENDE |
||
</syntaxhighlight> |
|||
</source> |
|||
===Resource compiler=== |
===Resource compiler=== |
||
Sol_Asm includes a small resource compiler. This little example will define a dialog box: |
Sol_Asm includes a small resource compiler. This little example will define a dialog box: |
||
< |
<syntaxhighlight lang="asm"> |
||
IDD_DIALOG1 equ 100 |
IDD_DIALOG1 equ 100 |
||
IDD_BUTTON1 equ 101 |
IDD_BUTTON1 equ 101 |
||
Line 175: | Line 175: | ||
CONTROL "Hello", IDC_BUTTON1, "Button", 0x50010000, 10, 10, 50, 24, 0x00000000 |
CONTROL "Hello", IDC_BUTTON1, "Button", 0x50010000, 10, 10, 50, 24, 0x00000000 |
||
END |
END |
||
</syntaxhighlight> |
|||
</source> |
|||
<references group="Note" /> |
|||
⚫ | |||
==See Also== |
==See Also== |
Latest revision as of 11:57, 17 June 2024
Solar Assembler (aka Sol_Asm) is a multipass macro assembler written by Bogdan Ontanu. It supports HLL primitives, like procedures, structures/unions, .IF/.ENDIF, .WHILE/.ENDWHILE, .REPEAT/.UNTIL, etc. Sol_Asm can produce binary files, PE executables (32/64-bit), COFF object files (32/64-bit), ELF object files (32/64-bit) and Mach-O object files (32-bit only).
Sol_Asm syntax
Syntax comparison
The syntax of Sol_Asm is easy to learn and has similarities with the syntax of TASM or MASM. This table shows the differences between Sol_Asm and other HLL assemblers:
SOL_ASM | TASM | MASM / JWASM | FASM with HLL macros | |
---|---|---|---|---|
Procedures | PROC TestProc
USES eax, ebx
ARG Var1, Var2
LOCAL Var3
...
ENDP
|
TestProc PROC
USES eax, ebx
ARG Var1:DWORD, Var2:BYTE
LOCAL Var3:WORD
...
ENDP
|
TestProc PROC \
USES eax, ebx \
Var1:DWORD, Var2:BYTE
LOCAL Var3:WORD
...
TestProc ENDP
|
proc TestProc \
USES eax ebx \
Var1:DWORD, Var2:BYTE
LOCAL Var3:WORD
...
endp
|
Structures | STRUC StructTest
Var1 db ?
Var2 dw ?
Var3 dd ?
ENDS
|
StructTest STRUC
Var1: db ?
Var2: dw ?
Var3: dd ?
ENDS
|
StructTest STRUC
Var1: db ?
Var2: dw ?
Var3: dd ?
StrucTTest ENDS
|
struct StructTest
Var1: db ?
Var2: dw ?
Var3: dd ?
ends
|
Reserve non initialized data | Buffer: rb 256
|
Buffer: db 256 dup(?)
|
Buffer: db 256 dup(?)
|
Buffer: db 256 dup(?)
or
Buffer: rb 256
|
I/O ports | in al, [92h]
or al, 02h
out [92h], al
|
in al, 92h
or al, 02h
out 92h, al
|
in al, 92h
or al, 02h
out 92h, al
|
in al, 92h
or al, 02h
out 92h, al
|
.IF/.ENDIF | .IF ( eax == 2 .or. ebx != 3 )
; something...
.ENDIF
|
.IF (eax == 2 or ebx != 3)
; something...
.ENDIF
|
.IF (eax == 2 or ebx != 3)
; something...
.ENDIF
|
.if (eax == 2 or ebx != 3)
; something...
.endif
|
Original features
Sol_Asm also implements some original features.
ENUMs
It is possible to define some constants like C language with the ENUM keyword. This little example will generate: TASK_ZOMBIE equ 0, TASK_READY equ 1, TASK_RUNNING equ 2, etc.
ENUM TASK, 0, 4
TASK_ZOMBIE
TASK_READY
TASK_RUNNING
TASK_WAITING
TASK_SLEEPING
ENDE
Resource compiler
Sol_Asm includes a small resource compiler. This little example will define a dialog box:
IDD_DIALOG1 equ 100
IDD_BUTTON1 equ 101
IDD_DIALOG1 DIALOGEX 10, 10, 320, 240
CAPTION "Hello!"
STYLE 0x10CF0000
BEGIN
CONTROL "Hello", IDC_BUTTON1, "Button", 0x50010000, 10, 10, 50, 24, 0x00000000
END
- ↑ By default, arguments and locals are always dwords.