EASy68K  
It is currently Sat Nov 16, 2019 10:28 pm

All times are UTC




Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: Fri Aug 12, 2011 9:06 am 
Offline

Joined: Tue Aug 02, 2011 8:32 am
Posts: 13
clive wrote:
You're falling in two traps here.

a) Your code extends from $400400 to $40068C at least, you simply can't place your data at arbitrary absolute locations in the middle of it. Look at the listing file generated by the assembler.

b) The assembler needs to know where the storage locations should be placed, it's going to have to be after the ORG statement, and ideally toward the end of the code. The EASy68K assembler is assuming a zero origin, and is not generating an error, are you using some other assembler?


your program works perfectly..tq professor,

then i modified a bit the program, to make it compare number so that it will become like this

1st digit entered display at the 1st 7segmen
2nd digit entered display at the 2nd 7segmen
3rd digit entered display at the 3rd 7segmen
4th digit entered display at the 4th 7segmen
all number display at he same time

it will become like this

1...

.2..
..3.
...4
1234

, i try to change to make it become like this
1...
12..
123.
1234

but it doest works.


then, user enter 5th digit,6th digit,7th digit and 8th digit

and 5th,6th,7th,8th, will de display at the 7segmen, then the value will be compare with 1st,2nd,3rd,4th respectively

i try to use lea command but it doest works also,
this part i need to compare the value inside the storage with another storage. is it posible to do that?


this is the program

***************** Declarations ****************
PgCR equ $800001 ;Port general control register
PaCR equ $80000D ;PortA control register
PaDDR equ $800005 ;PortA data direction register
PaDR equ $800011 ;PortA data register
PbCR equ $80000f ;PortB control register
PbDDR equ $800007 ;PortB data direction register
PbDR equ $800013 ;PortB data register
;****************************************************************************
;****************************************************************************
Org $400400 ;Start address
Start Move.b #$00,PgCR ;Set port to general mode
Move.b #$80,PaCR ;Set portA to submode IX
Move.b #$0F,PaDDR ;Set bits PA0-PA3=outputs, PA4-PA7=inputs
Move.b #$80,PbCR ;Set portA to submode IX
Move.b #$FF,PbDDR ;Set bits PA0-PA7=outputs, ;Move.b #$00,PbDR
Move.b #$ff,PbDR

Move.b #$8f,no1 ; set the address to be blank for 7segment
Move.b #$4f,no2
Move.b #$2f,no3
Move.b #$1f,no4

;****************************************************************************
prestart Move.w #12,D6 ;use D6 as pin number counter
Again Bsr Get_Key ;key pressed?
Cmp.b #$10,D0 ;if return code is $10
Beq Again ; check again
Move.b D0,KeyStore ;Save key
Bsr Delay ;Wait for a while
Bsr Get_Key ;check key again
Move.b KeyStore,D1
Cmp.b D0,D1 ;is there a match?
Bne Again ;no: check again
Bsr Display ;if not $10 then display
Clr.w D0
sub.b #1,D6 ;minus 1 from pin number counter
Cmp.b #8,D6 ;compare with zero
beq viewall
Cmp.b #4,D6 ;compare with zero
beq check
Cmp.b #0,D6 ;compare with zero
beq finally

;beq prestart

