Dmitry Telenkov 22 годин тому
батько
коміт
50fb620659
5 змінених файлів з 24 додано та 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. 17 0
      asm/test_6.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



+ 17 - 0
asm/test_6.asm

@@ -0,0 +1,17 @@
+    .file "test_6.asm"
+    .data
+data:
+    .byte 0x12
+    .byte 0x34
+    .word 0x1234
+    .word 0x5678
+
+    .text
+    .global _start
+
+_start:
+
+    //exit
+    movq $60, %rax
+    movq $0, %rdi
+    syscall