News:

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

How to execute in EasyCode?

Started by jackie, August 09, 2008, 07:17:50 PM

Previous topic - Next topic

jackie

I have years of Masm/Tasm experience, but now I am trying to use Masm32 in EasyCode. I want to use it to teach a class in architecture/assembler, so I just need to be able to write simple console apps and display or print output. I'd like the students to be able to use EasyCode, but I can't figure out how to execute a program or open a program and create a project from it.
    I've opened the console code demos using EasyCode, which seems to be the supplied editor. The program's comment at the top says
;                 Build this with the "Project" menu using
;                       "Console Assemble and Link"
But the Project menu doesn't have that option! I can build the code, but I can't figure out how to run it. If there were an .exe file, I could run it outside the editor, but the compilation creates a project.  I have looked for documentation, and I see nothing on how to run a program from within EasyCode. I did get a demo to run using ml and link, but that doesn't sound like the right way to do it, since the output window closes immediately after execution.
      Once I get past this hump, I should be fine. Can anyone help?
Thanks for your help,
-jackie

jj2007

Quote from: jackie on August 09, 2008, 07:17:50 PMI did get a demo to run using ml and link, but that doesn't sound like the right way to do it, since the output window closes immediately after execution.
Can't help you with specific EasyCode questions, but from ml and link you get an exe that you can run - e.g. from a DOS prompt, so that you can see the output... another option to prevent the window from closing is this:

...
print chr$(13,10,10)
inkey "Press any key to exit..."
exit
end start


EDIT:
Attached a "barebone" console app, complete with build file. You can use Notepad to edit the *.asm, then drag it over bldConsole.bat


[attachment deleted by admin]

jackie

Thank you! Being able to keep the window open means I have at least SOME way for my students to work if I must use this program. And your barebones code shows me the source of the I/O functions. The sample code with MASM32 is so full of include files that I don't know what is necessary.  I'd still like to know how to use EasyCode in some manner. And I'm not sure that batch file is going to work for the students who have to run in Vista...
-jackie

AeroASM

My very inexperienced and highly unprofessional advice would be:

1. Use notepad as an editor.
2. Build using ml /c file.asm and then link /subsystem:console file.obj at the console. (I would put those two into a batch file.) Then run at the console by typing file.exe.
3. Use the C runtime library for I/O to the console. The only include you need is msvcrt.inc. (also includelib msvcrt.lib). I say this because there is a chance that some of your students may be familiar with it.

P

MichaelW

jackie,

I prefer to use the editor that comes with the MASM32 package, qeditor.exe. It has a large amount of functionality built in, and it can readily be customized to add more. Among many other things it includes a variety of code templates that can be inserted into the edit window by selecting them from the Code menu. If none of the templates meet your requirements, you can create your own, as I did for the console template that I use:

    call comment
    text     include \masm32\include\masm32rt.inc{lf}
    newline
    call comment
    text     .data{lf}
    newline
    text     .code{lf}
    call comment
    text start:{lf}
    linestart
    call comment
    newline
    text     inkey "Press any key to exit..."{lf}
    text     exit{lf}
    call comment
    newline
    call comment
    text end start{lf}

    exit
    comment:
      text {comment} «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««{lf}
    retn


And to add the template to the menu you place an appropriate statement in menus.ini, in my case:

My &Console Model,\MASM32\MY_CONSOLE_MODEL.QSC

This is a small app created from my template, coded, assembled, linked, and run from within the editor:

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    ;---------------------------------------------------
    ; Generate and display first 100 Fibonacci numbers.
    ;---------------------------------------------------
   
    xor eax, eax
    mov edi, 1
    mov ebx, 100
  @@:
    push edi
    add edi, eax
    print ustr$(edi),13,10
    pop eax
    dec ebx
    jnz @B

    inkey "Press any key to exit..."
    exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start


And you can even disassemble the EXE from within the editor by selecting Dis-assemble EXE file from the Tools menu:

D:\masm32\My\Junk\fibonacci.exe    (hex)           (dec)

.EXE size (bytes)                    490            1168
Minimum load size (bytes)            450            1104
Overlay number                         0               0
Initial CS:IP                  0000:0000
Initial SS:SP                  0000:00B8             184
Minimum allocation (para)              0               0
Maximum allocation (para)           FFFF           65535
Header size (para)                     4               4
Relocation table offset               40              64
Relocation entries                     0               0

Portable Executable starts at                 b8
Signature                               00004550 (PE)
Machine                                     014C (Intel 386)
Sections                                    0003
Time Date Stamp                         489C9A16 Fri Aug  8 15:10:14 2008
Symbol Table                            00000000
Number of Symbols                       00000000
Optional header size                        00E0
Characteristics                             010F
Relocation information stripped
Executable Image
Line numbers stripped
Local symbols stripped
32 bit word machine
Magic                                       010B
Linker Version                              5.12
Size of Code                            00000200
Size of Initialized Data                00000400
Size of Uninitialized Data              00000000
Address of Entry Point                  00001000
Base of Code                            00001000
Base of Data                            00002000
Image Base                              00400000
Section Alignment                       00001000
File Alignment                          00000200
Operating System Version                    4.00
Image Version                               0.00
Subsystem Version                           4.00
reserved                                00000000
Image Size                              00004000
Header Size                             00000400
Checksum                                00000000
Subsystem                                   0003 (Console)
DLL Characteristics                         0000
Size Of Stack Reserve                   00100000
Size Of Stack Commit                    00001000
Size Of Heap Reserve                    00100000
Size Of Heap Commit                     00001000
Loader Flags                            00000000
Number of Directories                   00000010

Directory Name                          VirtAddr  VirtSize
--------------------------------------  --------  --------
Export                                  00000000  00000000
Import                                  00002028  0000003C
Resource                                00000000  00000000
Exception                               00000000  00000000
Security                                00000000  00000000
Base Relocation                         00000000  00000000
Debug                                   00000000  00000000
Decription/Architecture                 00000000  00000000
Machine Value (MIPS GP)                 00000000  00000000
Thread Storage                          00000000  00000000
Load Configuration                      00000000  00000000
Bound Import                            00000000  00000000
Import Address Table                    00002000  00000028
Delay Import                            00000000  00000000
COM Runtime Descriptor                  00000000  00000000
(reserved)                              00000000  00000000

Section Table
-------------
01  .text    Virtual Address         00001000
Virtual Size            00000162
Raw Data Offset         00000400
Raw Data Size           00000200
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         60000020
Code
Executable
Readable

02  .rdata  Virtual Address         00002000
Virtual Size            00000110
Raw Data Offset         00000600
Raw Data Size           00000200
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         40000040
Initialized Data
Readable

03  .data    Virtual Address         00003000
Virtual Size            00000040
Raw Data Offset         00000800
Raw Data Size           00000200
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         C0000040
Initialized Data
Readable
Writeable


Imp Addr Hint Import Name from kernel32.dll - Not Bound
-------- ---- ---------------------------------------------------------------
00002000  16A GetStdHandle
00002004  2FB WriteFile
00002008   C6 FlushConsoleInputBuffer
0000200C  2BB Sleep
00002010   9B ExitProcess

Imp Addr Hint Import Name from msvcrt.dll - Not Bound
-------- ---- ---------------------------------------------------------------
00002018   CE _getch
0000201C  111 _kbhit
00002020  1B6 _ultoa

IAT Entry

00000000: 0000209A 000020AA - 000020B6 000020D0 - 0000208C 00000000
00000018: 000020F0 000020FA - 000020E6 00000000

Disassembly

