Jump to content



Euro to Drahmas (PHP)


Dr.Paneas

Recommended Posts

  • Replies 46
  • Created
  • Last Reply

Bourne Shell

#!/bin/bash
if [ -z "$2" ]; then
echo "Syntax: $0 <convertion> <value>
Convertions:
e2d euro to drahmas
d2e drahmas to euro";
exit 0
fi

CURRENCY=340

if [ $1 = 'e2d' ];then
let euro2drx=$2*$CURRENCY
echo "$2 euro -> $euro2drx drahmas"
else
let drx2euro=$2/$CURRENCY
echo "$2 drahmas -> $drx2euro euro"
fi

Link to comment
Share on other sites

Perl

#!/usr/bin/perl -w
use strict;

my $euro2drx;
my $drx2euro;
my $CURRENCY="340.75";

if (@ARGV ne 2){
print "Usage: conv.pl <convertion> <value>
Convertions:
e2d euro to drahmas
d2e drahmas to euro\n";
exit(0);
}

my $value=pop(@ARGV);
my $type=pop(@ARGV);

if ($type =~ "e2d"){
$euro2drx = $value * $CURRENCY;
print "$value euro -> $euro2drx drahmas\n";

}else{
$drx2euro = $value / $CURRENCY;
print "$value drahmas -> $drx2euro euro\n";

}

Καλα, πήρα φορα τωρα... :hehe:

Link to comment
Share on other sites

Assembly

;Πάνο πεσε το δώροοοοοοοοοο!!!!!!!!
;Χεχεχε...


.686p
.mmx
.model flat

_init segment para public 'CODE' use32
assume cs:_init

assume es:nothing, ss:nothing, ds:_data, fs:nothing, gs:nothing


public _init_proc
_init_proc proc near
push ebp
mov ebp, esp
sub esp, 8
call call_gmon_start
call frame_dummy
call __do_global_ctors_aux
leave
retn
_init_proc endp

_init ends


_plt segment dword public 'CODE' use32
assume cs:_plt
assume es:nothing, ss:nothing, ds:_data, fs:nothing, gs:nothing
dd 4 dup(?)
����������
sub_8048358 proc near
jmp ds:off_8049870
sub_8048358 endp

; ��������������������������������������
dword_804835E dd 2 dup(?)
db 2 dup(?)

sub_8048368 proc near
jmp ds:off_8049874
sub_8048368 endp

; ��������������������������������������
dword_804836E dd 2 dup(?)
db 2 dup(?)


sub_8048378 proc near ;
jmp ds:off_8049878
sub_8048378 endp

; ��������������������������������������
dword_804837E dd 2 dup(?)
db 2 dup(?)

sub_8048388 proc near
jmp ds:off_804987C
sub_8048388 endp

; ��������������������������������������
dword_804838E dd 2 dup(?)
db 2 dup(?)


sub_8048398 proc near
jmp ds:off_8049880
sub_8048398 endp

; ��������������������������������������
dword_804839E dd 2 dup(?)
db 2 dup(?)


sub_80483A8 proc near
jmp ds:off_8049884
sub_80483A8 endp

; ��������������������������������������
dword_80483AE dd 2 dup(?)
db 2 dup(?)
_plt ends

_text segment para public 'CODE' use32
assume cs:_text

assume es:nothing, ss:nothing, ds:_data, fs:nothing, gs:nothing

public _start
_start proc near
xor ebp, ebp
pop esi
mov ecx, esp
and esp, 0FFFFFFF0h
push eax
push esp
push edx
push offset __libc_csu_fini
push offset __libc_csu_init
push ecx
push esi
push offset main
call sub_8048368
hlt
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
_start endp

call_gmon_start proc near
push ebp
mov ebp, esp
push ebx
call __i686_get_pc_thunk_bx
add ebx, 146Bh
sub esp, 4
mov edx, [ebx-4]
test edx, edx
jz short loc_8048411
call sub_80483A8

loc_8048411:
pop eax
pop ebx
pop ebp
retn
call_gmon_start endp
��������������


public __i686_get_pc_thunk_bx
__i686_get_pc_thunk_bx proc near

mov ebx, [esp+0]
retn
__i686_get_pc_thunk_bx endp

����������������������������������
align 10h


__do_global_dtors_aux proc near
push ebp
mov ebp, esp
push eax
push eax
cmp ds:completed_4497, 0
jz short loc_804843A
jmp short locret_804844C
; ��������������������������������������

loc_8048430:
add eax, 4
mov p_4496, eax
call edx

