News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Program to sum two numbers

Started by blue, August 27, 2011, 09:52:50 AM

Previous topic - Next topic

dedndave

Michael posted a batch file
give me a little time - let me see if i can make it work   :P

blue

I tried to make it work and I assume that the framework.c must be compiled to an .obj file and then linked but I don't know how.

dedndave

i think you have to assemble io.asm to make io.obj and link it with your obj
give me a few minutes...

dedndave

yes - we have been trying to make things work in the console
and, apparently, some have had success with it too   :eek

it seems the framework files provide a dialog box for the results to be displayed
there must be a procedure in the book
have you skipped some chapters  ?   :P

the framework app could be re-written in asm
or, you could try to make the thing work in the console

the easiest path is probably to follow the book   :bg

i am not really a "C" person - lol

blue

I haven't skipped any chapter. I think this book is not for a beginner in assembler as far as I get these stupid errors. I think the book itself is stupid.
Anyway, the problem is with that framework.c: getInput and showOutput.

dedndave

i am looking at the book, now
page 10 gives a procedure for building this project (well - it's page 10 on the web)
http://docs.google.com/viewer?a=v&q=cache:FKU3A7Ay7k0J:www.neduet.edu.pk/cise/docs/CAO_2011.pdf+detmer+framework+asm+example&hl=en&gl=us&pid=bl&srcid=ADGEESg_uuUV7lh8PlG1rLuFce8-opUSymzONDBMllPm_e3YQuTFBMRAKep_olXTL37YkTfa4bln8xssJir3cTuc-ulXY14L482_jnIRZGizKBRAlcGhH0IScmTVZSNCZqrZdyku6mrG&sig=AHIEtbS7lGpJrve8sycjcZe08cmt8RBguQ

it says 2 things that leave me out of the game
1) visual C 2008 is required
2) an instructor will show you how to.....

i don't want to install visual C

but, this book was clearly written for a classroom environment
i suggest you set it on the shelf - you may be able to use parts of it as reference
but to get started, go with the masm32 package
once you know your way around a little, you will be better equipped to know which parts of the book are usable

blue

That's another edition of this book, which seems better organized.

LE: That;s the practical workbook. My mistake.

GregL

blue,

I have both the first and second editions of this book. I thought I had the files for the first edition but I can't locate them anywhere. I do have the files for the second edition, but they are different from the first edition. Sorry.




hutch--

blue,

Here is how to do your task in MASM32.


IF 0  ; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                      Build this template with "CONSOLE ASSEMBLE AND LINK"
ENDIF ; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm32\include\masm32rt.inc

    is_it_a_number PROTO :DWORD

    .code

start:
   
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    call main
    inkey
    exit

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

main proc

    LOCAL lpstring1 :DWORD
    LOCAL lpstring2 :DWORD

    LOCAL num1  :DWORD
    LOCAL num2  :DWORD
    LOCAL rslt  :DWORD

    jmp inp1

  err1:
    print "Numbers only, please re-enter input 1",13,10

  inp1:
    mov lpstring1, input("Enter 1st number here ",62," ")
    invoke is_it_a_number,lpstring1
    test eax, eax
    jz err1
    mov num1, uval(lpstring1)

    jmp inp2

  err2:
    print "Numbers only, please re-enter input 2",13,10

  inp2:
    mov lpstring2, input("Enter 2nd number here ",62," ")
    invoke is_it_a_number,lpstring2
    test eax, eax
    jz err2
    mov num2, uval(lpstring2)

    mov eax, num1
    add eax, num2
    mov rslt, eax

    print "the total of the 2 inputs is "
    print ustr$(rslt),13,10

    ret

main endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

is_it_a_number proc integer:DWORD

    mov ecx, integer
    sub ecx, 1

  lpst:
    add ecx, 1
    cmp BYTE PTR [ecx], 0
    je success
    cmp BYTE PTR [ecx], 48
    jb fail
    cmp BYTE PTR [ecx], 57
    ja fail
    jmp lpst

  success:
    mov eax, 1
    ret

  fail:
    xor eax, eax
    ret

is_it_a_number endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

end start
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

vanjast

ASCII codes and other things
http://www.ascii.cl/

Blue.. may I also add - While you're learning, practice thinking in 'little black boxes'.
It take a little while, but training yourself to containerise code into working boxes will help prevent you from smashing your keyboard.
90% of good programming starts on pieces of paper - from there it's 'manual labour' to tap the keyboard for days on end. :green2

Also if you do a good job, about 75% of your filesizes contain informative comments/desciptions - You will forget what you coded a few days ago.
It's nearly impossible to remember all that sh.1t
:wink