merge_my_devel

This commit is contained in:
neza 2023-03-16 23:28:12 +03:00
parent 8b4f4afeed
commit 4f9e5de8cd
3 changed files with 34 additions and 31 deletions

View File

@ -3,8 +3,7 @@ SET = 5 6 7 8 9
VALID := $(or $(filter ${T},${SET}),$(error Attempts must be in the set ${SET}))
FLAG = --gstabs+ --defsym S=$(T)
SRCDIR = src/
FILES = $(wildcard $(SRCDIR)*.s)
SRC = $(FILES:$(SRCDIR)%=%)
SRC = $(wildcard $(SRCDIR)*.s)
OBJ = $(SRC:.s=.o)
TARGET = guess
@ -13,16 +12,16 @@ all : $(TARGET)
$(TARGET) : $(OBJ)
ld -o $@ $^
%.o : $(SRCDIR)%.s
%.o : %.s
as $(FLAG) -o $@ $<
.PHONY : clean, cleanup, ready
clean :
rm -f $(TARGET) *.o
rm -f $(TARGET) src/*.o
cleanup :
rm -f $(TARGET) *~ .*~ *.o src/*~ src/.*~
rm -f $(TARGET) *~ .*~ src/*.o src/*~ src/.*~
ready :
strip $(TARGET)

View File

@ -3,16 +3,27 @@
conv:
push %rbp
mov %rsp, %rbp
sub $24, %rsp
push %rdi
mov $bye_len, %rsi
mov $bye, %rdi
call say
pop %rdi
call ntosn
# mov $18446744073709551615, %rsi
pop %rsi
mov %rsp, %rdi
# mov $buf, %rdi
call ntos
pop %rbp
mov %rax, %rsi
mov %rsp, %rdi
# mov $buf, %rdi
xor %rax, %rax
call say
leave
ret
.data

View File

@ -1,36 +1,29 @@
.text
.globl ntosn, ntos
ntos: mov $1, %r9 # without new line
jmp .l0
ntosn: xor %r9, %r9 # with new line
.l0: push %rbp
.globl ntos
ntos:
push %rbp
mov %rsp, %rbp
pushq $10
mov %rdi, %rax
mov $10, %ebx
mov %rsi, %rax
xor %r8, %r8
mov $-38, %rdx
.l1:
mov $10, %rbx
.l0:
dec %r8
add $48, %rdx
movb %dl, (%rbp,%r8)
xor %rdx, %rdx
div %rbx
cmp $0, %rax
jg .l1
add $48, %rdx
dec %r8
movb %dl, (%rbp,%r8)
movb %dl, (%rsp,%r8)
cmp $0, %rax
jg .l0
mov $1, %eax
mov $1, %edi
lea (%rbp,%r8), %rsi
add %r9, %r8
lea (%rsp,%r8), %rsi
neg %r8
mov %r8, %rdx
syscall
inc %r8
mov %r8, %rcx
rep movsb
mov %r8, %rax
pop %rbp
leave
ret