Tweezy Posted April 22, 2013 Content Count: 3791 Joined: 08/08/09 Status: Offline Share Posted April 22, 2013 I'm using the Intel x86 framework for my Assembly Programming at University. To be honest I am having quite a few issues understanding it. For example, the stack commands, moving address into memory or adding register values onto others. For example: mov ecx, 0 mov ecx, 27 sub ecx, 15 Give the final value in ecx in HEXADECIMAL (ignore leading zeroes) Assume the following instructions are executed: mov ax,22 mov bx,29 mov cx,32 push bx push cx push ax pop ax pop bx pop cx The result in ax (in DECIMAL) would be The result in bx (in DECIMAL) would be The result in cx (in DECIMAL) would be Assume that the following instructions are executed: mov eax, 0 mov eax, 4eh add eax, d7h Give the final value in eax in HEXADECIMAL (ignore leading zeroes). These are just some example questions in a practice exam. I really don't understand them... Link to comment
Bob Loblaw Posted April 22, 2013 Content Count: 3697 Joined: 01/07/09 Status: Offline Share Posted April 22, 2013 (edited) I'm using the Intel x86 framework for my Assembly Programming at University. To be honest I am having quite a few issues understanding it. For example, the stack commands, moving address into memory or adding register values onto others. For example: mov ecx, 0 mov ecx, 27 sub ecx, 15 Give the final value in ecx in HEXADECIMAL (ignore leading zeroes) Assume the following instructions are executed: mov ax,22 mov bx,29 mov cx,32 push bx push cx push ax pop ax pop bx pop cx The result in ax (in DECIMAL) would be The result in bx (in DECIMAL) would be The result in cx (in DECIMAL) would be Assume that the following instructions are executed: mov eax, 0 mov eax, 4eh add eax, d7h Give the final value in eax in HEXADECIMAL (ignore leading zeroes). These are just some example questions in a practice exam. I really don't understand them... I don't know the specific language you are using, but the first one should be 12. By the looks of it, you move 0 into register exc, then move 27 into it (overwriting 0), then sub 15 from exc = 12. Second you have 22 in ax, 29 in bx, 32 in cs. You push bx -> cx -> ax onto the stack. And stacks are LIFO. Then you pop into ax -> bx -> cx. So ax is the one on top, then you pop it back into ax, then you pop cx into bx, and bx into cx. So the other *should* be: 22 (ax), 32 (bx), 29 (cx). Last one is 293. We are used to base 10, but basically the number 25 (to us) means 2 * 10^1 + 5 * 10^0 = (20) + (5). Hex is the same, but base 16. So 4eh (h just means the number is already in hex I believe), so 4 * 16^1 + e * 16^0. a:10, b:11, c:12, d:13, e:14, f:15, and since it's base 16, that's as high as it goes (because then it overflows into next column, same reason why 9 is the highest number in base 10). So 4e = 14 * 16^0 = 14. 4 = 4 * 16^1 = 64 64 + 14 = 78. d7h (d7) = 7 * 16^0 + d * 16^1 (7) + 13 * 16^1 = (7) + (208) = 215. These 2 are added together via add eax so 215 + 78 = 293. edit: Answer to be left in hex so it's even easier. 4e +d7 ----- e+7 = 5 carry the 1. 4 + d + 1 = 2 carry 1 again. So you get 125h (not 125 in decimal, in hex -ie. 293 in decimal). Edited April 22, 2013 by Bob Loblaw Link to comment
fanatiik Posted April 22, 2013 Content Count: 833 Joined: 10/21/09 Status: Offline Share Posted April 22, 2013 glad to see I'm not the only one that doesn't understand x86! 2 Link to comment
MPQC Posted April 22, 2013 Content Count: 2167 Joined: 03/24/08 Status: Offline Share Posted April 22, 2013 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90. Link to comment
Tweezy Posted April 22, 2013 Content Count: 3791 Joined: 08/08/09 Status: Offline Share Posted April 22, 2013 I don't know the specific language you are using, but the first one should be 12. By the looks of it, you move 0 into register exc, then move 27 into it (overwriting 0), then sub 15 from exc = 12. Second you have 22 in ax, 29 in bx, 32 in cs. You push bx -> cx -> ax onto the stack. And stacks are LIFO. Then you pop into ax -> bx -> cx. So ax is the one on top, then you pop it back into ax, then you pop cx into bx, and bx into cx. So the other *should* be: 22 (ax), 32 (bx), 29 (cx). Last one is 293. We are used to base 10, but basically the number 25 (to us) means 2 * 10^1 + 5 * 10^0 = (20) + (5). Hex is the same, but base 16. So 4eh (h just means the number is already in hex I believe), so 4 * 16^1 + e * 16^0. a:10, b:11, c:12, d:13, e:14, f:15, and since it's base 16, that's as high as it goes (because then it overflows into next column, same reason why 9 is the highest number in base 10). So 4e = 14 * 16^0 = 14. 4 = 4 * 16^1 = 64 64 + 14 = 78. d7h (d7) = 7 * 16^0 + d * 16^1 (7) + 13 * 16^1 = (7) + (208) = 215. These 2 are added together via add eax so 215 + 78 = 293. edit: Answer to be left in hex so it's even easier. 4e +d7 ----- e+7 = 5 carry the 1. 4 + d + 1 = 2 carry 1 again. So you get 125h (not 125 in decimal, in hex -ie. 293 in decimal). You're a life saver. I understand! Link to comment
Recommended Posts
Reply to Thread
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now