View Single Post
  #1 (permalink)  
Old 04-23-2008, 12:11 PM
maple23 maple23 is offline
Newbie
 
Join Date: Apr 2008
Posts: 8
Credits: 0
Rep Power: 0
maple23 is on a distinguished road
Default Assembly Problem

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
Reply With Quote

Sponsored Links