Bra Again ;OR keep scanning
;****************************************************************************
Get_Key Movem.w D1-D3,-(SP)
Clr.w D0 ;Build hex. code in D0
Move.b #$FE,D1 ;Ground column 0
Move.w #4,D2 ;use D2 as counter
;****************************************************************************
Next Move.b D1,PaDR ;activate column line
Move.b PaDR,D0 ;read port A
Andi.b #$F0,D0 ;isolate column lines
Cmp.b #$F0,D0 ;any row line active?
Beq NextCol ;yes: means no key goto next column
Bra EndScan ;else same means key pressed
;****************************************************************************
NextCol Rol.b #1,D1 ;rotate column code
sub.b #1,D2 ;decrement counter by one
Cmp.b #$00,D2 ;if not zero
Bne Next ; check key again
;****************************************************************************
EndScan Bsr KeyCode
Movem.w (SP)+,D1-D3 ;restore registers
Rts
;****************************************************************************
KeyCode Move.b D1,D4 ;Store column
Not.b D4 ;Complement column code
Move.b D0,D5 ;Store row code
Not.b D5 ;Complement row code
Andi.b #$F0,D5 ;Mask bits 0-3
Add.b D4,D5 ;Combine row and column
Move.b D5,D0 ;Return new code
bsr IdKey
rts
;****************************************************************************
IdKey Movem.w D1-D3,-(SP)
move.b #$11,D1 ;key 1 ;A series of if-then-else
cmp.b D1,D0 ;to identify the correct key
beq Key1
move.b #$12,D1 ;key 2
cmp.b D1,D0
beq Key2
move.b #$14,D1 ;key 3
cmp.b D1,D0
beq Key3
move.b #$18,D1 ;key F
cmp.b D1,D0
beq KeyA
move.b #$21,D1 ;key 4
cmp.b D1,D0
beq Key4
move.b #$22,D1 ;key 5
cmp.b D1,D0
beq Key5
move.b #$24,D1 ;key 6
cmp.b D1,D0
beq Key6
move.b #$28,D1 ;key E
cmp.b D1,D0
beq KeyB
move.b #$44,D1 ;key 9
cmp.b D1,D0
beq Key9
move.b #$42,D1 ;key 8
cmp.b D1,D0
beq Key8
move.b #$41,D1 ;key 7
cmp.b D1,D0
beq Key7
move.b #$48,D1 ;key D
cmp.b D1,D0
beq KeyC
move.b #$81,D1 ;key F
cmp.b D1,D0
beq KeyF
move.b #$82,D1 ;key 0
cmp.b D1,D0
beq Key0
move.b #$84,D1 ;key E
cmp.b D1,D0
beq KeyE
move.b #$88,D1 ;key C
cmp.b D1,D0
beq KeyD
Bra Exist
;****************************************************************************
Key1 move.b #$01,D0 ;
bra Exist
Key2 move.b #$02,D0 ;
bra Exist
Key3 move.b #$03,D0 ;
bra Exist
KeyF move.b #$0F,D0 ;
bra Exist
Key4 move.b #$04,D0 ;
bra Exist
Key5 move.b #$05,D0 ;
bra Exist
Key6 move.b #$06,D0 ;
bra Exist
KeyE move.b #$0E,D0 ;
bra Exist
Key9 move.b #$09,D0 ;
bra Exist
Key8 move.b #$08,D0 ;
bra Exist
Key7 move.b #$07,D0 ;
bra Exist
KeyD move.b #$0D,D0 ;
bra Exist
KeyA move.b #$0A,D0 ;
bra Exist
Key0 move.b #$00,D0 ;
bra Exist
KeyB move.b #$0B,D0 ;
bra Exist
KeyC move.b #$0C,D0 ;
Exist Movem.w (SP)+,D1-D3
rts
;****************************************************************************
Delay Movem.w D1-D3,-(SP)
Move.l #95000,d1
Here subq.l #1,d1
Bne Here
Movem.w (SP)+,D1-D3
rts
;****************************************************************************
Display Andi.b #$0F,D0
cmp.b #12,D6
beq satu1
cmp.b #11,D6
beq dua1
cmp.b #10,D6
beq tiga1
cmp.b #9,D6
beq empat1

;****************************************************************************
cmp.b #8,D6
beq satu2
cmp.b #7,D6
beq dua2
cmp.b #6,D6
beq tiga2
cmp.b #5,D6
beq empat2

;****************************************************************************
cmp.b #4,D6
beq satu3
cmp.b #3,D6
beq dua3
cmp.b #2,D6
beq tiga3
cmp.b #1,D6
beq empat3

;****************************************************************************
satu1 add.b #$80,D0
move.b D0,no1
bra view

dua1 add.b #$40,D0
move.b D0,no2
bra view
tiga1 add.b #$20,D0
move.b D0,no3
bra view
empat1 add.b #$10,D0
move.b D0,no4

;****************************************************************************

satu2 add.b #$80,D0
move.b D0,no1
bra view

dua2 add.b #$40,D0
move.b D0,no2
bra view
tiga2 add.b #$20,D0
move.b D0,no3
bra view
empat2 add.b #$10,D0
move.b D0,no4

;****************************************************************************
satu3 add.b #$80,D0
move.b D0,no1
bra view

dua3 add.b #$40,D0
move.b D0,no2
bra view
tiga3 add.b #$20,D0
move.b D0,no3
bra view
empat3 add.b #$10,D0
move.b D0,no4
;****************************************************************************
view Move.b D0,PbDR
Trap #11
DC.W 8
Trap #11
DC.W 3
RTS
;****************************************************************************

viewall Move.b no1,PbDR
Move.b no2,PbDR
Move.b no3,PbDR
Move.b no4,PbDR
bra viewall

;****************************************************************************
;movea.b ,A0


finally cmpa.l no1,user1
bne wrong
cmp.b #(no2),user2
bne wrong
cmp.b #(no3),user3
bne wrong
cmp.b #(no4),user4
bne wrong
bra betul

;****************************************************************************

wrong move.b #$8A,PbDR
bra wrong

;****************************************************************************

betul move.b #$1B,PbDR
bra betul



;****************************************************************************

check cmp.b #(no1),conf1
bne prestart
cmp.b #(no2),conf2
bne prestart
cmp.b #(no3),conf3
bne prestart
cmp.b #(no4),conf4
bne prestart
bra Again

;****************************************************************************
KeyStore ds.b 4 ;Temp store for keypressed
no1 ds.l 1
no2 ds.l 1
no3 ds.l 1
no4 ds.l 1

conf1 ds.l 1
conf2 ds.l 1
conf3 ds.l 1
conf4 ds.l 1

user1 ds.l 1
user2 ds.l 1
user3 ds.l 1
user4 ds.l 1



;****************************************************************************
END START ; last line of source



the 68k said the error is illegal forcing and also bad number, tq btw:))
:cry: :cry:


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 12, 2011 8:27 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
Presumably you need something like this
Code:
check  move.b  no1,d0
       cmp.b   conf1,d0
       bne     prestart
       move.b  no2,d0
       cmp.b   conf2,d0
       bne     prestart
       move.b  no3,d0
       cmp.b   conf3,d0
       bne     prestart
       move.b  no4,d0
       cmp.b   conf4,d0
       bne     prestart
       bra     Again

