Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Assembly Problems

Status
Not open for further replies.

maple23

Programmer
Apr 23, 2008
2
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top