EASy68K  
It is currently Fri May 29, 2020 3:39 am

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Sat Dec 11, 2010 2:23 am 
Offline

Joined: Fri Dec 10, 2010 10:19 am
Posts: 6
Location: Malaysia
im using emu68k
a lil bit confuse here cause cant search coding related with emu68k
just easy68k

i want to make a program that search highest odd integer
but i dont know why its appear on cmd as address location wrong
here is my coding
and where and can find information about emu68k programming?
not an assignment, just doing test for final exam and this is the only one question i cant solved
Code:
   ORG   $8000
CR   EQU   $0D
LF   EQU   $0A
NINE   EQU   $39
SEVEN   EQU   $36
FIVE   EQU   $35
THREE   EQU   $33
ONE   EQU   $31
DATA   DC.B   13,13,13,32,32,32,32,32,32,32,32,32,32
   DC.B   32,32,32,32,32,32,32,32,32,32,32,32,32,32,32
   DC.B   'HIGHEST ODD NUMBER DETECTOR',10,10
   DC.B   32,32,'Please enter a string of characters to'
   DC.B   32,'search for the highest ODD integer:',10,10
;KEY   DS.L   5
      
   ORG   $8500
START   MOVEA.L   #DATA,A3
   TRAP   #3
;   CLR.W   D0
   CMPI.B   #N,D1
   BEQ   EXIT
   BNE   WARN
WARN   DC.B   'Please enter numbers',0
   MOVEA.L   #WARN,A3
   TRAP   #3
EXIT   TRAP   #9
   END   START

Tq


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 11, 2010 2:04 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1122
Your code needs :director: COMMENTS.

CMPI.B #N,D1 probably should be CMPI.B #'N',D1 if you are looking for the character 'N' in register D1

BNE WARN branches to the DC.B directive which is not code it is text.

There appears to be a loop missing because the program ends after displaying the prompt.

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2010 9:19 am 
Offline

Joined: Fri Dec 10, 2010 10:19 am
Posts: 6
Location: Malaysia
Code:
   ORG   $8000
DATA   DC.L   0,0,0,0
DATA2   DC.L   0,0,0,0
MSG1   DC.B   13,13,'Please enter a string for encryption '
   DC.B   ' (<6 characters):',13,13,0
MSG2   DC.B   13,13,'The original input ',0
MSG4   DC.B   13,13,' YOU HAVE ENTERED MORE THAN 6 CHARACTERS!'
   DC.B   ' THAT IS A BIG NO NO!',13,13,0
CR   DC.B   13,13
SEMBI   EQU   39   
TUJUH   EQU   37
LIMA   EQU   35
TIGA   EQU   33   
SATU   EQU   31
   
   ORG   $8200
START   CLR.L   D5
   CLR.L   D7
   MOVEA.L   #DATA,A5
   MOVEA.L   #DATA,A6

ASK   MOVEA.L   #MSG1,A3
   TRAP   #3

READ   TRAP   #0
   CMPI.B   #13,D1
   BEQ   SET
   TRAP   #1
   ADDQ.B   #1,D5
   CMPI.B   #6,D5
   BEQ   OVER
   MOVE.B   D1,(A5)+
   MOVE.B   #0,(A5)
   BRA   READ

SET   SUBA.L   #1,A5
   MOVEA.L   A5,A6
   MOVEA.L   #DATA,A5

LOOP   MOVE.B   (A5),D7
   EORI.B   #$41,D7

   CMPI.B   #SEMBI,D7
   BEQ   SAVE
   BNE   SEVEN

SEVEN   CMPI.B   #TUJUH,D7
   BEQ   SAVE
   BNE   FIVE

FIVE   CMPI.B   #LIMA,D7
   BEQ   SAVE
   BNE   THREE

THREE   CMPI.B   #TIGA,D7
   BEQ   SAVE
   BNE   ONE

ONE   CMPI.B   #SATU,D7
   BEQ   SAVE
   BNE   OVER


;   BTST   #9,D7
;   BEQ   SAVE
;   BTST   #7,D7
;   BNE   SAVE
;SWAP   EORI.B   #$24,D7
;   BRA   SAVE

;TEST   BTST   #5,D7
   ;BNE   SWAP

SAVE   MOVE.B   D7,(A7)+
   ADDA.L   #1,A5
   CMPA.L   A5,A6
   BLT   PRINT
   BRA   LOOP

PRINT   MOVE.B   #0,(A5)
   MOVEA.L   #MSG2,A3
   TRAP   #3
   MOVEA.L   #DATA,A3
   TRAP   #3
   MOVEA.L   #CR,A3
   TRAP   #3
   BRA   DONE

OVER   MOVEA.L   #MSG4,A3
   TRAP   #3

DONE   TRAP   #9
   END   START




it should check one by one character
i dont even know how to make a coding to check from first bit until fifth bit
can u help me prof?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2010 12:54 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1122
When I see some comments in your code I might offer some suggestions.

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2010 6:15 pm 
Offline

Joined: Fri Dec 10, 2010 10:19 am
Posts: 6
Location: Malaysia
thanks prof


Last edited by ery on Thu Dec 16, 2010 6:31 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: my coding comment
PostPosted: Thu Dec 16, 2010 6:23 pm 
Offline

Joined: Fri Dec 10, 2010 10:19 am
Posts: 6
Location: Malaysia
below is my comment Prof. Kelly


