The code isnt finished. Ignore sections to be added...but how do i fix the undefined symbol error...i was told i need to declare some variables.
Code:
-----------------------------------------------------------
ORG $1000
START
move.b #0,(fileAccessed)
move.b #22,(recordsize)
move.b #19,(namelength)
MOVE #0,D0 Set Trap task 1 (Print string)
MOVE #50,D1 Set String length to be printed to max 50
lea welcomePrompt,a1 load address of string to display into A1
trap #15 trap #15 activates input/output task
MOVE #0,D0 Set Trap task 1 (Print string)
MOVE #50,D1 Set String length to be printed to max 50
lea spacePrompt,a1 load address of string to display into A1
trap #15 trap #15 activates input/output task
BSR do_Menu
do_Menu
MOVE.w #$FF00,D1
move #11,d0
trap #15
MOVE #0,D0 Set Trap task 1 (Print string)
MOVE #50,D1 Set String length to be printed to max 50
lea FileAccessedPrompt,a1 load address of string to display into A1
move #30,d1
move #1,d0
trap #15 trap #15 activates input/output task
move.b (fileAccessed),d4
cmp #1,D4
BEQ do_ShowFileName
cmp #0,d4
BEQ do_ShowNoFile
do_ShowNoFile
lea NoFileString,a1
move #0,d0
move #4,d1
trap #15
bra do_ContinueMenu
do_ShowFileName
lea fileName,a1
move #0,d0
move #0,a4
BSR do_FileNameLengthToA4
move a4,d1
trap #15
bra do_ContinueMenu
do_ContinueMenu
lea LoadFilePrompt,a1 load address of string to display into A1
move.l #29,d1
trap #15 trap #15 activates input/output task
*Add code here to conditionally suppress menu
lea SaveFilePrompt,a1 load address of string to display into A1
move.l #23,d1
trap #15 trap #15 activates input/output task
MOVE.B (encrypted), d2
cmp.b #1,D2
BEQ do_ShowDecryptPrompt
lea EncryptPrompt,a1 load address of string to display into A1
move.l #26,d1
trap #15 trap #15 activates input/output task
bra do_ContinueMenu2
do_ShowDecryptPrompt
lea DecryptPrompt,a1 load address of string to display into A1
move.l #26,d1
trap #15 trap #15 activates input/output task
do_ContinueMenu2
lea ViewTotalsPrompt,a1 load address of string to display into A1
move.l #18,d1
trap #15 trap #15 activates input/output task
do_ShowExit
lea ExitPrompt,a1 load address of string to display into A1
move.l #14,d1
trap #15 trap #15 activates input/output task
MOVE.l #5,D0 Set Trap task 5 (Read char into D1)
trap #15 trap #15 activates input/output task
CMP #'L',D1
BEQ do_LoadOpenFile
CMP #'S',D1
BEQ do_SaveFile
CMP #'E',D1
BEQ do_EncodeFile
CMP #'D',D1
BEQ do_DecodeFile
CMP #'V',D1
BEQ do_Display
CMP #'X',D1
BEQ do_Exit
BRA do_Menu
do_LoadOpenFile
BSR do_InitFile * go setup stuff
BSR do_OpenFile * go open a file
MOVE.l #-1,d0 * set test value
CMP.l d0,d1 * test the file ID
BEQ do_Exit * if no file just quit
BSR do_LoadFile * load the file
BRA do_Menu
do_SaveFile
*1.4 Code to save file here (Will need to open the file for output then write to it)
BRA do_Menu
do_DecodeFile
* Insert Code that can decode a file here (do 1.5. and 1.6 first)
BRA do_Menu
do_EncodeFile
move.l #0,a3
LEA txtFile(a3),a4
move.l #0,d5
move.b #0,(currentRec)
move.w #0,(total) * to be used to store running total for the bills
move.B #1,(encryptmode)
BSR do_ProcessLines * was all ok so process the file
move.B #1,(encrypted)
BRA do_Menu
DO_Display
BSR do_DisplayFile
BRA do_Menu
do_Exit
MOVE.b #9,D0
Trap #15 * halt simulator
do_InitFile
MOVE.l #0,d1 * turn off keyboard echo
MOVE.l #12,d0 * keyboard echo
TRAP #15
MOVE.l #50,d0 * close all files
TRAP #15
RTS
do_OpenFile
move.l #0,A3
LEA dialogTitle(pc),a1 * set the request title string pointer
LEA dialogListAll(pc),a2 * set the file types list pointer
LEA fileName(a3),a3 * set the file name buffer pointer
MOVE.l #0,d1 * file open
MOVE.b d1,(a3) * ensure null source file
MOVE.l #58,d0 * file I/O
TRAP #15
MOVEA.L a3,a1 * copy the file name pointer
TST.L d1 * did the user hit open
BEQ.s do_NoOpenFile * if not do no file exit
MOVE.l #51,d0 * else open existing file
TRAP #15
MOVE.L d1,(fileId) * save the file ID
BSR do_FileNameLengthToA4
sub #3,A4
MOVE.b fileName(a4),d4
cmp #$65,d4
BEQ do_SetEncrypted
* if the third to last characters of the filename is e, then set encryption mode to 1
move.b #0,(Encrypted)
bra do_ExitOpen
do_SetEncrypted
move.b #1,(Encrypted)
do_ExitOpen
RTS
do_OpenOutFile
move.l #(outDialogTitle),a1 * set the request title string pointer
move.b (encrypted),d2
cmp.b #1,d2
BEQ do_SetEncryptFile
cmp.b #1,d2
BEQ do_SetTxtFile
do_SetTxtFile
LEA dialogListTxt(pc),a2 * set the file types list pointer
BRA do_ContinueOpenOutFile
do_SetEncryptFile
LEA dialogListEnc(pc),a2 * set the file types list pointer
BRA do_ContinueOpenOutFile
do_ContinueOpenOutFile
MOVE.L #(outFileName),a3 * set the file name buffer pointer
MOVE.l #0,d1 * file open
MOVE.b d1,(a3) * ensure null source file
MOVE.l #58,d0 * file I/O
TRAP #15
MOVE.l a3,a1 * copy the file name pointer
tst.l d1 * did the user hit open
BEQ.s do_NoOpenFile * if not do no file exit
MOVE.l #52,d0
TRAP #15
MOVE.l d1,(outFileID) * save the file ID
RTS
do_NoOpenFile
MOVE.l #-1,d1 * clear the file id
rts
do_FileNameLengthToA4 * WILL BE CALLED RIGHT AFTER THE USER SELECTS A FILE WITH THE OPEN DIALOG
Move.l #0,a4
do_CountFileAgain
Move.b filename(a4),d4
cmp #0,D4
beq do_doneFileNameLength
add #1,a4
bra do_CountFileAgain
do_doneFileNameLength
*a4 now contains length of filename
RTS
do_LoadFile
MOVE.l #0,a3
MOVE.l (fileId),d1 * get the file ID
move.l #0, d4
MOVE.L #(txtFile),a1 * point to the file buffer
do_ReadMore
MOVE.b (recordSize),d2 * set the byte count to load the file header
MOVE.l d2,d3 * copy the file header byte count
MOVE.l #53,d0 * read from the file
TRAP #15
CMP.l d3,d2 * compare the bytes read with the expected
* byte count
BNE.s do_ExitLoadFile * if incorrect do exit
ADD d2,a1
add #1,d4
BRA do_ReadMore
do_ExitLoadFile
move.b d4, (numRecords)
move.b #1, (fileAccessed)
RTS
do_DoneProcess
RTS
do_ConvertToNum
move.w d5,d6
and.w #$FF00,d6
lsr #8,d6
sub.b #$30,d6
mulu #10,d6
move.b d5,d7
sub #$30,d7
add d6,d7
RTS
do_ProcessLines
move.l #0, A2
move.b (numRecords),d4
move.l #0,d5
move.b (currentRec),d5
move.l #0,d6
move.l #0,D7
move.b (recordSize),D2
add #2,D2
BSR do_ProcessChars
add.b #1,d5
cmp d4,d5
BGE do_DoneProcessLines
move.b d5,(currentRec)
BRA do_ProcessLines
do_DoneProcessLines
RTS
do_ProcessChars
cmp d7,D2
BEQ do_ExitConvert
* 1.5 Using successive characters in the ID, encode/decode the file with the new value at a position given by "Old value - value of digit at position -10"
move.b (a4),d6
move.b (encryptmode),d0
cmp.b #1,d0
beq do_Encryption
do_Decryption
bsr do_CalcDecrypt
bra do_continueProcessChars
do_Encryption
bsr do_CalcEncrypt
bra do_continueProcessChars
do_ContinueProcessChars
add #1,d7
add #1,a4
add #1,A2
CMP #8,A2
BEQ do_ResetIdPos
BRA do_ProcessChars
do_ExitConvert
RTS
do_CalcEncrypt
*1.6 Code to perfrom encryption to be added here
RTS
do_CalcDecrypt
*1.7 Code to perform decryption may be added here
RTS
do_ResetIdPos
Move #0,A2
BRA do_ProcessChars
do_WriteOutFile
move.l (outFileID),d1
move #0,A3
move #0,d7
move.b (numrecords), d4
*lea filename(a3),a3 *load address of string to display into A1
lea txtfile(a3),a1
cmp d4,d7
BEQ do_doneWriting
BRA do_writeLine
*write output to file
do_WriteLine
*1.8 Add code to write to file
BRA do_doneWriting
do_doneWriting
move.l #56,d0
Trap #15
rts
do_DisplayFile
move.B (FileID),d1
move.l #0,A3
move.l #0,d7
move.w #0,(total)
MOVE.b #0,(currentrec)
move.b (numrecords),d4
MOVE.l #0,D0 Set Trap task 1 (Print string)
MOVE.l #50,D1 Set String length to be printed to max 50
lea RowSpacer,a1 load address of string to display into A1
trap #15 trap #15 activates input/output task
MOVE.l #0,D0 Set Trap task 1 (Print string)
MOVE.l #50,D1 Set String length to be printed to max 50
lea DisplayHeader,a1 load address of string to display into A1
trap #15 trap #15 activates input/output task
MOVE.l #0,D0 Set Trap task 1 (Print string)
MOVE.l #50,D1 Set String length to be printed to max 50
lea RowSpacer,a1 load address of string to display into A1
trap #15 trap #15 activates input/output task
lea filename(a3),a3 *load address of string to display into A1
Move.l #(txtfile),a1
cmp.b d4,d7
BEQ do_doneDisplay
BRA do_DisplayLine
do_DisplayLine
*1.9 Add code to display line number here
Move.l #0,d1
MOVE.l #0,D0 Set Trap task 1 (Print string)
MOVE.B (recordsize),D1 Set String length to be printed to max 50
trap #15 trap #15 activates input/output task
*move.b d5,(currentRec)
move.B (nameLength),d2
move.l a1,a4
add d2,a4
add #1,a4
move.l #0,d5
move.b (a4),d5
lsl #8,d5
add #1,a4
move.b (a4),d5
*1.10
add #3,a4 *three bytes after the end of the previous name, the next name starts (skipping past the colon and numbers)
move.b (recordsize),d1
add d1,a1
add #2,a1 * skip past CR and LF
*increment line
move.b (currentRec),d5
add.b #1, d5
move.b d5,(currentRec)
move.b (numrecords),d4
cmp.b d5,d4
* add #recordsize, d5
BEQ do_DoneDisplay
BRA do_DisplayLine
do_DoneDisplay
MOVE.l #0,D0 Set Trap task 1 (Print string)
MOVE.l #50,D1 Set String length to be printed to max 50
lea RowSpacer,a1 load address of string to display into A1
trap #15 trap #15 activates input/output task
move.b (encrypted),d2
cmp.b #1,d2
BEQ do_ShowEnterPrompt
*1.10b Add code to display the total
do_ShowEnterPrompt
MOVE.l #0,D0 Set Trap task 1 (Print string)
MOVE.l #50,D1 Set String length to be printed to max 50
lea EnterPrompt,a1 load address of string to display into A1
trap #15 trap #15 activates input/output task
do_ConfirmContinue
MOVE.l #0,D1
MOVE.l #5,D0 Set Trap task 1 (Print string)
trap #15 trap #15 activates input/output task
cmp #13,D1
BEQ do_Confirmed
BRA do_ConfirmContinue
do_Confirmed
rts
do_ProgramExit
MOVE.l #0,D0 Set Trap task 1 (Print string)
MOVE.l #50,D1 Set String length to be printed to max 50
lea spacePrompt,a1 load address of string to display into A1
trap #15 trap #15 activates input/output task
MOVE.l #0,D0 Set Trap task 1 (Print string)
MOVE.l #50,D1 Set String length to be printed to max 50
lea exitPrompt,a1 load address of string to display into A1l
trap #15 trap #15 activates input/output task
MOVE.l #0,D0 Set Trap task 1 (Print string)
MOVE.l #50,D1 Set String length to be printed to max 50
lea RowSpacer,a1 load address of string to display into A1
trap #15 trap #15 activates input/output task
BRA do_DoneProcess
*variable declarations
vars *base address for variables
dialogTitle
dc.b 'Open data file',0
outDialogTitle
dc.b 'Open output file',0
dialoglistAll
dc.b '*.txt;*.enc',0 * file type list
dialoglistEnc
dc.b '*.enc',0 * file type list
dialoglistTxt
dc.b '*.txt',0 * file type list
WelcomePrompt dc.b 'Welcome to the file reader: ',0 null terminated string
FileAccessedPrompt dc.b 'File Currently Accessed: ',0 null terminated string
EnterPrompt dc.b 'Please Hit Enter to Continue.',0 null terminated string
NoFileString dc.b 'None',0 null terminated string
RowSpacer dc.b '---------------------------',0 null terminated string
TotalFooter dc.b 'Total Value in File:',0 null terminated string
DisplayHeader dc.b 'Contents of File',0 null terminated string
*ExitPrompt dc.b 'Exiting the file reader: ',0 null terminated string
spacePrompt dc.b ' ',0 null terminated string
LoadFilePrompt dc.b '[L]oad a file to be processed' *30 chars
SaveFilePrompt dc.b '[S]ave the current file' *23 chars
EncryptPrompt dc.b '[E]ncrypt the current file' *26 chars
DecryptPrompt dc.b '[D]ecrypt the current file' *27 chars
ViewTotalsPrompt dc.b '[V]iew file totals' *18 chars
ExitPrompt dc.b 'E[X]it program' *14 chars
recordSize DS.B 1
nameLength DS.B 1
outFileName ds.l 100 * -variables
* file ID longword
outFileId ds.l 1
numRecords ds.b 1
fileId DS.L 1 * -variables
fileName DS.l 100 * -variables
* file ID longword
[code tags added by admin]