-
Newbie ; Is this right ?
Howdy.
I'm learning assembly in college (for the m68000).
Is the following conversion from java to assembly correct ?
Code:
int a, b, c, d;
d = (b - a) + c;
goes to
Code:
A DC.L 0
B DC.L 0
C DC.L 0
D DC.L 0
ORG $0000
MOVE D0,A
MOVE D1,B
MOVE D2,C
MOVE D3,D
SUB D1,D0
ADD D1,D2
MOVE D3,D1
NOP
END
-
I dont know about the variables, or opcodes, but the meat of the thing looks fine.
Z.
-
When you find out, will you let us know?
-
-
Did u get it back yet?
ChimpFace, your avatar looks like it's flipping me the bird.
:D
Do you program Visual C++?
-
Hes not, hes saying "number 1".
-
Im getting my results on the 4th of july (ffs :)).
Anyway I'll let yiz know :)
-
find out yet?
Isn't that chipset similar to the 6802 processor that the super nintendo uses?
- Dim A
-
In the exam we had an awful loop construct to do in assembly, so I didnt do too well. But I'll get the repeats :)
-
I wish I would have known. I could have helped you... err.. Here is the correct way to convert it. :)
From this...
int a, b, c, d;
d = (b - a) + c;
To this...
A DW 0 ;This sets it up as a 16-Bit variable.
B DW 0
C DW 0
D DW 0
MOV AX,1
MOV Word [A],AX
MOV Word [B],AX
MOV Word [C],AX
MOV Word [D],AX ;Now all of them are equal to 1
SUB Word [B],Word [A] ;B is now 0
ADD Word [B],Word [C] ;B is now 1
MOV Word [D],Word [B] ;D = 1
NOTE : This is NASM assembly code. NASM will compile cross platform for those who need it.
If your using TASM or MASM (shudder) then you will have to type it up slightly different with a PTR after the Word statements.
Hope this helps.. :)
Knight Vision
-
Well I need it for the M68K processor...
-
I don't know if it will for that processor or not. You can check with the people who make nasm. (Their website I meant.)
If not, do you know all of the REGISTERS and COMMANDS that the processor can take? If so, is it in a TXT file already? If so, can you post it for all of us? I could then look at it and rewrite the code for you.