[SOLVED] Why assembler x86 in c++ doesn't work? | SoloLearn: Learn to code for FREE!

+7

[SOLVED] Why assembler x86 in c++ doesn't work?

Code: https://code.sololearn.com/cWBsGAnND3iY/?ref=app

1/16/2021 3:25:53 PM

YAQUB꧁NEW꧂

26 Answers

New Answer

+10

i see you made efforts in trying to fix it. better than it was but still doesnt compile. i decided to help a bit. here is same code but with "GAS" syntax. https://code.sololearn.com/ciWbDOQ6u0O6/?ref=app i hope you notice all the differences.

+13

i agree with martin 100% except for one thing: msdos no longer exists. retro dos games fanboys are outraged reading this. hhh

+12

disclaimer: "please dont try this at home. these code stunts are performed by trained professionals"

+9

Martin Taylor definitely install dosbox and start playing games. even better is to use Qemu and have an imaged harddrive onto which you install DOS (may it be freedos). While on DOS on QEMU you can also do some assembly there as well. one of my fav game these days is R.O.T.T, just for the sound track. DOS games had the best sounds IMO :)

+8

꧁Ýąqůb꧂(New) you still didn't get it. C/C++ are just mediums he uses to access SL's command processor to get his hands on gcc to copile and run his codes.

+8

well your code doesnt even compile. so i think you are missing many concept at this point, which could just take a bit of learning practice and experimentations. best to start slow.

+7

not just for me but i did practice a lot you know, so probably best to take learning at a slow steady pace. one must learn to walk straight before he goes running.

+6

Because here you are writing an assembler code and assuming that your compiler (which only understands C++) will understand it. Check out any of the ChillPill 's code for example. What he do is put the code in another file and use gcc to compile that code. And as he can't directly acess SL's server, thus uses C++'s system() function to "hackingly" access their command processor.

+6

hhh. there are no fast way.

+6

ChillPill ngl, I was literally laughing this whole thread (espcially his C code, no offence) ꧁Ýąqůb꧂(New) "But now I am going to fix the code" Calm down bruh. Stop with the assembly fetish bro, take a chill pill and start slow as ChillPill said. And where did you even get the assembly code? It's total rubbish for the GCC assembler.

+6

Line 24 of your code has an unnecessary '}' character in it. It would also be beneficial to surround the code with an escape word to permit parenthesis within the code R"MASM( your code here. )MASM"; The main problem is that the assembly code you are using is 30 year old 16-bit MS-DOS Microsoft Macro Assembler (masm) code. You do know that 16-bit MS-DOS code is not supported on 64-bit machines? GCC probably doesn't like masm syntax either. The .model tiny masm directive is for informing the assembler that a 16-bit ms-dos .com format file is being requested. Modern systems use a flat memory model. The int 21h instruction is a software interrupt instruction to request an ms-dos function (which no longer exists). Int 21h, function 9 = write string to console in ms-dos. So it's not really surprising that the assembler refused to assemble your code. If you are so determined to use masm to learn ms-dos assembly language then you will need to install an ms-dos emulator such as dosbox and find an old copy of masm 5.1 for dos.

+5

@ChillPill, Where did I say ms-dos exists? I informed the OP that the reason their code will not assemble is because it is 16-bit x86 MASM specific MS-DOS assembly language code that they are trying to pass to an x64 gnu assembler. Though dos is still available in the form of rom dos for embedded systems as well as FreeDOS and the DosBox emulator. https://www.datalight.com/products/rom-dos/ https://www.freedos.org/ https://www.dosbox.com/ I may have to install dosbox and dig out one of my old backup CDs for a nostalgic trip to masm and codeview land. I think the retro games fanboys wrote dosbox.

+5

ChillPill I try it in my home without Trainer Now I am in Hospital 🏥😂

+2

😂 So.. Assembly only for ChillPill

+2

ChillPill gold words. But I choose hard way. Fast and experimental

+2

😂 It didn't work out. Who did I lie to? I must learn more. But now I am going to fix code.

+2

Sujan Paudel be careful with assembly

+2

For me Turbo C++ with Tasm was a brilliant combination and allowed for so many hacks that otherwise would have either been impossible or very time consuming 🙂

+1

I understood I must write this code in C compiler without any hacking compiler.

+1

Agreed ChillPill ! 👍😄😅 The codes should be only used for learning purposes for those who aren't aware and trained to write such codes.