Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
41 views5 pages

Exercise

The document provides examples of MASM code and instructions for writing MASM programs. It includes examples for printing text, accepting user input, performing math operations like addition and calculating averages, and solving equations.

Uploaded by

dangpkse183312
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views5 pages

Exercise

The document provides examples of MASM code and instructions for writing MASM programs. It includes examples for printing text, accepting user input, performing math operations like addition and calculating averages, and solving equations.

Uploaded by

dangpkse183312
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Ex1: Use the Opcodes help of the menu Help, describe syntaxes of following MASM

instructions
(1) ADD
(2) SUB
(3) MUL, IMUL
(4) DIV, IDIV. Which register will store the remainder ?
Ex2 : Write a masm Locals.asm program that will print the following :

; Source code From masm32\tutorial\console\demo4\locals.asm


.486 ; create 32 bit code
.model flat, stdcall ; 32 bit memory model
option casemap :none ; case sensitive

include \masm32\include\windows.inc ; always first


include \masm32\macros\macros.asm ; MASM support macros
include \masm32\include\masm32.inc
include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
show_text PROTO :DWORD ; prototype a method + type of parameter
.code ; Tell MASM where the code starts
start: ; The CODE entry point to the program
call main ; branch to the "main" procedure
exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
main proc
LOCAL txtinput:DWORD ; a "handle" for the text returned by "input"
mov txtinput, input("Type some text at the cursor : ") ; get input string
invoke show_text, txtinput ; show inputted string
ret
main endp
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
show_text proc string:DWORD
print chr$("This is what you typed at the cursor",13,10," *** ")
print string ; show the string at the console
print chr$(" ***",13,10)
ret
show_text endp
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start ; Tell MASM where the program ends
Ex2-1:
Write a MASM program that will print the following cantor of Hàn Mặc Tử

Guide ex2

Ex3: Write a program that will accept 3 numbers, then sum of them and their average
will be printed out.
Guide ex3
Ex4: Write a MASM program that will solve the equation ax+b=0
Ex5: Write a MASM program that will accept 2 numbers, v1, v2 then print out v1+v2,
v1-v2, v1*v2, v1/v2.

You might also like