| | |
Question regarding output
Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Aug 2008
Posts: 57
Reputation:
Solved Threads: 1
I have an assignment due for my Assembly class and I have a quick couple of questions regarding it.
The requirement is initialize 3 variables as 16bit words with values (10, -60, 30) add those values as the following equation y = var1 + var2 + var3, use no more than 3 lines of code to produce results. Show results in EAX register.
Question #1: The professor gave us nothing to go off of to ensure we have our code done correctly, so can someone give me the display of the EAX register as it should display if I accomplish the above correctly? (no code, just a screen shot of the output).
Here is the code I have so far:
As you can see I have 4 lines of code to produce the results (at least I'm assuming the output is correct). What am I missing that would allow me to drop 1 line of code?
Thanks.
Oh and I realize there is lines missing from the above code, I left them out intentionally since they weren't relevant to my questions.
The requirement is initialize 3 variables as 16bit words with values (10, -60, 30) add those values as the following equation y = var1 + var2 + var3, use no more than 3 lines of code to produce results. Show results in EAX register.
Question #1: The professor gave us nothing to go off of to ensure we have our code done correctly, so can someone give me the display of the EAX register as it should display if I accomplish the above correctly? (no code, just a screen shot of the output).
Here is the code I have so far:
Assembly Syntax (Toggle Plain Text)
.data arrayD WORD 10, -60, 30 .code mov esi, OFFSET arrayD add eax, [esi] add eax, [esi] add eax, [esi] call DumpRegs call WaitMsg exit
Thanks.
Oh and I realize there is lines missing from the above code, I left them out intentionally since they weren't relevant to my questions.
Last edited by RayvenHawk; Oct 22nd, 2009 at 1:34 pm.
Old saying: "If it ain't broke don't fix it"
Microsofts saying: "If it ain't broke, update it so it will be."
Programmers - Making other people rich for over 50yrs.
Microsofts saying: "If it ain't broke, update it so it will be."
Programmers - Making other people rich for over 50yrs.
•
•
Join Date: Aug 2008
Posts: 57
Reputation:
Solved Threads: 1
0
#2 Oct 22nd, 2009
Ok I modified the code as follows, is there any problem with it?
Assembly Syntax (Toggle Plain Text)
.data arrayD WORD 10,-60,30 .code mov esi,OFFSET arrayD add eax,[esi+esi+esi] call DumpReg call WaitMsg exit
Old saying: "If it ain't broke don't fix it"
Microsofts saying: "If it ain't broke, update it so it will be."
Programmers - Making other people rich for over 50yrs.
Microsofts saying: "If it ain't broke, update it so it will be."
Programmers - Making other people rich for over 50yrs.
0
#3 Oct 22nd, 2009
Assembly Syntax (Toggle Plain Text)
.data arrayD WORD 10, -60, 30 .code mov esi, OFFSET arrayD mov ax, [esi+0] ; AX=10 initialize AX to value of ; first word add ax, [esi+2] ; AX=AX + -60 = -50 add ax, [esi+4] ; AX=AX + 30 = -20 call DumpRegs call WaitMsg exit
register for adding these 16-bit words, this would
cause it to treat two words at a time as a single value.
I believe MOVZX is the only MOVe which can use
two different datatypes.
MOV AX, [ESI] ; moves a word into AX
MOV EAX, [ESI] ; moves a dword into EAX
MOVZX EAX, BYTE PTR [EBX] ; move byte zero-extended into EAX
Every instruction needs complementary datatypes.
1111111111101100
AX=FFEC = -20
Good day.
----------------------------------------------------------
To control a mind violates a man, and all it has been used for is
hurting and afflicting. Nowonder I progam in assembly...
--->Now available http://dotcoding.netai.net/
To control a mind violates a man, and all it has been used for is
hurting and afflicting. Nowonder I progam in assembly...
--->Now available http://dotcoding.netai.net/
0
#4 Oct 22nd, 2009
IF ESI=OFFSET ARR and Addr ARR=00000100h
[ESI+ESI] -> DS:00000200h 256 bytes past first byte of array
[ESI+ESI] -> DS:00000200h 256 bytes past first byte of array
----------------------------------------------------------
To control a mind violates a man, and all it has been used for is
hurting and afflicting. Nowonder I progam in assembly...
--->Now available http://dotcoding.netai.net/
To control a mind violates a man, and all it has been used for is
hurting and afflicting. Nowonder I progam in assembly...
--->Now available http://dotcoding.netai.net/
![]() |
Similar Threads
- Output values into mutiple cells in excel from VBA code (Visual Basic 4 / 5 / 6)
- Output and null (Java)
- Help Understand an Output (C++)
- Quick question on output... (C++)
- How to render a formatted output using HTML? (HTML and CSS)
- I need a Pseudocode or advice here,Please help!! (C++)
- [basics] LZ(W) compression explanation. (C)
- Deleting a pointer? (C++)
Other Threads in the Assembly Forum
- Previous Thread: Changing current directory. Help.
- Next Thread: Reading GDT
Views: 329 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Assembly
3d 68hc11 6811 80386 :( adress array asm assembler assembly boot bootloader buffer compression cursor debug directory division docs dos draw emulator endtask error exceptions file int10h integer intel interrupt interrupts language loop newbie nohau osdevelopment print program range read remainder shape string text theory tsr x86