00401000                    start:
00401000 33C0                   xor     eax,eax
00401002 BF01000000             mov     edi,1
00401007 BB64000000             mov     ebx,64h
0040100C                    loc_0040100C:
0040100C 57                     push    edi
0040100D 03F8                   add     edi,eax
0040100F 6A0A                   push    0Ah
00401011 6800304000             push    403000h
00401016 57                     push    edi
00401017 FF1520204000           call    dword ptr [_ultoa]
0040101D 83C40C                 add     esp,0Ch
00401020 6800304000             push    403000h
00401025 E82E000000             call    fn_00401058
0040102A 6814304000             push    403014h
0040102F E824000000             call    fn_00401058
00401034 58                     pop     eax
00401035 4B                     dec     ebx
00401036 75D4                   jnz     loc_0040100C
00401038 6817304000             push    403017h
0040103D E816000000             call    fn_00401058
00401042 E849000000             call    fn_00401090
00401047 6830304000             push    403030h
0040104C E807000000             call    fn_00401058
00401051 6A00                   push    0
00401053 E8DA000000             call    fn_00401132
00401058                    fn_00401058:
00401058 55                     push    ebp
00401059 8BEC                   mov     ebp,esp
0040105B 83C4F4                 add     esp,0FFFFFFF4h
0040105E 6AF5                   push    0FFFFFFF5h
00401060 E8D3000000             call    fn_00401138
00401065 8945FC                 mov     [ebp-4],eax
00401068 FF7508                 push    dword ptr [ebp+8]
0040106B E850000000             call    fn_004010C0
00401070 8945F4                 mov     [ebp-0Ch],eax
00401073 6A00                   push    0
00401075 8D45F8                 lea     eax,[ebp-8]
00401078 50                     push    eax
00401079 FF75F4                 push    dword ptr [ebp-0Ch]
0040107C FF7508                 push    dword ptr [ebp+8]
0040107F FF75FC                 push    dword ptr [ebp-4]
00401082 E8B7000000             call    fn_0040113E
00401087 8B45F8                 mov     eax,[ebp-8]
0040108A C9                     leave
0040108B C20400                 ret     4
0040108E CC                     int     3
0040108F CC                     int     3
00401090                    fn_00401090:
00401090 6AF6                   push    0FFFFFFF6h
00401092 E8A1000000             call    fn_00401138
00401097 50                     push    eax
00401098 E8A7000000             call    fn_00401144
0040109D                    loc_0040109D:
0040109D 6A01                   push    1
0040109F E8A6000000             call    fn_0040114A
004010A4 FF151C204000           call    dword ptr [_kbhit]
004010AA 85C0                   test    eax,eax
004010AC 74EF                   jz      loc_0040109D
004010AE FF1518204000           call    dword ptr [_getch]
004010B4 C3                     ret
004010B5 CC                     int     3
004010B6 CC                     int     3
004010B7 CC                     int     3
004010B8 CC                     int     3
004010B9 CC                     int     3
004010BA CC                     int     3
004010BB CC                     int     3
004010BC CC                     int     3
004010BD CC                     int     3
004010BE CC                     int     3
004010BF CC                     int     3
004010C0                    fn_004010C0:
004010C0 8B442404               mov     eax,[esp+4]
004010C4 8D5003                 lea     edx,[eax+3]
004010C7 55                     push    ebp
004010C8 57                     push    edi
004010C9 BD80808080             mov     ebp,80808080h
004010CE                    loc_004010CE:
004010CE 8B38                   mov     edi,[eax]
004010D0 83C004                 add     eax,4
004010D3 8D8FFFFEFEFE           lea     ecx,[edi-1010101h]
004010D9 F7D7                   not     edi
004010DB 23CF                   and     ecx,edi
004010DD 23CD                   and     ecx,ebp
004010DF 7539                   jnz     loc_0040111A
004010E1 8B38                   mov     edi,[eax]
004010E3 83C004                 add     eax,4
004010E6 8D8FFFFEFEFE           lea     ecx,[edi-1010101h]
004010EC F7D7                   not     edi
004010EE 23CF                   and     ecx,edi
004010F0 23CD                   and     ecx,ebp
004010F2 7526                   jnz     loc_0040111A
004010F4 8B38                   mov     edi,[eax]
004010F6 83C004                 add     eax,4
004010F9 8D8FFFFEFEFE           lea     ecx,[edi-1010101h]
004010FF F7D7                   not     edi
00401101 23CF                   and     ecx,edi
00401103 23CD                   and     ecx,ebp
00401105 7513                   jnz     loc_0040111A
00401107 8B38                   mov     edi,[eax]
00401109 83C004                 add     eax,4
0040110C 8D8FFFFEFEFE           lea     ecx,[edi-1010101h]
00401112 F7D7                   not     edi
00401114 23CF                   and     ecx,edi
00401116 23CD                   and     ecx,ebp
00401118 74B4                   jz      loc_004010CE
0040111A                    loc_0040111A:
0040111A F7C180800000           test    ecx,8080h
00401120 7506                   jnz     loc_00401128
00401122 C1E910                 shr     ecx,10h
00401125 83C002                 add     eax,2
00401128                    loc_00401128:
00401128 D0E1                   shl     cl,1
0040112A 1BC2                   sbb     eax,edx
0040112C 5F                     pop     edi
0040112D 5D                     pop     ebp
0040112E C20400                 ret     4
00401131 CC                     int     3
00401132                    fn_00401132:
00401132 FF2510204000           jmp     dword ptr [ExitProcess]
00401138                    fn_00401138:
00401138 FF2500204000           jmp     dword ptr [GetStdHandle]
0040113E                    fn_0040113E:
0040113E FF2504204000           jmp     dword ptr [WriteFile]
00401144                    fn_00401144:
00401144 FF2508204000           jmp     dword ptr [FlushConsoleInputBuffer]
0040114A                    fn_0040114A:
0040114A FF250C204000           jmp     dword ptr [Sleep]
00401150 FF2520204000           jmp     dword ptr [_ultoa]
00401156 FF2518204000           jmp     dword ptr [_getch]
0040115C FF251C204000           jmp     dword ptr [_kbhit]

eschew obfuscation

jackie

Wow! Thanks to both of you! When Hutch referred me to the built-in editor, I thought he meant EasyCode, because it installed on my system with the Masm32 package, and opening any .asm file initiates it. All the replies have really steered me in the right direction. Maybe I can get somewhere now!
-jackie

hutch--

jackie,

Ramon's Easycode is an excellent tool but its primarily for GUI applcations where you can use its resource building capacity for interface design. The default editor in masm32 has just been rewritten in MASM from scratch and it has two seperate scripting engines, a legacy version to handle older QE scripts and a new one that is designed to extend the editor with scripts that are much more powerful than the earlier versions.

There are two seperate options on the menus to convert either source files to script form or binary files for things like icopns and bitmaps so if you have a design you want to easily replicate, convert it to script format then add whatever logic you need for file naming, optional code inclusion and the like.

The console template system in masm32 is designed to make algorithm test beds fast and easy to write and this is highly suitable for the task of teaching students useful things like data manipulation, integer and FP maths rather than wasting a semester doing bare screen display in 16 bit DOS. By etting the trudgery out of basic display IO, file IO and the like you can point students into modern 32 bit protected mode programming where they actually learn something useful.

The release version of masm32 version 10 is close, I am inclined to nitpick it to try and get more reliable but there is little left to do on it so it will be out soon.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php