News:

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

Main Menu

x86 assembly language newbie requesting help on a project.

Started by ProtoflareX, February 28, 2016, 09:52:25 AM

Previous topic - Next topic

ProtoflareX

Hello, masm32 forum users. I am taking an x86 assembly language course this semester and am struggling to grasp it as well as I was able to grasp Java. As a result of this, I am having quite a bit of trouble completing a project that my professor assigned recently (which is embarassing, because it is supposed to be a novice level course). To make matters worse, I cannot actually test code myself since I get an "A1000 error" each time I attempt to do a console build all. I was wondering if some of the forum users here could assist me with the project and provide useful hints / tips that will allow me to more easily work through it. I have posted picture of the project requirements as well as my current progress (which is barely anything) below. Oh, and I will be using the MASM32 editor in order to write the code.

Project requirements: http://puu.sh/nmguK/40e9e448d6.png

Current Progress: http://puu.sh/nnMI1/27ae69be6e.png

I am currently attempting to complete the task described in the first bullet point. Since I cannot test my code, I would like to know if I have completed that task, or if I have made any mistakes (which is highly likely).


jj2007

Error A1000 means probably that a file is missing. But you forgot to tell us which one.

ProtoflareX

This is the exact message: http://puu.sh/nnOg4/84e5bd0245.png

The thing is, I just checked that directory and the file is definitely there, as shown in this picture: http://puu.sh/nnOdS/8cf4a1c712.png

GoneFishing


ProtoflareX

Quote from: GoneFishing on February 28, 2016, 10:49:49 AM
Does Project1 file have .asm extension ?

I added the esm extension after reading your comment. I also facepalmed very hard when it worked. That was so obvious, but I still didn't realize. Oh well, thank you for helping me fix that, that would have been a major problem throughout the entire semester. Hopefully someone can help me with the requirements now.

hutch--

Just note that we have a firm "No Homework" rule in this forum, members will help you but only if you do your own work. Ask other people to do your work for you and you will be shown the door.  :badgrin:

jj2007

Quote from: ProtoflareX on February 28, 2016, 10:55:51 AMThat was so obvious

Don't worry, that happened to me, too. It is a bad habit of certain editors to save files without ending ;-)
Now go ahead and attack your agenda, step by step. We'll help you to correct errors in your code. How much time is left? Is your teacher Kip Irvine, or do you have another reason to use his library? Here, almost everybody uses Masm32...

ProtoflareX

I've continued to work on the project since my last response. I haven't made much progress, but that's besides the point. I am currently experiencing an issue in which I get error A2006 "undefined symbol : prompt" when I attempt a console build all. The line of code containing the prompt is similar to an example that I saw in my textbook, so I'm not sure what's causing the error. I have linked pictures of my current code and the error below. Would anyone happen to know why this is occurring?

Code: http://puu.sh/noIv3/43f1c653b3.png

Error: http://puu.sh/noIGx/94ab7ed071.png

GoneFishing

Probably assembler wants symbol prompt to be defined
Give to ML what he  wants
add  this to .data:
prompt BYTE "Hello I'm prompt",0

ProtoflareX

Quote from: GoneFishing on February 29, 2016, 06:08:10 AM
Probably assembler wants symbol prompt to be defined
Give to ML what he  wants
add  this to .data:
prompt BYTE "Hello I'm prompt",0

Ah, I see. It worked, thank you.

dedndave

you probably want something like "Enter a string" as a prompt

you have some other problems, though...

first, you probably want more than a single byte for an input buffer
in fact, the ReadString function needs a buffer that will accomodate the null terminator so, at least 2 bytes are needed
i suggest you use 256 characters for the buffer

theStringArray BYTE 256 dup(?)

also, the ReadString function needs 2 registers to be set...
ReadString inputs:
EDX = offset of the input buffer
ECX = maximum characters to input (including terminal null)


so, you probably want something like
    mov     edx,offset theStringArray
    mov     ecx,sizeof theStringArray
    call    ReadString

ProtoflareX

Quote from: dedndave on February 29, 2016, 09:39:44 AM
you probably want something like "Enter a string" as a prompt

you have some other problems, though...

first, you probably want more than a single byte for an input buffer
in fact, the ReadString function needs a buffer that will accomodate the null terminator so, at least 2 bytes are needed
i suggest you use 256 characters for the buffer

theStringArray BYTE 256 dup(?)

also, the ReadString function needs 2 registers to be set...
ReadString inputs:
EDX = offset of the input buffer
ECX = maximum characters to input (including terminal null)


so, you probably want something like
    mov     edx,offset theStringArray
    mov     ecx,sizeof theStringArray
    call    ReadString


After making changes based on your comment, my current code looks like what is linked in the picture below. However, when I do a console build all, I do not receive an input prompt. Would you happen to know the reason for this?

Current code: http://puu.sh/np4w9/e8c34a000c.png

Result of "console build all": http://puu.sh/np4GL/8e454a282f.png

dedndave

i sure do
you moved the ReadString call from the PROC, and placed it at the beginning of the program

it isn't very convenient that you post images of the code text
copy and paste the text into the reply window, then highlight it, then click on the # icon above the reply window
that way, we can copy and paste without having to do a lot of typing

originally, a partial looked like this

.code
main PROC
mov edx,offset theStringArray
call requestInput
EXIT
main ENDP

requestInput PROC

mov edx,offset prompt
call WriteString
call ReadString
ret
requestInput ENDP
END main


i suggested this modification
    mov     edx,offset theStringArray
    mov     ecx,sizeof theStringArray
    call    ReadString


you totally butchered my intent - lol

try this code...

    .CODE

main PROC

    mov     edx,offset theStringArray
    mov     ecx,sizeof theStringArray
    call    requestInput
    exit

main ENDP

requestInput PROC

    push    edx
    push    ecx
    mov     edx,offset prompt
    call    WriteString
    pop     ecx
    pop     edx
    call    ReadString
    ret

requestInput ENDP

    END     main

ProtoflareX

The result of your code is linked below. I'm going to assume that isn't the desired result. It feels absolutely awful to be incapable of discerning the problem myself. Also, I'll listen to your suggestion about pasting my code in the future.

Result of your code: http://puu.sh/npcSu/e9fc74f1bd.png

dedndave

that looks ok - did you try to run the program ?

Kip Irvine's library isn't very modular
so, everything gets pulled in, resulting in larger than needed EXE's
so, 9 KB might be ok