Micro Lab 3
Micro Lab 3
Micro Lab 3
LAB-3
Objective: Students will learn Assembly programming Irvine procedure, and
explore simple Assembly Language procedure in assembly and run them.
INCLUDE Irvine32.inc
.data
str1 BYTE "Sample string, in color",0dh,0ah,0
.code
main PROC
call GetTextColor
call DumpRegs
exit
main ENDP
END main
Lab Work -2 :
As the second example we will see the Clrscr, Crlf, DumpMem, ReadInt,
SetTextColor, ; WaitMsg, WriteBin, WriteHex, and WriteString procedures. Each
student should run the program and should try to trace it as well.
INCLUDE Irvine32.inc
.data
COUNT = 4
BlueTextOnGray = blue + (lightGray * 16)
DefaultColor = lightGray + (black * 16)
.code
main PROC
mov eax,BlueTextOnGray
call SetTextColor
call Clrscr ; clear the screen
exit
main ENDP
END main
INCLUDE Irvine32.inc
.data
caption db "Dialog Title", 0
exit
main ENDP
END main
--------------second example -------------------------
; MsgBoxAsk demo (msgboxAsk.asm)
INCLUDE Irvine32.inc
.data
caption BYTE "Survey Completed",0
question BYTE "Thank you for completing the survey."
BYTE 0dh,0ah
BYTE "Would you like to receive the results?",0
results BYTE "The results will be sent via email.",0dh,0ah,0
.code
main PROC
exit
main ENDP
END main
Lab Work -4:
As the fourth example we will see the reversing a string using stack. Each student
should run the program and should try to trace it as well.
; Reversing a String (RevStr.asm)
; This program reverses a string.
.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword
.data
aName byte "Abraham Lincoln",0
nameSize = ($ - aName) - 1
.code
main proc
mov ecx,nameSize
mov esi,0
mov ecx,nameSize
mov esi,0
INCLUDE Irvine32.inc
.code
main PROC
call Randomize ; init random generator
call Rand1
call Rand2
exit
main ENDP
Rand1 PROC
; Generate ten pseudo-random integers.
mov ecx,10 ; loop 10 times
call Crlf
ret
Rand1 ENDP
Rand2 PROC
; Generate ten pseudo-random integers between -50 and +49
mov ecx,10 ; loop 10 times
call Crlf
ret
Rand2 ENDP
END main
H.W. 3 (deadline: two week)
1. Write a program that displays a single character in all possible combinations of
foreground and background colors (16 x 16 = 256). The colors are numbered from
0 to 15, so you can use a nested loop to generate all possible combinations.
2. Write a procedure that produces N values in the Fibonacci number series and
stores them in an array of doubleword. Input parameters should be a pointer to an
array of doubleword, a counter of the number of values to generate. Write a test
program that calls your procedure, passing N = 47. The first value in the array will
be 1, and the last value will be 2,971,215,073. Use the Visual Studio debugger to
open and inspect the array contents.