no1    ds.b    1
no2    ds.b    1
no3    ds.b    1
no4    ds.b    1

conf1  ds.b    1
conf2  ds.b    1
conf3  ds.b    1
conf4  ds.b    1


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 13, 2011 2:48 pm 
Offline

Joined: Tue Aug 02, 2011 8:32 am
Posts: 13
clive wrote:
Presumably you need something like this
Code:
check  move.b  no1,d0
       cmp.b   conf1,d0
       bne     prestart
       move.b  no2,d0
       cmp.b   conf2,d0
       bne     prestart
       move.b  no3,d0
       cmp.b   conf3,d0
       bne     prestart
       move.b  no4,d0
       cmp.b   conf4,d0
       bne     prestart
       bra     Again

no1    ds.b    1
no2    ds.b    1
no3    ds.b    1
no4    ds.b    1

conf1  ds.b    1
conf2  ds.b    1
conf3  ds.b    1
conf4  ds.b    1



is it mean i cant compare the value if i dont copy it to data memory?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 13, 2011 4:40 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
sayyid wrote:
is it mean i cant compare the value if i dont copy it to data memory?

The 68K instruction set does not afford you with a memory-to-memory compare in the "cmp.b memX,memY" form, so you'll either need to hold one, or both values in a register.

If you can hold your values in registers, you don't need to put them in memory. When comparing 4 bytes you could pack them in one LONG, and compare them all at once.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2011 10:34 am 
Offline

Joined: Tue Aug 02, 2011 8:32 am
Posts: 13
Code:
***************** Declarations ****************

PgCR    equ $800001 ;Port general control register
PaCR    equ $80000D ;PortA control register
PaDDR    equ $800005 ;PortA data direction register
PaDR    equ $800011 ;PortA data register
PbCR    equ $80000f ;PortB control register
PbDDR    equ $800007 ;PortB data direction register
PbDR    equ $800013 ;PortB data register

;****************************************************************************
;****************************************************************************

   Org $400400 ;Start address
Start    Move.b #$00,PgCR ;Set port to general mode
   Move.b #$80,PaCR ;Set portA to submode IX
   Move.b #$0F,PaDDR ;Set bits PA0-PA3=outputs, PA4-PA7=inputs
   Move.b #$80,PbCR ;Set portA to submode IX
   Move.b #$FF,PbDDR ;Set bits PA0-PA7=outputs, ;Move.b #$00,PbDR
   Move.b #$ff,PbDR

   Move.b #$8f,no1 ; set the address to be blank for 7segment
   Move.b #$4f,no2
   Move.b #$2f,no3
   Move.b #$1f,no4

;****************************************************************************

prestart   Move.w #12,D6 ;use D6 as pin number counter
      ;movea.l   #hi,a4
      ;Trap   #3
      ;Trap   #9


Again    Bsr Get_Key ;key pressed?
   Cmp.b #$10,D0 ;if return code is $10
   Beq Again ; check again
   Move.b D0,KeyStore ;Save key
   Bsr Delay ;Wait for a while
   Bsr Get_Key ;check key again
   Move.b KeyStore,D1
   Cmp.b D0,D1 ;is there a match?
   Bne Again ;no: check again
   Bsr Display ;if not $10 then display
   
   Clr.w D0
   sub.b #1,D6 ;minus 1 from pin number counter
   Cmp.b #8,D6 ;compare with zero
   beq viewall
   Cmp.b #4,D6 ;compare with zero
   beq check
   Cmp.b #0,D6 ;compare with zero
   beq finally
   ;beq prestart
   Bra Again ;OR keep scanning
;****************************************************************************

Get_Key Movem.w D1-D2,-(SP)
   Clr.w D0 ;Build hex. code in D0
   Move.b #$FE,D1 ;Ground column 0
   Move.w #4,D2 ;use D2 as counter

;****************************************************************************

Next    Move.b D1,PaDR ;activate column line
   Move.b PaDR,D0 ;read port A
   Andi.b #$F0,D0 ;isolate column lines
   Cmp.b #$F0,D0 ;any row line active?
   Beq NextCol ;yes: means no key goto next column
   Bra EndScan ;else same means key pressed

;****************************************************************************

NextCol Rol.b #1,D1 ;rotate column code
   sub.b #1,D2 ;decrement counter by one
   Cmp.b #$00,D2 ;if not zero
   Bne Next ; check key again

;****************************************************************************

EndScan Bsr KeyCode
   Movem.w (SP)+,D1-D2 ;restore registers
   Rts

;****************************************************************************

KeyCode Move.b D1,D4 ;Store column
   Not.b D4 ;Complement column code
   Move.b D0,D5 ;Store row code
   Not.b D5 ;Complement row code
   Andi.b #$F0,D5 ;Mask bits 0-3
   Add.b D4,D5 ;Combine row and column
   Move.b D5,D0 ;Return new code
   bsr IdKey
   rts

;****************************************************************************

