Added some more ASM languages and Squirrel.

This commit is contained in:
Daniel Clarke
2012-04-29 09:11:36 -04:00
parent 38f6567c5c
commit 7214a08a5f
6 changed files with 83 additions and 1 deletions

16
a/assembler_fasm_dos.asm Normal file
View File

@@ -0,0 +1,16 @@
format MZ
entry .code: start
segment .code
start:
mov ax, .data ; put data segment into ax
mov ds, ax ; there, I setup the DS for you
mov dx, msg ; now I give you the offset in DX. DS:DX now completed.
mov ah, 9h
int 21h
mov ah, 4ch
int 21h
segment .data
msg db 'Hello World', '$'

17
a/assembler_masm_dos.asm Normal file
View File

@@ -0,0 +1,17 @@
; 16 bit dos assembly
.model small
.stack
.data
message db "Hello world!", "$"
.code
main proc
mov ax,seg message
mov ds,ax
mov ah,09
lea dx,message
int 21h
mov ax,4c00h
int 21h
main endp
end main

View File

@@ -0,0 +1,31 @@
section .text
global _start ;must be declared for linker (ld)
_syscall:
int 0x80 ;system call
ret
_start: ;tell linker entry point
push dword len ;message length
push dword msg ;message to write
push dword 1 ;file descriptor (stdout)
mov eax,0x4 ;system call number (sys_write)
call _syscall ;call kernel
;the alternate way to call kernel:
;push eax
;call 7:0
add esp,12 ;clean stack (3 arguments * 4)
push dword 0 ;exit code
mov eax,0x1 ;system call number (sys_exit)
call _syscall ;call kernel
;we do not return from sys_exit,
;there's no need to clean stack
section .data
msg db "Hello, world!",0xa ;our string
len equ $ - msg ;length of our string

View File

@@ -0,0 +1,18 @@
section .text
global _start ;must be declared for linker (ld)
_start: ;tell linker entry point
mov edx,len ;message length
mov ecx,msg ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
mov eax,1 ;system call number (sys_exit)
int 0x80 ;call kernel
section .data
msg db 'Hello, world!',0xa ;our string
len equ $ - msg ;length of our string

View File

@@ -1 +0,0 @@
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.

1
s/squirrel.nut Normal file
View File

@@ -0,0 +1 @@
print("Hello World!");