In: Computer Science
Please complete both questions in MASM. Explain code clearly, thank you. Please screenshot memory outputs.
Write a program that defines symbolic names for several string literals (characters between quotes). Use each symbolic name in a variable definition.
Use this code to get started:
; Symbolic Text Constants
Comment !
Description: Write a program that defines symbolic names
for several string literals (characters between quotes).
Use each symbolic name in a variable definition.
!
.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword
.data
.code
main PROC
INVOKE ExitProcess,0
main ENDP
END main
Generate a listing file for the AddTwoSum program and write a description of the machine code bytes generated for each instruction. You might have to guess at some of the meanings of the byte values.
AddTwoSum code:
.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword
.code
main PROC
; Give each register an integer value
mov eax, 100 ; A = EAX = 10
mov ebx, 24 ; B = EBX = 24
mov ecx, 8 ; C = ECX = 23
mov edx, 23 ; D = EDX = 8
; Add everything
add eax, ebx ; EAX = A + B (b/c eax is first)
add ecx, edx ; ECX = C + D
sub eax, ecx ; EAX = (A + B) - (C + D)
INVOKE ExitProcess,0
main ENDP
END main
1)Symbolic Text Constants
Generally a symbolic constant is created by associating an identifier (a symbol) with either an integer expression or some text. Unlike a variable definition, which reserves storage, a symbolic constant does not use any storage. The value of a symbolic constant is defined by the assembler and does not change at run time.
2)
Hey i didn't understand the code that u asked me to start with, but this program that i'm gonna write will print characters between quotes. and also The program cannot be run on an online editor, please use MASM to run the program and use dos box to run MASM, you might use any 8086 emulator to run the program.
MODEL SMALL
.STACK 100H
.DATA
;The string to be printed
STRING DB 'This is a sample string', '$'
.CODE
MAIN PROC FAR
MOV AX,@DATA
MOV DS,AX
; load address of the string
LEA DX,STRING
;output the string
;loaded in dx
MOV AH,09H
INT 21H
;interrupt to exit
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN
Hope it helps, if u get want u wanted give a thumps
up, it means a lot thanks:)