d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Help With Question And Learning
Add Reply New Topic New Poll
Member
Posts: 11,079
Joined: Sep 2 2015
Gold: 930,081.00
Nov 19 2021 03:49pm
What topic is this question from? And where can I get more information about learning this stuff.

Also, if someone can explain this question to me that would be great.

Member
Posts: 1,365
Joined: Aug 3 2006
Gold: 36,263.00
Nov 20 2021 04:32am
Those are assembler instructions. It's like a super low level programming language.
Member
Posts: 8
Joined: Oct 18 2021
Gold: 75.00
Nov 24 2021 11:04pm
Yeah these look like the intel's assembly syntax specifically. If you want to learn this just for fun then go for it but if you're seriously considering programming as a career then there are much better languages to learn.

Assembly is a very niche language, used to program hardware components like CPUs. Depending on your location, it might be impossible to find a job and get good pay off you only know assembly.

You'd be better off learning popular general purpose language like: java, golang, python and javascript.

As for the exercise. They want you to move the variable from mem1 to mem2. However, I might be missing some context, but it seems impossible to move the value without making it negative because the only instruction given to move from memory to registry is subtraction.

Anyway, here's what I would do but it might be incorrect:
sub reg1, mem1
mov mem2, reg1
Member
Posts: 1,894
Joined: Sep 11 2011
Gold: 19,615.00
Nov 26 2021 04:32pm
Quote (saulius @ Nov 25 2021 06:04am)
Yeah these look like the intel's assembly syntax specifically.


What makes you say that? If anything it looks more like ARM to me with the numbered registers instead of the 2/3 letter acronyms (eax, rbp, ..) used on x86. But of course it's probably neither and just pseudocode written by the prof.

This question also left me puzzled at first and looking for missing instructions but actually I think the solution is pretty simple:

Code
Initial state with 3 as example value:

MEM1 MEM2 REG1 REG2

3 0 0 0

SUB REG1, MEM1 (Reg1 = Reg1 - Mem1 = 0 - 3 = -3)

MEM1 MEM2 REG1 REG2

3 0 -3 0

MOV MEM2, REG1 (Put contents of REG1 into MEM2)

MEM1 MEM2 REG1 REG2

3 -3 -3 0

SUB REG2, MEM2 (REG2 = REG2 - MEM2 = 0 - (-3) = 3)

MEM1 MEM2 REG1 REG2

3 -3 -3 3

MOV MEM2, REG2 (Put contents of REG2 into MEM2)


MEM1 MEM2 REG1 REG2

3 3 -3 3

MEM1 copied to MEM2.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll