• Forum
  • Lounge
  • I need help ASAP, if you can help it’d

 
I need help ASAP, if you can help it’d be greatly appreciated.

main.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
	.file	"main.lol"
	.text
	.p2align 4,,15
	.def	__tcf_0;	.scl	3;	.type	32;	.endef
	.seh_proc	__tcf_0
__tcf_0:
.LFB2250:
	.seh_endprologue
	leaq	_ZStL8__ioinit(%rip), %rcx
	jmp	_ZNSt8ios_base4InitD1Ev
	.seh_endproc
	.def	__main;	.scl	2;	.type	32;	.endef
	.section .rdata,"dr"
	.align 8
.LC1:
	.ascii "Enter number of tickets to purchase: \0"
	.section	.text.startup,"x"
	.p2align 4,,15
	.globl	main
	.def	main;	.scl	2;	.type	32;	.endef
	.seh_proc	main
main:
.LFB1764:
	subq	$56, %rsp
	.seh_stackalloc	56
	.seh_endprologue
	call	__main
	movq	.refptr._ZSt4cout(%rip), %rcx
	leaq	.LC1(%rip), %rdx
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	.refptr._ZSt3cin(%rip), %rcx
	leaq	44(%rsp), %rdx
	movl	$0, 44(%rsp)
	call	_ZNSirsERi
	movl	44(%rsp), %eax
	cmpl	$5, %eax
	jg	.L8
	testl	%eax, %eax
	jle	.L7
	pxor	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	mulsd	.LC3(%rip), %xmm0
.L5:
	movsd	.LC4(%rip), %xmm4
	movsd	.LC6(%rip), %xmm3
	movsd	.LC5(%rip), %xmm5
	mulsd	%xmm4, %xmm0
	movapd	%xmm0, %xmm2
	movapd	%xmm0, %xmm1
	andpd	%xmm3, %xmm2
	ucomisd	%xmm2, %xmm5
	jbe	.L6
	cvttsd2siq	%xmm0, %rax
	pxor	%xmm2, %xmm2
	movsd	.LC7(%rip), %xmm5
	andnpd	%xmm0, %xmm3
	cvtsi2sdq	%rax, %xmm2
	cmpnlesd	%xmm2, %xmm1
	andpd	%xmm5, %xmm1
	addsd	%xmm2, %xmm1
	orpd	%xmm3, %xmm1
.L6:
	divsd	%xmm4, %xmm1
	movq	.refptr._ZSt4cout(%rip), %rcx
	call	_ZNSo9_M_insertIdEERSoT_
	leaq	43(%rsp), %rdx
	movl	$1, %r8d
	movb	$10, 43(%rsp)
	movq	%rax, %rcx
	call	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_x
	xorl	%eax, %eax
	addq	$56, %rsp
	ret
.L8:
	pxor	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	mulsd	.LC2(%rip), %xmm0
	jmp	.L5
.L7:
	pxor	%xmm0, %xmm0
	jmp	.L5
	.seh_endproc
	.p2align 4,,15
	.def	_GLOBAL__sub_I_main;	.scl	3;	.type	32;	.endef
	.seh_proc	_GLOBAL__sub_I_main
_GLOBAL__sub_I_main:
.LFB2251:
	subq	$40, %rsp
	.seh_stackalloc	40
	.seh_endprologue
	leaq	_ZStL8__ioinit(%rip), %rcx
	call	_ZNSt8ios_base4InitC1Ev
	leaq	__tcf_0(%rip), %rcx
	addq	$40, %rsp
	jmp	atexit
	.seh_endproc
	.section	.ctors,"w"
	.align 8
	.quad	_GLOBAL__sub_I_main
.lcomm _ZStL8__ioinit,1,1
	.section .rdata,"dr"
	.align 8
.LC2:
	.long	0
	.long	1078472704
	.align 8
.LC3:
	.long	858993459
	.long	1078895411
	.align 8
.LC4:
	.long	0
	.long	1079574528
	.align 8
.LC5:
	.long	0
	.long	1127219200
	.align 16
.LC6:
	.long	-1
	.long	2147483647
	.long	0
	.long	0
	.align 8
.LC7:
	.long	0
	.long	1072693248
	.ident	"GCC: (GNU) 7.1.0"
	.def	_ZNSt8ios_base4InitD1Ev;	.scl	2;	.type	32;	.endef
	.def	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc;	.scl	2;	.type	32;	.endef
	.def	_ZNSirsERi;	.scl	2;	.type	32;	.endef
	.def	_ZNSo9_M_insertIdEERSoT_;	.scl	2;	.type	32;	.endef
	.def	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_x;	.scl	2;	.type	32;	.endef
	.def	_ZNSt8ios_base4InitC1Ev;	.scl	2;	.type	32;	.endef
	.def	atexit;	.scl	2;	.type	32;	.endef
	.section	.rdata$.refptr._ZSt3cin, "dr"
	.globl	.refptr._ZSt3cin
	.linkonce	discard
.refptr._ZSt3cin:
	.quad	_ZSt3cin
	.section	.rdata$.refptr._ZSt4cout, "dr"
	.globl	.refptr._ZSt4cout
	.linkonce	discard
.refptr._ZSt4cout:
	.quad	_ZSt4cout


Assemble with:
g++ main.s -o main

g++ (GCC) 7.1.0
build/host/target: x86_64-w64-mingw32
Last edited on
@Ganado, ROFL :)

@veronicamarrufo,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <cctype>
#include <limits>

int main()
{
   std::cout << "Do you want someone to do all the work for you? ";
   char answer { };
   std::cin >> answer;

   std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

   if (std::toupper(answer) == 'Y' ) { std::cout << "Post it in the Jobs section.\n"; }

   else { std::cout << "Show what you have coded so far.\n"; }

   std::cout << "Good luck.\n";
}
@Ganado That was the most amazing thing I’ve seen all day.
lmao, with the first post now gone, it looks like I'm asking for help with assembly.
That was also my first impression. What did the original post ask? And did you generate the assembly code from c++ code that would have been the answer to that question? The mangled names and the label names look like g++ assembly output to me.
Yes it's g++ MinGW assembly. Probably won't build on linux, because of that SEH stuff. The original post asked (without showing any effort) for a program that did some really simple stuff (calculated the cost of buying tickets when there's a discount if you buy more than 5).

The joke was that they asked for a program, but didn't specify which language. The assembly is 100% a solution to the original question, and this was posted in the Lounge section and not the C++ sections. I even made sure I rounded the decimal places to the hundredths. But now I've over-explained the joke.
Last edited on
I like it. Maybe we should start giving them incoherent C++ solutions...
Ganado wrote:
The assembly is 100% a solution to the original question

I suspected as such, not that I had a clue about the assembly. That is why I laughed at it.

But now I've over-explained the joke.

I still find it intensely hilarious. :)

Probably more so since the punchline was Lucy 'splained.
Ganado wrote:
The assembly is 100% a solution to the original question

Before the question was deleted the OP said they had found the solution on their own and complained your reply was of no help. "...thanks for nothing..." was the response.
Oh. That's hilarious. Guess they'll keep copying until it eventually bites them in the--.
Thank you Ganado for the explanation.

@jonnin
Like an obfuscated C++ contest but for low-effort homework related questions?
exactly!
Topic archived. No new replies allowed.