코드

*-----------------------------------------------------------

* Title : 68k Disassembler

* Written by :

* Date : 06/xx/2020

* Description: Final Project

*-----------------------------------------------------------

ORG $1000

START: ; first instruction of program


* Put program code here

*_______Basic Print Out Welcome Message__________

LEA Mes_Welcome, A1

MOVE.B #13, D0

TRAP #15

*_______Get User Input____________________________

GetInput

LEA Mes_Start_Adr, A1 ; ask start loc

MOVE.B #14, D0

Trap #15

*BRA Invalid

LEA UserInput, A1

MOVE.B #2, D0

TRAP #15

CLR.L D2

CLR.L D3

JSR ConvertInput

* Store user Input start address to A5

MOVE.L D3, StartLocData

MOVE.L StartLocData, A5

* Subroutine

*_________________________________________________

ConvertInput

MOVE.B (A1)+, D2

JSR ConvertASCII

ADD.L D2, D3

CMPI.B #$0, (A1)

BEQ GoBack

*LSL.B #4, D2

*LSR.B #4, D2

LSL.L #4, D3

*ADD.L D2, D3

BRA ConvertInput

GoBack

RTS

*LSR.B

ConvertASCII

* 30~39 Number

* 41~46 Cap Letter Till F

* 61~66 Till f

CMPI.B #$40, D2 * 40 is immeidate data use CMPI

BLT IsNumber * If less than 40 then execute

CMPI.B #$41, D2 * if not compare with 41 (A)

BGE IsLetter *Bigger than or Equal to 41 then execute

IsNumber

SUB.B #$30, D2

*BRA ConvertASCII

CMPI.B #$9, D2 * Compare with 9 should be less or equal to be number

BGT Invalid * if Sub is bigger than 9 than invalid

RTS

IsLetter

* figure out either small leter or capital letter

CMPI.B #$46, D2 * Compare with small letter F

BLE CapitalLetter * if less or equal to 46 than small letter

BRA SmallLetter * else go to capital letter

CapitalLetter

SUB.B #$37, D2

RTS

SmallLetter

SUB.B #$57, D2

RTS

* tomorrow continue (less than 39) then subtract 30

Invalid

LEA Extra_Space, A1

MOVE.B #14, D0

TRAP #15

LEA Mes_Invalid, A1

MOVE.B #14, D0

TRAP #15

MOVE.B #9, D0

TRAP #15

SIMHALT ; halt simulator


* Put variables and constants here

* Basic Print Message

*____________________________________________________________________

CR EQU $0D * Carriage Return

LF EQU $0A * Line Feed




Mes_Welcome DC.B 'Welcome to Disassembler Program', CR, LF

DC.B 'Final Project for CSS 422', CR, LF, 0

Mes_Start_Adr DC.B 'Please Enter Starting Location: ', 0

Mes_End_Adr DC.B 'Please Enter Ending Location: ', 0


Mes_Invalid DC.B 'The Address You provided is Invalid', CR, LF

DC.B 'Terminating Program.', CR, LF, 0

Extra_Space DC.B CR, LF, 0


* Define Storage

*_____________________________________________________________________

UserInput DS.L 1

StartLocData DS.L 1 * store starting address

END START ; last line of source


결과값



우선 위 사진 처럼 유저는 당연히 메모리 주소 를 입력함


근대 사실 메모리에 저장된 값은 아스키 값으 로 저장됨 36 30 30 30 => 핵사로 6000

그걸 맨 윗쪽에 있는 코드 로 비트 를 날라서 핵사로 변환,


바로 이렇게 쨘~


끝이냐고?

ㄴㄴ 물론 아니제






이렇게 인풋 체크도 해줌 ㅇㅅㅇ