IdKey    Movem.w D1-D2,-(SP)
   move.b #$11,D1 ;key 1 ;A series of if-then-else
   cmp.b D1,D0 ;to identify the correct key
   beq Key1
   move.b #$12,D1 ;key 2
   cmp.b D1,D0
   beq Key2
   move.b #$14,D1 ;key 3
   cmp.b D1,D0
   beq Key3
   move.b #$18,D1 ;key F
   cmp.b D1,D0
   beq KeyA
   move.b #$21,D1 ;key 4
   cmp.b D1,D0
   beq Key4
   move.b #$22,D1 ;key 5
   cmp.b D1,D0
   beq Key5
   move.b #$24,D1 ;key 6
   cmp.b D1,D0
   beq Key6
   move.b #$28,D1 ;key E
   cmp.b D1,D0
   beq KeyB
   move.b #$44,D1 ;key 9
   cmp.b D1,D0
   beq Key9
   move.b #$42,D1 ;key 8
   cmp.b D1,D0
   beq Key8
   move.b #$41,D1 ;key 7
   cmp.b D1,D0
   beq Key7
   move.b #$48,D1 ;key D
   cmp.b D1,D0
   beq KeyC
   move.b #$81,D1 ;key F
   cmp.b D1,D0
   beq KeyF
   move.b #$82,D1 ;key 0
   cmp.b D1,D0
   beq Key0
   move.b #$84,D1 ;key E
   cmp.b D1,D0
   beq KeyE
   move.b #$88,D1 ;key C
   cmp.b D1,D0
   beq KeyD
   Bra Exist

;****************************************************************************

Key1    move.b #$01,D0 ;
   bra Exist
Key2    move.b #$02,D0 ;
   bra Exist
Key3    move.b #$03,D0 ;
   bra Exist
KeyF    move.b #$0F,D0 ;
   bra Exist
Key4    move.b #$04,D0 ;
   bra Exist
Key5    move.b #$05,D0 ;
   bra Exist
Key6    move.b #$06,D0 ;
   bra Exist
KeyE    move.b #$0E,D0 ;
   bra Exist
Key9    move.b #$09,D0 ;
   bra Exist
Key8    move.b #$08,D0 ;
   bra Exist
Key7    move.b #$07,D0 ;
   bra Exist
KeyD    move.b #$0D,D0 ;
   bra Exist
KeyA    move.b #$0A,D0 ;
   bra Exist
Key0    move.b #$00,D0 ;
   bra Exist
KeyB    move.b #$0B,D0 ;
   bra Exist
KeyC    move.b #$0C,D0 ;
Exist    Movem.w (SP)+,D1-D2
   rts

;****************************************************************************

Delay    Movem.w D1-D2,-(SP)
   Move.l #95000,d1
Here    subq.l #1,d1
   Bne Here
   Movem.w (SP)+,D1-D2
   rts

;****************************************************************************

Display Andi.b #$0F,D0
   cmp.b #12,D6
   beq satu1
   cmp.b #11,D6
   beq dua1
   cmp.b #10,D6
   beq tiga1
   cmp.b #9,D6
   beq empat1

;****************************************************************************
   cmp.b #8,D6
   beq satu2
   cmp.b #7,D6
   beq dua2
   cmp.b #6,D6
   beq tiga2
   cmp.b #5,D6
   beq empat2

;****************************************************************************
   cmp.b #4,D6
   beq satu3
   cmp.b #3,D6
   beq dua3
   cmp.b #2,D6
   beq tiga3
   cmp.b #1,D6
   beq empat3

;****************************************************************************
satu1    add.b #$80,D0
   move.b D0,no1
   bra view
dua1    add.b #$40,D0
   move.b D0,no2
   bra view
tiga1    add.b #$20,D0
   move.b D0,no3
   bra view
empat1    add.b #$10,D0
   move.b D0,no4

;****************************************************************************

satu2    add.b #$80,D0
   move.b D0,conf1
   bra view
dua2    add.b #$40,D0
   move.b D0,conf2
   bra view
tiga2    add.b #$20,D0
   move.b D0,conf3
   bra view
empat2    add.b #$10,D0
   move.b D0,conf4

;****************************************************************************
satu3    add.b #$80,D0
   move.b D0,user1
   bra view
dua3    add.b #$40,D0
   move.b D0,user2
   bra view
tiga3    add.b #$20,D0
   move.b D0,user3
   bra view
empat3    add.b #$10,D0
   move.b D0,user4
;****************************************************************************
view    Move.b D0,PbDR
   Trap #11
   DC.W 8
   Trap #11
   DC.W 3
   RTS
;****************************************************************************

viewall move.l #255556,d3
lap   Move.b no1,PbDR
   Move.b no2,PbDR
        Move.b no3,PbDR
        Move.b no4,PbDR
   subq.l    #1,D3
   bne   lap
   Move.b #$ff,PbDR
   Cmp.b #0,D6 ;compare with zero
   beq habis
   bra Again

;****************************************************************************

finally move.b  no1,d7
   cmp.b    user1,d7
   bne    wrong
   move.b  no2,d7
   cmp.b    user2,d7
   bne    wrong1
   move.b  no3,d7
   cmp.b    user3,d7
   bne    wrong2
   move.b  no4,d7
   cmp.b    user4,d7
   bne    wrong3
   bra    habis

;****************************************************************************

wrong    move.b #$FA,PbDR
   bra wrong

wrong1    move.b #$FB,PbDR
   bra wrong1

wrong2    move.b #$FC,PbDR
   bra wrong2

