The MASM Forum

Projects => Rarely Used Projects => GoAsm => Topic started by: asmNOOB on July 30, 2014, 12:22:12 PM

Title: I cant SUBtract GoASM
Post by: asmNOOB 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
Title: Re: I cant SUBtract GoASM
Post by: Yuri 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.
Title: Re: I cant SUBtract GoASM
Post by: Gunther 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