Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How do I edit this assembly code to remove the user input and ONLY print out the

ID: 3756781 • Letter: H

Question

How do I edit this assembly code to remove the user input and ONLY  print out the values from 1 to 128 in hexadecimal, one value per line. It just needs to run and print those numbers without any other input whatsoever.
;
#MAKE_COM# ;instruct compiler to make COM file
include emu8086.inc ;use include file for macros
ORG 100h ;directive for COM program, set offset to 100h
;
MOV DX, offset msg1 ;moves value of msg1 to the data register
;   
MOV AH, 9 ;moves the value 9 to the high accumulator register
;to be used with the interrupt
INT 21h ;invokes interrupt to print string to DOS window
;
MOV DX,13 ;these lines
MOV AH,2 ;create a
INT 21h ;newline
MOV DX,10 ;and
MOV AH,2 ;move the cursor
INT 21h ;to the newline
;
CALL SCAN_NUM ;calls macro to scan numeric keyboard input
;error catching is included in macro
;number is stored in CX
MOV DX,13 ;these lines
MOV AH,2 ;create a
INT 21h ;newline
MOV DX,10 ;and
MOV AH,2 ;move the cursor
INT 21h ;to the newline
;
MOV DX, offset msg2 ;moves value of msg2 to the data register
MOV AX, CX ;copies scanned number to AX to be printed
;as part of message
;MOV AH, 9 ;moves the value 9 to the high accumulator register
;to be used with the interrupt
;INT 21h ;invokes interrupt to print string to DOS window


CALL PRINT_NUM_UNS ;prints hexadecimal value at end of msg2
MOV CONVERTEDNUMBER, CX
;   
MOV AH, 9 ;moves the value 9 to the high accumulator register
;to be used with the interrupt
INT 21h ;invokes interrupt to print string to DOS window
;
MOV AX, 0 ;wait for any key
INT 16h ;prevents window from closing immediately
;
msg1 db "Type an integer between 1 and 10000, and press enter. $"
;declare string variable
msg2 db " in hexadecimal is: $"
;
DEFINE_SCAN_NUM ;defines macro from include file
;gets multidigit signed number from keyboard
DEFINE_PRINT_NUM_UNS ;defines macro from include file
;prints unsigned number in AX
;   
CONVERTEDNUMBER DW 0 ;declare variable
;
RET ;return to operating system
END ;directive to stop compiler

Explanation / Answer

//You can replace the CALL SCAN_NUM with MOV CX, 128. Below is the modified code

;
#MAKE_COM# ;instruct compiler to make COM file
include emu8086.inc ;use include file for macros
ORG 100h ;directive for COM program, set offset to 100h
;
MOV DX, offset msg1 ;moves value of msg1 to the data register
;
MOV AH, 9 ;moves the value 9 to the high accumulator register
;to be used with the interrupt
INT 21h ;invokes interrupt to print string to DOS window
;
MOV DX,13 ;these lines
MOV AH,2 ;create a
INT 21h ;newline
MOV DX,10 ;and
MOV AH,2 ;move the cursor
INT 21h ;to the newline
;
MOV CX, 128
MOV DX,13 ;these lines
MOV AH,2 ;create a
INT 21h ;newline
MOV DX,10 ;and
MOV AH,2 ;move the cursor
INT 21h ;to the newline
;
MOV DX, offset msg2 ;moves value of msg2 to the data register
MOV AX, CX ;copies scanned number to AX to be printed
;as part of message
;MOV AH, 9 ;moves the value 9 to the high accumulator register
;to be used with the interrupt
;INT 21h ;invokes interrupt to print string to DOS window


CALL PRINT_NUM_UNS ;prints hexadecimal value at end of msg2
MOV CONVERTEDNUMBER, CX
;
MOV AH, 9 ;moves the value 9 to the high accumulator register
;to be used with the interrupt
INT 21h ;invokes interrupt to print string to DOS window
;
MOV AX, 0 ;wait for any key
INT 16h ;prevents window from closing immediately
;
msg1 db "Type an integer between 1 and 10000, and press enter. $"
;declare string variable
msg2 db " in hexadecimal is: $"
;
DEFINE_SCAN_NUM ;defines macro from include file
;gets multidigit signed number from keyboard
DEFINE_PRINT_NUM_UNS ;defines macro from include file
;prints unsigned number in AX
;
CONVERTEDNUMBER DW 0 ;declare variable
;
RET ;return to operating system
END ;directive to stop compiler

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote