(By using HCS12 assembly)You have a table of 10 Fahrenheit temperatures stored a
ID: 3753268 • Letter: #
Question
(By using HCS12 assembly)You have a table of 10 Fahrenheit temperatures stored as words in Flash. Use the posted lab1_b.asm file as starting point. Write an assembly program that converts every Fahrenheit temperature element in Fahrs array into a Celsius temperature and stores the result at the corresponding element in Cels array. Use this relation: C = (5/ 9) * (F 32) for conversion. Because temperatures are signed, you will have to use signed multiplication and division instructions in your work.
lab1_b.asm file:
Explanation / Answer
Since the lab1_b.asm file is not give, I haved assumed that teperatures are entered as requested. You can modify them accordingly DATA SEGMENT T DB ? RES DB 10 DUP ('$') MSG1 DB "Temperature in Celsius is: $" MSG2 DB 10,13,"Temperature in Farenheit is : $" DATA ENDS CODE SEGMENT ASSUME DS:DATA,CS:CODE START: MOV AX,DATA MOV DS,AX LEA DX,MSG1 MOV AH,9 INT 21H MOV AH,1 INT 21H SUB AL,30H MOV AH,0 MOV BL,10 MUL BL MOV BL,AL MOV AH,1 INT 21H SUB AL,30H MOV AH,0 ADD AL,BL MOV T,AL MOV DL,9 MUL DL MOV BL,5 DIV BL MOV AH,0 ADD AL,32 LEA SI,RES CALL HEX2DEC LEA DX,MSG2 MOV AH,9 INT 21H LEA DX,RES MOV AH,9 INT 21H MOV AH,4CH INT 21H CODE ENDS HEX2DEC PROC NEAR MOV CX,0 MOV BX,10 LOOP1: MOV DX,0 DIV BX ADD DL,30H PUSH DX INC CX CMP AX,9 JG LOOP1 ADD AL,30H MOV [SI],AL LOOP2: POP AX INC SI MOV [SI],AL LOOP LOOP2 RET HEX2DEC ENDP END START
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.