Author Topic: I cant SUBtract GoASM  (Read 2216 times)

asmNOOB

  • Regular Member
  • *
  • Posts: 1
I cant SUBtract GoASM
« on: July 30, 2014, 12:22:12 PM »
Hi, first english is not my mother toungue so, i will try to explain my problem the more clearly i can XD. I just have start learning GoASM , so i try to do a program that add and subtrcat two number this is my code:
Code: [Select]
.Data
inicio DD 0
var1 DD 5   ;modificar
var2 DD 4   ;modificar
resultado DD 1
suma DD 43
resta DD 45
igual DD 61
show DD 1
.Code

start:


Push - 11
Invoke GetStdHandle
Push 0, Addr inicio
Push 2, Addr show
Mov Bx, [var1]
Add Bx, 30H
Mov [show], Bx
Push Eax
Call WriteFile

Push - 11
Invoke GetStdHandle
Push 0, Addr inicio
Push 2, Addr resta
Push Eax
Call WriteFile

Push - 11
Invoke GetStdHandle
Push 0, Addr inicio
Push 2, Addr show
Mov Bx, [var2]
Add Bx, 30H
Mov [show], Bx
Push Eax
Call WriteFile

Push - 11
Invoke GetStdHandle
Push 0, Addr inicio
Push 2, Addr igual
Push Eax
Call WriteFile


Push - 11
Invoke GetStdHandle
Push 0, Addr inicio
Push 1D, Addr resultado
Mov Bx, [var2]
Mov Cx, [var1]
Sub Cx, Bx
Add Bx, 30H
Mov [resultado], Bx
Push Eax
Call WriteFile

Ret


I just can add two number, but i cant do it to subtract.

Thanks

Yuri

  • Member
  • **
  • Posts: 175
Re: I cant SUBtract GoASM
« Reply #1 on: July 30, 2014, 01:37:53 PM »
Code: [Select]
    Sub Cx, Bx
    Add Bx, 30H
    Mov [resultado], Bx

The result is in CX, not BX.

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: I cant SUBtract GoASM
« Reply #2 on: July 31, 2014, 11:48:47 AM »
Hi asmNOOB,

Yuri is right. You should write:

Code: [Select]
    Sub Cx, Bx
    Add CX, 30H
    Mov [resultado], CX

And welcome to the forum.

Gunther
Get your facts first, and then you can distort them.