Skip to content

Commit

Permalink
release(v1.0): Kroha
Browse files Browse the repository at this point in the history
  • Loading branch information
vorotynsky committed Aug 30, 2020
2 parents ec4a7c2 + 1fc2963 commit e48e668
Show file tree
Hide file tree
Showing 22 changed files with 656 additions and 870 deletions.
42 changes: 13 additions & 29 deletions HLasm.cabal → Kroha.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack

name: HLasm
version: 0.4.0.0
name: Kroha
version: 1.0.0.0
description: Please see the README on GitHub at <https://github.com/vorotynsky/HLasm#readme>
homepage: https://github.com/vorotynsky/HLasm#readme
bug-reports: https://github.com/vorotynsky/HLasm/issues
Expand All @@ -22,18 +22,18 @@ source-repository head
type: git
location: https://github.com/vorotynsky/HLasm

library
exposed-modules:
HLasm.Ast
HLasm.Backend.Nasm
HLasm.Error
HLasm.Frame
HLasm.Instructions
HLasm.Parser
HLasm.Scope
HLasm.Types
executable Kroha
main-is: Main.hs
other-modules:
Paths_HLasm
Kroha
Kroha.Ast
Kroha.Backends.Nasm
Kroha.Instructions
Kroha.Parser
Kroha.Scope
Kroha.Stack
Kroha.Types
Paths_Kroha
hs-source-dirs:
src
build-depends:
Expand All @@ -42,19 +42,3 @@ library
, extra >=1.0 && <1.8
, parsec >=3.1.0 && <=3.1.14.0
default-language: Haskell2010

executable HLasm-exe
main-is: Main.hs
other-modules:
Funcs
Paths_HLasm
hs-source-dirs:
app
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
HLasm
, base >=4.7 && <5
, containers >=0.6 && <0.7
, extra >=1.0 && <1.8
, parsec >=3.1.0 && <=3.1.14.0
default-language: Haskell2010
141 changes: 69 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# HLasm
# Kroha

Improve your assembly experience with HLasm!
Improve your assembly experience with Kroha!
This language is more comfortable than a pure assembly.

## Example
Expand All @@ -11,62 +11,59 @@ Instead of documentation

```asm
program {
fake frame <act>
manual frame act {
mov ax, [bp-4]
inc ax
leave
ret
}
frame (main) {
frame main {
reg a : ax
a = 5
call <act> (a)
}
frame (act) {
!mov ax, [bp-4];
!inc ax;
}
}
```

Compiled

```asm
section .text
act:
mov ax, [bp-4]
inc ax
leave
ret
section .text
main:
push bp
mov bp, sp
sub sp, 0
mov ax, 5
push ax
call act
add sp, 0
mov ax, 5
push ax
call act
add sp, 2
leave
ret
act:
push bp
mov bp, sp
sub sp, 0
mov ax, [bp-4]
inc ax
leave
ret
```

### Variables

```asm
program {
var a : int(16) = 32
var b : int(8) = 1
const c : int(16) = 32
const d : int(8) = 1
var a : int16 = 32
var b : int8 = 1
const c : int16 = 32
const d : int8 = 1
frame (main) {
manual var arr : &int8 {
times 64 db 0
}
frame main {
reg ra : ax
reg ptr : bx
var sb : int(16)
var sb : int16
ra = 5
sb = 6
ptr = b
Expand All @@ -77,41 +74,48 @@ program {
Compiled

```asm
section .text
main:
push bp
mov bp, sp
sub sp, 2
mov ax, 5
mov WORD [bp-2], 6
mov bx, b
leave
ret
section .data
a: dw 32
section .data
a: DW 32
b: DB 1
b: db 1
section .rodata
c: DW 32
d: DB 1
c: dw 32
section .rodata
d: db 1
section .data
arr:
times 64 db 0
section .text
main:
mov ax, 5
mov [bp - 2], 6
mov bx, [b]
leave
ret
```

### Conditions and loops

```asm
program {
frame (main) {
frame main {
reg val : ax
val = 0
while (LOOP) {
loop (LOOP) {
if (val > 5, CMP) {
break (LOOP)
}
!inc ax;
else {
!dec bx
}
!inc ax
}
}
}
Expand All @@ -121,30 +125,23 @@ Compiled

```asm
section .text
main:
push bp
mov bp, sp
sub sp, 0
mov ax, 0
LOOPbegin:
cmp ax, 5
jg CMP1
jmp CMPend
CMP1:
jmp LOOPend
jmp CMPend
CMPend:
inc ax
jmp LOOPbegin
LOOPend:
mov ax, 0
LOOP_begin:
cmp ax, 5
jg CMP_begin
dec bx
jmp CMP_end
CMP_begin:
jmp LOOP_end
CMP_end:
inc ax
jmp LOOP_begin
LOOP_end:
leave
ret
```

> Generated code in these examples was manually formatted.
## Build and install

Build using [stack](https://docs.haskellstack.org).
Expand All @@ -159,10 +156,10 @@ Install using [stack](https://docs.haskellstack.org).
stack install
```

## Run HLasm
## Run Kroha

It compiles each file individually and prints nasm to the terminal.

```sh
HLasm ./file1 ./file2 ./file3
Kroha ./file1 ./file2 ./file3
```
19 changes: 0 additions & 19 deletions app/Funcs.hs

This file was deleted.

32 changes: 0 additions & 32 deletions app/Main.hs

This file was deleted.

21 changes: 6 additions & 15 deletions package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: HLasm
version: 0.4.0.0
name: Kroha
version: 1.0.0.0
github: "vorotynsky/HLasm"
license: GPL-3
author: "Vorotynsky Maxim"
Expand All @@ -21,19 +21,10 @@ description: Please see the README on GitHub at <https://github.com/voro
dependencies:
- base >= 4.7 && < 5
- containers >= 0.6 && < 0.7
- extra >= 1.0 && < 1.8
- parsec >= 3.1.0 && <= 3.1.14.0

library:
source-dirs: src
- extra >= 1.0 && < 1.8

executables:
HLasm-exe:
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- HLasm
Kroha:
source-dirs: src
main: Main.hs
Loading

0 comments on commit e48e668

Please sign in to comment.