aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2020-11-04 13:15:52 +0300
committerCyrill Gorcunov <gorcunov@gmail.com>2020-11-04 13:15:52 +0300
commitdc4a6194265962f288b73cca8097b850283bfb5f (patch)
tree800006dbf973ed37d533f19f686d0ae1b63985ba
parent93c774d482694643cafbc82578ac8b729fb5bc8b (diff)
downloadnasm-dc4a6194265962f288b73cca8097b850283bfb5f.tar.gz
nasm-dc4a6194265962f288b73cca8097b850283bfb5f.tar.xz
nasm-dc4a6194265962f288b73cca8097b850283bfb5f.zip
travis: add br3392637
Code for testcase provided by Suhwan. Reported-by: Suhwan <prada960808@gmail.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-rw-r--r--travis/test/br3392637.asm46
-rw-r--r--travis/test/br3392637.json21
-rw-r--r--travis/test/br3392637.o.tbin0 -> 848 bytes
-rw-r--r--travis/test/br3392637.stderr15
4 files changed, 82 insertions, 0 deletions
diff --git a/travis/test/br3392637.asm b/travis/test/br3392637.asm
new file mode 100644
index 00000000..1a5ee975
--- /dev/null
+++ b/travis/test/br3392637.asm
@@ -0,0 +1,46 @@
+; -----------------------------------------------------------------------------
+; A 64-bit Linux application that writes the first 90 Fibonacci numbers. To
+; assemble and run:
+;
+; nasm -felf64 fib.asm && gcc fib.o && ./a.out
+; -----------------------------------------------------------------------------
+
+ global main
+ extern printf
+
+ section .text
+main:
+ push rbx ; we have to save this since we use it
+
+ mov ecx, 90 ; ecx will countdown to 0
+ xor rax, rax ; rax will hold the current number
+ xor rbx, rbx ; rbx will hold the next number
+ inc rbx ; rbx is originally 1
+print:
+ ; We need to call printf, but we are using rax, rbx, and rcx. printf
+ ; may destroy rax and rcx so we will save these before the call and
+ ; restore them afterwards.
+
+ push rax ; caller-save register
+ push rcx ; caller-save register
+
+ mov rdi, format ; set 1st parameter (format)
+ mov rsi, rax ; set 2nd parameter (current_number)
+ xor rax, rax ; because printf is varargs
+
+ ; Stack is already aligned because we pushed three 8 byte registers
+ call printf ; printf(format, current_number)
+
+ pop rcx ; restore caller-save register
+ pop rax ; restore caller-save register
+
+ mov rdx, rax ; save the current number
+ mov rax, rbx ; next number is now current
+ add rbx, rdx ; get the new next number
+ dec ecx ; count down
+ jnz print ; if not done counting, do some more
+
+ pop rbx ; restore rbx before returning
+ ret
+format:
+ db "%20ld", 10, 0
diff --git a/travis/test/br3392637.json b/travis/test/br3392637.json
new file mode 100644
index 00000000..3a3de297
--- /dev/null
+++ b/travis/test/br3392637.json
@@ -0,0 +1,21 @@
+[
+ {
+ "description": "Test for br3392637 (pass)",
+ "id": "br3392637",
+ "source": "br3392637.asm",
+ "format": "elf64",
+ "option": "-Ox",
+ "target": [
+ { "output": "br3392637.o" }
+ ]
+ },
+ {
+ "description": "Test for br3392637 (nil dereference)",
+ "ref": "br3392637",
+ "format": "ieee",
+ "target": [
+ { "stderr": "br3392637.stderr" }
+ ],
+ "error" : "expected"
+ }
+]
diff --git a/travis/test/br3392637.o.t b/travis/test/br3392637.o.t
new file mode 100644
index 00000000..e96bb76b
--- /dev/null
+++ b/travis/test/br3392637.o.t
Binary files differ
diff --git a/travis/test/br3392637.stderr b/travis/test/br3392637.stderr
new file mode 100644
index 00000000..5016bd40
--- /dev/null
+++ b/travis/test/br3392637.stderr
@@ -0,0 +1,15 @@
+./travis/test/br3392637.asm:13: error: instruction not supported in 16-bit mode
+./travis/test/br3392637.asm:16: error: instruction not supported in 16-bit mode
+./travis/test/br3392637.asm:17: error: instruction not supported in 16-bit mode
+./travis/test/br3392637.asm:18: error: instruction not supported in 16-bit mode
+./travis/test/br3392637.asm:24: error: instruction not supported in 16-bit mode
+./travis/test/br3392637.asm:25: error: instruction not supported in 16-bit mode
+./travis/test/br3392637.asm:27: error: instruction not supported in 16-bit mode
+./travis/test/br3392637.asm:28: error: instruction not supported in 16-bit mode
+./travis/test/br3392637.asm:29: error: instruction not supported in 16-bit mode
+./travis/test/br3392637.asm:34: error: instruction not supported in 16-bit mode
+./travis/test/br3392637.asm:35: error: instruction not supported in 16-bit mode
+./travis/test/br3392637.asm:37: error: instruction not supported in 16-bit mode
+./travis/test/br3392637.asm:38: error: instruction not supported in 16-bit mode
+./travis/test/br3392637.asm:39: error: instruction not supported in 16-bit mode
+./travis/test/br3392637.asm:43: error: instruction not supported in 16-bit mode