Question: I wrote an assembly program, which converts TNS format in IEEE 754 single floating-point format, and also which converts IEEE 754 single floating-point format to
I wrote an assembly program, which converts TNS format in IEEE 754 single floating-point format, and also which converts IEEE 754 single floating-point format to TNS format. Can some one help me to debug my program. I'm still having one error. ARM Language, the program is below
; **********************************
; File: Conversion.s
; Programmer: L. Chikumba
; Description: A Program to make a conversion from both
; IEEE to TNS and also vice versa
; Project: Conversion.arj
; Date: March 2018
;************************************
AREA Coversion, CODE, READONLY
EXPORT main
SWI_WriteC EQU &0 ; Output character
SWI_WriteC EQU &2 ; Output String
SWI_Exit EQU &11 ; Finish program
ENTRY
main LDR R0, IEEE ; Loading IEEE formatted # into r0
BL IeeeToTNS ; brach to IEEE TNS conversion subroutine
BL Print ; Branch to print the number
BL TNSToIeee ; Branch to TNS to IEEE conersion subroutine
BL Print ; Branch to print numbers
SWI SWI_Exit ; Exit the program
; Loading IEEE Masks into the registers.
IeeeToTNS LDR R1, SIGNMASK ; Loading sign mask into r1
LDR R2, IEEEEXPMASK ; Load exponetnt mask into r2
LDR R3, IEEESIGNMASK ; Load IEEE Significant mask into r3
; Convert from IEEE to TSN
AND R4, R0, R1 ; Unpack sign bot, store in r4
AND R5, R2, R0 ; Initial unpack of exp, store in r5
MOV R5, R5, LSR #23 ; Shift exponent right 23 bits
AND R5, R5, #129 ; Add 129(10) to exp to correct the excess encoding for TSN
AND R6, R3, R0 ; Initial unpack of the significant, store in r6
AND R6, R7, R6, LSL #8 ; Shift the significant left 8 bits, kill off LSB
ORR R0, R4, R5 ; Pack sign and exponent
ORR R0, R0, R6 ; Pack significant with sign and exponent
; r0 now holda IEEE to TSN converted word
MOV PC, LR ; Return to main subroutine
; Loading the TSN Masks
TNSToIeee LDR R1, SIGNMASK ; Load sign mask into r1
LDR R2, TNSSIGNMASK ; Load TSN Significant mask into r2
LDR R3, TNSEXPMASK ; Load TNS Exp mask into r3
; Convert back to IEEE
AND R4, R0, R1 ; Unpack sign bit
AND R5, R2, R0 ; Initial unpack of the significant, store in r5
MOV R5, R5, LSR #8 ; Shift significant right 8 bits
AND R6, R3, R0 ; Initial unpack of exp, store in r6
SUB R6, R6, #129 ; Subtract 129 to correct excess encoding
ADD R6, R7, R6, LSL #23 ; Shift exp left 23 bits
; Pack the converted number into r0
ORR R0, R4, R5 ; Pack the sign and significant
ORR R0, R0, R6 ; Pack exp with sign and signoficant
; r0 now holds TSN to IEEE converted word
MOV PC, LR ; Return to main subroutine
; Print the number to the console
Print MOV R2, #8 ; Count of nibbles
MOV R1, R0 ; Move numbers to r1
MOV R3, R0 ; Store converted number in r3 for later
LOOP MOV R0, R1, LSL #28 ; Go into the top nibble
CMP R0, #9 ; Hex number 0-9 or A-F
ADDGT R0, R0, #"A"-10 ; ASCII A-F
ADDLE R0, R0, #"0" ; ASCII 0-9
SWI WriteC ; Print character to console
MOV R1, R1, LSL #4 ; Shift left one nibble
SUBS R2, R2, #1 ; Decrement nibble count
BNE LOOP ; If more nibbles loop again
MOV R0, #10 ; Load 10 into r0, ASCII code for carriage return
SWI WriteC ; Print carriage return to console
MOV R0, R3 ; Move converted number back to r0
MOV PC, LR ; Return to main subroutine
AREA Values, DATA, READWRITE
IEEE DCD 0x0000, 0x41FE ; IEEE Representation of 31.75, 41FE0000(16)
TNS DCD 0x0103, 0xFE00 ; TNS Representation of 31.75, FE000103(16)
SIGNMASK DCD 0x0000, 0x8000 ; Mask for sign bit
IEEEEXPMASK DCD 0x0000, 0x7F80 ; Mask for IEEE exp
IEEESIGNMASK DCD 0xFFFF, 0x007F ; Mask for IEEE Sign
TNSSIGNMASK DCD 0xFE00, 0x7FFF ; Mask for TSN Sign
TNSEXPMASK DCD 0x01FF, 0x0000 ; Mask for TNS exp
STRING DCB "HELLOW WORLD", 0
END
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