wrong3    move.b #$FD,PbDR
   bra wrong3


;****************************************************************************

betul    move.b #$FE,PbDR
   bra betul

;****************************************************************************

check   clr.w   d7
   move.b  no1,d7
          cmp.b   conf1,d7   
   bne     wrong
          move.b  no2,d7
          cmp.b   conf2,d7
          bne     wrong1 
          move.b  no3,d7
          cmp.b   conf3,d7
          bne     wrong2 
          move.b  no4,d7
          cmp.b   conf4,d7 
          bne     wrong3 
          bra     Again

;****************************************************************************
habis   Move.b #$ff,PbDR
   bsr   Delay
   Move.b #$fa,PbDR
   bsr   Delay
   Move.b #$fb,PbDR
   bsr   Delay
   Move.b #$fc,PbDR
   bsr   Delay
   Move.b #$fd,PbDR       0
   bsr   Delay
   Move.b #$fe,PbDR
   bsr   Delay
   bra    habis
;****************************************************************************


KeyStore ds.b 4 ;Temp store for keypressed
no1       ds.b    1
no2       ds.b    1
no3       ds.b    1
no4       ds.b    1

conf1     ds.b    1
conf2     ds.b    1
conf3     ds.b    1
conf4    ds.b    1

user1    ds.b    1
user2    ds.b    1
user3    ds.b    1
user4    ds.b    1

;hi   dc.b   'insert'
;re   dc.l   're-enter your new pin code for confirmation'
;fal     dc.l   'your new pin code is wrong'
;con     dc.l    'your pin code is confirmed'
;use      dc.l    'please enter your pin code'
;****************************************************************************
   END START ; last line of source



after i edit the program, it works, then i want to enter some strings but doest works,

i use the command

movea.l #hi,a4
Trap #3
Trap #9

hi dc.b 'insert'

is it i cannot pass the string to a4?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2011 2:10 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
Use LEA

lea hi,A4

Use a zero terminated string, so it knows where the string ends.

hi dc.b 'insert',0

Use "LEA insert,A6; TRAP#11; DC.W 5" sequence, what are TRAP#3 and TRAP#9, or using A4? Remember I don't have your board, or your manuals, the page I cited earlier uses TRAP#11 calls.

http://viking.cmsa.wmin.ac.uk/flight/flight68k.html


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2011 3:22 pm 
Offline

Joined: Tue Aug 02, 2011 8:32 am
Posts: 13
clive wrote:
Use LEA

what are TRAP#3 and TRAP#9, or using A4? Remember I don't have your board, or your manuals, the page I cited earlier uses TRAP#11 calls.


trap#3 and trap #9 is to getch and also endcharacter, i follow the instruction from the text book, but is ok, i will try the thing that u suggest:)

coz myb my text book is referred to ide68k but what im using is flight68k,


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2011 12:59 am 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
That doesn't sound like IDE68K, but I think we need to focus on what the Flight68K expects.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 22, 2011 7:38 am 
Offline

Joined: Tue Aug 02, 2011 8:32 am
Posts: 13
Code:
***************** Declarations ****************

PgCR    equ $800001 ;Port general control register
PaCR    equ $80000D ;PortA control register
PaDDR    equ $800005 ;PortA data direction register
PaDR    equ $800011 ;PortA data register
PbCR    equ $80000f ;PortB control register
PbDDR    equ $800007 ;PortB data direction register
PbDR    equ $800013 ;PortB data register

;****************************************************************************
;****************************************************************************

   Org $400400 ;Start address
Start    Move.b #$00,PgCR ;Set port to general mode
   Move.b #$80,PaCR ;Set portA to submode IX
   Move.b #$0F,PaDDR ;Set bits PA0-PA3=outputs, PA4-PA7=inputs
   Move.b #$80,PbCR ;Set portA to submode IX
   Move.b #$FF,PbDDR ;Set bits PA0-PA7=outputs, ;Move.b #$00,PbDR
   Move.b #$ff,PbDR
   Move.b #$8f,no1 ; set the address to be blank for 7segment
   Move.b #$4f,no2
   Move.b #$2f,no3
   Move.b #$1f,no4
   move.l #4,D1 ;this is to count the error in confirmation
   move.l #3,D2
;****************************************************************************

puk   move.w #16,D6
   lea pkc,A6
   TRAP #11
   DC.W 5
   bra Again
 
prestart Move.w #12,D6 ;use D6 as pin number counter
   TRAP #11 ; prompt to confirm
   DC.W 12
   lea hi,A6
   TRAP #11
   DC.W 5
;****************************************************************************

Again    
   Bsr Get_Key ;key pressed?
   Cmp.b #$10,D0 ;if return code is $10
   Beq Again ; check again
   Move.b D0,KeyStore ;Save key
   Bsr Delay ;Wait for a while
   Bsr Get_Key ;check key again
   Move.b KeyStore,D1
   Cmp.b D0,D1 ;is there a match?
   Bne Again ;no: check again
   Bsr Display ;if not $10 then display

;****************************************************************************
   
   Clr.w D0
   sub.b #1,D6 ;minus 1 from pin number counter
;***************************************************************************   
   Cmp.b #16,D6 ;compare with 16
   beq comkal
   
;***************************************************************************   
   Cmp.b #12,D6 ;compare with 12
   beq viewall2
;***************************************************************************   
   Cmp.b #8,D6 ;compare with 8
   beq viewall
;****************************************************************************

   Cmp.b #4,D6 ;compare with zero
   beq check
;****************************************************************************

   Cmp.b #0,D6 ;compare with zero
   beq finally ; go to last compare the user password
   Bra Again ;OR keep scanning
;****************************************************************************

Get_Key Movem.w D1-D2,-(SP)
   Clr.w D0 ;Build hex. code in D0
   Move.b #$FE,D1 ;Ground column 0
   Move.w #4,D2 ;use D2 as counter

;****************************************************************************

Next    Move.b D1,PaDR ;activate column line
   Move.b PaDR,D0 ;read port A
   Andi.b #$F0,D0 ;isolate column lines
   Cmp.b #$F0,D0 ;any row line active?
   Beq NextCol ;yes: means no key goto next column
   Bra EndScan ;else same means key pressed

;****************************************************************************

NextCol Rol.b #1,D1 ;rotate column code
   sub.b #1,D2 ;decrement counter by one
   Cmp.b #$00,D2 ;if not zero
   Bne Next ; check key again

;****************************************************************************

EndScan Bsr KeyCode
   Movem.w (SP)+,D1-D2 ;restore registers
   Rts

;****************************************************************************

KeyCode Move.b D1,D4 ;Store column
   Not.b D4 ;Complement column code
   Move.b D0,D5 ;Store row code
   Not.b D5 ;Complement row code
   Andi.b #$F0,D5 ;Mask bits 0-3
   Add.b D4,D5 ;Combine row and column
   Move.b D5,D0 ;Return new code
   bsr IdKey
   rts

;****************************************************************************

IdKey    Movem.w D1-D2,-(SP)
   move.b #$11,D1 ;key 1 ;A series of if-then-else
   cmp.b D1,D0 ;to identify the correct key
   beq Key1
   move.b #$12,D1 ;key 2
   cmp.b D1,D0
   beq Key2
   move.b #$14,D1 ;key 3
   cmp.b D1,D0
   beq Key3
   move.b #$18,D1 ;key F
   cmp.b D1,D0
   beq KeyA
   move.b #$21,D1 ;key 4
   cmp.b D1,D0
   beq Key4
   move.b #$22,D1 ;key 5
   cmp.b D1,D0
   beq Key5
   move.b #$24,D1 ;key 6
   cmp.b D1,D0
   beq Key6
   move.b #$28,D1 ;key E
   cmp.b D1,D0
   beq KeyB
   move.b #$44,D1 ;key 9
   cmp.b D1,D0
   beq Key9
   move.b #$42,D1 ;key 8
   cmp.b D1,D0
   beq Key8
   move.b #$41,D1 ;key 7
   cmp.b D1,D0
   beq Key7
   move.b #$48,D1 ;key D
   cmp.b D1,D0
   beq KeyC
   move.b #$81,D1 ;key F
   cmp.b D1,D0
   beq KeyF
   move.b #$82,D1 ;key 0
   cmp.b D1,D0
   beq Key0
   move.b #$84,D1 ;key E
   cmp.b D1,D0
   beq KeyE
   move.b #$88,D1 ;key C
   cmp.b D1,D0
   beq KeyD
   Bra Exist

;****************************************************************************

Key1    move.b #$01,D0 ;
   bra Exist
Key2    move.b #$02,D0 ;
   bra Exist
Key3    move.b #$03,D0 ;
   bra Exist
KeyF    move.b #$0F,D0 ;
   bra Exist
Key4    move.b #$04,D0 ;
   bra Exist
Key5    move.b #$05,D0 ;
   bra Exist
Key6    move.b #$06,D0 ;
   bra Exist
KeyE    move.b #$0E,D0 ;
   bra Exist
Key9    move.b #$09,D0 ;
   bra Exist
Key8    move.b #$08,D0 ;
   bra Exist
Key7    move.b #$07,D0 ;
   bra Exist
KeyD    move.b #$0D,D0 ;
   bra Exist
KeyA    move.b #$0A,D0 ;
   bra Exist
Key0    move.b #$00,D0 ;
   bra Exist
KeyB    move.b #$0B,D0 ;
   bra Exist
KeyC    move.b #$0C,D0 ;
Exist    Movem.w (SP)+,D1-D2
   rts

;****************************************************************************

Delay    Movem.w D1-D2,-(SP)
   Move.l #95000,d1
Here    subq.l #1,d1
   Bne Here
   Movem.w (SP)+,D1-D2
   rts

;****************************************************************************

Display Andi.b #$0F,D0 ;masking

;****************************************************************************
   cmp.b #20,D6 ;
   beq satu5
   cmp.b #19,D6
   beq dua5
   cmp.b #18,D6
   beq tiga5
   cmp.b #17,D6
   beq empat5

;****************************************************************************
   cmp.b #16,D6 ;
   beq satu0
   cmp.b #15,D6
   beq dua0
   cmp.b #14,D6
   beq tiga0
   cmp.b #13,D6
   beq empat0
 ;****************************************************************************
   cmp.b #12,D6 ; 1st 7segment 1st number
   beq satu1
   cmp.b #11,D6
   beq dua1
   cmp.b #10,D6
   beq tiga1
   cmp.b #9,D6
   beq empat1

;****************************************************************************
   cmp.b #8,D6 ;1st 7segment 2nd number
   beq satu2
   cmp.b #7,D6
   beq dua2
   cmp.b #6,D6
   beq tiga2
   cmp.b #5,D6
   beq empat2

;****************************************************************************
   cmp.b #4,D6 ;1st 7segment 3rd number
   beq satu3
   cmp.b #3,D6
   beq dua3
   cmp.b #2,D6
   beq tiga3
   cmp.b #1,D6
   beq empat3

;****************************************************************************
satu5    add.b #$80,D0
   move.b D0,po1
   bra view
dua5    add.b #$40,D0
   move.b D0,po2
   bra view
tiga5    add.b #$20,D0
   move.b D0,po3
   bra view
empat5    add.b #$10,D0
   move.b D0,po4
   
   
;****************************************************************************
satu0    add.b #$80,D0
   move.b D0,puk1
   bra view
dua0    add.b #$40,D0
   move.b D0,puk2
   bra view
tiga0    add.b #$20,D0
   move.b D0,puk3
   bra view
empat0    add.b #$10,D0
   move.b D0,puk4

;****************************************************************************
satu1    add.b #$80,D0
   move.b D0,no1
   bra view
dua1    add.b #$40,D0
   move.b D0,no2
   bra view
tiga1    add.b #$20,D0
   move.b D0,no3
   bra view
empat1    add.b #$10,D0
   move.b D0,no4

;****************************************************************************

satu2    add.b #$80,D0
   move.b D0,conf1
   bra view
dua2    add.b #$40,D0
   move.b D0,conf2
   bra view
tiga2    add.b #$20,D0
   move.b D0,conf3
   bra view
empat2    add.b #$10,D0
   move.b D0,conf4

;****************************************************************************
satu3    add.b #$80,D0
   move.b D0,user1
   bra view
dua3    add.b #$40,D0
   move.b D0,user2
   bra view
tiga3    add.b #$20,D0
   move.b D0,user3
   bra view
empat3    add.b #$10,D0
   move.b D0,user4
;****************************************************************************

view    Move.b D0,PbDR
   Trap #11
   DC.W 8
   Trap #11
   DC.W 3
   RTS
;****************************************************************************

viewall move.l #255556,d3
lap   Move.b no1,PbDR
   Move.b no2,PbDR
        Move.b no3,PbDR
        Move.b no4,PbDR
   subq.l    #1,D3
   bne   lap
   Move.b #$ff,PbDR
   Cmp.b #0,D6 ;compare with zero
   beq habis
   Cmp.b #8,D6 ;compare with 8
   beq khey ; proceed to confirmation pin code
   bra Again

;****************************************************************************

khey   TRAP #11 ; prompt to confirm
   DC.W 12
   lea re,A6
   TRAP #11
   DC.W 5
   bra Again

;****************************************************************************
 ;****************************************************************************

viewall2 move.l #255556,d3
lap2   Move.b puk1,PbDR
   Move.b puk2,PbDR
        Move.b puk3,PbDR
        Move.b puk4,PbDR
   subq.l    #1,D3
   bne   lap2
   Move.b #$ff,PbDR
   bra prestart
;****************************************************************************

finally TRAP #11 ;last part of comparing the password
   DC.W 12
   move.b  no1,d7
   cmp.b    user1,d7
   bne    denied
   move.b  no2,d7
   cmp.b    user2,d7
   bne    denied
   move.b  no3,d7
   cmp.b    user3,d7
   bne    denied
   move.b  no4,d7
   cmp.b    user4,d7
   bne    denied ; user enter wrong pin password
   bra    habis

;****************************************************************************

wrong    TRAP #11 ;promp wrong for confirmation
   DC.W 12
   lea fal,A6
   TRAP #11
   DC.W 5
   TRAP #11 ;promp wrong for confirmation
   DC.W 12
   move.b #$38,PbDR
        bsr   Delay
   bsr   Delay
   move.b #$0F,PbDR
   bsr   Delay
   bsr   Delay
   subq.l #1,D1   ;add 1 to count the error
   cmp.b #0,D1
   beq   babai; puk code block due 3 error confirmation
   bra prestart

;****************************************************************************

denied   TRAP #11 ;promp wrong for user
   DC.W 12
   lea den,A6
   TRAP #11
   DC.W 5
   bsr Delay
   move.b #$38,PbDR
        bsr   Delay
   bsr   Delay
   move.b #$0F,PbDR
   bsr   Delay
   subq.l #1,D2
   cmp.b #$0,D2
   beq   babai
   TRAP #11 ;prompt wrong for user
   DC.W 12
   lea use,A6
   TRAP #11
   DC.W 5
   bsr Delay
   move.b #$04,D6
   bra Again

;****************************************************************************


;****************************************************************************

check   TRAP #11
   DC.W 12
   clr.w   d7
   move.b  no1,d7
          cmp.b   conf1,d7   
   bne     wrong
          move.b  no2,d7
          cmp.b   conf2,d7
          bne     wrong 
          move.b  no3,d7
          cmp.b   conf3,d7
          bne     wrong 
          move.b  no4,d7
          cmp.b   conf4,d7 
          bne     wrong
   Move.b #$ff,PbDR 
   lea con,A6
   TRAP #11
   DC.W 5          
   TRAP #11
   DC.W 12
   bsr Delay
   bsr Delay
   bsr Delay
   lea use,A6
   TRAP #11
   DC.W 5
   bra     Again

