flat assembler
Message board for the users of flat assembler.

Index > Linux > Problem with macro / variables

Author
Thread Post new topic Reply to topic
andyz74



Joined: 26 Nov 2007
Posts: 36
Location: Germany
andyz74 30 Nov 2008, 10:06
Hello folks, I have some problem, that I don't understand.
There's some code, which simply should display a decimal number, which looks like this

Code:
format elf executable

entry start

macro print_dez wo
{
pusha
mov ax, wo
xor cx,cx
mov bx,10

schl1:
xor dx,dx
div bx
push dx
inc cx
cmp dx,0

jnz schl1

schl2:
pop dx
mov [ziffer],dl
push ecx
mov eax, 4
mov ebx, 1
mov ecx, ziffer
mov edx, 1
int 128
pop ecx
loop schl2

popa
}

start:


print_dez 1234


mov eax,1
int 128


; here just variables ------  end of code -------------------------------


eingabe db 90h,90h,90h
ziffer db 0

hello db 90h,90h,90h
    


Unfortunately, nothing is displayed. I debugged using "ald" and it seems, that the macro isnt't able to write to my variable "ziffer", which will later be displayed.

Does anybody know, where's the problem?
ThX in advance, Andy

Btw: the 90h in the end are just for myself to find my variable better in the disassembler, so don't mind. Smile
Post 30 Nov 2008, 10:06
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20571
Location: In your JS exploiting you and your system
revolution 30 Nov 2008, 11:10
you probably mean this:
Code:
...
inc cx
cmp ax,0 ;instead of cmp dx,0
...    
and add this:
Code:
...
pop dx
add dl,'0' ;add this to get dl into ASCII codes
mov [ziffer],dl ;check this, do you want a null termimated string?
...    
Post 30 Nov 2008, 11:10
View user's profile Send private message Visit poster's website Reply with quote
andyz74



Joined: 26 Nov 2007
Posts: 36
Location: Germany
andyz74 30 Nov 2008, 11:25
Yeah, now it works. Two unnecesssary errors. Maybe "brain-debugging" is more necessary than code-debugging. :-/

Thank U revolution! Smile
Post 30 Nov 2008, 11:25
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.