d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Iso Assembly Programming Tutor! > Masm Assembly
12Next
Add Reply New Topic New Poll
Member
Posts: 1,756
Joined: Jan 8 2013
Gold: 0.00
Nov 3 2015 06:47pm
hey everyone, Im just curious if anybody here is familiar with assembly programming. Im using visual basics, and I kind of need help trying to understand it. anybody's input is welcome! thanks and regards.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Nov 3 2015 06:53pm
which assembly language? since you mentioned VB, are you just referring to MSIL? or perhaps something common in school like MIPS/LC3? or something like x86?

/edit oh i see, masm. what do you need help understanding in particular? i dont have experience with that one in particular, but assembly in general is all the same. you have instructions with an op code then registers or values.

This post was edited by carteblanche on Nov 3 2015 06:56pm
Member
Posts: 1,756
Joined: Jan 8 2013
Gold: 0.00
Nov 3 2015 07:16pm
Quote (carteblanche @ Nov 3 2015 04:53pm)
which assembly language? since you mentioned VB, are you just referring to MSIL? or perhaps something common in school like MIPS/LC3? or something like x86?

/edit oh i see, masm. what do you need help understanding in particular? i dont have experience with that one in particular, but assembly in general is all the same. you have instructions with an op code then registers or values.


masm x86. im really struggling in this class =(. i just need help trying to understand the logic.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Nov 3 2015 07:31pm
Quote (chubbycakez @ Nov 3 2015 08:16pm)
masm x86. im really struggling in this class =(. i just need help trying to understand the logic.


what are you already comfortable with? if i told you to, say, add the numbers 3 and 2 and store it in a register, could you do it? if you got sample code, are you capable of tracing it to understand how it works?

http://www.cs.virginia.edu/~evans/cs216/guides/x86.html

when i was learning it in school, i first wrote in c-style pseudo-code, then converted pseudo code to assembly-like pseudo code. basically looking at what registers / memory i need to use to achieve it. then after i have that, i'd convert to assembly. it also helps to comment every line.

This post was edited by carteblanche on Nov 3 2015 07:53pm
Member
Posts: 1,756
Joined: Jan 8 2013
Gold: 0.00
Nov 3 2015 10:21pm
Quote (carteblanche @ Nov 3 2015 05:31pm)
what are you already comfortable with? if i told you to, say, add the numbers 3 and 2 and store it in a register, could you do it? if you got sample code, are you capable of tracing it to understand how it works?

http://www.cs.virginia.edu/~evans/cs216/guides/x86.html

when i was learning it in school, i first wrote in c-style pseudo-code, then converted pseudo code to assembly-like pseudo code. basically looking at what registers / memory i need to use to achieve it. then after i have that, i'd convert to assembly. it also helps to comment every line.


mov eax, 3
add eax, 2

depending where you want me to store it:
if eax, just leave it
if ebx, then simply (mov ebx,eax)

i understand some parts of it, but not all of it. right now we are doing floating point. i cant understand it. although i understand the fact that the stacks are kind of set up like a revolver when loading and storing values
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Nov 4 2015 08:00pm
Quote (chubbycakez @ Nov 3 2015 11:21pm)
mov eax, 3
add eax, 2

depending where you want me to store it:
if eax, just leave it
if ebx, then simply (mov ebx,eax)

i understand some parts of it, but not all of it. right now we are doing floating point. i cant understand it. although i understand the fact that the stacks are kind of set up like a revolver when loading and storing values


the stack is a stack

what really helped me with the floating point stuff was always putting a comment next to each instruction showing what the stack would contain at that point

I still have some on my HDD lol

Code
push ebx
call exp ;ToS = x^n
fst Q[t_i] ; t_i = x^n
fld1
fld1
fadd ; ToS = 2, x^n
push ebx
call exp ; ToS = 2^n, x^n
push ebx
call fact ; eax = n!
mov [tmp_sto], eax
fild Q[tmp_sto] ; ToS = n!, 2^n, x^n
fmul ; ToS = n! * 2^n, x^n
fdiv ; ToS = t0 case (x^n / (n! * 2^n))
fst Q[result]
fstp Q[t_i] ; ToS = empty, result = t_i = t0
.loop
finit
fld Q[x_val]
fld Q[x_val]
fmul ; ToS = x^2
mov eax, 4
mov [tmp_sto], eax
fild Q[tmp_sto] ; ToS = 4, x^2
mov [tmp_sto], ecx
fild Q[tmp_sto] ; ToS = i, 4, x^2
fmul ; ToS = 4*i, x^2
mov [tmp_sto], ebx
fild Q[tmp_sto] ; ToS = n, 4*i, x^2
mov [tmp_sto], ecx
fild Q[tmp_sto] ; ToS = i, n, 4*i, x^2
fadd ; ToS = (n+i), 4*i, x^2
fmul ; ToS = (4*i)*(n+i), x^2
fdiv ; ToS = x^2 / (4*i*(n+i))
fld Q[t_i] ; ToS = t_(i-1), x^2 / (4*i*(n+i)))
fmul ; ToS = t_i
fchs ; ToS = -(t_i)
fst Q[t_i]
fld Q[result]
fadd ; ToS = current result
fstp Q[result] ; ToS = empty
inc ecx
Member
Posts: 1,756
Joined: Jan 8 2013
Gold: 0.00
Nov 4 2015 10:21pm
Quote (Eep @ Nov 4 2015 06:00pm)
the stack is a stack

what really helped me with the floating point stuff was always putting a comment next to each instruction showing what the stack would contain at that point

I still have some on my HDD lol

Code
push ebx
call exp ;ToS = x^n
fst Q[t_i] ; t_i = x^n
fld1
fld1
fadd ; ToS = 2, x^n
push ebx
call exp ; ToS = 2^n, x^n
push ebx
call fact ; eax = n!
mov [tmp_sto], eax
fild Q[tmp_sto] ; ToS = n!, 2^n, x^n
fmul ; ToS = n! * 2^n, x^n
fdiv ; ToS = t0 case (x^n / (n! * 2^n))
fst Q[result]
fstp Q[t_i] ; ToS = empty, result = t_i = t0
.loop
finit
fld Q[x_val]
fld Q[x_val]
fmul ; ToS = x^2
mov eax, 4
mov [tmp_sto], eax
fild Q[tmp_sto] ; ToS = 4, x^2
mov [tmp_sto], ecx
fild Q[tmp_sto] ; ToS = i, 4, x^2
fmul ; ToS = 4*i, x^2
mov [tmp_sto], ebx
fild Q[tmp_sto] ; ToS = n, 4*i, x^2
mov [tmp_sto], ecx
fild Q[tmp_sto] ; ToS = i, n, 4*i, x^2
fadd ; ToS = (n+i), 4*i, x^2
fmul ; ToS = (4*i)*(n+i), x^2
fdiv ; ToS = x^2 / (4*i*(n+i))
fld Q[t_i] ; ToS = t_(i-1), x^2 / (4*i*(n+i)))
fmul ; ToS = t_i
fchs ; ToS = -(t_i)
fst Q[t_i]
fld Q[result]
fadd ; ToS = current result
fstp Q[result] ; ToS = empty
inc ecx


this is what i mean. i dont even understand this =/
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Nov 4 2015 10:48pm
Quote (chubbycakez @ Nov 4 2015 11:21pm)
this is what i mean. i dont even understand this =/


to be fair, that is incomplete code, and it doesn't exactly giveaway functionality just from looking.

I believe the entire program was for calculating the bessel function

This post was edited by Eep on Nov 4 2015 10:48pm
Member
Posts: 1,756
Joined: Jan 8 2013
Gold: 0.00
Nov 5 2015 12:50am
Quote (Eep @ Nov 4 2015 08:48pm)
to be fair, that is incomplete code, and it doesn't exactly giveaway functionality just from looking.

I believe the entire program was for calculating the bessel function


you think you can tutor me a little? i'd really appreciate it!
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Nov 5 2015 05:53pm
Quote (chubbycakez @ Nov 5 2015 01:50am)
you think you can tutor me a little? i'd really appreciate it!


as with most problems, post your current code, and your big road block - maybe me (or someone else) can help
Go Back To Programming & Development Topic List
12Next
Add Reply New Topic New Poll