News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

I cant SUBtract GoASM

Started by asmNOOB, July 30, 2014, 12:22:12 PM

Previous topic - Next topic

asmNOOB

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:
.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


    Sub Cx, Bx
    Add Bx, 30H
    Mov [resultado], Bx


The result is in CX, not BX.

Gunther

Hi asmNOOB,

Yuri is right. You should write:

Quote from: Yuri on July 30, 2014, 01:37:53 PM

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


And welcome to the forum.

Gunther
You have to know the facts before you can distort them.