Click here to Skip to main content
15,507,293 members

Comments by deXo-fan (Top 20 by date)

deXo-fan 21-Nov-21 2:25am View    
Hi Chris!
Thank you for your answer, it is exactly what I was looking for!
However, I am still a little confused about the whole concept. Let me try to explain:

If we use the site I linked to as an example, then I guess the only benefit they reap by using JavaScript routing is that you can also select a specific episode by specifying the episode number in the URL in your browser before you enter the site? In other words, with JS routing there are two ways to choose an episode:
1) Type its URL in the address bar in the browser, then enter the site
2) Enter the site, then click a link to an episode

Where as if you don't use JS routing or links but simply add click event handlers to e.g. buttons, then to watch a specific episode you only have the second option:
2) Enter the site, then click a button

Is that correct? I'm asking because if JavaScript can learn the URL the moment the page loads (the ENTIRE URL, which I believe it can?), then what advantage does JS routing give you exactly that the button solution doesn't have? What good is it that the URL in the address bar changes? How does it help the user and how does it make life easier for the developer?
deXo-fan 12-Nov-21 13:54pm View    
Thank you so much! You did an amazing job writing from your smartphone, and during your vacation no less :D If you hadn't told me, I would have never guessed! I'm sorry I didn't thank you sooner, but I've been so busy I completely forgot I asked this question. I could really use a vacation myself! I hope you had a good one!
deXo-fan 29-Oct-21 16:05pm View    
Well, I can tell you this: I had only read about half way through your answer when I thought to myself, "This person is a goldmine of information!". Seriously, I've learned A LOT from you, and I immensely appreciate you taking the time to answer all my questions so thoroughly and detailed! Thank you! I take it as a compliment that you think I'm asking more and more in-depth questions, sort of like "You're learning" ;), and that's also a positive reflection on you since I probably wouldn't be asking these questions if I didn't understand your answers.

But I don't want to keep you if you are tired of all my questions, which would be quite understandable. However, if you're not then I have just a couple more:

1) Do you have to set EBP manually to point to the end of the stack at the beginning of every function, and is that what this code does? (These are the first 3 lines of a function I wrote):
push ebp ; bytes=1
mov ebp, esp ; bytes=2
push ecx ; bytes=1
Why is it necessary to push ebp before moving esp into it? Does the compiler know somehow that it has a necessary value in it already before entering the function? Aren't we repurposing it by doing this? And by restoring EBP, is that what we're doing here, which is the last lines of the function?
mov esp, ebp ; bytes=2
pop ebp ; bytes=1

This is the entire code for the function:
; 13   : void f(char& a, char& b) {

  00000	55		 push	 ebp			; bytes=1
  00001	8b ec		 mov	 ebp, esp		; bytes=2
  00003	51		 push	 ecx			; bytes=1

; 14   :     char A = a;

  00004	8b 45 08	 mov	 eax, DWORD PTR _a$[ebp]	; bytes=3
  00007	8a 08		 mov	 cl, BYTE PTR [eax]	; bytes=2
  00009	88 4d ff	 mov	 BYTE PTR _A$[ebp], cl	; bytes=3

; 15   :     a = b;

  0000c	8b 55 08	 mov	 edx, DWORD PTR _a$[ebp]	; bytes=3
  0000f	8b 45 0c	 mov	 eax, DWORD PTR _b$[ebp]	; bytes=3
  00012	8a 08		 mov	 cl, BYTE PTR [eax]	; bytes=2
  00014	88 0a		 mov	 BYTE PTR [edx], cl	; bytes=2

; 16   :     b = A;

  00016	8b 55 0c	 mov	 edx, DWORD PTR _b$[ebp]	; bytes=3
  00019	8a 45 ff	 mov	 al, BYTE PTR _A$[ebp]	; bytes=3
  0001c	88 02		 mov	 BYTE PTR [edx], al	; bytes=2

; 17   : }

  0001e	8b e5		 mov	 esp, ebp		; bytes=2
  00020	5d		 pop	 ebp			; bytes=1
  00021	c3		 ret	 0			; bytes=1
?f@@YAXAAD0@Z ENDP					; f


2) Can you recommend a good book on learning Assembly, preferably MASM32?
deXo-fan 27-Oct-21 18:55pm View    
Thank you for sharing your knowledge with me, den2k88! (I don't know what else to call you). I really appreciate it. I have a couple more questions if you don't mind answering them.

About STRUCT being a macro, does this mean that the MASM32 Assembler converts that code into something that looks like the ebp snippet?

And whenever you make an object in C(++) that is a struct/class, does the compiler simply treat every member of every struct as global variables? Also, how does malloc() fit into this way of keeping track of things?

Does ebp always point at the end of the stack? Why 4 bytes before its start? Does that mean 4 bytes before the end of the stack? I thought eax was the primary/preferred register to put return values into.
deXo-fan 26-Oct-21 18:00pm View    
I see. I don't know why, but I thought it stood for Microsoft Assembler. Do you know how they keep track of objects and their members without STRUCTs? Like that line I talked about:

_TEXT SEGMENT
_obj$ = -4 ; size = 4
... (ca. 13 lines later)
mov DWORD PTR _obj$[ebp], 30 ; bytes=7, 0000001eH

What's going on here? It looks to me like they're setting an integer variable to -4, but then later on accessing that same variable as though it were an array or something similar.