Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/imakebotsforyou/assemblyrust

An x86 assembly emulator in rust
https://github.com/imakebotsforyou/assemblyrust

asm assembler assembly compiler deassembler decompiler emulator rust tasm x86 x86-assembly

Last synced: 24 days ago
JSON representation

An x86 assembly emulator in rust

Awesome Lists containing this project

README

        

# 8086 TASM Simulator with 32-bit Registers

This project is an 8086 TASM (Turbo Assembler) simulator that supports 32-bit registers. The simulator includes various assembly commands for performing operations such as data movement, arithmetic, stack manipulation, and conditional jumps.

## Features

- **32-bit Registers**: EAX, EBX, ECX, EDX, ESI, EDI
- **16-bit, 8-bit Registers**: AX (AL/AH), BX (BH/BL), etc.
- **Stack Operations**: `push` and `pop` commands
- **Arithmetic Operations**: Addition, subtraction, multiplication, and division.
- **Conditional and Unconditional Jumps**: For flow control.

## Supported Commands

### Mov
Move data between registers, memory, and constants.

Syntax:
* mov \, \
* mov \, [\]
* mov [\], \
* mov \, \
* mov [\], \

### Push
Push data onto the stack.

Syntax:
* push \
* push [\]
* push \

csharp

### Pop
Pop data from the stack.

Syntax:
* pop \
* pop [\]

### Lea
Load effective address.

Syntax:
* lea \, [\]

### Add
Add values to registers or memory.

Syntax:
* add \, \
* add \, [\]
* add \, \
* add [\], \
* add [\], \

### Sub
Subtract values from registers or memory.

Syntax:
* sub \, \
* sub \, [\]
* sub \, \
* sub [\], \
* sub [\], \

### Inc
Increment a register or memory value.

Syntax:
* inc \
* inc [\]

### Dec
Decrement a register or memory value.

Syntax:
* dec \
* dec [\]

### Mul
Unsigned multiplication.

Syntax:
* mul \
* mul [\]
* mul \
* mul \

### Imul
Signed multiplication.

Syntax:
* imul \
* imul [\]
* imul \
* imul \

### Div
Unsigned division.

Syntax:
* div \
* div [\]
* div \
* div \

### Idiv
Signed division.

Syntax:
* idiv \
* idiv [\]
* idiv \
* idiv \

### Jmp
Unconditional jump.

Syntax:
* jmp \

### Je
Jump if equal.

Syntax:
* je \

### Jne
Jump if not equal.

Syntax:
* jne \

### Jz
Jump if zero.

Syntax:
* jz \

### Jnz
Jump if not zero.

Syntax:
* jnz \

### Jg
Jump if greater.

Syntax:
* jg \

### Jge
Jump if greater or equal.

Syntax:
* jge \

### Jle
Jump if less or equal.

Syntax:
* jle \

### Jl
Jump if less.

Syntax:
* jl \

### Jb
Jump if below.

Syntax:
* jb \

### Jbe
Jump if below or equal.

Syntax:
* jbe \

### Ja
Jump if above.

Syntax:
* ja \

### Jae
Jump if above or equal.

Syntax:
* jae \

### Cmp
Compare two values.

Syntax:
* cmp \, \
* cmp \, [\]
* cmp \, \
* cmp [\], \
* cmp [\], \

## Example Code

The following example generates a Fibonacci sequence.

```assembly
a dd 0
b dd 1
c dd 0

mov CX, 10

loop:
mov EAX, [a]
add EAX, [b]
mov [c], EAX

mov EAX, [b]
mov [a], EAX
mov EAX, [c]
mov [b], EAX
print [c]
dec CX
jnz loop
```

Output:
```
[SAVED] Saved variable a @ 0
[SAVED] Saved variable b @ 4
[SAVED] Saved variable c @ 8

[PRINT]@[IP=15] [c]: 1
[PRINT]@[IP=15] [c]: 2
[PRINT]@[IP=15] [c]: 3
[PRINT]@[IP=15] [c]: 5
[PRINT]@[IP=15] [c]: 8
[PRINT]@[IP=15] [c]: 13
[PRINT]@[IP=15] [c]: 21
[PRINT]@[IP=15] [c]: 34
[PRINT]@[IP=15] [c]: 55
[PRINT]@[IP=15] [c]: 89

Execution completed successfully.
Register EAX: 89 (00000000 01011001)
Register EBX: 0 (00000000 00000000)
Register ECX: 0 (00000000 00000000)
Register EDX: 0 (00000000 00000000)
Register ESI: 0 (00000000 00000000)
Register EDI: 0 (00000000 00000000)
Register IP: 17 (00000000 00010001)
Register FLAG: 10 (00000000 00001010)
```