So when I take an argument off the stack it seems that is in the form of a string, is there a way i can convert it to a integer so i can "cmp" it with another argument which i also wish to convert to an int? I am a newbie to ASM but i do realize this isn't going to be as easy as it is in higher level languages. Any help?

So when I take an argument off the stack it seems that is in the form of a string, is there a way i can convert it to a integer so i can "cmp" it with another argument which i also wish to convert to an int? I am a newbie to ASM but i do realize this isn't going to be as easy as it is in higher level languages. Any help?

Could we see the code please...As for values(strings) on the stack well I guess that depends on what was pushed onto the stack...

I'm extremely new to assembly, and I don't even know if this is the source of my problem could you tell be why it always says argument 2 is larger even though its not. And please Don't criticize my code, I'm new and I'm really not in the mood to deal with it.

section .data
	one: db 'arg1 is larger'
	ol:  equ $-one
	two: db 'arg2 is larger'
	tl:  equ $-two
	three: db 'args are equal'
	thl:  equ $-three
section .text
	global _one ;if arg1 is larger
	global _two ;if arg2 is larger
	global _three ;if they're equal
	global _start ;main function

_start:
	pop ebx
	pop ebx
	pop eax
	pop ebx
	cmp eax,ebx
	jg _one
	cmp ebx,eax
	jg _two
	mov eax,1
	mov eax,0
_one:
	mov eax,4
	mov ebx,1
	mov ecx,one
	mov edx,ol
	int 80h
	mov eax,1
	mov ebx,0
	int 80h
_two:
	mov eax,4
	mov ebx,1
	mov ecx,two
	mov edx,tl
	int 80h
	mov eax,1
	mov ebx,0
	int 80h
_three:
	mov eax,4
	mov ebx,1
	mov ecx,three
	mov edx,thl
	int 80h
	mov eax,1
	mov ebx,0
	int 80h

Right away I have to ask, are you popping the program's arguments off the stack? If you are then the values are pointers to strings and not the the strings themselves

yeah im popping arguments off the stack. could someone lead me in the right direction?

Well your heading in the right direction, maybe a little ahead of yourself right now. Can you pop off a string pointer value from the stack and display it using the write system call?

I have to run right now but try this code...will it print the first argument "one" when you run it like <filename> one

.section .data

.section .bss

.section .text
	global _start
_start:
  pop ecx
  pop ecx

  mov eax,4
  mov ebx,1
  mov edx,3
  int 80h

  mov eax, 1
  mov ebx, 0
  int 80h

My apologizes if it doesn't work, I don't use nasm

I've done that and a few other things, I've also linked in C programs and used them.

I'm extremely new to assembly, and I don't even know if this is the source of my problem could you tell be why it always says argument 2 is larger even though its not. And please Don't criticize my code, I'm new and I'm really not in the mood to deal with it.

To answer this question "why is argument 2 larger" its because your comparing pointer values and not the values themselves. Try dereferencing the value(s) on the stack

Awesome thank you. Case closed

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.