Download presentation
1
Coding
2
MOVZX INCLUDE Irvine32.inc .data Uarray WORD 1000h,2000h,3000h,4000h
.code main PROC ; Move with zero extension: movzx eax,Uarray movzx ebx,Uarray+2 movzx ecx,Uarray+4 movzx edx,Uarray+6 call DumpRegs exit main ENDP END main
3
MOVSX INCLUDE Irvine32.inc .data Sarray SWORD -1,-2,-3,-4 .code
main PROC ; Move with sign extension: ;movsx eax,Sarray ;movsx ebx,Sarray+2 ;movsx ecx,Sarray+4 ;movsx edx,Sarray+6 call DumpRegs exit main ENDP END main
4
INCLUDE irvine32.inc .code main PROC mov ax,15 ; start ax=15
LOOP INCLUDE irvine32.inc .code main PROC mov ax,15 ; start ax=15 call DumpRegs mov ecx,6 ; set start ecx = 6 L1: ; L1 = destination dec ax loop L1 exit main ENDP END main
5
mov ecx, 6 ;loop ecx = 7 times ..6 5 4 3 2 1 0 call DumpRegs L2:
INCLUDE Irvine32.inc .code main PROC mov eax, 1 ;start eax=1 mov ebx, 1 ;ebx = 1 mov edx, 10 ;edx = 10 mov ecx, 6 ;loop ecx = 7 times call DumpRegs L2: inc ebx dec edx add eax, 1 ; add value in eax + 1 loop L2 exit main ENDP END main LOOP
6
Color TITLE Chapter 5 Exercise 1 (ch05_01.asm) Comment @
Description: Write a program that displays the same string in four different colors, using a loop. Call the SetTextColor procedure from the book's link library. Any colors may be chosen, but you may find it easiest to change the foreground color.
7
INCLUDE Irvine32.inc .data str1 BYTE "This line is displayed in color",0 .code main PROC mov eax, white + (green * 16) ; white on green backgrouund mov ecx,4 ; loop counter L1: call SetTextColor mov edx,OFFSET str1 call WriteString call Crlf add eax,2 ; add 2 to foreground color loop L1 exit main ENDP END main
8
Print output to screen INCLUDE Irvine32.inc .code main PROC
mov eax,1234h ; input argument call WriteHex ; show hex number call Crlf ; end of line ; no call DumpRegs bcoz no register to be display exit main ENDP END main
9
Clear screen before print output
INCLUDE Irvine32.inc .code main PROC call Clrscr ; clear screen first mov eax,15 ; eax = F call Delay call DumpRegs exit main ENDP END main
10
; Display a null-terminated string and ; move the cursor to the beginning of the next screen line.
INCLUDE Irvine32.inc .data str1 BYTE "Assembly language is easy!",0 .code main PROC mov edx,OFFSET str1 call WriteString call Crlf exit main ENDP END main
11
;Display a null-terminated string and ;move the cursor to the beginning of the next screen line (use embedded CR/LF) INCLUDE Irvine32.inc .data str1 BYTE "Assembly language is easy!",0Dh,0Ah,0 str2 BYTE "I like Assembly language!",0Dh,0Ah,0 .code main PROC mov edx,OFFSET str1 call WriteString call Crlf mov edx,OFFSET str2 exit main ENDP END main
12
Display an unsigned integer in binary, decimal, and hexadecimal, each on a separate line.
INCLUDE Irvine32.inc .data IntVal = 35 .code main PROC mov eax,IntVal call WriteBin ; display binary call Crlf call WriteDec ; display decimal call WriteHex ; display hexadecimal exit main ENDP END main
13
Assignment 1 USAGE of LIBRARY PROCEDURE
Display a null-terminated string and move the cursor to the beginning of the next screen line (use embedded CR/LF) for the following strings USAGE of LIBRARY PROCEDURE Clrscr - Clears console, locates cursor at upper left corner DumpRegs – Displays general-purpose registers and flags (hex) WriteChar - Writes a single character to standard output WriteHex - Writes an unsigned 32-bit integer in hexadecimal format SetTextColor - Sets foreground and background colors of all subsequent console text output
14
Assignment 2 Write a program to display a null-terminated string and move the cursor to the beginning of the next screen line (use embedded CR/LF) as the following output. Before proceed to next string, display an unsigned integer 85 in binary, decimal, and hexadecimal, each on a separate line. Please refer the following output.
15
Use the following variable definition for the remaining questions in this section: .data MyByte SBYTE -4,-2,3,1 MyWord WORD 1000h,2000h,3000h,4000h For the following statements, state whether or not the instruction is valid. Give comment to describe the reason why the instruction become valid or invalid. mov ax, MyByte mov ax,MyWord What will be the value of the destination operand after each of the following instructions executes in sequence? mov ax, MyWord ; c) ax:______________________________ mov ax,[MyWord + 2] ; d) ax:_____________________________ add ax, [MyWord + 2] ; e) ax:_____________________________
16
By Using PTR keywords, create and complete the following program that can produce the following output based on given variables. .data varB BYTE 65h,31h,56h,65h varW WORD 6543h,1202h varD DWORD h .code mov _____________________ ; answer : 6556h mov _____________________ ; answer : 21h mov _____________________ ; answer : 02h mov _____________________ ; answer: 8765 mov _____________________ ; answer : h
17
mov ax,WORD PTR [varB+2] mov bl,BYTE PTR varD mov bl,BYTE PTR [varW+2] mov ax,WORD PTR [varD+2] mov eax,DWORD PTR varW
18
TITLE Add and Subtract, Version 2 (AddSub2. asm) INCLUDE Irvine32. inc
TITLE Add and Subtract, Version 2 (AddSub2.asm) INCLUDE Irvine32.inc .data val1 dword 10000h val2 dword 40000h val3 dword 0DDh val4 dword 200h finalVal dword ? .code main PROC add eax,val1 ; start with 10000h add eax,val2 ; add 40000h sub eax,val3 ; subtract 20000h add eax,val4 mov finalVal,eax ; store the result (30000h) Call DumpRegs ; display the registers Exit main ENDP END main
19
TITLE mul binary and hexa, Version 2 (mulbinhexa.asm) INCLUDE Irvine32.inc .data num1 dword 1111b num2 dword 0Ah finalnum dword ? .code main PROC mov eax,num1 ; start 100b mov eax,num2 ; mul 11b mul eax mov finalnum,eax ; store the result (12=C call DumpRegs ; display the registers exit main ENDP END main
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.