Jump to content

Assembly Problem

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
9 replies to this topic

#1
maple23

maple23

    Newbie

  • Members
  • Pip
  • 8 posts
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.

#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.
.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

#2
R-G

R-G

    Programmer

  • Members
  • PipPipPipPip
  • 142 posts
Well, I personally don't like the computer software assembler Turbo. If you have already developed the software algorithm in the computer programming language C (not C++ as you mentioned) why should you develop another one that should solve the same problem?

Translate the source software code algorithm with a compiler software in a executable digital file and translate it back with a disassembler software. You should however watch for the quality of the translation so you'll not get unuseful source software code written in the computer programming language Assembly.
Like an angel without a sense of mercy.

#3
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
I agree with R-G. TASM is not the best assembler to use when you can find many other free alternatives. If you're doing Windows programming, I think you should consider either FASM or NASM(X). Both of them have extensively support for the Windows application programming interfaces.

#4
R-G

R-G

    Programmer

  • Members
  • PipPipPipPip
  • 142 posts
Without a doubt. I 100% agree with the computer software assembler Flat.
Like an angel without a sense of mercy.

#5
maple23

maple23

    Newbie

  • Members
  • Pip
  • 8 posts
I do not have a reason for using TASM. I can switch compilers if I need to. How would this be done with a different compiler?

#6
R-G

R-G

    Programmer

  • Members
  • PipPipPipPip
  • 142 posts
Everyone has a reason for something. What do you mean with switch the compiler software? What does this have to do with it? Maybe, you mean the assembler software?
Like an angel without a sense of mercy.

#7
TkTech

TkTech

    The Crazy One

  • Moderators
  • 1,396 posts
Fasm is an excellent, highly portable ( I ported to my os in under 3 hours ) assembler that makes me leap with joy. I'd recommend it any day over tasm.

#8
maple23

maple23

    Newbie

  • Members
  • Pip
  • 8 posts
I mean if I change compilers from TASM to <ENTER YOUR FAVORITE COMPILER HERE>, would you be able to help me?

#9
R-G

R-G

    Programmer

  • Members
  • PipPipPipPip
  • 142 posts
Did you read the second part of my first message?
Like an angel without a sense of mercy.

#10
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
I haven't had a lot of experience in Assembly, but Fasm seems to have a higher reputation than Tasm.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums