aldweb

Fermer I. aldweb

Fermer II. Gratuitiels PC

Fermer III. Gratuitiels Palm

Fermer IV. Partagiciels Palm

Fermer V. iziBasic Palm

Fermer VI. Connaissance Palm

Fermer VII. Ordinateur Poche

Fermer VIII. miniPortail

Recherche




Newsletter
Pour avoir des nouvelles de ce site, inscrivez-vous à notre Newsletter.
S'abonner
Se désabonner
293 Abonnés
Webmaster - Infos
Visites

   visiteurs

   visiteurs en ligne

Pagerank

Pub Google
article.gifUtilisation poussée du Sharp PC-1360 grâce au Langage Machine

Sharp Pocket Computer 1360 - Competence Center

Deeper use of the Sharp PC-1360 with Machine Language




How to avoid systematic ALL RESET...



It took me quite a while to understand the clue that I will explain here. I have two RAM cards in my Sharp PC-1360. When using them in SET MEM B mode, some of my Machine Language programs would not work and bring me Error messages or, worst, a ALL RESET request. When using them in SET MEM C mode (only the first RAM card is active in this case), the same programs would work fine.

I finally got to figure out that X register is used by the Sharp PC-1360 to point to some RAM addresses in SET MEM B mode.

So, before using the IX, DX, IXL and DXL opcodes that all manage with XL and XH registers (having X = XL + 256 x XH) or even before putting any value in these two registers, you should always save these registers and then restore them back before the final RTN instruction.

PockASM code:
        ORG     33000
XL_REG EQU 4
XH_REG EQU 5
YL_REG EQU 6
YH_REG EQU 7
SAVEX: DW 0 # Place to save X Register
BEGIN: LIDP SAVEX # DP <- @(SAVEX)
LP XH_REG # P points to XH
MVDM # [DP] <- [P] (save XH value)
LIDP SAVEX+1 # DP <- @(SAVEX+1)
LP XL_REG # P points to XL
MVDM # [DP] <- [P] (save XL value)
#############################################
# insert your Machine Language program here #
#############################################
END: LIDP SAVEX # DP <- @(SAVEX)
LP XH_REG # P points to XH
MVMD # [P] <- [DP] (restore XH value)
LIDP SAVEX+1 # DP <- @(SAVEX+1)
LP XL_REG # P points to XL
MVMD # [P] <- [DP] (restore XL value)
RTN


BEEP in Machine Language



On most Sharp Pocket Computers, and especially on the Sharp PC-1360, the beeper is associated with the XOUT line, managed by bits 5, 6 and 7 of the Control Port (at address &5F of Internal RAM, OUTC opcode).

The following ML program outputs a beep of a given tone and for a given period of time (the addresses are given as an example, they should be adapted as explained in my Web page about ML) .

PockASM code:
        $ JR             #  compilation instruction set
ORG 33000
K_REG EQU 8
L_REG EQU 9
M_REG EQU 10
PORTC EQU 95
TONE: DB 0 # Beep Tone (set by Basic program)
DURAT: DW 0 # Beep Duration (set by Basic program)
BEEP: LIDP TONE # DP <- @(TONE)
LP M_REG # P points to M
MVMD # [P] <- [DP]
LIDP BEEP2+1 # DP <- @(BEEP2+1) = where to poke frequency
MVDM # [DP] <- [P] , we poke frequency
LIDP DURAT # DP <- @(DURAT)
LP L_REG # P points to L
MVMD # [P] <- [DP]
LIDP DURAT+1 # DP <- @(DURAT+1)
LP K_REG # P points to K
MVMD # [P] <- [DP]
LIB 0 # B <- 0
LIA 1 # A <- 1
BEEP1: LIP PORTC # P points to PortC
ORIM 16 # [P] <- [P] or 16 (update PortC)
OUTC # Init Beeper
BEEP2: WAIT 0 # We need to poke the right tone value at the place we put 0
ANIM 233 # [P] <- [P] and 233 (update PortC)
OUTC # Update Beeper
LP K_REG # P points to K
SBB # [P+1,P] <- [P+1,P] - (B,A) , Duration is decreased of 1 unit
JRNZM BEEP1 # if Duration <> 0 then go back
RTN # Exit

The Basic program that will use this ML program looks like this :
10 CLS : WAIT 0
20 FOR A=33000 TO 33040
30 READ B
40 POKE A,B
50 NEXT A
60 INPUT "TONE=";T
70 INPUT "DURATION=";D
80 DH= INT (D/256)
90 DL=D-256*DH
100 POKE 33000,T,DH,DL
110 CALL 33003
120 END
130 DATA 0,0,0,16,128,232,138,85,16,129
140 DATA 8,83,16,128,233,137,85,16,128,234
150 DATA 136,85,3,0,2,1,18,95,97,16
160 DATA 223,78,0,96,233,223,136,21,41,13
170 DATA 55


INKEY$ in Machine Language



In the Sharp PC-1360, the pressing of key will be tracked with the use of two ports :
  1. the standard I/O Port A
  2. and one unusual port that will be at address &3E00. We wil call it the K port for Keyboard port.
These two ports are building a key matrix to tell what keys' pressings to look for. The result, meaning the pressed key, will always be found in the I/O Port A.



The following ML program outputs a value to the I/O Port A and to the K Port, and awaits for a valid key to be pressed then returns the I/O Port A value as from the pressed key (the addresses are given as an example, they should be adapted as explained in my Web page about ML) .

PockASM code:
        $ JR             #  compilation instruction set
ORG 33000
PORTA EQU 92 # I/O Port A internal RAM address
PORTK EQU 15872 # K Port external RAM address
IA_IN: DB 0 # I/O Port A input value (set by Basic program)
K_IN: DB 0 # K Port input value (set by Basic program)
VALUE: DB 0 # I/O Port A return value storage
LIDP IA_IN # DP points to I/O Port A input value
LIP PORTA # P points to I/O Port A
MVMD # [P] <- [DP] (I/O Port A now contains IA_IN value)
OUTA # Initialization of the I/O Port A
LIDP K_IN # DP points to K Port input value
LDD # A <- [DP] (A now contains K_IN value)
LIDP PORTK # DP points to K Port
STD # [DP] <- A (K Port now containts K_IN value)
KEYIN: INA # A <- I/O Port A, if a valid key is pressed, A will
# receive the value according to the matrix
CPIA 0 # Sets Zero Flag if A is equal to zero
JRZM KEYIN # Go back to KEYIN if no key was pressed, meaning A is equal to zero
LIDP VALUE # DP now points to the return value storage address
STD # [DP] <- A, the return value storage now contains the value of A
RTN # Return, exit from ML program and goes back to Basic

The Basic program that will use this ML program looks like this :
10 CLS : WAIT 0
20 FOR A=33000 TO 33027
30 READ B
40 POKE A,B
50 NEXT A
60 INPUT "I/O PORT A = ";I
70 INPUT "KEYBOARD PORT = ";K
80 POKE 33000,I,K
90 PRINT "PRESS A KEY..."
100 CALL 33003
110 PRINT "RESULT I/O PORT A = "; PEEK (33002)
120 END
130 DATA 0,0,0,16,128,232,18,92,85,93
140 DATA 16,128,233,87,16,62,0,82,76,103
150 DATA 0,57,4,16,128,234,82,55

Date de création : 01/01/2003 @ 00:00
Dernière modification : 01/01/2003 @ 00:00
Catégorie :


Imprimer l'article Imprimer l'article

 
react.gifRéactions à cet article


Réaction n°1 

par Bert le 04/04/2010 @ 22:57

     Hi :

     I think PC-1350 does not require special  routines to save ML

I use &6900 memory location with 16 Kb Card. on my 1350

     I use Port PINs for Controlling Outside Devices even TODAY 

 
Spécial !



Version mobile
de l'aldweb Site

m.aldweb.com


Ni Français, ni Anglais ?

Essayez donc l'un de ces drapeaux :
[de] [es] [it] [pt]
Géolocalisation
Météo / Spam / www

Météo Lyon


aldweb contre le SPAM


Sites web de la famille

Sondage
Comment trouve-tu le nouvel habillage de l'aldweb Site ?
 
Superbe !
Joli
Moyen
Moche...
Résultats
News Amis
^ Haut ^