September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
19
Task/Program-name/X86-Assembly/program-name-1.x86
Normal file
19
Task/Program-name/X86-Assembly/program-name-1.x86
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
FORMAT=-f elf
|
||||
RUN=./
|
||||
BIN=scriptname
|
||||
OBJ=scriptname.o
|
||||
|
||||
all: test
|
||||
|
||||
test: $(BIN)
|
||||
$(RUN)$(BIN)
|
||||
|
||||
$(BIN): $(OBJ)
|
||||
ld -o $(BIN) $(OBJ)
|
||||
|
||||
$(OBJ): scriptname.asm
|
||||
nasm $(FORMAT) -o $(OBJ) scriptname.asm
|
||||
|
||||
clean:
|
||||
-rm $(BIN)
|
||||
-rm $(OBJ)
|
||||
72
Task/Program-name/X86-Assembly/program-name-2.x86
Normal file
72
Task/Program-name/X86-Assembly/program-name-2.x86
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
bits 32
|
||||
|
||||
section .data
|
||||
|
||||
stdout equ 1
|
||||
|
||||
sys_write equ 4
|
||||
sys_exit equ 1
|
||||
|
||||
kernel equ 0x80
|
||||
|
||||
program db "Program: ", 0
|
||||
programlen equ $-program
|
||||
|
||||
nl db "", 10, 0
|
||||
nllen equ $-nl
|
||||
|
||||
section .bss
|
||||
|
||||
scriptname resd 1
|
||||
scriptnamelen resd 1
|
||||
|
||||
section .text
|
||||
|
||||
global _start
|
||||
|
||||
strlen: ; eax: a string ending in 0
|
||||
push eax ; cache eax
|
||||
|
||||
.strloop:
|
||||
mov bl, byte [eax]
|
||||
cmp bl, 0
|
||||
je .strret ; return len if bl == 0
|
||||
inc eax ; else eax++
|
||||
jmp .strloop
|
||||
|
||||
.strret:
|
||||
pop ebx ; ebx = cached eax
|
||||
sub eax, ebx ; eax -= ebx
|
||||
ret ; eax = len
|
||||
|
||||
_start:
|
||||
mov eax, esp
|
||||
add eax, 4
|
||||
mov eax, [eax]
|
||||
mov dword [scriptname], eax
|
||||
|
||||
mov eax, sys_write
|
||||
mov ebx, stdout
|
||||
mov ecx, program
|
||||
mov edx, programlen
|
||||
int kernel
|
||||
|
||||
mov dword eax, [scriptname]
|
||||
call strlen
|
||||
mov dword [scriptnamelen], eax
|
||||
|
||||
mov eax, sys_write
|
||||
mov ebx, stdout
|
||||
mov dword ecx, [scriptname]
|
||||
mov dword edx, [scriptnamelen]
|
||||
int kernel
|
||||
|
||||
mov eax, sys_write
|
||||
mov ebx, stdout
|
||||
mov ecx, nl
|
||||
mov edx, nllen
|
||||
int kernel
|
||||
|
||||
mov eax, sys_exit
|
||||
mov ebx, 0
|
||||
int kernel
|
||||
27
Task/Program-name/X86-Assembly/program-name-3.x86
Normal file
27
Task/Program-name/X86-Assembly/program-name-3.x86
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# FreeBSD defaults
|
||||
|
||||
FORMAT=-f elf
|
||||
RUN=./
|
||||
BIN=scriptname
|
||||
OBJ=scriptname.o
|
||||
|
||||
# Mac OS X
|
||||
ifeq ($(shell uname -s),Darwin)
|
||||
FORMAT=-f macho
|
||||
MINV=-macosx_version_min 10.6
|
||||
endif
|
||||
|
||||
all: test
|
||||
|
||||
test: $(BIN)
|
||||
$(RUN)$(BIN)
|
||||
|
||||
$(BIN): $(OBJ)
|
||||
ld -o $(BIN) $(MINV) $(OBJ)
|
||||
|
||||
$(OBJ): scriptname.asm
|
||||
nasm $(FORMAT) -o $(OBJ) scriptname.asm
|
||||
|
||||
clean:
|
||||
-rm $(BIN)
|
||||
-rm $(OBJ)
|
||||
79
Task/Program-name/X86-Assembly/program-name-4.x86
Normal file
79
Task/Program-name/X86-Assembly/program-name-4.x86
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
bits 32
|
||||
|
||||
section .data
|
||||
|
||||
stdout equ 1
|
||||
|
||||
sys_write equ 4
|
||||
sys_exit equ 1
|
||||
|
||||
kernel equ 0x80
|
||||
|
||||
program db "Program: ", 0
|
||||
programlen equ $-program
|
||||
|
||||
nl db "", 10, 0
|
||||
nllen equ $-nl
|
||||
|
||||
section .bss
|
||||
|
||||
scriptname resd 1
|
||||
scriptnamelen resd 1
|
||||
|
||||
section .text
|
||||
|
||||
global start
|
||||
|
||||
strlen: ; eax: a string ending in 0
|
||||
push eax ; cache eax
|
||||
|
||||
.strloop:
|
||||
mov bl, byte [eax]
|
||||
cmp bl, 0
|
||||
je .strret ; return len if bl == 0
|
||||
inc eax ; else eax++
|
||||
jmp .strloop
|
||||
|
||||
.strret:
|
||||
pop ebx ; ebx = cached eax
|
||||
sub eax, ebx ; eax -= ebx
|
||||
ret ; eax = len
|
||||
|
||||
start:
|
||||
mov eax, esp
|
||||
add eax, 4
|
||||
mov eax, [eax]
|
||||
mov dword [scriptname], eax
|
||||
|
||||
push programlen
|
||||
push program
|
||||
push stdout
|
||||
mov eax, sys_write
|
||||
sub esp, 4
|
||||
int kernel
|
||||
add esp, 4 + 4 * 3
|
||||
|
||||
mov dword eax, [scriptname]
|
||||
call strlen
|
||||
mov dword [scriptnamelen], eax
|
||||
|
||||
push dword [scriptnamelen]
|
||||
push dword [scriptname]
|
||||
push stdout
|
||||
mov eax, sys_write
|
||||
sub esp, 4
|
||||
int kernel
|
||||
add esp, 4 + 4 * 3
|
||||
|
||||
push nllen
|
||||
push nl
|
||||
push stdout
|
||||
mov eax, sys_write
|
||||
sub esp, 4
|
||||
int kernel
|
||||
add esp, 4 + 4 * 3
|
||||
|
||||
push 0
|
||||
mov eax, sys_exit
|
||||
sub esp, 4
|
||||
int kernel
|
||||
19
Task/Program-name/X86-Assembly/program-name-5.x86
Normal file
19
Task/Program-name/X86-Assembly/program-name-5.x86
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
FORMAT=-f win32
|
||||
BIN=scriptname.exe
|
||||
OBJ=scriptname.obj
|
||||
RUN=
|
||||
|
||||
all: test
|
||||
|
||||
test: $(BIN)
|
||||
$(RUN)$(BIN)
|
||||
|
||||
$(BIN): $(OBJ)
|
||||
golink /fo $(BIN) $(OBJ) /console kernel32.dll Msvcrt.dll
|
||||
|
||||
$(OBJ): scriptname.asm
|
||||
nasm $(FORMAT) -o $(OBJ) scriptname.asm
|
||||
|
||||
clean:
|
||||
-rm $(BIN)
|
||||
-rm $(OBJ)
|
||||
94
Task/Program-name/X86-Assembly/program-name-6.x86
Normal file
94
Task/Program-name/X86-Assembly/program-name-6.x86
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
bits 32
|
||||
|
||||
section .data
|
||||
|
||||
program db "Program: ", 0
|
||||
programlen equ $-program
|
||||
|
||||
nl db "", 13, 10, 0
|
||||
nllen equ $-nl
|
||||
|
||||
stdouthandle equ -11
|
||||
|
||||
section .bss
|
||||
|
||||
stdout resd 1
|
||||
|
||||
charswritten resd 1
|
||||
|
||||
env resd 1
|
||||
argc resd 1
|
||||
argv resd 255
|
||||
|
||||
scriptname resd 1
|
||||
scriptnamelen resd 1
|
||||
|
||||
section .text
|
||||
|
||||
global Start
|
||||
extern GetStdHandle
|
||||
extern __getmainargs
|
||||
extern WriteConsoleA
|
||||
extern ExitProcess
|
||||
|
||||
strlen: ; eax: a string ending in 0
|
||||
push eax ; cache eax
|
||||
|
||||
.strloop:
|
||||
mov bl, byte [eax]
|
||||
cmp bl, 0
|
||||
je .strret ; return len if bl == 0
|
||||
inc eax ; else eax++
|
||||
jmp .strloop
|
||||
|
||||
.strret:
|
||||
pop ebx ; ebx = cached eax
|
||||
sub eax, ebx ; eax -= ebx
|
||||
ret ; eax = len
|
||||
|
||||
Start:
|
||||
push 0
|
||||
push env
|
||||
push argv
|
||||
push argc
|
||||
call __getmainargs
|
||||
mov eax, [argv]
|
||||
mov eax, [eax]
|
||||
mov [scriptname], eax
|
||||
add esp, 4 * 4
|
||||
|
||||
push stdouthandle
|
||||
call GetStdHandle
|
||||
mov [stdout], eax
|
||||
add esp, 4 * 1
|
||||
|
||||
push 0
|
||||
push charswritten
|
||||
push programlen
|
||||
push program
|
||||
push dword [stdout]
|
||||
call WriteConsoleA
|
||||
add esp, 4 * 5
|
||||
|
||||
mov eax, [scriptname]
|
||||
call strlen
|
||||
mov [scriptnamelen], eax
|
||||
|
||||
push 0
|
||||
push charswritten
|
||||
push dword [scriptnamelen]
|
||||
push dword [scriptname]
|
||||
push dword [stdout]
|
||||
call WriteConsoleA
|
||||
add esp, 4 * 5
|
||||
|
||||
push 0
|
||||
push charswritten
|
||||
push nllen
|
||||
push nl
|
||||
push dword [stdout]
|
||||
call WriteConsoleA
|
||||
add esp, 4 * 5
|
||||
|
||||
push 0
|
||||
call ExitProcess
|
||||
Loading…
Add table
Add a link
Reference in a new issue