Using the below assembly code as a base, build upon it to write a program that w
ID: 3738574 • Letter: U
Question
Using the below assembly code as a base, build upon it to write a program that will allow the user to specify how many times the program will loop and display the title of the program (include name in the title). Print from inside the loop a string and count.
Page 58,132 Title MASMLab For MASM Hello.asm MASM Hello cseg segment 'code assume cs:cseg,ds:cseg, SS:Cseg,es:cse org 100h start: mov cx,10 mov ah,9 again: mov dx, offset Hello int 21h mov dx, offset Num msg int 21h inc byte ptr Num msg Loopne again done: mov ah, 4ch int 21h org 200h Hello db "Hello World", 20h, 20h, "$" Num msg db 30h,13,10, 36 cseg ends end startExplanation / Answer
DATA:
title DB "NAME_TITLE", 10h, "$"
inp DB "HOW MANY NUMBERS", 10h,10h,10h,"$"
inpnum DB "ENTER NUMBER", 10h,10h,"$"
n DB ?
MAIN:
mov ah, 9
mov dx, offset title
int 21h
mov ah, 9
mov dx, offset inp
int 21h
str al, n ; save the counter into n
mov cx,al l loop counter, initialize to number entered by user
LOOP:
bez cx, END ; if cx is 0 then exit loop
; ask user to input a number
mov ah, 9
mov dx, offset inpnum
int 21h
;display number
mov ah, 2
mov dx, al
int 21h
;display count
mov ah, 2
mov dx, cx
int 21h
dec cx ; increment loop counter
b LOOP
END:
_exit
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.