Last edited by ery on Thu Dec 16, 2010 6:27 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: my coding
PostPosted: Thu Dec 16, 2010 6:27 pm 
Offline

Joined: Fri Dec 10, 2010 10:19 am
Posts: 6
Location: Malaysia
highest odd integer, 5 input

Code:
   ORG   $8000
DATA   DC.L   0,0,0,0,0

MSG1   DC.B   13,13,'Please enter a string for encryption '
   DC.B   ' (<6 characters):',13,13,0
MSG2   DC.B   13,13,'The original input ',0
MSG3   DC.B   13,13,' YOU HAVE ENTERED MORE THAN 6 CHARACTERS!'
   DC.B   ' THAT IS A BIG NO NO!',13,13,0
CR   DC.B   13,13
   
   ORG   $8200
START   CLR.L   D5      ;D5 count the number of char
   CLR.L   D7      ;D7 will be used for testing
   MOVEA.L   #DATA,A5   ;A5 is the general pointer
   MOVEA.L   #DATA,A6   ;A6 will point to the end of string

ASK   MOVEA.L   #MSG1,A3   ;prompt the user for input
   TRAP   #3

READ   TRAP   #0      ;read input from keyboard
   CMPI.B   #13,D1      ;check for carriage return
   BEQ   SET      ;if CR met, test immediately
   TRAP   #1      ;echo the user input
   ADDQ.B   #1,D5      ;increment the counter
   CMPI.B   #6,D5      ;check if you have more than 6 inputs
   BEQ   OVER      ;if more than 6,exit program
   MOVE.B   D1,(A5)+   ;write to memory
   MOVE.B   #0,(A5)      ;write end of string marker
   BRA   READ

SET   SUBA.L   #1,A5      ;make A5 point to the last character
   MOVEA.L   A5,A6      ;A6 points to the last character
   MOVEA.L   #DATA,A5   ;A5 points to the first character
   
LOOP   MOVE.B   (A5),D7      ;get character from memory
   EORI.B   #$41,D7      ;toggle bit 0 and 6

   CMPI.B   #39,D7      ;compare number 9 with memory
   BEQ   SAVE      ;save if same
   BNE   SEVEN      ;if not, go to seven
SEVEN   CMPI.B   #37,D7      ;compare number 7 with memory
   BEQ   SAVE      ;save if same
   BNE   FIVE      ;if not, go to five
FIVE   CMPI.B   #35,D7      ;compare number 5 with memory
   BEQ   SAVE      ;save if same
   BNE   THREE      ;if not, go to three
THREE   CMPI.B   #33,D7      ;compare number 3 with memory
   BEQ   SAVE      ;save if same
   BNE   ONE      ;if not, go to one
ONE   CMPI.B   #31,D7      ;compare number 1 with memory
   BEQ   SAVE      ;save if same
   BNE   OVER      ;if not, display error
   BRA   SAVE

SAVE   MOVE.B   D7,(A7)+   ;save encrypted data to memory
   ADDA.L   #1,A5      ;increment point of A5
   CMPA.L   A5,A6      ;check for end of string
   BLT   PRINT      ;if end of string, print result
   BRA   LOOP      ;else, loop back

PRINT   MOVE.B   #0,(A5)      ;write end of string marker
   MOVEA.L   #MSG2,A3
   TRAP   #3
   MOVEA.L   #DATA,A3
   TRAP   #3
   MOVEA.L   #CR,A3
   TRAP   #3
   BRA   DONE

OVER   MOVEA.L   #MSG3,A3
   TRAP   #3

DONE   TRAP   #9
   END   START


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2010 9:05 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1122
I'm not familiar with the simulator you are using so I can not tell if the trap tasks are being used correctly. I made the following observations:

The BNE instruction is redundant and may be removed since it branches to the following instruction.
BNE SEVEN ;if not, go to seven
SEVEN CMPI.B #37,D7 ;compare number 7 with memory

The BNE instruction is redundant and may be removed since it branches to the following instruction.
BNE FIVE ;if not, go to five
FIVE CMPI.B #35,D7 ;compare number 5 with memory

The BNE instruction is redundant and may be removed since it branches to the following instruction.
BNE THREE ;if not, go to three
THREE CMPI.B #33,D7 ;compare number 3 with memory

The BNE instruction is redundant and may be removed since it branches to the following instruction.
BNE ONE ;if not, go to one
ONE CMPI.B #31,D7 ;compare number 1 with memory

The BRA instruction is redundant and may be removed since it branches to the following instruction.
BRA SAVE

SAVE MOVE.B D7,(A7)+ ;save encrypted data to memory

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2010 11:10 pm 
Offline

Joined: Fri Dec 10, 2010 10:19 am
Posts: 6
Location: Malaysia
oh i see
ok prof i will try to remove it

do you have coding for read and compare each character?
im using asm68k and emu68k


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 17, 2010 1:07 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1122
I am not familiar with asm68k and emu68k.

_________________
Prof. Kelly


Top
 Profile  
 
PostPosted: Sun Dec 08, 2013 2:27 am 
Offline

Joined: Sun Dec 08, 2013 2:19 am
Posts: 2
Bro, may i request from you, i want this program source code, because recently i have 1 assignment topic same as you " Finding highest odd integer"


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 11 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