Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sher70ck #68

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ASM/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### Instructions
First, you will need:
- qemu (on linux : sudo apt-get install qemu

Then run:
```
$ nasm -f bin hello.asm -o hello.bin
$ qemu-system-i386 hello.bin
```

<img src="hello.png" />
125 changes: 125 additions & 0 deletions ASM/hello.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
org 0x7c00
jmp main


msg db 'HELLO WORLD',0


getchar:
mov ah, 0x0
int 16h
ret
scanf:
scan_loop:
call getchar


cmp al, 13
je scan_end

mov ah, 0xe
int 10h
mov ah, 0

cmp al, 8
je backspace
inc dx

stosb
jmp scan_loop

backspace:
cmp dx, 0
je scan_loop
add dx, -1
mov byte[di], 0
add di, -1
mov ah, 0xe
mov al, 0
int 10h
mov al, 8
int 10h
mov ah, 0
xor ax, ax
jmp scan_loop


scan_end:
mov ah, 0xe
call endl
xor ax, ax
stosb
ret
putchar:

mov ah, 0xe
int 10h
ret
endl:
mov ah,0xe
mov al, 10
xor cx, cx
int 10h
endl_loop:
cmp cx, dx
je endl_loop_end
mov al, 8
int 10h
inc cx
jmp endl_loop
endl_loop_end:
mov ah, 0xe
mov bl, 10
mov cx, 01h
ret

printf:
xor dx, dx
print_loop:
lodsb
cmp al,0
je end_print
inc dx
call putchar
jmp print_loop
end_print:
call endl
ret


main:

xor ax, ax
mov bx, ax
mov cx, ax
mov dx, ax



mov ah, 0
mov al, 13h
int 10h

mov ah, 0xb
mov bh, 0
mov bl, 4
int 10h

mov ah, 0xe
mov al, 8
mov bh, 0
mov bl, 0xf
mov cx, 01h
int 10h



mov si, msg
mov di, msg
call printf


jmp $
times 510-($-$$) db 0
dw 0xaa55

Binary file added ASM/hello.bin
Binary file not shown.
Binary file added ASM/hello.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.