-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelpers.X68
103 lines (79 loc) · 4.69 KB
/
helpers.X68
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
*-----------------------------------------------------------
* Title :
* Written by :
* Date :
* Description:
*-----------------------------------------------------------
*ASCII to Hexadecimal conversion Loop helper
*This subroutine is used to convert the ASCII inputting in by user into
*hexadecimal format
*-----------------------------------------------------------
sub_AsToHeLoop MOVE.B (A1)+,D0 *gets first byte
JSR sub_breakDownAs *breaks down ASCII code
ADD.L D0,D1 *load that char into D1
CMPI.B #$0,(A1) *checks if more needs to be broken down
BEQ athEndLoop *if no more is needed to be worked on, exits
LSL.L #$4,D1 *else, shift remaining char in D1 for next char
BRA sub_AsToHeLoop *loops through again
athEndLoop MOVE.L D1,D7 *hex number in D7
RTS
*-----------------------------------------------------------
*Breaks down ASCII code from digits 0-9, a-f or A-F
*Makes the assumption that D0 holds $30-$39, $41-$46
*-----------------------------------------------------------
sub_breakDownAs CMP.B #$30,D0 *$is it a 0-9 digit or an a-f letter?
BLT as_ERROR
CMP.B #$39,D0 *is it an A-F letter?
BGT as_LETTER
BRA as_NUMBER
as_number SUB.B #$30,D0 *subtract 30, used for digits
RTS
as_LETTER CMP.B #$41,D0 *letters A-F helper
BLT as_ERROR
CMP.B #$46, D0
BGT as_ERROR
SUBI.B #$37,D0 *subtract 37, used for A-F
RTS
as_ERROR LEA 'err',A1 *will display error if conversion cannot happen
MOVE.B #13,D0
TRAP #15
*-----------------------------------------------------------
*start reading data helper method
*This subroutine is used to check the validity of the start
*address inputted by user
*-----------------------------------------------------------
sub_StartReadingData BTST #0,D1 *checks if Least Significant Bit is 1, (looks at XNZVC and sees if Z is 1)
BNE srdFailAddrOddB *if 1, then address is odd and invalid
MOVE.L #0,D7 *if D7 equals 0, then address is valid
srdFinish RTS
srdFailAddrOddB LEA addr_oddBit_msg,A1
MOVE.B #14,D0
TRAP #15
MOVE.L #1,D7 *if D7 equals 1, then address is invalid
BRA srdFinish
*-----------------------------------------------------------
*-----------------------------------------------------------
*end reading data helper method
*This subroutine is used to check the validity of the end
*address inputted by user
*-----------------------------------------------------------
sub_EndReadingData BTST #0,D1 *checks if LSB is 1,
BNE erdFailAddrOddB *if 1, then address is odd and invalid
CMP.L A3,A2 *end address must be greater than start address
BGT erdFailAddrOrder *if start addres is greater, go to error
erdFinish RTS
erdFailAddrOrder LEA addr_order_check,A1
MOVE.B #14,D0
TRAP #15
MOVE.L #1,D7
BRA erdFinish
erdFailAddrOddB LEA addr_oddBit_msg,A1
MOVE.B #14,D0
TRAP #15
MOVE.L #1,D7 *if D7 equals 1, then address is invalid
BRA erdFinish
*-----------------------------------------------------------
*~Font name~Courier New~
*~Font size~10~
*~Tab type~1~
*~Tab size~4~