Hardware Reference
In-Depth Information
cmdlinelen
equ
40
org
$1000
inbuf
ds.b
20
err_flag
ds.b
1
sign_flag
ds.b
1
org
$1500
lds
#$1500
ldd
#prompt1
jsr
[printf,PCR]
; output a prompt to remind the user to enter
ldd
#cmdlinelen
; an integer
pshd
ldd
#inbuf
call
[getcmdline,PCR]
; read in a string that represents an integer
leas
2,sp
ldd
#prompt3
; move cursor to the next line
jsr
[printf,PCR]
; “
ldd
#inbuf
pshd
ldd
#prompt2
jsr
[printf,PCR]
; output the number that you entered
leas
2,sp
ldd
#prompt3
jsr
[printf,PCR]
; move cursor to the next line
swi
prompt1
db
“Please enter a number: “,CR,LF,0
prompt2
db
“The entered number is: %s “,0
prompt3
db
“ “,CR,LF,0
end
When you see the message “Please enter a number:,” enter an integer followed by a carriage
return. The screen output should be similar to what appears here.
>g 1500
Please enter a number:
The entered number is: 1234
User Bkpt Encountered
PP PC
SP
X
Y
D = A:B
CCR = SXHI NZVC
30 1533
1500
1500
156C
00:03
1001 0000
xx:1533
50
NEGB
>
L4.2 Temperature conversion. Write a subroutine that will convert the temperature in
Fahrenheit to Celsius accurate to one decimal digit. Write a main program that will
1. Prompt the user to enter a temperature in Fahrenheit by displaying the message
“Please enter a temperature in Fahrenheit:” .
2. Call the GetCmdLine() function to read in the temperature.
3. Call a subroutine to convert the input string (representing a decimal number) into a
binary number.
4. Call the temperature conversion subroutine to convert it to Celsius.
 
Search WWH ::




Custom Search