loc_804843A:
mov eax, p_4496
mov edx, [eax]
test edx, edx
jnz short loc_8048430
mov ds:completed_4497, 1

locret_804844C:
leave
retn
__do_global_dtors_aux endp
����������������������������������
align 10h


frame_dummy proc near
push ebp
mov ebp, esp
push ecx
push ecx
mov edx, ds:__JCR_LIST__
test edx, edx
jz short locret_8048475
mov eax, 0
test eax, eax
jz short locret_8048475
sub esp, 0Ch
push offset __JCR_LIST__
call eax
add esp, 10h

locret_8048475:
leave
retn
frame_dummy endp

������������������������������
align 4


public main
main proc near

var_28 = word ptr -28h
var_26 = word ptr -26h
var_18 = dword ptr -18h
var_14 = dword ptr -14h
var_10 = dword ptr -10h
var_C = dword ptr -0Ch
var_8 = dword ptr -8
var_4 = dword ptr -4
arg_0 = dword ptr 8
arg_4 = dword ptr 0Ch

push ebp
mov ebp, esp
push ebx
sub esp, 24h
and esp, 0FFFFFFF0h
mov eax, 0
add eax, 0Fh
add eax, 0Fh
shr eax, 4
shl eax, 4
sub esp, eax
cmp [ebp+arg_0], 3
jz short loc_80484CB
mov eax, [ebp+arg_4]
mov eax, [eax]
sub esp, 8
push eax
push offset aSyntaxSConvert
call sub_8048378
add esp, 10h
sub esp, 0Ch
push offset a1EuroToDrahmas
call sub_8048358
add esp, 10h
sub esp, 0Ch
push 0
call sub_8048388

loc_80484CB:
mov [ebp+var_18], 1
jmp short loc_80484FD
; ��������������������������������������

loc_80484D4:
mov eax, [ebp+var_18]
shl eax, 2
mov ebx, eax
add ebx, [ebp+arg_4]
mov eax, [ebp+var_18]
shl eax, 2
add eax, [ebp+arg_4]
mov eax, [eax]
sub esp, 0Ch
push eax
call sub_8048398
add esp, 10h
mov [ebx], eax
lea eax, [ebp+var_18]
inc dword ptr [eax]

loc_80484FD:
mov eax, [ebp+var_18]
cmp eax, [ebp+arg_0]
jl short loc_80484D4
mov eax, [ebp+arg_4]
add eax, 4
mov eax, [eax]
cmp eax, 1
jnz short loc_8048564
mov [ebp+var_14], 0
mov [ebp+var_C], 0
mov eax, [ebp+arg_4]
add eax, 8
mov eax, [eax]
mov [ebp+var_14], eax
fild [ebp+var_14]
fld ds:dbl_8048778
fmulp st(1), st
fnstcw [ebp+var_26]
mov ax, [ebp+var_26]
mov ah, 0Ch
mov [ebp+var_28], ax
fldcw [ebp+var_28]
fistp [ebp+var_C]
fldcw [ebp+var_26]
sub esp, 4
push [ebp+var_C]
push [ebp+var_14]
push offset aDEuroDDrahmas
call sub_8048378
add esp, 10h
jmp short loc_80485B4
; ��������������������������������������

loc_8048564:
mov [ebp+var_10], 0
mov [ebp+var_8], 0
mov eax, [ebp+arg_4]
add eax, 8
mov eax, [eax]
mov [ebp+var_10], eax
fild [ebp+var_10]
fld ds:dbl_8048778
fdivp st(1), st
fnstcw [ebp+var_26]
mov ax, [ebp+var_26]
mov ah, 0Ch
mov [ebp+var_28], ax
fldcw [ebp+var_28]
fistp [ebp+var_8]
fldcw [ebp+var_26]
sub esp, 4
push [ebp+var_8]
push [ebp+var_10]
push offset aDDrahmasDEuro
call sub_8048378
add esp, 10h

loc_80485B4:
mov ebx, [ebp+var_4]
leave
retn
main endp

align 10h


public __libc_csu_init
__libc_csu_init proc near

var_10 = dword ptr -10h
var_C = dword ptr -0Ch
var_8 = dword ptr -8
var_4 = dword ptr -4

push ebp
mov ebp, esp
sub esp, 18h
mov [ebp+var_C], ebx
call __i686_get_pc_thunk_bx
add ebx, 1296h
mov [ebp+var_8], esi
mov [ebp+var_4], edi
call _init_proc
lea eax, [ebx+30h]
lea edx, [ebx+30h]
sub eax, edx
sar eax, 2
mov [ebp+var_10], eax
jnz short loc_8048602
mov ebx, [ebp+var_C]
mov esi, [ebp+var_8]
mov edi, [ebp+var_4]
mov esp, ebp
pop ebp
retn
; ��������������������������������������

loc_8048602:
xor edi, edi
mov esi, edx
lea esi, [esi+0]
lea edi, [edi+0]

loc_8048610:
inc edi
call dword ptr [esi]
add esi, 4
cmp edi, [ebp+var_10]
jb short loc_8048610
mov ebx, [ebp+var_C]
mov esi, [ebp+var_8]
mov edi, [ebp+var_4]
mov esp, ebp
pop ebp
retn
__libc_csu_init endp

�����������������������������������
align 10h


public __libc_csu_fini
__libc_csu_fini proc near

var_10 = dword ptr -10h
var_C = dword ptr -0Ch
var_8 = dword ptr -8
var_4 = dword ptr -4

push ebp
mov ebp, esp
sub esp, 18h
mov [ebp+var_C], ebx
call __i686_get_pc_thunk_bx
add ebx, 1226h
mov [ebp+var_8], esi
mov [ebp+var_4], edi
lea eax, [ebx+30h]
lea edx, [ebx+30h]
sub eax, edx
sar eax, 2
mov [ebp+var_10], eax
dec eax
cmp eax, 0FFFFFFFFh
jz short loc_804867B
lea esi, [edx+eax*4]
xor edi, edi
lea esi, [esi+0]

loc_8048670:
inc edi
call dword ptr [esi]
sub esi, 4
cmp [ebp+var_10], edi
jnz short loc_8048670

loc_804867B:
call _term_proc
mov ebx, [ebp+var_C]
mov esi, [ebp+var_8]
mov edi, [ebp+var_4]
mov esp, ebp
pop ebp
retn
__libc_csu_fini endp
�����������������������������������
align 10h


__do_global_ctors_aux proc near
push ebp
mov ebp, esp
push ebx
push edx
mov eax, ds:__CTOR_LIST__
cmp eax, 0FFFFFFFFh
jz short loc_80486B1
mov ebx, offset __CTOR_LIST__

loc_80486A4:
call eax
mov eax, [ebx-4]
sub ebx, 4
cmp eax, 0FFFFFFFFh
jnz short loc_80486A4

loc_80486B1:
pop eax
pop ebx
pop ebp
retn
__do_global_ctors_aux endp

�����������������������������������
align 4
_text ends


_fini segment para public 'CODE' use32
assume cs:_fini

assume es:nothing, ss:nothing, ds:_data, fs:nothing, gs:nothing


public _term_proc
_term_proc proc near
push ebp
mov ebp, esp
push ebx
sub esp, 4
call __i686_get_pc_thunk_bx
add ebx, 1198h
call __do_global_dtors_aux
pop ecx
pop ebx
pop ebp
retn
_term_proc endp

_fini ends

_rodata segment para public 'CONST' use32
assume cs:_rodata

public _fp_hw
_fp_hw dd 3
public _IO_stdin_used
_IO_stdin_used dd 20001h
aSyntaxSConvert db 'Syntax:',0Dh,0Ah
db ' %s <convertion> <value>',0Dh,0Ah
db 'Convertions:',0Dh,0Ah,0
align 4
a1EuroToDrahmas db '1',9,'euro to drahmas',0Ah
db '2',9,'drahmas to euro',0Dh,0
aDEuroDDrahmas db '%d euro -> %d drahmas',0Dh,0Ah,0
aDDrahmasDEuro db '%d drahmas -> %d euro',0Dh,0Ah,0
db 0
db 0
db 0
db 0
db 0
db 0
db 0
dbl_8048778 dq 3.4075e2
_rodata ends

_eh_frame segment dword public 'CONST' use32
assume cs:_eh_frame
__FRAME_END__ db 0
db 0
db 0
db 0
_eh_frame ends

_ctors segment dword public 'DATA' use32
assume cs:_ctors

__CTOR_LIST__ dd 0FFFFFFFFh

__CTOR_END__ db 0
db 0
db 0
db 0
_ctors ends


_dtors segment dword public 'DATA' use32
assume cs:_dtors

__DTOR_LIST__ db 0FFh
db 0FFh
db 0FFh
db 0FFh
__DTOR_END__ db 0
db 0
db 0
db 0
_dtors ends


_jcr segment dword public 'DATA' use32
assume cs:_jcr

__JCR_LIST__ dd 0

_jcr ends


_got segment dword public 'DATA' use32
assume cs:_got
dd offset __gmon_start__
_got ends


_got_plt segment dword public 'DATA' use32
assume cs:_got_plt

public _GLOBAL_OFFSET_TABLE_
_GLOBAL_OFFSET_TABLE_ db 98h
db 97h
db 4
db 8
db 0
db 0
db 0
db 0
db 0
db 0
db 0
db 0
off_8049870 dd offset dword_804835E
off_8049874 dd offset dword_804836E
off_8049878 dd offset dword_804837E
off_804987C dd offset dword_804838E
off_8049880 dd offset dword_804839E
off_8049884 dd offset dword_80483AE
_got_plt ends


_data segment dword public 'DATA' use32
assume cs:_data

public data_start
data_start db 0
db 0
db 0
db 0
public __dso_handle
__dso_handle db 0
db 0
db 0
db 0
p_4496 dd offset __DTOR_END__

_data ends

_bss segment dword public 'BSS' use32
assume cs:_bss

assume es:nothing, ss:nothing, ds:_data, fs:nothing, gs:nothing
completed_4497 db ?

align 4
_bss ends


__fini_array_end= 8049894h
__fini_array_start= 8049894h
__init_array_end= 8049894h
__init_array_start= 8049894h
public __bss_start
__bss_start = 8049894h
public _edata
_edata = 8049894h
public _end
_end = 8049898h

extrn puts@@GLIBC_2_0:near
extrn __libc_start_main@@GLIBC_2_0:near
extrn printf@@GLIBC_2_0:near
extrn exit@@GLIBC_2_0:far
extrn atoi@@GLIBC_2_0:near
extrn puts:near
extrn __libc_start_main:near
extrn printf:near
extrn exit:far
extrn atoi:near
extrn _Jv_RegisterClasses
extrn __gmon_start__

end _start

*To encoding (μόνο πλεον) γμ*

Link to comment
Share on other sites

fortran...

program evrw
implicit none

real:: e,d,n,a

print*, "Kalws hr8ate ston metatropea"
print*, "evrw <=> draxmes"

print*, "Pieste 1 an 8elete na metatrepsete evrw se draxmes"
print*, "Pieste 2 an 8elete na metatrepsete draxmes se evrw"

read*, n

if (n==1) then

print*, "Dwsete to poso se evrw"
read*, a

d = a*340.75

print*, "To antistoixo twn", a, "evrw se draxmes einai", d

else if (n==2) then

print*, "Dwsete to poso se draxmes"
read*, a

e = a/340.75

print*, "To antistoixo twn", a, "draxmwn se evrw einai", e

else

print*, "Min eisai malakas, eipame pata 1 i 2..."

end if

end program

δεν εχω εδώ compiler, θα το ελέγξω αύριο και θα επανέλθω με πιθανές διορθώσεις.... :)

Link to comment
Share on other sites


;******************************************************************************v.0.001*******
;***************************************************************************UNCHECKED CODE***
;****************************************SOTIRIS*********************************************
;*******Very Basic Euro2Drachmas Program for AVR 8515 class microprocessor*******************
;******Code under GPLv2 - see [url]www.gnu.org/copyleft/gpl.html[/url] for information*****************
;**************************************Written in Vi*****************************************
;********************************************************************************************
;**************************************BASIC CONCEPT*****************************************
;****Load values via serial interface to microprocessor and get result through terminal if***
;********************************************************************************************
;*******************************************START********************************************
.include "8515def.inc"
;defining universal register
.def ur=R16
rjmp main
main:
;*************************************STACKPOINTER CONFIG************************************
;
ldi ur,LOW(RAMEND)
out SPL,ur
ldi ur,HIGH(RAMEND)
out SPH,ur
;
;***************************SETTING UP DDR (data direction registry)*************************
;
ldi ur,0x00
out DDRD,ur
;
;********************************************************************************************
;***************************kai ta loipa*****************************************************

Θα το συνεχίσω μόλις βρω λίγο χρόνο και κάτι σημειώσεις μου που αγνοούνται (πάνω στο uart :p)

Αυτή είναι assembly, όχι σαν κάτι λουλούδες πού χουμε στο forum.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Δημιουργία...

Important Information

Ο ιστότοπος theLab.gr χρησιμοποιεί cookies για να διασφαλίσει την καλύτερη εμπειρία σας κατά την περιήγηση. Μπορείτε να προσαρμόσετε τις ρυθμίσεις των cookies σας , διαφορετικά θα υποθέσουμε ότι είστε εντάξει για να συνεχίσετε.