The MASM Forum

General => The Campus => Topic started by: Evan on December 02, 2013, 04:36:06 AM

Title: WARNING: CONFUSION A MUST
Post by: Evan on December 02, 2013, 04:36:06 AM

I'm trying to assemble but these things fall apart so easily.
;Warning i don't want to fry anything



;Goal: make a binary counter that outputs number sheets
;And clear out some registers
;I'm trying to own my computer



mov yallin BINARY(1000000)
mov yallout BINARY(0000001)
loopin
   move A2 yallin
   move A1 yallout
      yallin(A1 + 1)
         if A1 > A2
            end.
loopout


loopin(end.)
   move A2 0
   move A1 0
;I'm thinking I'm easing that A1 with that A2 maybe
loopout



Could you guys kinda help me?

I am really trying to start.
Title: Re: I do not remember how I learned to count when I was little
Post by: Evan on December 02, 2013, 04:48:05 AM
I assume I will be able to translate this through macros???

Can I just through this in a string or array or some shit and keep going if I write it right?
Title: Re: I do not remember how I learned to count when I was little
Post by: Evan on December 02, 2013, 04:51:43 AM
This code can show me it's output on a console when it is assembled correctly.
I got the console output macro down packed I'm thinking.
Title: Re: WARNING: CONFUSION A MUST
Post by: dedndave on December 02, 2013, 06:26:18 AM
hi Evan - i thought we lost you

are you set up so that you can assemble programs ?
irvine library ?
Masm32 ?
Title: Re: WARNING: CONFUSION A MUST
Post by: Evan on December 02, 2013, 06:27:55 AM
Yep I can assemble my good old EXE files fine and dandy. I think the only macro I have is the console.
I'm a little funnied out. I wonder how extreme what which choices are when it comes to this stuff.
Title: Re: WARNING: CONFUSION A MUST
Post by: dedndave on December 02, 2013, 06:29:01 AM
ok - but, i need to know which package you have working - or both ?
Title: Re: WARNING: CONFUSION A MUST
Post by: Evan on December 02, 2013, 06:30:38 AM
Quote from: dedndave on December 02, 2013, 06:29:01 AM
ok - but, i need to know which package you have working - or both ?
Sorry I edit my comments so much.  What do you mean by packages? Oh! Those little pesky guys before my start?
Title: Re: WARNING: CONFUSION A MUST
Post by: dedndave on December 02, 2013, 06:31:51 AM
the Masm32 package is the one that you download from this site
the Irvine library package goes with the book - and is available on Kip's site

maybe - show me a program that you can assemble
Title: Re: WARNING: CONFUSION A MUST
Post by: Evan on December 02, 2013, 06:33:10 AM
Quote from: dedndave on December 02, 2013, 06:31:51 AMthe Masm32 package is the one that you download from this site
the Irvine library package goes with the book - and is available on Kip's site

maybe - show me a program that you can assemble

Yeah I get my assembly tools from MASM as much as I can.


Sorry I abuse my internet so much. It's that google fiber kickin in of something.




Idk I don't get it.





    .486                                    ; create 32 bit code
    .model flat, stdcall                    ; 32 bit memory model
    option casemap :none                    ; case sensitive
 
    include \masm32\include\windows.inc     ; always first
    include \masm32\macros\macros.asm       ; MASM support macros


  ; -----------------------------------------------------------------
  ; include files that have MASM format prototypes for function calls
  ; ;---------------------------yeah c;omputer destryed----------------------------------------
    include \masm32\include\masm32.inc
    include \masm32\include\gdi32.inc
    include \masm32\include\user32.inc
    include \masm32\include\kernel32.inc


  ; ------------------------------------------------
  ; Library files that have definitions for function
  ; exports and tested reliable prebuilt code.
  ; ------------------------------------------------
    includelib \masm32\lib\masm32.lib
    includelib \masm32\lib\gdi32.lib
    includelib \masm32\lib\user32.lib
    includelib \masm32\lib\kernel32.lib


    .code                       ; Tell MASM where the code starts
