This is supposed to find the GCD

gcd:= number1;
remainder := number2;
repeat
  dividend := gcd;
  gcd := remainder;
  remainder := dividend mod gcd;
until (remainder = 0);

using windows32 write a program that uses dialog boxes to prompt for and input values for number1 and number2, implements the above design to find their GCD and uses a message box to display the GCD.

Any help with this please???
Posted on 2009-10-22 18:14:44 by whitey300
1. read about win32 programming in general
2. read about dialog boxes
3. write this function
Posted on 2009-10-23 00:04:35 by ti_mo_n
1. pay attention in class
2. ????
3. profit!

...if you actually put in some effort of your own but have trouble getting things to work, you're more likely to receive help fixing things up. But don't expect us to do your homework for you.
Posted on 2009-10-23 03:22:02 by f0dder
who gives this stupid homework in assembly? this should be better done in a somewhat high level language, at least java or better scheme or something..

Posted on 2009-10-23 04:58:56 by beaster

who gives this stupid homework in assembly? this should be better done in a somewhat high level language, at least java or better scheme or something..
I disagree - it's a too simple assignment in a higher-level language (especially given that pseudocode has been given), but while it's simple it should pose a challenge when you're new to assembly.

Especially if you're working on a one-register load/store no-named-labels architecture, it's fun :)
Posted on 2009-10-23 11:09:30 by f0dder
I have managed to come up with this code so far but now I am stuck on what I am missing or did wrong.

.586
.MODEL FLAT
INCLUDE io.h            ; header file for input/output
.STACK 4096

.DATA
number1 DWORD ?
number2 DWORD ?
gcd DWORD ?
prompt1 BYTE       "Number 1?", 0
prompt2 BYTE       "Number 2?", 0
string         BYTE       40 DUP (?)
gcdLbl BYTE       "Answer:", 0


.CODE
_MainProc PROC
input  prompt1, string, 40         ; read ASCII characters
atod    string ; convert to integer
mov    number1, eax         ; store in memory

input  prompt2, string, 40         ; read ASCII characters
atod    string ; convert to integer
mov    number2, eax         ; store in memory
       
mov eax, number1 ; gcd := number1
mov ebx, number2 ; remainder := number2
until:         mov ecx, eax ; dividend := gcd
mov eax, ebx ; gcd := remainder
div eax ; dividend mod gcd
mov ebx, ecx ; remainder := dividend mod gcd
cmp ebx, 0 ; remainder = 0
jnz until ; go check condition again
endUntil:
dtoa         gcd, eax       ; convert to ASCII
output gcdLbl, gcd ; output label and GCD

                        mov    eax, 0         ; exit with return code 0
                        ret
_MainProc ENDP
END ; end of source code
Posted on 2009-10-23 16:54:57 by whitey300
see http://www.penguin.cz/~literakl/intel/d.html#DIV
Posted on 2009-10-23 22:34:44 by lone_samurai5
If "input, output, atod and dtoa" are procedures, you will need to add the word "invoke" to the beginning of the lines which mention them.

And you will need to INCLUDE the .inc (and INCLUDELIB the .lib) files for the Libraries which contain those procedures, OR, include the sourcecode for those procedures, so that the assembler (and linker) can know what they look like (ie the #params, and where to find them).
Posted on 2009-10-24 00:07:28 by Homer