فهرست منبع

Merge branch 'master' of dtelenkov:Home/codewars

dtelenkov 5 روز پیش
والد
کامیت
79b5cad166
6فایلهای تغییر یافته به همراه56 افزوده شده و 17 حذف شده
  1. 4 14
      asm/Makefile
  2. 3 3
      asm/test_5.asm
  3. BIN
      asm/test_5.exe
  4. BIN
      asm/test_5.o
  5. 36 0
      asm/test_6.asm
  6. 13 0
      asm/test_7.asm

+ 4 - 14
asm/Makefile

@@ -1,18 +1,8 @@
-test_2:
-	as test_2.asm -o test_2.o
-	ld test_2.o -o test_2.exe
+file_name = $(file)
 
-test_3:
-	as test_3.asm -o test_3.o
-	ld test_3.o -o test_3.exe
-
-test_4:
-	as test_4.asm -o test_4.o
-	ld test_4.o -o test_4.exe
-
-test_5:
-	as test_5.asm -o test_5.o
-	ld test_5.o -o test_5.exe
+all:
+	as $(file).asm -o $(file).o
+	ld $(file).o -o $(file).exe
 
 clean:
 	rm -rf *.o *.exe

+ 3 - 3
asm/test_5.asm

@@ -8,10 +8,10 @@ _start:
     // print "test\n"
     movq $1, %rax
     movq $1, %rdi
-    movb $data, %rsi
+    movq $data, %rsi
     leaq data, %rsi
-    leaq data(%rip), %rsi // относительная адресация
-    movq %5, %rdx
+    leaq data(%rip), %rsi; // относительная адресация
+    movq $5, %rdx
 
     // exit
     movq $60, %rax

BIN
asm/test_5.exe


BIN
asm/test_5.o


+ 36 - 0
asm/test_6.asm

@@ -0,0 +1,36 @@
+    .file "test_6.asm"
+    .data
+data:
+    .byte 0x12
+    .byte 0x34
+    .word 0x1234
+    .word 0x5678
+
+    .text
+    .global _start
+
+_start:
+
+    movq %rsp, %rbp
+    subq $6, %rsp; // вычесть число 6 из %rsp
+
+    leaq data, %rbx; // загрузить адрес сигмента данных в регистр rbx
+    movb 0(%rbx), %al
+    movb %al, 0(%rsp)
+
+    movb 1(%rbx), %al
+    movb %al, 1(%rsp)
+
+    movw 2(%rbx), %ax
+    movw %ax, 1(%rsp)
+
+    movw 4(%rbx), %ax
+    movw %ax, 4(%rsp)
+
+M:
+    movq %rbp, %rsp
+
+    //exit
+    movq $60, %rax
+    movq $0, %rdi
+    syscall

+ 13 - 0
asm/test_7.asm

@@ -0,0 +1,13 @@
+    .file "test_7.asm"
+    .data
+str:
+    .ascii "test"
+    .text
+    .global _start
+_start:
+
+    //exit
+    movq $60, %rax
+    movq $0, %rdi
+
+