flat assembler
Message board for the users of flat assembler.
Index
> Windows > I have the assembler, now what? Goto page Previous 1, 2, 3, 4, 5, 6 Next |
Author |
|
C0deHer3tic 29 Mar 2017, 19:12
@ctl3d32, That link is not working.... It may be just me though.
|
|||
29 Mar 2017, 19:12 |
|
rugxulo 29 Mar 2017, 19:47
C0deHer3tic wrote: @ctl3d32, That link is not working.... It may be just me though. Try again, it works for me. Also, WayBack has it as well. |
|||
29 Mar 2017, 19:47 |
|
C0deHer3tic 29 Mar 2017, 20:38
Thank you, rugxulo. It works now.
|
|||
29 Mar 2017, 20:38 |
|
rugxulo 29 Mar 2017, 21:00
C0deHer3tic wrote:
If you're only going to do the same ol' boring stuff that you can do in C, then it's not worth doing. Just learning "mov ax,word [mydata]" is not beneficial enough. Sure, SIMD can be practical, but it's also highly system-specific. Also, x86 asm can do rotates and use flags (e.g. carry) to great effect, something C normally can't do. But beyond that, it's not super unique. (Reading in, out ports is also too low-level in most modern OSes, so that also isn't usually available.) Quote:
Unfortunately, there's more to assembly than just raw instructions. But at least old NASM 0.98.39 (circa 2005, up through SSE2) had some good instruction listings. Quote:
It just seems like a red flag, a situation asking for trouble. "Let's learn xyz flavor of the month, it'll live forever!" I'm no Comp. Sci. professional, but I feel like all the professors would strongly argue against too much system-specific code. Some is okay for learning, but don't obsess over it, it won't last! Quote:
2k and XP are dead. Vista will be dead (totally unsupported) in less than a month. Win7 is already considered "too old" for some things. "Win32" (API) is "legacy" and outdated in lieu of "Metro" (Win8). But IA-32 is also deprecated in lieu of AMD64, which is finally mature (after many years), thus even Win10 requires a late-model P4, minimum! "My current working environment" ... Obviously it's hard to program without a working computer and toolset (although maybe Dijkstra would disagree). I'm not really suggesting you learn OpenRISC in your browser! But beware, obsoletion is coming soon! Emulators are your only friend in that case. Quote:
I'm not a professional, nor well-trained, nor do I care about latest trends. So I eschew AMD64 (programming, but it's fine for simple web browsing!) because I don't care. On some level I think we jumped the shark with so many additions to x86. Having said that, it's ridiculous to pretend that AMD64 is going away or isn't mature. It's just not my cup of tea. So I don't have to care. But it would make more sense, from a longevity standpoint, to target top tier rather than deprecated IA-32. (Again, I honestly don't care, I still poke around in DOS, usually in emulators but also natively.) I just don't see the point of intentionally going against the grain for a long-term goal. I only do it because, frankly, I don't have the energy to learn/migrate/modernize everything (although I did learn some Wirth languages in recent years, which was probably wise given the volatility of modern computing and the weakened reliance on binary compatibility). Quote:
I dislike Windows, but it works for simple end use. I don't program for it directly, as it's not interesting to me. Yes, I almost forgot about WINE (which, same as WSL, is API translation and not slow emulation). So maybe targeting Windows isn't a complete waste of time. I also dislike the throwaway nature of it all, but it's not impossible to find old Windows editions (e.g. MSDN). Linux is also somewhat volatile (except LTS), but at least it's super easy to find/download and has (some) standardized tools worth relying on. Don't get me wrong, Windows isn't going anywhere and is still extremely popular. I just don't prefer it at all these days. From a programming standpoint (unless you want to sell software), you don't need Windows, and some things are easier (or even faster) on Linux. BTW, does WINE even support Win64?? Not AFAIK. But WSL is Linux 64-bit only. So that's another wrinkle. I still feel that 64-bit is heavily preferred these days, whether we like it or not. Quote:
Sorry, maybe I'm confusing you with my own confusion! It's a messy world. Simplicity is a virtue, but it's almost impossible these days as everything is overcomplicated. I just don't trust anybody to preserve anything anymore, even if it works, even if it was well-tested and developed over decades. Therefore, I don't recommend jumping on a sinking ship, even if it technically "works", if only because I assume it will be thrown away "soon". So, honestly, you're fighting against the grain wasting time with IA-32. A million geeks would yell and scream at you for doing so intentionally. So I can't in good conscience tell you to do what everyone else hates. But it's not a crime, just unpopular and "going away eventually". |
|||
29 Mar 2017, 21:00 |
|
Trinitek 29 Mar 2017, 21:20
rugxulo wrote: I just don't trust anybody to preserve anything anymore, even if it works, even if it was well-tested and developed over decades. Therefore, I don't recommend jumping on a sinking ship, even if it technically "works", if only because I assume it will be thrown away "soon". So, honestly, you're fighting against the grain wasting time with IA-32. A million geeks would yell and scream at you for doing so intentionally. So I can't in good conscience tell you to do what everyone else hates. But it's not a crime, just unpopular and "going away eventually". |
|||
29 Mar 2017, 21:20 |
|
rugxulo 29 Mar 2017, 21:38
Trinitek wrote: He's picked his toolset and target OS. Distracting him with superfluous arguments about platform longetivity and stack alignments is doing him a disservice. Let's not forget what's actually going on here; he needs something to get his foot in the door to learn assembly. AMD64 and Linux/whatever can come later. It would be dishonest to mislead or omit crucial information about deprecation. Learning assembly on an obsolete platform (e.g. DOS) may be fun, but it's not directly useful anymore. Sorry, but IA-32 is every bit as old. Just because it does all you need from it doesn't mean it's wise advice to tell anyone else to go back in time to target an outdated platform. Hey, I'm sympathetic, but it's just not good advice. C0deHer3tic wrote:
Why in the world would you recommend 32-bit when he/she already has a 64-bit system?? Are they ever going to run their code on a 32-bit only machine (e.g. early P4s)? Then why bother?? The last thing we want is for him/her to come back in a few years and say, "I wasted my time, I didn't know that nobody used Win32 anymore." It's like those people who say, "Learn C before C++", which isn't fair and is mostly a waste of time. I don't want to overreact here, but it's better to hear tough love in the beginning than find out the hard way later. |
|||
29 Mar 2017, 21:38 |
|
C0deHer3tic 29 Mar 2017, 21:45
rugxulo wrote: If you're only going to do the same ol' boring stuff that you can do in C, then it's not worth doing. Just learning "mov ax,word [mydata]" is not beneficial enough. I am eager to learn assembly. What I am doing, since I have no step by step guides, is making C programs, and trying to redo the same thing in C. That is all I know, seeing that is all I have been taught so far. I don't need to use printf, scanf, or any C function whatsoever, I am merely the student, and you all are my teachers. Quote: It just seems like a red flag, a situation asking for trouble. "Let's learn xyz flavor of the month, it'll live forever!" I'm no Comp. Sci. professional, but I feel like all the professors would strongly argue against too much system-specific code. Some is okay for learning, but don't obsess over it, it won't last! I am just wanting to learn this on my current platform right now. I will, and do plan on branching out. I learned C in windows first, then learned how the libraries and coding changed for Linux, and thus learned that as well. I have never owned or programmed for a Macintosh, and so I can safely say that is the only thing I am not really apt to learning for quite a while. Trinitek gets it. He/she understands that this is my chosen programming environment to learn in. By all means give me code foreign to the C functions. But pardon me, I am a beginner. I want to learn assembly, and not merely assembly running possible C functions in it. However I am the student, and am learning from what you all are saying. I thank you all very much for the time and patience with me. It is hard for me to understand the code, but I am trying. - Sincerely and thankful to you all, C0deHer3tic _________________ - Just because something is taught one way, does not mean there is not a different way, possibly more efficient. - |
|||
29 Mar 2017, 21:45 |
|
Trinitek 29 Mar 2017, 21:52
C0deHer3tic wrote: This works. However I am not understanding the pointer thing. Code: int myNum = 42; Code: myNum dq 42 Code: mov eax, myNum ; eax <- ptr to QWORD that contains 42 mov eax, [myNum] ; eax <- 42 |
|||
29 Mar 2017, 21:52 |
|
Trinitek 29 Mar 2017, 22:14
rugxulo wrote: Why in the world would you recommend 32-bit when he/she already has a 64-bit system?? Are they ever going to run their code on a 32-bit only machine (e.g. early P4s)? Then why bother?? rugxulo wrote: The last thing we want is for him/her to come back in a few years and say, "I wasted my time, I didn't know that nobody used Win32 anymore." It's like those people who say, "Learn C before C++", which isn't fair and is mostly a waste of time. |
|||
29 Mar 2017, 22:14 |
|
C0deHer3tic 29 Mar 2017, 22:30
Using this reference:
http://www.friedspace.com/assembly/loops.php I got this code: Code: format PE Console entry start include 'win32a.inc' section 'idata' import data readable library kernel32, "kernel32.dll", \ msvcrt, "msvcrt.dll" import kernel32, \ ExitProcess, "ExitProcess" import msvcrt, \ printf, "printf" ;section 'data' data readable writeable prints db "",1010b,0 prompt1 db "Enter a number:",1001b,0000b prompt2 db "Now enter another number:",9,0 result db "%d added to %d = %d.",1010b,0 getNumber db "%d",0 section '.main' data readable lines: mov ecx, 4 myLoop: push prints call [printf] add esp, 4 dec ecx LOOP myLoop ret start: call lines push 0 call [ExitProcess] And it loops forever....Why not only 4 times? I want the ability print as many lines as I want. Like this C func I made: Code: void lines() { printf("\n"); return; } // Original code is /*void lines(int x) { int i; for(i=0;i!=x;i++) printf("\n\n"); return; } */ However I have no idea how to pass a variable to a func like lines(4) in assembly. What am I doing wrong? Honestly, am I moving too fast? Or not moving at all? haha _________________ - Just because something is taught one way, does not mean there is not a different way, possibly more efficient. - |
|||
29 Mar 2017, 22:30 |
|
Trinitek 29 Mar 2017, 22:43
The loop instruction decrements ecx for you, so dec ecx isn't necessary.
Second, the stdcall convention says that ecx is designated for use by functions, so you need to save it before and restore it after calling printf somehow, either to a global variable, a local variable on the stack, or a separate register that isn't in use (and isn't designated for use by stdcall!). |
|||
29 Mar 2017, 22:43 |
|
C0deHer3tic 29 Mar 2017, 22:53
Thank you.
|
|||
29 Mar 2017, 22:53 |
|
system error 29 Mar 2017, 23:09
@Heretic
I warned you long ago that jumping straight into some advanced level in assembly programming wouldn't do you any good and would lead to even more confusions. What you're doing right now is actually delaying your progress and will take u longer than it should to understand simple asm concepts. Your early focus should be to get yourself comfortable and well-acquainted around the CPU components, - registers, memory and stack and the corresponding instructions. You need to re-calibrate your learning focus to the correct one. In assembly programming, we don't actually need printf or any C library. We use them as a tool of proof only. We use them to visually verify the feedback from the CPU (displaying the registers, memory content etc). That's all there is. That's the reason I gave you the code template and it's C counter part to begin with. You been beating around the bush for quite a few days now without asking how to actually see the value of a register using printf service - that's the kind of question that you should ask us here as of now. But I don't see any of that. You're not focusing on the real objective of learning assembly language - how to 'talk' to the CPU and its components. Last edited by system error on 29 Mar 2017, 23:17; edited 1 time in total |
|||
29 Mar 2017, 23:09 |
|
Furs 29 Mar 2017, 23:12
@rugxulo: Wine supports 64-bit for a long time yet, and running 32-bit in the same "windows system" (called a wineprefix) just like Windows with WOW64. I actually use Wine for 95% of windows programs or so (and those are the majority of apps I run under Linux lol), rest few in VMs since Wine doesn't work well with them.
It can also run 16-bit Windows (not DOS) programs natively if you use a 32-bit "wineprefix" (that is a "32-bit windows system" without syswow64 etc). No emulation. Which is not a big deal since you can have as many prefixes as you want (assuming you have hard disk space ofc). But who said Win32 API (including 64) or even 32 bit is deprecated at all? Besides, you're making too much of an issue out of this thing. If he ends up in a place where calling conventions are the only thing he doesn't know about (i.e. difference between 64-bit and 32-bit for these simple codes), that would be good already. Since that's quite trivial compared to rest of asm... |
|||
29 Mar 2017, 23:12 |
|
system error 29 Mar 2017, 23:27
Furs wrote: @system error: You know your behavior is exactly that of a kid not getting his way in an argument, covering his ears while shouting the same thing over and over again, right? Looks like you could use some more schooling First thing, I want to know what do you mean by "bloat"? Where in MS64 ABI it is 'bloated'? Code: func_fastcall: sub rsp,8 ... do your things add rsp,8 ret vs your "clean" stdcall calling convention; Code: func_furr: push rbp mov rbp,rsp sub rsp, some_locals and rsp,-16 ... your INCOMPETENT thing mov rsp,rbp pop rbp ret 8*incompetent size Bloated where? Your INCOMPETENT BRAIN? |
|||
29 Mar 2017, 23:27 |
|
C0deHer3tic 30 Mar 2017, 00:07
system error wrote: I warned you long ago that jumping straight into some advanced level in assembly programming wouldn't do you any good and would lead to even more confusions. What you're doing right now is actually delaying your progress and will take u longer than it should to understand simple asm concepts. Your early focus should be to get yourself comfortable and well-acquainted around the CPU components, - registers, memory and stack and the corresponding instructions. You need to re-calibrate your learning focus to the correct one. First off, I have been pleading and asking where to begin. Your outburst just now, and scolding me like a three year old girl, justifies that you are clueless to what I have been asking. I have been trying to learn the registers, memory, and stacks. However I am simply a beginner. If there is a correct one, don't come off with a scold when you yourself failed to provide me a basic, "Here is what you start off with" step. I am constantly researching, and still trying to find out more of this assembly language. Second, I have been beating around the bush?! I have been studying, exercising, and coding, using methods I am learning. Do I really need you to be griping at me, when you yourself led me down this path, without no possible routes elsewhere? How do you ask a question when you have no idea about the question in the first place? I am trying to learn asm and if I knew the correct questions, which I had already notified you about, I would ask them. With all that being said, if you feel I am doing this all wrong, point me in the right direction with less scolding. I have no need for your false assumptions of me, and what I am trying to do. I AM TRYING TO LEARN ASM Not anything else. Can you help? Or do you plan on scolding me like a child for something I am unknown to? _________________ - Just because something is taught one way, does not mean there is not a different way, possibly more efficient. - |
|||
30 Mar 2017, 00:07 |
|
revolution 30 Mar 2017, 00:27
C0deHer3tic wrote: And it loops forever....Why not only 4 times? |
|||
30 Mar 2017, 00:27 |
|
system error 30 Mar 2017, 00:33
C0deHer3tic wrote: First off, I have been pleading and asking where to begin. Your outburst just now, and scolding me like a three year old girl, justifies that you are clueless to what I have been asking. You all have been throwing around code like rotten like, expecting me to eat it diligently. I have been trying to learn the registers, memory, and stacks. However I am simply a beginner. If there is a correct one, don't come off with a scold when you yourself failed to provide me a basic, "Here is what you start off with" step. I am constantly researching, and still trying to find out more of this assembly language. I don't know where I am anywhere near 'scolding' you. I been advising you nicely. I am warning you nicely even! AFAIK, you are the one with font size 18 shouting to people like they're your paid employees. Your 'begging tone' doesn't actually conceal your true attitude and don't really influence me in anyway. You want to learn, you listen to what I suggest and DO whatt I want you to do. You want STACK IMBALANCE, keep listening to craps from Trinitek and Furr. They been suggesting codes full of stack imbalance right from the beginning but boasting about pointer manipulations. Btw, you been using my code template + C in your examples as I suggested to you earlier in the thread. You should be thankful to me instead for showing you the way |
|||
30 Mar 2017, 00:33 |
|
C0deHer3tic 30 Mar 2017, 01:04
system error wrote: You been beating around the bush for quite a few days now without asking how to actually see the value of a register using printf service - that's the kind of question that you should ask us here as of now. But I don't see any of that. You're not focusing on the real objective of learning assembly language - how to 'talk' to the CPU and its components. How do I learn to talk to the CPU and its components? _________________ - Just because something is taught one way, does not mean there is not a different way, possibly more efficient. - |
|||
30 Mar 2017, 01:04 |
|
Goto page Previous 1, 2, 3, 4, 5, 6 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.