New Posts  All Forums:Forum Nav:

[SOLVED]Assembly help?

post #1 of 4
Thread Starter 
Hey. Im taking a class and the book isn't realy helping me out. This is what I need to do.
Add up 3 variable and output the result. I am using Irvine32.

this is the code I have

INCLUDE Irvine32.inc
.data
Var1 SWORD 10
Var2 SWORD -60
Var3 SWORD 30
.code
main PROC

mov eax,Var1 ;Set eax value to Var1
add eax,Var2 ;Adds EAX and Var2 together
add eax,Var3 ;Adds EAX and Var3 together
call WriteInt
exit

main ENDP

END main

That code doesnt work. I cant compile. I i do
mov eax,10 ;Set eax value to Var1
add eax,-60 ;Adds EAX and Var2 together
add eax,30 ;Adds EAX and Var3 together
call WriteInt

I get the result I expect. any ideas? Or at least shove my face in the right direction?
Valery
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k GA-P67A-UD4-B3 Radeon 7970 Reference G. Skill Sniper 
Hard DriveOptical DriveOSMonitor
Corsair NOVA SSD 64gb + 500gb Storage + 1TB Storag HP DVD burner Windows 7 64bit 37" 1080p60hz 
KeyboardPowerCaseMouse
Razer Blackwidow Ultimate Rosewill Lightning 1000W Single Rail LianLi PC-K58 Razer Spectre 
Mouse Pad
Razer Goliathus Speed 
  hide details  
Reply
Valery
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k GA-P67A-UD4-B3 Radeon 7970 Reference G. Skill Sniper 
Hard DriveOptical DriveOSMonitor
Corsair NOVA SSD 64gb + 500gb Storage + 1TB Storag HP DVD burner Windows 7 64bit 37" 1080p60hz 
KeyboardPowerCaseMouse
Razer Blackwidow Ultimate Rosewill Lightning 1000W Single Rail LianLi PC-K58 Razer Spectre 
Mouse Pad
Razer Goliathus Speed 
  hide details  
Reply
post #2 of 4
mov eax, DWORD PTR [Var1]
add eax, DWORD PTR [Var2]
add eax, DWORD PTR [Var3]

I think. Been a long time. Do you understand pointers?

btw. I don't recommend MASM, it's horrible. Look into FASM/NASM smile.gif
Current rig.
(19 items)
 
  
CPUMotherboardGraphicsRAM
3770k @ 5GHz ASUS Maximus V Formula 780 Classified 1280/1603 Samsung Green 2222MHz 
Hard DriveCoolingCoolingCooling
HD204UI 2TB Direct-die waterloop XSPC Liang D5 + XTOP-CSQ-Plexi EK-Supremacy Plexi 
CoolingCoolingOSMonitor
Alphacool Monsta 240mm + 2 AP-15s EK-X3-Res 250mm Windows 8 64bit BenQ XL2420T + E2350V 
KeyboardPowerCaseMouse
Logitech G15 rev 2 XFX 850W Silver Phantom 630 Razer DeathAdder 
AudioOtherOther
ASUS Essense STX Vertex 4 256GB AegoM 2.1 Speakers 
  hide details  
Reply
Current rig.
(19 items)
 
  
CPUMotherboardGraphicsRAM
3770k @ 5GHz ASUS Maximus V Formula 780 Classified 1280/1603 Samsung Green 2222MHz 
Hard DriveCoolingCoolingCooling
HD204UI 2TB Direct-die waterloop XSPC Liang D5 + XTOP-CSQ-Plexi EK-Supremacy Plexi 
CoolingCoolingOSMonitor
Alphacool Monsta 240mm + 2 AP-15s EK-X3-Res 250mm Windows 8 64bit BenQ XL2420T + E2350V 
KeyboardPowerCaseMouse
Logitech G15 rev 2 XFX 850W Silver Phantom 630 Razer DeathAdder 
AudioOtherOther
ASUS Essense STX Vertex 4 256GB AegoM 2.1 Speakers 
  hide details  
Reply
post #3 of 4
Thread Starter 
I wish, but masm is required for the course i am taking. I will look into how pointers work in this.
Valery
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k GA-P67A-UD4-B3 Radeon 7970 Reference G. Skill Sniper 
Hard DriveOptical DriveOSMonitor
Corsair NOVA SSD 64gb + 500gb Storage + 1TB Storag HP DVD burner Windows 7 64bit 37" 1080p60hz 
KeyboardPowerCaseMouse
Razer Blackwidow Ultimate Rosewill Lightning 1000W Single Rail LianLi PC-K58 Razer Spectre 
Mouse Pad
Razer Goliathus Speed 
  hide details  
Reply
Valery
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k GA-P67A-UD4-B3 Radeon 7970 Reference G. Skill Sniper 
Hard DriveOptical DriveOSMonitor
Corsair NOVA SSD 64gb + 500gb Storage + 1TB Storag HP DVD burner Windows 7 64bit 37" 1080p60hz 
KeyboardPowerCaseMouse
Razer Blackwidow Ultimate Rosewill Lightning 1000W Single Rail LianLi PC-K58 Razer Spectre 
Mouse Pad
Razer Goliathus Speed 
  hide details  
Reply
post #4 of 4
Thread Starter 
I figured it out Had to set eax to 0 at the start then us ax instead of eax since it was 16 bit and not 32 bit. Finished looks like
INCLUDE Irvine32.inc
.data
Var1 SWORD 10
Var2 SWORD -60
Var3 SWORD 30
.code
main PROC
mov eax,0 ;set eax to 0
mov ax,Var1 ;Set eax value to Var1
add ax,Var2 ;Adds EAX and Var2 together
add ax,Var3 ;Adds EAX and Var3 together

exit

main ENDP

END main
Valery
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k GA-P67A-UD4-B3 Radeon 7970 Reference G. Skill Sniper 
Hard DriveOptical DriveOSMonitor
Corsair NOVA SSD 64gb + 500gb Storage + 1TB Storag HP DVD burner Windows 7 64bit 37" 1080p60hz 
KeyboardPowerCaseMouse
Razer Blackwidow Ultimate Rosewill Lightning 1000W Single Rail LianLi PC-K58 Razer Spectre 
Mouse Pad
Razer Goliathus Speed 
  hide details  
Reply
Valery
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k GA-P67A-UD4-B3 Radeon 7970 Reference G. Skill Sniper 
Hard DriveOptical DriveOSMonitor
Corsair NOVA SSD 64gb + 500gb Storage + 1TB Storag HP DVD burner Windows 7 64bit 37" 1080p60hz 
KeyboardPowerCaseMouse
Razer Blackwidow Ultimate Rosewill Lightning 1000W Single Rail LianLi PC-K58 Razer Spectre 
Mouse Pad
Razer Goliathus Speed 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming