Program for reading telephone cards
Dear Mr ,
I have read your HOW_CHIP file (FTP.FUNET.FI:pub/doc/telecom/phonecard)
I solved the problem in the following way:
(Assembly for IBM PC)
******************************************************************************
;
page 60,132
;
;Connecting of the card-reader:
;OUT(2)--> -BUSY(11) 8 7 6 5
;Vcc(5)--> DATA7(9) | | | |
;GND(4)--> GND(18-25) \ /
;Vpp(3)--> DATA6(8) / \\
;WE(6) --> DATA2(4) | | | |
;CK(7) --> DATA0(2) 1 2 3 4
;-RE(8)--> DATA1(3)
;The left side -the appropriate pinout and the number of the card
;The right side -the appropriate pinout and the number of the printer
;port
;
kod segment
assume cs:kod,ds:kod,es:kod
org 0100h
start:
call cls
call home
mov ah,9
lea dx,bejel
int 21h
lea dx,portcim
mov ah,9
int 21h
call ktilt
push ds
xor ax,ax
mov ds,ax
lea di,portc
lpttest: mov ah,7
int 21h
cmp al,1bh
jz escv
cmp al,'1'
jz lpt1
cmp al,'2'
jz lpt2
cmp al,'3'
jz lpt3
jmp lpttest
;
escv: jmp vege
;
lpt1: mov si,0408h
jmp lptk
;
lpt2: mov si,040ah
jmp lptk
;
nemel:
pop ds
mov ah,9
lea dx,nemelo
int 21h
mov ax,91
call ido
jmp start
;
lpt3: mov si,040ch
lptk:
mov cx,1
lodsw
cmp ax,0
jz nemel
stosw
pop ds
mov ax,cs
mov ds,ax
mov ah,9
lea dx,filen
int 21h
call keng
lea dx,neve
mov ah,0ah
int 21h
call ktilt
lea ax,neve+2
cld
mov si,ax
folyt: lodsb
cmp al,13
jnz folyt
mov ax,si
mov di,ax
dec di
mov al,0
stosb
mov ah,3ch
lea dx,neve+2
mov cx,0
int 21h
jnc nyitva
mov ah,9
lea dx,fhiba
int 21h
jmp vege
nyitva:
push ax
lea si,portc
mov cx,1
lodsw
mov dx,ax
mov al,0
out dx,al
lea dx,uzen
mov ah,9
int 21h
mov ah,7
int 21h
mov ah,9
lea dx,uzenn
int 21h
lea si,portc
mov cx,1
lodsw
mov dx,ax
mov al,10000000b
out dx,al
mov ax,10
call ido
mov al,11000000b
out dx,al
mov bx,0
mov al,11000001b
out dx,al
and al,0c0h
out dx,al
inc dx
in al,dx
rol al,1
not al
and al,1
add al,30h
mov dl,al
mov ah,2
int 21h
mov al,dl
mov dx,cx
mov cx,1
lea di,bajt
cld
stosb
mov cx,dx
pop ax
push bx
push cx
mov bx,ax
mov cx,1
lea dx,bajt
mov ah,40h
int 21h
mov ax,bx
pop cx
pop bx
push ax
inc bl
lea si,portc
mov cx,1
lodsw
mov dx,ax
mov cx,255
mov al,11000010b
out dx,al
kerek: mov al,11000011b
out dx,al
and al,0c2h
out dx,al
inc dx
in al,dx
rol al,1
not al
and al,1
add al,30h
mov dl,al
mov ah,2
int 21h
mov al,dl
mov dx,cx
mov cx,1
lea di,bajt
cld
stosb
mov cx,dx
pop ax
push bx
push cx
mov bx,ax
mov cx,1
lea dx,bajt
mov ah,40h
int 21h
mov ax,bx
pop cx
pop bx
push ax
inc bl
cmp bl,8
jnz kerek1
mov dl,' '
mov ah,2
int 21h
mov bl,0
inc bh
cmp bh,8
jnz kerek1
call enter
mov bx,0
kerek1:
push cx
lea si,portc
mov cx,1
lodsw
mov dx,ax
pop cx
loop kerek
vege:
pop ax
mov bx,ax
mov ah,3eh
int 21h
lea si,portc
mov cx,1
lodsw
mov dx,ax
mov al,0
out dx,al
call keng
mov ah,4ch
int 21h
;
bejel: db 'This is a programme for reading phonecards. ver.:1.01 ',10,13
db 'Connecting the card to the right hardware '
db 'you can save the contents of the ROM.',10,13
db 9,9,9,9,'-eri-',10,10,10,13
db '$'
portcim: db 7,'Which port do you want to use?'
db '1.-->LPT1: 2.-->LPT2: 3.-->LPT3:',10,13,'$'
filen: db 'Give the device or file name and the path:$'
uzen: db 10,13,'Insert the card! (press any key to continue...)',7,10,13,'$'
uzenn: db 10,'The binary contents of the card (from 0 to 255):',10,13,'$'
nemelo: db 7,13,10,10,'There isnot such a parallel port in this computer!'
db 7,13,10,'$'
fhiba: db 7,10,13,'You couldnot open the file...',7,10,13,'$'
;
portc: dw 0000h
neve: db 40 dup(255)
bajt: db 0a5h
;
home: mov dx,0
call kurpoz
ret
;
ktilt: push cx
push ax
mov cx,0e00h
mov ah,1
int 10h
pop ax
pop cx
ret
;
keng: push cx
push ax
mov cx,0607h
mov ah,1
int 10h
pop ax
pop cx
ret
;
kurpoz: push ax
push bx
mov bh,0
mov ah,2
int 10h
pop bx
pop ax
ret
;
enter: push dx
push ax
mov dx,offset entr
mov ah,9
int 21h
pop ax
pop dx
ret
;
entr db 10,13,'$'
;
ido: push dx
push ds
push ax
mov ax,0
mov ds,ax
pop ax
mov dx,(DS:046ch)
add ax,dx
ko%r: mov dx,(DS:046ch)
cmp ax,dx
jnz ko%r
pop ds
pop dx
ret
;
cls: push ax
push bx
push cx
push dx
xor al,al
xor cx,cx
mov dh,24
mov dl,79
mov bh,7
mov ah,6
int 10h
pop dx
pop cx
pop bx
pop ax
ret
;
kod ends
end start
******************************************************************************
The structure of the Hungarian phonecard is the next:
Memory Map for cards from Hungary:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Bytes Bits Binary Hexa
+-----------+-----+
1 1 --> 8 | | |
+-----------+-----+
2 9 --> 16 | 1000 0011 | $83 | ---> hungary card
+-----------+-----+
3 17 --> 24 | | |
+-----------+-----+
4 25 --> 32 | | |
+-----------+-----+
5 33 --> 40 | | |
+-----------+-----+
6 41 --> 48 | | |
+-----------+-----+
7 49 --> 56 | | |
+-----------+-----+
8 57 --> 64 | | |
+-----------+-----+
9 65 --> 72 | | |
+-----------+-----+
10 73 --> 80 | 0000 0011 | $03 | ---> 120 units card
| 0000 1010 | $0A | ---> 50 units card
+-----------+-----+
11 81 --> 88 | 0001 0001 | $11 |
+-----------+-----+
12 89 --> 96 | | |
+-----------+-----+
13-32 97 --> 256 | | | ---> The units area: each time a unit
| | | is used, then a bit is set to "1";
| | | Generaly the first ten units are
| | | fused in factory as test.
| | |
| | |
| | |
+-----------+-----+
******************************************************************************
Yours sincerely:
Racz Istvan
E-mail: [email protected]
[email protected]
[email protected]
HUNGARY