programming langauge is x86 MASM Write a program in assembly masm that converts
ID: 3685387 • Letter: P
Question
programming langauge is x86 MASM
Write a program in assembly masm that converts ascii to integer and can handle any character in the string. if string is "1234h" then V = 4660.
I started the code the check portion of the code should check each character of the string. below is the code I started the code below the check can convert 0-9 but the code should be able to handle any character. use 80x86 Assembly (MASM) instructions to implement procedures using stack frames. Use a procedure called str2hex. Pass the value of offsets of the expression and V to the procedure. The expression should be null-terminated so that you know the end of the expression. e.g.:
express DB "A + B" , 0 ; 0 is used to mark end of the string.
.MODEL SMALL ;one data and one code segent
.386 ;enables 32-bits
.STACK ;defines memory (default 1024)
.DATA
X DWORD "1234",0
V DWORD 10 DUP (?)
.CODE ;start of code segment
MAIN PROC FAR ;defines a procedure and a distance
.STARTUP
;HEX TO DEC
MOV ECX, LENGTHOF X
CHECK:
CMP X[SI],20H
JE DONE
CMP X[SI],22H
JE DONE
CMP X[SI],27H
JE DONE
CMP X[SI],41H
JB DONE
CMP X[SI],5BH
JB UPPER_CASE
CMP X[SI],61H
JB DONE
CMP X[SI],7BH
JG DONE
CMP X[SI],30H
JE COMPLETE
UPPER_CASE ;converts to uppercase
SUB X[SI],20H
JMP DONE
DONE:
INC SI
LOOP CHECK
;this portion of code converts 0-9
MOV CX,0
MOV BX,10
L1: MOV DX,0
DIV BX
ADD DL,30H
INC CX
CMP AX,9
JG L1
ADD AL,30H
MOV [SI],AL
ADD AL,30H ;FINAL BIT LOCATED WITH IN AL
MOV [SI], AL ;MOVES AL IN MEMORY LOACTION OF SI
COMPLETE:
.EXIT ;exit to DOS
MAIN ENDP ;end main procedure directive
END
Explanation / Answer
Try this code for your reference
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.