FAQ | Points | Add... | Recent posts | Search | Register | Log in


Asembler (Gnu As) - prosty programik


Post new topic  Reply to topic      Main Page -> Forum Index -> Programming Generally -> Beginners Programming -> Asembler (Gnu As) - prosty programik
Author
Message
_piotr86_
Poziom 3
Poziom 3


Joined: 15 Jan 2009
Posts: 5

Post#1 Post from the author of the topic 14 May 2009 19:35   

Asembler (Gnu As) - prosty programik


Witam! Mam tablice danych .byte. Chce wyswietlic jakis element (np. pierwszy), tzn. odpowiednik liczby w tablicy ASCII. Dlaczego to nie dziala? (GNU As)

Code:
############################################

SYSEXIT = 1
SYSREAD = 3
SYSWRITE = 4
STDOUT = 1
STDIN = 0
EXIT_SUCCESS = 0

.section .data

data1:
    .byte 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x30


.section .text

.globl _start

_start:

mov $0, %edi


mov $SYSWRITE, %eax
mov $STDOUT, %ebx
mov data1(,%edi,1), %ecx    # - chyba ta linijka jest zla...
mov $1, %edx
int $0x80


movl $1, %eax
movl $0, %ebx
int $0x80


###############################


Po prostu nic mi nie wypisuje :(


Prosze o pomoc....


Pozdrawiam
Piotr

Proszę umieszczać kod w znacznikach [code] - poprawiłem.
[Dr.Vee]

Back to top
   
Google

Google Adsense


Post# Post from the author of the topic 14 May 2009 19:35   





Back to top
   
Dr.Vee
Poziom 22
Poziom 22


Joined: 16 May 2008
Posts: 1808
Location: Wrocław

Post#2 14 May 2009 21:34   

Re: Asembler (Gnu As) - prosty programik


Wszystko jest źle ;)
Spróbuj:
Code:
movl $SYSWRITE, %eax
movl $STDOUT, %ebx
movl $data1, %ecx
movl $1, %edx
int  $0x80
Pozdrawiam,
Dr.Vee
Back to top
   
_piotr86_
Poziom 3
Poziom 3


Joined: 15 Jan 2009
Posts: 5

Post#3 Post from the author of the topic 14 May 2009 21:45   

Re: Asembler (Gnu As) - prosty programik


Dzieki, ale to mnie nie urzadza...

Tez tak probowalem i dziala... Tylko pojawia sie drugi problem... Jak dobrac sie do drugiego elementu tablicy, trzeciego itd.????


Pozdrawiam serdecznie i prosze jeszcze o pomoc

Piotr
Back to top
   
Google

Google Adsense


Post# Post from the author of the topic 14 May 2009 21:45   





Back to top
   
Dr.Vee
Poziom 22
Poziom 22


Joined: 16 May 2008
Posts: 1808
Location: Wrocław

Post#4 14 May 2009 22:50   

Re: Asembler (Gnu As) - prosty programik


Możesz zrobić tak:
Code:
movl $data1, %edi
leal 1(%edi), %ecx
Ewentualnie:
Code:
movl $data1, %ecx
addl $1, %ecx
Albo też:
Code:
movl $1, %edi
leal data1(%edi), %ecx
Pozdrawiam,
Dr.Vee
Back to top
   
_piotr86_
Poziom 3
Poziom 3


Joined: 15 Jan 2009
Posts: 5

Post#5 Post from the author of the topic 15 May 2009 01:07   

Re: Asembler (Gnu As) - prosty programik


Dr.Vee wrote:
Możesz zrobić tak:
Code:
movl $data1, %edi
leal 1(%edi), %ecx
Ewentualnie:
Code:
movl $data1, %ecx
addl $1, %ecx
Albo też:
Code:
movl $1, %edi
leal data1(%edi), %ecx
Pozdrawiam,
Dr.Vee



Niestety nie za bardzo chce to dzialac :( . Nic nie wypisuje... (bledow tez nie ma)
Back to top
   
Dr.Vee
Poziom 22
Poziom 22


Joined: 16 May 2008
Posts: 1808
Location: Wrocław

Post#6 15 May 2009 11:01   

Re: Asembler (Gnu As) - prosty programik


No chyba nie muszę za Ciebie pisać całego kodu...
Tymi przykładami zastąp linię
Code:
movl $data1, %ecx
Każdy z podanych przykładów działa na moim systemie (linux i386).

Pozdrawiam,
Dr.Vee
Back to top
   
Google

Google Adsense


Post# 15 May 2009 11:01   





Back to top
   
_piotr86_
Poziom 3
Poziom 3


Joined: 15 Jan 2009
Posts: 5

Post#7 Post from the author of the topic 18 May 2009 02:23   

Re: Asembler (Gnu As) - prosty programik


Slicznie Ci dziekuje... Napisalem pierwsza instrukcje i dziala... Prosze jeszcze o pomoc... wydawalo to mi sie banalne... ale niestety znowu mi tradycyjnie nie dziala :(

Program teraz wyswietla mi odpowiedniki w ASCII elementu tablicy data1 ... Jaka instrukcja "zamienie" to na cyfry???

Probuje dodac 0x30

Code:
 addl $0x30, %ecx


... Ale to jest zle...

Liczbe data1, mam tak napisana:

Code:

data1:
    .byte 0x00, 0x00, 0x00 itd...


czyli po dodaniu 0x30 powinien dostac znak '0' i to ladnie powinno mi wypisac... Niestety tego nie robi...


Prosze o pomoc...


Pozdrawiam serdecznie
Piotr
Back to top
   
pawelhabas
Poziom 4
Poziom 4


Joined: 07 Jun 2008
Posts: 10
Location: Tczew

Post#8 18 May 2009 23:28   

Re: Asembler (Gnu As) - prosty programik


Przestaw operandy.
Back to top
   
Post new topic  Reply to topic      Main Page -> Forum Index -> Programming Generally -> Beginners Programming -> Asembler (Gnu As) - prosty programik
Page 1 of 1
Similar topics
Prosty programik asembler zaświecanie diód LED (4)
Prosty programik w C, problem (9)
Prosty programik w java (4)
potrzebuje prosty programik w delphi 5 (1)
Prosty programik c++ - sprawdzil by mi ktos...? (1)
[Turbo Delphi] Prosty Programik (4)
Poprawilem prosty programik .bat (4)
Prosty programik losujący - totolotek (13)
Napisze ktoś prosty programik PIC16F84 ? (3)
Prośba o prosty programik (BASCOM) M16 (35)

Page generation time: 0.088 seconds


FAQ || Administrator || Moderators || Widgets and banners || Contact
elektroda.pl topic RSS feed