+1(978)310-4246 credencewriters@gmail.com
Select Page

Description

please use the pdf and the instruction provided below ;=================================================================================

;THE BINARY REPRESENTATION OF THE USER-ENTERED DECIMAL NUMBER MUST BE STORED IN R1

;=================================================================================

.ORIG x3000

;————-

;Instructions

;————-

; output intro prompt

; Set up flags, counters, accumulators as needed

; Get first character, test for ‘n’, ‘+’, ‘-‘, digit/non-digit

; is very first character = ‘n’? if so, just quit (no message)!

; is it = ‘+’? if so, ignore it, go get digits

; is it = ‘-‘? if so, set neg flag, go get digits

; is it < '0'? if so, it is not a digit - o/p error message, start over ; is it > ‘9’? if so, it is not a digit – o/p error message, start over

; if none of the above, first character is first numeric digit – convert it to number & store in target register!

; Now get remaining digits from user in a loop (max 5), testing each to see if it is a digit, and build up number in accumulator

; remember to end with a newline!

HALT

;—————

; Program Data

;—————

introPromptPtr.FILL xB000

errorMessagePtr.FILL xB200

;————

; Remote data

;————

.ORIG xB000; intro prompt

.STRINGZ “Input a positive or negative decimal number (max 5 digits), followed by ENTERn”

.ORIG xB200; error message

.STRINGZ “ERROR: invalid inputn”

;—————

; END of PROGRAM

;—————

.END

;——————-

; PURPOSE of PROGRAM

;——————-

; Convert a sequence of up to 5 user-entered ascii numeric digits into a 16-bit two’s complement binary representation of the number.

; if the input sequence is less than 5 digits, it will be user-terminated with a newline (ENTER).

; Otherwise, the program will emit its own newline after 5 input digits.