about summary refs log tree commit diff stats
path: root/example/samples/human.S
diff options
context:
space:
mode:
Diffstat (limited to 'example/samples/human.S')
-rw-r--r--example/samples/human.S22
1 files changed, 19 insertions, 3 deletions
diff --git a/example/samples/human.S b/example/samples/human.S
index 750aa5b7..6cdeab0f 100644
--- a/example/samples/human.S
+++ b/example/samples/human.S
@@ -1,11 +1,11 @@
 	;;  Walk a human link list and print its information
 main:
 	TEST       RDI, RDI
-	JZ         end
+	JZ         next
 
 	PUSH       RBX
 	MOV        RBX, RDI
-loop:
+loop_arg:
 	LEA        RSI, QWORD PTR [RBX+0x10]
 	LEA        RDI, QWORD PTR [name-_+RIP]
 	XOR        EAX, EAX
@@ -23,9 +23,23 @@ loop:
 
 	MOV        RBX, QWORD PTR [RBX]
 	TEST       RBX, RBX
-	JNZ        loop
+	JNZ        loop_arg
 
 	POP        RBX
+next:
+
+
+	LEA        RBX, QWORD PTR [struct_human_ptr-_+RIP]
+loop_global:
+	CMP        RBX, 0
+	JZ         end
+
+	LEA        RSI, QWORD PTR [RBX+0x10]
+	LEA        RDI, QWORD PTR [name-_+RIP]
+	XOR        EAX, EAX
+	CALL       printf
+	MOV        RBX, QWORD PTR [RBX]
+	JMP        loop_global
 end:
 	RET
 
@@ -39,3 +53,5 @@ height:
 .string "Height: %d\n"
 name:
 .string "Name: %s\n"
+struct_human_ptr:
+.dword 0xdead, 0xcafe