|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Assembly - New To Assembly
I am brand new to assembly, and i have just learned how to add two numbers. However I need to add eight numbers, and I just dont know how. here is my trial code
short int num1 = 0x1; short int num2 = 0x0; short int num3 = 0x1; short int num4 = 0x3; short int num5 = 0x6; short int num6 = 0x6; short int num7 = 0x5; short int num8 = 0x4; short int ans1 = 0; __asm { // | | | mov ax,num1 ;get first num to add mov ax,num2 ;get second num to add mov ax,num3 ;get third num to add mov ax,num4 ;get fourth num to add mov ax,num5 ;get fifth num to add mov ax,num6 ;get sixth num to add mov ax,num7 ;get seventh num to add mov ax,num8 ;get eigth num to add add ax,num2 ;form sum add ax,num3 ;form sum add ax,num4 ;form sum add ax,num5 ;form sum add ax,num6 ;form sum add ax,num7 ;form sum add ax,num8 ;form sum mov ans1,ax ;store result } |
|
#2
|
|||
|
|||
|
When you move something into a register, it overwrites the old value of the register, so your data moves are pointless. You should do it by either moving one of the numbers to the register and adding the rest to it, or simply zeroing out the register and adding all the numbers to it.
|
|
#3
|
|||
|
|||
|
Quote:
thanks for the timely response. so something like this should work? mov ax,num1 ;get first num to add add ax,num2 ;form sum add ax,num3 ;form sum add ax,num4 ;form sum add ax,num5 ;form sum add ax,num6 ;form sum add ax,num7 ;form sum add ax,num8 ;form sum mov ans1,ax ;store result |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Other Programming Languages > Assembly - New To Assembly |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|