Title: Re: WARNING: CONFUSION A MUST
Post by: dedndave on December 02, 2013, 06:34:14 AM
ok - i am guessing A1 and A2 are registers
is that correct ?
Title: Re: WARNING: CONFUSION A MUST
Post by: Evan on December 02, 2013, 06:35:53 AM
Yeah that was my plan. But now I'm trying to convert my hackl assembly into masm assembly.
Title: Re: WARNING: CONFUSION A MUST
Post by: Evan on December 02, 2013, 06:37:30 AM
This was my idea


Carve myself out a something to use for counting so i can get a window going and draw a line.
Title: Re: WARNING: CONFUSION A MUST
Post by: dedndave on December 02, 2013, 06:41:36 AM
let's see how this goes....
        INCLUDE    \Masm32\Include\Masm32rt.inc

;###############################################################################################

        .DATA

yallin  db 80h
yallout db 1

;***********************************************************************************************

        .DATA?

;###############################################################################################

        .CODE

;***********************************************************************************************

_main   PROC

        xor     eax,eax           ;EAX = 0
        xor     edx,edx           ;EDX = 0

        mov     al,yallout        ;AL = yallout = 1
        mov     dl,yallin         ;DL = yallin = 80h = 10000000b

loop00: inc     al                ;AL = AL +1
        cmp     al,dl             ;compare AL with DL
        jb      loop00            ;jump if below back to loop00

        print   uhex$(eax),13,10  ;show EAX in hexadecimal

;wait for a key, then exit

        print   chr$(13,10)
        inkey
        INVOKE  ExitProcess,0

_main   ENDP

;###############################################################################################

        END     _main
Title: Re: WARNING: CONFUSION A MUST
Post by: Evan on December 02, 2013, 06:43:50 AM
I was thinking that if I just used the console for my window it would make this project even better. Kinda a lot.
The console is good for showing some forms of data.
Title: Re: WARNING: CONFUSION A MUST
Post by: Evan on December 02, 2013, 06:45:11 AM
Quote from: dedndave on December 02, 2013, 06:41:36 AM
let's see how this goes....
        INCLUDE    \Masm32\Include\Masm32rt.inc

;###############################################################################################

        .DATA

yallin  db 80h
yallout db 1

;***********************************************************************************************

        .DATA?

;###############################################################################################

        .CODE

;***********************************************************************************************

_main   PROC

        xor     eax,eax           ;EAX = 0
        xor     edx,edx           ;EDX = 0

        mov     al,yallout        ;AL = yallout = 1
        mov     dl,yallin         ;DL = yallin = 80h = 10000000b

loop00: inc     al                ;AL = AL +1
        cmp     al,dl             ;compare AL with DL
        jb      loop00            ;jump if below back to loop00

        print   uhex$(eax),13,10  ;show EAX in hexadecimal

;wait for a key, then exit

        print   chr$(13,10)
        inkey
        INVOKE  ExitProcess,0

_main   ENDP

;###############################################################################################

        END     _main



Okay I will try to understand that really good and then most likely run it no matter what.
Title: Re: WARNING: CONFUSION A MUST
Post by: dedndave on December 02, 2013, 06:47:30 AM
here's another version
i added 5 more lines of code to show each step of the loop
Title: Re: WARNING: CONFUSION A MUST
Post by: dedndave on December 02, 2013, 06:52:40 AM
in both of those, i used BYTE values for yallin and yallout

in 32-bit code, 32-bit values are often easier to work with (and sometimes faster)
in this version, i made everything DWORD's
Title: Re: WARNING: CONFUSION A MUST
Post by: dedndave on December 02, 2013, 06:59:18 AM
in the above programs, we loaded yallin into EDX
we can compare a register value with another register value

we can also compare a register value directly with a memory value
we cannot compare a memory value directly with another memory value
    cmp     yallin,yallout
will not work

(it can be done with string instructions, but let's keep things simple)