-
February 21st, 2012, 10:09 AM
#1
New to Assembly Language
I have a problem...
Write a program in assembly language to perform the following operation:
C=A + B
Consider A=7, B= 148 (hexadecimal)
The origin of the program is 100 (hexadecimal)
Would this be a Fortran program?
If so, I had this...
INTEGER A,B,C
DATA A,7 B,148
C=A+B
END
Is this correct?
-
February 21st, 2012, 10:17 AM
#2
Re: New to Assembly Language
Or would it be something like this...
LDA AL
ADD BL
STA CL
CLA
CIL
ADD AH
ADD BH
STA CH
HLT
-
February 21st, 2012, 12:00 PM
#3
Re: New to Assembly Language
Originally Posted by halt4814
Or would it be something like this...
[...]
Depends on the architecture that's meant for, I'd say. To me that looks somewhat like 6502-style instructions, but with the 8086 register set or at least variables named like the 8086 registers.
At the very least it's much closer than the one from post #1 which rather looks like BASIC.
However, it doesn't declare or initalize the variables, neither does it account for the part of the assigment about the program origin.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
February 21st, 2012, 01:57 PM
#4
Re: New to Assembly Language
So if I add ORG 100 to the top, then what?
-
February 21st, 2012, 03:09 PM
#5
Re: New to Assembly Language
Given the assembler that finally has to process that source code understands that directive and interprets integer literals as being hexadecimal by default (rather uncommon, IMO, at least without a directive telling it to do so), that would fix at least one of the potential problems I mentioned. However, without knowing more about your environment, I can't really say anything for sure.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
February 24th, 2012, 08:27 AM
#6
Re: New to Assembly Language
I do not think it needs to be double precision,so couldn't be as simple as...
ORG 100
LDA A
ADD B
STA C
HLT
A, 7
B, 148
-
February 24th, 2012, 08:48 AM
#7
Re: New to Assembly Language
Your code seems to deal with integral numbers, and if that assumption is correct, the term double precision does not apply here, since it referts to floating point arithmetic.
In case you're refering to the bitness (width) of integer operands in registers, now that doesn't match the model of the 8086 register set anymore: It has a 16-bit AX register, of which the high-order 8 bits can be accessed under the name AH and the low-order 8 bits can be accessed as AL. However, they're still no distinct registers: Modifying AL unconditionally modifies AX as well, for instance. Likewise for the registers BX, CX and DX. (There are more registers with properties differing from those, but I think we can ignore them here for now.)
Again, it's quite important to know for which architecture you're writing your assembly language code. Assembly languages for different architectures can be quite different as well. And the more specific it gets, the more important that is.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|