summaryrefslogblamecommitdiff
path: root/pasmgen-linux.asm
blob: 56113e6847cd5277bf365f0e9814f42a4845d19f (plain) (tree)










































































                              
format ELF64 executable

segment readable executable

main:
	;; No arg preload case
	cmp [rsp], word 1
	jne argparse

	mov r8, qword 3
	mov r9, qword 2
	mov r10, qword 3

	jmp generate

argparse:
	;; Check args (need 3)
	cmp [rsp], word 3
	jle fail

	;; load arg1
	mov r8, [rsp+16]
	mov r8, [r8]
	and r8, 0xFF
	sub r8, 48

	;; load arg2
	mov r9, [rsp+24]
	mov r9, [r9]
	and r9, 0xFF
	sub r9, 48

	;; load arg3
	mov r10, [rsp+32]
	mov r10, [r10]
	and r10, 0xFF
	sub r10, 48

	jmp generate

ok:
	;; Write
	mov rdi, 1  ;; stdout
	mov rdx, rsi
	mov rsi, out_buf
	mov rax, 0x01
	syscall

	;; Exit (code 0)
	mov rdi, 0
	mov rax, 0x3c
	syscall

fail:
	;; Write
	mov rdi, 1  ;; stdout
	mov rsi, usage
	mov rdx, usage_len
	mov rax, 0x01
	syscall

	;; Exit 1
	mov rdi, 1
	mov rax, 0x3c
	syscall


include 'pasmgen.inc'


segment readable writeable

include 'constants.inc'

out_buf rb 64