×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Simple Assembly Problems

Simple Assembly Problems

Simple Assembly Problems

(OP)
I have been working with assembly (TASM32) for a few months now and have ran into a problem which I cannot fix.  Here's a working example written in C++ which needs to be converted to assembly.

CODE

#include <windows.h>

int    main(){
    char    *name_list[5] = {"Micheal", "Stefan", "Judy", "William", "Lora"};
    for(int i = 0; i < 5; i++){
        MessageBox(0, name_list[i], name_list[i], 0);
    }
    return 0;
}
Here's the assembly version I've written.  It goes through the five names fine, after the names, it brings up a message box with random characters.

CODE

.386
.model flat

EXTRN    MessageBoxA : PROC
EXTRN    ExitProcess : PROC

.DATA
    dd ?            ; TASM gayness

.CODE
MAIN:
    pushad
    call    lblNames
        db "Micheal", 0
        db "Stefan", 0
        db "Judy", 0
        db "William", 0
        db "Lora", 0

lblNames:
    pop    esi        ; esi = current name
    push    5        ; 5 names
    pop    ecx        ; ecx = counter

lblNameLoop:
    push    0
    push    esi
    push    esi
    push    0
    call    MessageBoxA

lblNextChar:
    lodsb
    test    al, al
    jnz    lblNextChar

    pop    ecx
    loop    lblNameLoop

    popad

    push    0
    call    ExitProcess
END    MAIN
Does anyone know what the problem is, or have any suggestions for me?  This seems much more complicated than it should be...

Sorry for my English.

Thank you,
Stefan Kendrick

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close