Skip to content

Commit dc4a619

Browse files
committed
travis: add br3392637
Code for testcase provided by Suhwan. Reported-by: Suhwan <prada960808@gmail.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
1 parent 93c774d commit dc4a619

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed

travis/test/br3392637.asm

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
; -----------------------------------------------------------------------------
2+
; A 64-bit Linux application that writes the first 90 Fibonacci numbers. To
3+
; assemble and run:
4+
;
5+
; nasm -felf64 fib.asm && gcc fib.o && ./a.out
6+
; -----------------------------------------------------------------------------
7+
8+
global main
9+
extern printf
10+
11+
section .text
12+
main:
13+
push rbx ; we have to save this since we use it
14+
15+
mov ecx, 90 ; ecx will countdown to 0
16+
xor rax, rax ; rax will hold the current number
17+
xor rbx, rbx ; rbx will hold the next number
18+
inc rbx ; rbx is originally 1
19+
print:
20+
; We need to call printf, but we are using rax, rbx, and rcx. printf
21+
; may destroy rax and rcx so we will save these before the call and
22+
; restore them afterwards.
23+
24+
push rax ; caller-save register
25+
push rcx ; caller-save register
26+
27+
mov rdi, format ; set 1st parameter (format)
28+
mov rsi, rax ; set 2nd parameter (current_number)
29+
xor rax, rax ; because printf is varargs
30+
31+
; Stack is already aligned because we pushed three 8 byte registers
32+
call printf ; printf(format, current_number)
33+
34+
pop rcx ; restore caller-save register
35+
pop rax ; restore caller-save register
36+
37+
mov rdx, rax ; save the current number
38+
mov rax, rbx ; next number is now current
39+
add rbx, rdx ; get the new next number
40+
dec ecx ; count down
41+
jnz print ; if not done counting, do some more
42+
43+
pop rbx ; restore rbx before returning
44+
ret
45+
format:
46+
db "%20ld", 10, 0

travis/test/br3392637.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[
2+
{
3+
"description": "Test for br3392637 (pass)",
4+
"id": "br3392637",
5+
"source": "br3392637.asm",
6+
"format": "elf64",
7+
"option": "-Ox",
8+
"target": [
9+
{ "output": "br3392637.o" }
10+
]
11+
},
12+
{
13+
"description": "Test for br3392637 (nil dereference)",
14+
"ref": "br3392637",
15+
"format": "ieee",
16+
"target": [
17+
{ "stderr": "br3392637.stderr" }
18+
],
19+
"error" : "expected"
20+
}
21+
]

travis/test/br3392637.o.t

848 Bytes
Binary file not shown.

travis/test/br3392637.stderr

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
./travis/test/br3392637.asm:13: error: instruction not supported in 16-bit mode
2+
./travis/test/br3392637.asm:16: error: instruction not supported in 16-bit mode
3+
./travis/test/br3392637.asm:17: error: instruction not supported in 16-bit mode
4+
./travis/test/br3392637.asm:18: error: instruction not supported in 16-bit mode
5+
./travis/test/br3392637.asm:24: error: instruction not supported in 16-bit mode
6+
./travis/test/br3392637.asm:25: error: instruction not supported in 16-bit mode
7+
./travis/test/br3392637.asm:27: error: instruction not supported in 16-bit mode
8+
./travis/test/br3392637.asm:28: error: instruction not supported in 16-bit mode
9+
./travis/test/br3392637.asm:29: error: instruction not supported in 16-bit mode
10+
./travis/test/br3392637.asm:34: error: instruction not supported in 16-bit mode
11+
./travis/test/br3392637.asm:35: error: instruction not supported in 16-bit mode
12+
./travis/test/br3392637.asm:37: error: instruction not supported in 16-bit mode
13+
./travis/test/br3392637.asm:38: error: instruction not supported in 16-bit mode
14+
./travis/test/br3392637.asm:39: error: instruction not supported in 16-bit mode
15+
./travis/test/br3392637.asm:43: error: instruction not supported in 16-bit mode

0 commit comments

Comments
 (0)