From df9df3b662a2e957eea37b6bed653efdddf1248b Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Sun, 4 Nov 2018 11:50:16 +0300 Subject: [PATCH] test: nasm-t -- Add aouttest Signed-off-by: Cyrill Gorcunov --- travis/test/aouttest-o0.o.t | Bin 0 -> 500 bytes travis/test/aouttest-ox.o.t | Bin 0 -> 500 bytes travis/test/aouttest.asm | 83 ++++++++++++++++++++++++++++++++++++ travis/test/aouttest.json | 20 +++++++++ 4 files changed, 103 insertions(+) create mode 100644 travis/test/aouttest-o0.o.t create mode 100644 travis/test/aouttest-ox.o.t create mode 100644 travis/test/aouttest.asm create mode 100644 travis/test/aouttest.json diff --git a/travis/test/aouttest-o0.o.t b/travis/test/aouttest-o0.o.t new file mode 100644 index 0000000000000000000000000000000000000000..49132e052a83327671a252a126f8d941d214ecdd GIT binary patch literal 500 zcmX|-y-EW?6oqdfnkXx%AXrI2tc;SvfQ5l=#42E8VIj*VJ4wWe8)gShVG$usNaHI6 zUqpyt?JEd^g^wVt=S)V2{pOx~=4bERQX!F0#8F0k0vyL+8(d62r>EsI;~djQ==2PzO|~WOrx=vR4Y1d z#~RKeYp4DGU2L$jD!h9GJb+Drx{9oYaR;#=66_)_Bj5La&F8Kpk+mc5^BqNeCw?88 z=iLarrnd!_oGZeA&|3iqfIjQtoh1+gf1mKZX8^Sb8*vV}X9zC6<~v$|_l>{}V6Vr3 zXQF{YA375GCP<`BYGbSZ#i5Q{N=wu=N?D2Gte;u)caG9Eb3o6kp>-lty5ofJ`eF|f F`2|`BUjYCB literal 0 HcmV?d00001 diff --git a/travis/test/aouttest-ox.o.t b/travis/test/aouttest-ox.o.t new file mode 100644 index 0000000000000000000000000000000000000000..9b282a04901e2bb2fd12ae0e18eab5c212bbca1d GIT binary patch literal 500 zcmX|-ze)o^5XL7EO_UQ<5UeC1Rz^u-z{0>a!75;5VIj*Uw@Ji3H|#B%!s5U*AiknaOE|>qYL=H4BP_l z^#t%4F*4{wpM-A$31zg6to#?pD(Xr_Vqm1SB%(A)t@%60(lv9$o|R+kL@HI^3E%bQ H9whV&4AWq< literal 0 HcmV?d00001 diff --git a/travis/test/aouttest.asm b/travis/test/aouttest.asm new file mode 100644 index 000000000..a11824f67 --- /dev/null +++ b/travis/test/aouttest.asm @@ -0,0 +1,83 @@ +; test source file for assembling to a.out +; build with: +; nasm -f aout aouttest.asm +; gcc -o aouttest aouttest.c aouttest.o +; (assuming your gcc is a.out) + +; This file should test the following: +; [1] Define and export a global text-section symbol +; [2] Define and export a global data-section symbol +; [3] Define and export a global BSS-section symbol +; [4] Define a non-global text-section symbol +; [5] Define a non-global data-section symbol +; [6] Define a non-global BSS-section symbol +; [7] Define a COMMON symbol +; [8] Define a NASM local label +; [9] Reference a NASM local label +; [10] Import an external symbol +; [11] Make a PC-relative call to an external symbol +; [12] Reference a text-section symbol in the text section +; [13] Reference a data-section symbol in the text section +; [14] Reference a BSS-section symbol in the text section +; [15] Reference a text-section symbol in the data section +; [16] Reference a data-section symbol in the data section +; [17] Reference a BSS-section symbol in the data section + + BITS 32 + GLOBAL _lrotate ; [1] + GLOBAL _greet ; [1] + GLOBAL _asmstr ; [2] + GLOBAL _textptr ; [2] + GLOBAL _selfptr ; [2] + GLOBAL _integer ; [3] + EXTERN _printf ; [10] + COMMON _commvar 4 ; [7] + + SECTION .text + +; prototype: long lrotate(long x, int num); +_lrotate: ; [1] + push ebp + mov ebp,esp + mov eax,[ebp+8] + mov ecx,[ebp+12] +.label rol eax,1 ; [4] [8] + loop .label ; [9] [12] + mov esp,ebp + pop ebp + ret + +; prototype: void greet(void); +_greet mov eax,[_integer] ; [14] + inc eax + mov [localint],eax ; [14] + push dword [_commvar] + mov eax,[localptr] ; [13] + push dword [eax] + push dword [_integer] ; [1] [14] + push dword _printfstr ; [13] + call _printf ; [11] + add esp,16 + ret + + SECTION .data + +; a string +_asmstr db 'hello, world', 0 ; [2] + +; a string for Printf +_printfstr db "integer==%d, localint==%d, commvar=%d" + db 10, 0 + +; some pointers +localptr dd localint ; [5] [17] +_textptr dd _greet ; [15] +_selfptr dd _selfptr ; [16] + + SECTION .bss + +; an integer +_integer resd 1 ; [3] + +; a local integer +localint resd 1 ; [6] diff --git a/travis/test/aouttest.json b/travis/test/aouttest.json new file mode 100644 index 000000000..1de51e292 --- /dev/null +++ b/travis/test/aouttest.json @@ -0,0 +1,20 @@ +[ + { + "description": "Test aout format (-Ox)", + "id": "aouttest", + "format": "aout", + "source": "aouttest.asm", + "option": "-Ox", + "target": [ + { "output": "aouttest-ox.o" } + ] + }, + { + "description": "Test aout format (-O0)", + "ref": "aouttest", + "option": "-O0", + "target": [ + { "output": "aouttest-o0.o" } + ] + } +]