;****************************************************************************
habis   
   lea agr,A6
   TRAP #11
   DC.W 5
   TRAP #11
   DC.W 12
   Move.b #$ff,PbDR
   bsr   Delay
   Move.b #$fa,PbDR
   bsr   Delay
   Move.b #$fb,PbDR
   bsr   Delay
   Move.b #$fc,PbDR
   bsr   Delay
   Move.b #$fd,PbDR      
   bsr   Delay
   Move.b #$fe,PbDR
   bsr   Delay
   bra    song
;****************************************************************************
song   move.b #$Ca,PbDR
   bsr Delay   
   bsr Delay   
   bsr Delay   
   move.b #$0f,PbDR
   bsr Delay   
   bsr Delay   
   move.b #$Cb,PbDR
   bsr Delay   
   move.b #$0f,PbDR
   bsr Delay   
   bsr Delay   
   move.b #$Cc,PbDR
   bsr Delay   
   move.b #$0f,PbDR
   bsr Delay   
   bsr Delay   
   bsr Delay   
   move.b #$Cd,PbDR
   bsr Delay   
   bsr Delay   
   move.b #$0f,PbDR
   bsr Delay   
   move.b #$Ce,PbDR
   bsr Delay   
   move.b #$0f,PbDR
   bra   song


;****************************************************************************

babai     TRAP #11 ;promp wrong for user
   DC.W 12
   lea bai,A6
   TRAP #11
   DC.W 5
   TRAP #11
   DC.W 12
   bsr Delay
   bsr Delay
   bsr Delay
   bsr Delay
   bsr Delay
   move.b #$38,PbDR
        bsr   Delay
   bsr   Delay
   move.b #$0F,PbDR
   bsr   Delay
   bra haikal

;****************************************************************************
haikal  TRAP #11 ;promp wrong for user
   DC.W 12
   lea kal,A6
   TRAP #11
   DC.W 5
   move.w #20,D6
   bra Again

comkal  TRAP #11
   DC.W 12
   
   move.l #25556,d3
lap3   Move.b po1,PbDR
   Move.b po2,PbDR
        Move.b po3,PbDR
        Move.b po4,PbDR
   subq.l    #1,D3
   bne   lap3
   Move.b #$ff,PbDR
   
   clr.w   d7
first   move.b  po1,d7
          cmp.b   puk1,d7   
   beq     second
second    move.b  po2,d7
          cmp.b   puk2,d7
          beq     third 
third     move.b  po3,d7
          cmp.b   puk3,d7
          beq     fourth 
fourth    move.b  po4,d7
          cmp.b   puk4,d7 
          beq     prestart
   Move.b #$ff,PbDR 
   
   bra     wrongs

;****************************************************************************
wrongs    TRAP #11 ;promp wrongs for user
   DC.W 12
   lea tech,A6
   TRAP #11
   DC.W 5
   bra effect

effect   move.b #$3f,PbDR
   bsr Delay
   move.b #$00,PbDR
   bsr Delay
   move.b #$3f,PbDR
   bsr Delay
   bsr Delay
   bsr Delay
   move.b #$00,PbDR
   bsr Delay
   bsr Delay
   bsr Delay
   move.b #$3f,PbDR
   bsr Delay
   bsr Delay
   move.b #$00,PbDR
   bsr Delay
   bsr Delay
   bra effect

;****************************************************************************


KeyStore ds.b 4 ;Temp store for keypressed
no1       ds.b    1
no2       ds.b    1
no3       ds.b    1
no4       ds.b    1

conf1     ds.b    1
conf2     ds.b    1
conf3     ds.b    1
conf4    ds.b    1

user1    ds.b    1
user2    ds.b    1
user3    ds.b    1
user4    ds.b    1

puk1    ds.b    1
puk2    ds.b    1
puk3    ds.b    1
puk4    ds.b    1

po1    ds.b    1
po2    ds.b    1
po3    ds.b    1
po4    ds.b    1


hi   dc.b   'Set new pin code : '
   dc.b   0
re   dc.b   'Re-enter pin code  : '
   dc.b   0
fal     dc.b   'Pin code does not match (-___-") '
   dc.b   0
con     dc.b    'Pin code is confirmed (^-^)V '
   dc.b   0
use      dc.b    'Enter pin code : '
   dc.b   0
agr     dc.b    'Access granted (~_~) '
   dc.b   0
den     dc.b    'Access denied (T_T) '
   dc.b   0
bai     dc.b    'Sorry, you have exceeded the trial limit '
   dc.b   0
pkc     dc.b    'Set PUK code :'
   dc.b   0
kal   dc.b    'Enter PUK code :'
   dc.b   0
tech   dc.b    'Call Pn. Siti Fatimah for further assistance'
   dc.b   0
;****************************************************************************
   END START ; last line of source




this is the latest coding..

the function is to make a safety box,
there will be a PUK code,
and also safety code,
then confirmation code,

after that is prompt to enter code to log in..

is there any part where i can put a reset button?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 9 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group