;this variable is used to keep the mans position. ;this variable is used to keep the zombies position
|
|
- Lesley Holmes
- 6 years ago
- Views:
Transcription
1 TITLE MASM Template (main.asm) ; Description: This was my final project for my Assembly Language Course. It is a Zombie Video game. You as the player move around with your arrow keys and try to avoid getting ;eaten by the zombie or falling into the pits! You can use the arrow keys or i,j,k,l keys. The more you play the harder it gets. It will keep track of the previous pit that was ;filled by a zombie, if you make it that far. Green is the zombie, Red is the pit and gray is the human ; ;BY JOSH RICKARD ; Revision date: INCLUDE Irvine32.inc ;---- ;Macro to set color to whatever color, example color red ;---- color MACRO color mov eax, color ENDM ;----.data ;data section of the project ;---- manpos WORD? zompos WORD 50 DUP (?) pitpos WORD? delval WORD 3000 delcnt WORD? level BYTE 0 xycord BYTE 5 fillpitpos WORD 0 ;this variable is used to keep the mans position ;this variable is used to keep the zombies position ;this variable is used to keep the pits position ;this is used to keep the count going, time ;used to keep track of the time ;this keeps track of the different levels in the game ;this keeps positions for print screens and other gotoxy events ;this keeps ths position of the the filled pit position after a zombie falls in skiplinechar BYTE " ",0 manchar = 02h zomchar = 0CBh pitcharempty = 0B2h pitcharfull = 0BDh wallchar= 07Ch nochar = 20h doneflag BYTE 0 answer BYTE? ;I used this within my skipline procedure ;this is the character used for the man, its gray ;this is the character used for the zombie, its green ;this fills in the zombie character when it mpves ;this fills the pit when a zombie has fallen, its cyan ;this is representing the wall character, you can't see it ;this clears out the man when he moves ;this variable is set when you are done playing or died ;this variable holds the answers to any questions asked gamegrid BYTE 25*80 dup(020h) ;this varialbe is used to keep the game grid initgrid BYTE 10*80 dup(nochar),39 dup(nochar),39 dup (nochar), ;this is used to keep the position of the map relevant to the players, ie zombie, man etc. 20 dup (nochar), 20 dup (nochar), 13*80 dup (nochar) theendmsg BYTE "THE END!",0 ;use this to print out when you have reached the end firstmsg BYTE "Do you need instructions (Y/N)? ",0 ;basic instruction text that is printed out. SplashMsg1 BYTE " ", 0ah, ;main splash screen, not centered, it is meant to be that way "... ", 0ah,
2 " C C / ", 0ah, " /< / ", 0ah,0 SplashMsg2 BYTE " /_# =o ", 0ah, "/(- /(\_\ \ ", 0ah, "\ ) \ )_ \o \ ", 0ah,0 SplashMsg3 BYTE "/ \ / \ ", 0ah, " _ ", 0ah, " /o \ ", 0ah, " / ' ", 0ah, " / / ", 0ah, " /_/\ ", 0ah, " ( _( < ", 0ah,0 SplashMsg4 BYTE " \ \ \ ", 0ah, " \ \ ", 0ah, " \ \ \ ", 0ah, " \_\ \_\ ", 0ah, " ", 0ah,0 SplashMsg5 BYTE " ",0ah, ;second splash screen, there is a delay, no need to press any buttons " ",0ah, " ",0ah, " ",0ah,0 SplashMsg6 BYTE" ",0ah, " ",0ah,0 SplashMsg7 BYTE" ",0ah, " ",0ah, " ",0ah,0 SplashMsg8 BYTE" ",0ah, " ",0ah, " ",0ah,0 createdby BYTE "Created By Josh Rickard, Master of the Universe!",0 ;used with the second splash screen above playagain BYTE "Would you like to play again? (Y or N): ",0ah, 0 ;if you lose this will ask you to play again InstMsg1 BYTE "Welcome To Zombies!",0 ;instructions menu, print screen, must select yes to see it InstMsg2 BYTE "If you want to try and win follow these simple isntructions, ",0 InstMsg3 BYTE "but beware, you will die!!!!",0 InstMsg4 BYTE "1. Use your up, down, left, right or I, K, J, L keys on ",0 InstMsg5 BYTE "your keyboard",0 InstMsg6 BYTE "2. Avoid the Zombies!",0 InstMsg7 BYTE "3. Avoide the Pits!",0 InstMsg8 BYTE "4. Watch out, the more you win the harder it gets!",0 InstMsg9 BYTE "Good Luck! HAHAHAHAHAHA!!!!",0 levelmsg BYTE "Level ",0 diedmsg BYTE "You died of desentary! and falling into the pit!",0dh,0ah,0 ;if you fall into the pit, you have died message congratsmsg BYTE "Congrats! You Have Won!!!",0dh,0ah,0 ;if you win the entire game, you get this message, but you probably won't manwonmsg1 BYTE " ", 0ah, ;if you killed the zombie, you get this message " ", 0ah, " ", 0ah, " ", 0ah, " ", 0ah, " ", 0ah, " ", 0ah, " ", 0ah,0 manwonmsg2 BYTE " ", 0ah, " ", 0ah, " ", 0ah, " ", 0ah, " ", 0ah, " ", 0ah, " ", 0ah, " ", 0ah, " ", 0ah, " GOOD JOB! YOU WON!!!!! ",0ah,0 zomwonmsg1 BYTE " (()))",0ah, ;if the zombie kills you, you get this message. displays blood in red " / x x ",0ah, " /\( - )",0ah, ".-._/\/ ",0ah,0 zomwonmsg2 BYTE " /=`_'-'-'/ ",0 blooddrops1 BYTE "!! ",0ah,0 zomwonmsg3 BYTE " -{-_-_-} ",0 blooddrops2 BYTE"! ",0ah,0 zomwonmsg4 BYTE " (-{-_-_-} ",0 blooddrops3 BYTE"! ",0ah,0 zomwonmsg5 BYTE " \{_-_-_} ",0
3 blooddrops4 BYTE"! ",0ah,0 zomwonmsg6 BYTE " }-_-_-} ",0ah, " {-_ -_} ",0ah, " {-_ _-} ",0ah, " {_- -_} ",0ah, " {_- -_} ",0ah, ",0ah, " ",0ah, "Zombie ate man - NOM NOM NOM NOM!!!!",0ah,0 ;----.code ;this is the code section/main section of the program, it calls other procedures within ;---- main PROC call Splashy ;display a splash screen ;clears the screen for next splash screen color red ;using color macro from the top newgame: gameloop: mov dh, 10 mov dl, 25 mov edx, OFFSET firstmsg call ReadChar and al, b cmp al,"y" jne newgame call InstructMe ;mov xycord, 5 cmp delval, 0 jbe youwin sub delval, 100 inc level color green mov dh, 10 mov dl, 35 mov edx,offset levelmsg movzx eax, level call WriteDec mov doneflag,0 call setupboard ;setting the height to print ;setting the width to print ;going to that spot/cursor position ;Do you need instructions ;printing do you need isntructions ;reading y or n or Y or N ;making it capital Y ;if yes then ;if not then go to newgame ;display instructions by calling procedure ;placing cursor position to print level ;NEW GAME LOOP, used to display a new game when you win or lose ;compare count to 0, if it is then you have won ;jump if count is zero, count is speed ;subtracting 100 from the time of 3000 ;incrementing the level, originally set to 0 ;clearing screen ;setting color to green ;printing level message ;printing the level number ;setting a delay of 3 seconds ;clear screen ;doneflag is used to check if messages are set or not ;set up game board, procedure ;start game loop
4 dozombie: gameover: call readkey jz dozombie call moveman cmp doneflag,0 je gameloop jne gameover dec delcnt jnz gameloop mov ax,delval mov delcnt,ax call movezom cmp doneflag,5 je newgame cmp doneflag,0 jne gameover je gameloop cmp doneflag, 40 je theend cmp doneflag, 41 je theend cmp doneflag, 50 je newgame cmp doneflag, 51 je theend youwin: theend: mov dh, 10 mov dl, 20 mov edx, OFFSET congratsmsg jmp askplayagain mov dh, 0 mov dl, 35 mov ebx, edx mov edx, OFFSET theendmsg theendloopscreen: mov eax, 300 mov edx, ebx cmp dh, 24 je askplayagain inc dh ;mov dl, 35 mov ebx, edx color red mov edx, OFFSET theendmsg ;see if man needs to move ;if not then jump to the zombie and let him move ;if yes then move the man ;check and see if the doneflag is set or not ;if it still equals 0, go back to gameloop ;if not then game over ;zombie is moving ;decrement the count ;if it is not zero then go to game loop and start over ;moving the delay value into ax ;moving ax, into delay count ;finally moving zombie ;if the doneflag is set to 5, start a new game ;jump to the top, means you won, the level ;if it is set to 0 ;if it is not set to 0 then gameover ;jump to the game loop ;gameover loop ;see what doneflag was set and jump to the appropriate loop ;you win loop ;printing out that you have won ;play again? ;the end loop to print The End! over and over
5 loop theendloopscreen askplayagain: mov dh, 10 mov dl, 20 mov edx, OFFSET playagain mov dh, 10 mov dl, 60 call ReadChar and al, b cmp al,"y" mov delval, 2000 mov level, 0 je newgame and al, b cmp al, "N" jne askplayagain ;this is used to ask the player if they want to play again mov dh, 20 mov dl, 25 exit main ENDP ;the end of main ;---- ;Splashy Procedure to print out the splash screen ;---- splashy PROC ;printing splash screen mov edx, OFFSET SplashMsg1 mov edx, OFFSET SplashMsg2 mov edx, OFFSET SplashMsg3 mov edx, OFFSET SplashMsg4 call waitmsg mov eax, green + (black * 16) mov edx, OFFSET SplashMsg5 mov eax, green + (black * 16) mov edx, OFFSET SplashMsg6 mov eax, green + (black * 16) mov edx, OFFSET SplashMsg7 mov eax, green + (black * 16) mov edx, OFFSET SplashMsg8
6 mov dh, 15 mov dl, 15 mov edx, OFFSET createdby mov eax, green + (black * 16) splashy ENDP ;end of splashy procedure ;---- ;Instruct me to print out instructions ;---- instructme PROC call ScreenPos mov edx, OFFSET InstMsg1 mov edx, OFFSET InstMsg2 mov edx, OFFSET InstMsg3 mov edx, OFFSET InstMsg4 mov edx, OFFSET InstMsg5 mov edx, OFFSET InstMsg6 mov edx, OFFSET InstMsg7 mov edx, OFFSET InstMsg8 mov edx, OFFSET InstMsg9 call waitmsg instructme ENDP ;end of isntruct me menu ;---- ;Skipline Procedure skips lines when needed ;---- SkipLine PROC mov edx, OFFSET skiplinechar call ScreenPos SkipLine ENDP ;end of skip line procedure ;---- ;Screen Position Procedure is used to set the screen position, when needed
7 ;---- ScreenPos PROC ;beginning of screen position function mov dh, xycord ;setting xycord to dh position mov dl, 10 ;setting 25 to dl position call Gotoxy ;calling Gotoxy to set the position inc xycord ;incrementing xycord position ;urning to main ScreenPos ENDP ;end of screen Position funciton ;---- ;SetupBoard is used within the main, from new game. THis procedure places the PitCharFull variable onto the positon of the last pit that a zombie has fell in. It also prints out the characters ;of the zombies, the man, and the original pit. All of this within the gamegrid. It is index with esi and produces accurate results ;---- setupboard PROC cld mov ecx,lengthof gamegrid mov esi,offset initgrid mov edi,offset gamegrid rep movsb mov dx, pitpos color cyan mov al, pitcharfull call WriteChar mov gamegrid[esi], pitcharfull call randomposition mov manpos,dx color gray mov al,manchar mov gamegrid[esi],manchar randomzomagain: call randomposition mov zompos, dx cmp dx, manpos je randomzomagain color green mov al,zomchar mov gamegrid[esi],zomchar randompitagain: call randomposition mov pitpos, dx cmp dx, manpos je randompitagain cmp dx, zompos je randompitagain color red mov al,pitcharempty mov gamegrid[esi],pitcharempty color white mov ax,delval mov delcnt,ax
8 setupboard ENDP ;---- ;moveman procedure is used to check key values and see if the man is moving or not. It will aslo make sure that the man does not move above the game grid or move down the game grid ;this procedure also sets doneflags that are used in main to see what the next step is. It also prints msgs based on if the zombie won or the man one. ;---- moveman PROC mov dx,manpos and al, b ;Uppercase it jz Arrowcheck cmp al,"x" jne checkletters mov doneflag,47 jmp godone checkletters: cmp al,"i" je goup cmp al,"k" je godown cmp al,"j" je goleft cmp al,"l" je goright cmp al,"w" je goup cmp al,"s" je godown cmp al,"a" je goleft cmp al,"d" je goright Arrowcheck: cmp ah,48h je goup cmp ah,50h je godown cmp ah,4bh je goleft cmp ah,4dh je goright jmp godone goup: cmp dh,0 je godone dec dh jmp gomove godown: cmp dh,24 je godone inc dh jmp gomove goleft: cmp dl,0 je leftwrap dec dl jmp gomove leftwrap: mov dl,79 jmp gomove goright: cmp dl,79 je rightwrap inc dl jmp gomove rightwrap: mov dl,0 ;jmp gomove gomove: cmp gamegrid[esi],nochar jne mannogo mov gamegrid[esi],manchar push edx
9 mov dx,manpos mov gamegrid[esi],nochar mov al,nochar pop edx mov manpos,dx color gray mov al,manchar jmp godone mannogo: cmp gamegrid[esi], pitcharfull je godone cmp gamegrid[esi],wallchar je godone cmp gamegrid[esi],zomchar je maneaten cmp gamegrid[esi],pitcharempty je mandied jmp godone maneaten: mov edx,offset zomwonmsg mov doneflag,40 jmp godone mandied: mov edx,offset diedmsg mov doneflag,41 godone: color white moveman ENDP ;---- ;Movezom procedure is used to move the zombie around based on where the man has moved. It can move left, right, up, down, and diagonally. It cannot move up or down off of the screen ;It will aslo print messages if the man has died or the zombie has died, by the pit, or if the zombie ate the man. It also sets the currentpitpos so it can be reused to print the ;pitcharfull within the setupboard function ;---- movezom PROC mov ebx, esi mov dx,zompos mov esi, ebx ;blank out where he used to be mov al," " mov gamegrid[esi],nochar mov bx,manpos cmp dl,bl ja zomleft jb zomright jmp checkupdown zomleft: dec dl jmp checkupdown zomright: inc dl ;jmp movhim checkupdown:
10 cmp dh,bh ja zomup jb zomdown jmp movhim zomup: dec dh jmp movhim zomdown: inc dh jmp movhim movhim: cmp gamegrid[esi],nochar jne whynot mov ebx, esi mov zompos,dx mov esi, ebx stayput: mov gamegrid[esi],zomchar color green mov al,0cbh jmp zommoved whynot: cmp gamegrid[esi], pitcharfull je keeppitcharspot cmp gamegrid[esi],wallchar jne zompit mov dx,zompos jmp stayput zompit: cmp gamegrid[esi],pitcharempty jne zomman mov edx, OFFSET manwonmsg1 mov edx, OFFSET manwonmsg2 mov dx, fillpitpos mov doneflag,50 jmp zommoved zomman: call zomwonmsg mov doneflag,51 jmp zommoved keeppitcharspot: mov dx, fillpitpos mov doneflag,5 color red zommoved: movezom ENDP zomwonmsg PROC color green + (black * 16) mov edx,offset zomwonmsg1 mov edx, OFFSET zomwonmsg2 color red + (black * 16) mov edx, OFFSET blooddrops1 color green + (black * 16) mov edx, OFFSET zomwonmsg3 color red + (black * 16) mov edx, OFFSET blooddrops2 color green + (black * 16)
11 mov edx, OFFSET zomwonmsg4 color red + (black * 16) mov edx, OFFSET blooddrops3 color green + (black * 16) mov edx, OFFSET zomwonmsg5 color red + (black * 16) mov edx, OFFSET blooddrops4 color green + (black * 16) mov edx, OFFSET zomwonmsg6 zomwonmsg ENDP ;---- ;Ramdomposition procedure is setting random places for the man, zombie, and pit within the setupboard procedure. This will always randomize the placement of these characters ;---- randomposition PROC mov edx, 0 mov eax, 78 call randomrange mov dl, al mov eax, 23 call randomrange mov dh, al randomposition ENDP ;---- ;Getindex procedure is setting esi so that gamegrid knows where to look. this is crucial for the entire program, complicated ;---- getindex PROC ;*** urn index in esi push edx mov ax,80 mov bx,0 mov bl,dh mul bx pop edx mov ebx,0 mov bl,dl add eax,ebx mov esi,eax ;call dumpregs ;call waitmsg getindex ENDP ;80 columns in the grid ;clear the upper byte END main ;---- ;END OF THE PROGRAM ;*****Sorry for the lack of comments, I was finishing up the program instead of commenting. ;*****I know you don't like that but I do know what is happening in this program and wanted a good grade, but i guess I wont. ;----
db "Please enter up to 256 characters (press Enter Key to finish): ",0dh,0ah,'$'
PA4 Sample Solution.model large.stack 100h.data msg1 db "This programs scans a string of up to 256 bytes and counts the repetitions of the number 4206 and sums them.",0dh,0ah,'$' msg2 db "Please enter
More informationCOMPUTER ENGINEERING DEPARTMENT
Page 1 of 14 COMPUTER ENGINEERING DEPARTMENT Jan. 7, 2010 COE 205 COMPUTER ORGANIZATION & ASSEMBLY PROGRAMMING Major Exam II First Semester (091) Time: 3:30 PM-6:00 PM Student Name : KEY Student ID. :
More informationCOMPUTER ENGINEERING DEPARTMENT
Page 1 of 11 COMPUTER ENGINEERING DEPARTMENT December 31, 2007 COE 205 COMPUTER ORGANIZATION & ASSEMBLY PROGRAMMING Major Exam II First Semester (071) Time: 7:00 PM-9:30 PM Student Name : KEY Student ID.
More informationMarking Scheme. Examination Paper. Module: Microprocessors (630313)
Philadelphia University Faculty of Engineering Marking Scheme Examination Paper Department of CE Module: Microprocessors (630313) Final Exam Second Semester Date: 12/06/2017 Section 1 Weighting 40% of
More informationAssembly Language for Intel-Based Computers, 4 th Edition. Chapter 5: Procedures. Chapter Overview. The Book's Link Library
Assembly Language for Intel-Based Computers, 4 th Edition Kip R Irvine Chapter 5: Procedures Slides prepared by Kip R Irvine Revision date: 10/3/2003 Chapter corrections (Web) Assembly language sources
More informationWe will first study the basic instructions for doing multiplications and divisions
MULTIPLICATION, DIVISION AND NUMERICAL CONVERSIONS We will first study the basic instructions for doing multiplications and divisions We then use these instructions to 1. Convert a string of ASCII digits
More informationLab 6: Conditional Processing
COE 205 Lab Manual Lab 6: Conditional Processing Page 56 Lab 6: Conditional Processing Contents 6.1. Unconditional Jump 6.2. The Compare Instruction 6.3. Conditional Jump Instructions 6.4. Finding the
More informationCONTENTS. 1. Display a Message Display a one Digit Number Accept a Character from keyboard and display the character 4
University of Kashmir, North Campus Course Code Course Name Course Instructor MCA-104-DCE Assembly Language Programming Bilal Ahmad Dar CONTENTS 1. Display a Message 2 2. Display a one Digit Number 3 3.
More informationLab 5: Input/Output using a Library of Procedures
COE 205 Lab Manual Lab 5: Input/Output using a Library of Procedures - Page 46 Lab 5: Input/Output using a Library of Procedures Contents 5.1. Using an External Library of Procedures for Input and Output
More informationMarking Scheme. Examination Paper Department of CE. Module: Microprocessors (630313)
Philadelphia University Faculty of Engineering Marking Scheme Examination Paper Department of CE Module: Microprocessors (630313) Final Exam Second Semester Date: 02/06/2018 Section 1 Weighting 40% of
More informationAssembly Language for Intel-Based Computers, 5 th Edition. Chapter 9: Strings and Arrays
Assembly Language for Intel-Based Computers, 5 th Edition Kip R. Irvine Chapter 9: Strings and Arrays Slide show prepared by the author Revision date: June 4, 2006 (c) Pearson Education, 2006-2007. All
More informationEC 333 Microprocessor and Interfacing Techniques (3+1)
EC 333 Microprocessor and Interfacing Techniques (3+1) Lecture 6 8086/88 Microprocessor Programming (Arithmetic Instructions) Dr Hashim Ali Fall 2018 Department of Computer Science and Engineering HITEC
More informationOverview: 1. Overview: 2
1: TITLE Binary equivalent of characters BINCHAR.ASM 3: Objective: To print the binary equivalent of 4: ASCII character code. 5: Input: Requests a character from keyboard. 6: Output: Prints the ASCII code
More informationEx: Write a piece of code that transfers a block of 256 bytes stored at locations starting at 34000H to locations starting at 36000H. Ans.
INSTRUCTOR: ABDULMUTTALIB A H ALDOURI Conditional Jump Cond Unsigned Signed = JE : Jump Equal JE : Jump Equal ZF = 1 JZ : Jump Zero JZ : Jump Zero ZF = 1 JNZ : Jump Not Zero JNZ : Jump Not Zero ZF = 0
More informationX86 Addressing Modes Chapter 3" Review: Instructions to Recognize"
X86 Addressing Modes Chapter 3" Review: Instructions to Recognize" 1 Arithmetic Instructions (1)! Two Operand Instructions" ADD Dest, Src Dest = Dest + Src SUB Dest, Src Dest = Dest - Src MUL Dest, Src
More informationExperiment 8 8 Subroutine Handling Instructions and Macros
Introduction Experiment 8 8 Subroutine Handling Instructions and Macros In this experiment you will be introduced to subroutines and how to call them. You will verify the exchange of data between a main
More informationConditional Processing
١ Conditional Processing Computer Organization & Assembly Language Programming Dr Adnan Gutub aagutub at uqu.edu.sa Presentation Outline [Adapted from slides of Dr. Kip Irvine: Assembly Language for Intel-Based
More informationmith College Computer Science CSC231 Assembly Week #9 Spring 2017 Dominique Thiébaut
mith College Computer Science CSC231 Assembly Week #9 Spring 2017 Dominique Thiébaut dthiebaut@smith.edu 2 Videos to Watch at a Later Time https://www.youtube.com/watch?v=fdmzngwchdk https://www.youtube.com/watch?v=k2iz1qsx4cm
More informationCSCI516: Program 1 - October 11, 2010 The Program is due: October 25, 2010 in the beginning of the class
CSCI516: Program 1 - October 11, 2010 The Program is due: October 25, 2010 in the beginning of the class For Late Submissions 10 out of 100 points will be taken off. For your first program, you are to
More information.code. lea dx,msg2. Page 1/8. Problem 1: Programming in Assembly [25 Points]
Problem : Programming in Assembly [ Points] The following assembly program is supposed to: receive three integer numbers from the console, call a function, name sort, function sort arranges the three input
More informationAssembly Language Programming
Assembly Language Programming Integer Constants Optional leading + or sign Binary, decimal, hexadecimal, or octal digits Common radix characters: h hexadecimal d decimal b binary r encoded real q/o - octal
More informationModule 3 Instruction Set Architecture (ISA)
Module 3 Instruction Set Architecture (ISA) I S A L E V E L E L E M E N T S O F I N S T R U C T I O N S I N S T R U C T I O N S T Y P E S N U M B E R O F A D D R E S S E S R E G I S T E R S T Y P E S O
More informationAssembly Language for Intel-Based Computers, 4 th Edition. Chapter 5: Procedures
Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 5: Procedures Slides prepared by the author Revision date: June 4, 2006 (c) Pearson Education, 2002. All rights reserved.
More informationIslamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB
Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB Lab # 6 Input/output using a Library of Procedures April, 2014 1 Assembly Language LAB Using
More informationLab 2: Introduction to Assembly Language Programming
COE 205 Lab Manual Lab 2: Introduction to Assembly Language Programming - page 16 Lab 2: Introduction to Assembly Language Programming Contents 2.1. Intel IA-32 Processor Architecture 2.2. Basic Program
More informationUNIT 4. Modular Programming
1 UNIT 4. Modular Programming Program is composed from several smaller modules. Modules could be developed by separate teams concurrently. The modules are only assembled producing.obj modules (Object modules).
More informationEXPERIMENT WRITE UP. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM
EXPERIMENT WRITE UP AIM: Assembly language program to search a number in given array. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM
More informationmith College Computer Science CSC231 Assembly Week #10 Fall 2017 Dominique Thiébaut
mith College Computer Science CSC231 Assembly Week #10 Fall 2017 Dominique Thiébaut dthiebaut@smith.edu 2 Videos to Start With https://www.youtube.com/watch?v=fdmzngwchdk https://www.youtube.com/watch?v=k2iz1qsx4cm
More informationMicroprocessors ( ) Fall 2010/2011 Lecture Notes # 15. Stack Operations. 10 top
Microprocessors (0630371) Fall 2010/2011 Lecture Notes # 15 Stack Operations Objectives of the Lecture Runtime Stack PUSH Operation POP Operation Initializing the Stack PUSH and POP Instructions Stack
More informationPrograms for Assembly Language Programming
;Program to print lower case alphabets.stack 100 mov dl, 'a' mov cl, 26 print: mov ah, 02h inc dl loop print mov ah, 4ch Programs for Assembly Language Programming ;Program to printf upper case alphabets.stack
More informationLecture (08) x86 programming 7
Lecture (08) x86 programming 7 By: Dr. Ahmed ElShafee 1 Conditional jump: Conditional jumps are executed only if the specified conditions are true. Usually the condition specified by a conditional jump
More informationCOE 205 Lab Manual Experiment N o 12. Experiment N o Using the Mouse
Experiment N o 12 12 Using the Mouse Introduction The mouse is an I/O device that replaces the arrow keys on the keyboard for graphical and text style programs. This experiment shows how to add the mouse
More informationStrings and Arrays. Overview. String primitive instructions MOVSB, MOVSW, MOVSD
Overview Strings and Arrays Computer Organization and Assembly Languages Yung-Yu Chuang 00//0 Assembly is for efficient code. Loops are what you likely want to optimize. Loops are usually used to process
More informationEECE.3170: Microprocessor Systems Design I Summer 2017 Homework 4 Solution
1. (40 points) Write the following subroutine in x86 assembly: Recall that: int f(int v1, int v2, int v3) { int x = v1 + v2; urn (x + v3) * (x v3); Subroutine arguments are passed on the stack, and can
More informationLecture 15 Intel Manual, Vol. 1, Chapter 3. Fri, Mar 6, Hampden-Sydney College. The x86 Architecture. Robb T. Koether. Overview of the x86
Lecture 15 Intel Manual, Vol. 1, Chapter 3 Hampden-Sydney College Fri, Mar 6, 2009 Outline 1 2 Overview See the reference IA-32 Intel Software Developer s Manual Volume 1: Basic, Chapter 3. Instructions
More informationAssembler Programming. Lecture 8
Assembler Programming Lecture 8 Lecture 8 Decision directives. Loops. Text macros. Macro procedures. String directives. Macro functions. Decision directives You can use the HLL structures for decision
More informationQ1: Multiple choice / 20 Q2: Data transfers and memory addressing
16.317: Microprocessor Systems Design I Fall 2014 Exam 1 October 1, 2014 Name: ID #: For this exam, you may use a calculator and one 8.5 x 11 double-sided page of notes. All other electronic devices (e.g.,
More informationCSC 2400: Computer Systems. Towards the Hardware: Machine-Level Representation of Programs
CSC 2400: Computer Systems Towards the Hardware: Machine-Level Representation of Programs Towards the Hardware High-level language (Java) High-level language (C) assembly language machine language (IA-32)
More informationExperiment #5. Using BIOS Services and DOS functions Part 1: Text-based Graphics
Experiment #5 Using BIOS Services and DOS functions Part 1: Text-based Graphics 5.0 Objectives: The objective of this experiment is to introduce BIOS and DOS interrupt service routines to be utilized in
More informationJump instructions. Unconditional jumps Direct jump. do not change flags. jmp label
do not change flags Unconditional jumps Direct jump jmp label Jump instructions jmp Continue xor eax,eax Continue: xor ecx,ecx Machine code: 0040340A EB 02 0040340C 33 C0 0040340E 33 C9 displacement =
More informationPESIT Bangalore South Campus
INTERNAL ASSESSMENT TEST 2 Date : 02/04/2018 Max Marks: 40 Subject & Code : Microprocessor (15CS44) Section : IV A and B Name of faculty: Deepti.C Time : 8:30 am-10:00 am Note: Note: Answer any five complete
More informationA4 Sample Solution Ch3
A4 Sample Solution Ch3 2. AL, AH, BL, BH,CL,CH,DLl, DH 3. AX, BX, CX, DX, SP, BP, SI, DI, CS, DS, ES, SS, FS, GS 4. EAX, EBX, ECX, EDX, ESP, EBP, EDI, ESI 5. RAX, RBX, RCX, RDX, RSP, RBP, RSI, RDI and
More informationAssembly Language for Intel-Based Computers, 4 th Edition. Chapter 6: Conditional Processing. Chapter Overview. Boolean and Comparison Instructions
Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 6: Conditional Processing Slides prepared by Kip R. Irvine Revision date: 10/19/2002 Chapter corrections (Web) Assembly language
More informationLibraries and Procedures
Computer Organization and Assembly Language Computer Engineering Department Chapter 5 Libraries and Procedures Presentation Outline Link Library Overview The Book's Link Library Runtime Stack and Stack
More informationIslamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB. Lab # 10. Advanced Procedures
Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB Lab # 10 Advanced Procedures May, 2014 1 Assembly Language LAB Stack Parameters There are
More informationAM2: Programming with Contemporary Instruction Set
: Programming with Contemporary Instruction Set Duration: 3 hours Components: Lab exercises and report. Objectives: (a) To examine how protected-mode programming is done on x86 based computer. (b) To evaluate
More informationMarking Scheme. Examination Paper. Module: Microprocessors (630313)
Philadelphia University Faculty of Engineering Marking Scheme Examination Paper Department of CE Module: Microprocessors (630313) Final Exam First Semester Date: 30/01/2018 Section 1 Weighting 40% of the
More informationCOMP211 ASSEMBLY PROGRAMMING
COMP211 ASSEMBLY PROGRAMMING Chapter 6: Conditional Processing Cristina G. Rivera 2 Chapter Overview Boolean and Comparison Instructions Conditional Jumps Conditional Loop Instructions Conditional Structures
More informationIslamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB. Lab # 8. Conditional Processing
Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB Lab # 8 Conditional Processing April, 2014 1 Assembly Language LAB Unconditional Jump The
More informationThe x86 Architecture
The x86 Architecture Lecture 24 Intel Manual, Vol. 1, Chapter 3 Robb T. Koether Hampden-Sydney College Fri, Mar 20, 2015 Robb T. Koether (Hampden-Sydney College) The x86 Architecture Fri, Mar 20, 2015
More information16.317: Microprocessor Systems Design I Fall 2014
16.317: Microprocessor Systems Design I Fall 2014 Exam 2 Solution 1. (16 points, 4 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling
More informationThe registers(di,si) are automatically incremented or decremented depending on the value of the direction flag:
String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures being accessed or manipulated. The operation
More informationAssembly Language. Lecture 5 Procedures
Assembly Language Lecture 5 Procedures Ahmed Sallam Slides based on original lecture slides by Dr. Mahmoud Elgayyar Linking to External Library The Irvine library Stack Operations Runtime Stack PUSH, POP
More informationLecture 16: Passing Parameters on the Stack. Push Examples. Pop Examples. CALL and RET
Lecture 1: Passing Parameters on the Stack Push Examples Quick Stack Review Passing Parameters on the Stack Binary/ASCII conversion ;assume SP = 0202 mov ax, 124h push ax push 0af8h push 0eeeh EE 0E F8
More informationIn order to run the program, go to the folder Release and run project.exe.
Assembly Language and System Software Lab exercise You need to implement seven programs. In this lab exercise, you are going to get familiar with assembly programming. You should follow the guideline to
More informationSPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY
BACKGROUND 8086 CPU has 8 general purpose registers listed below: AX - the accumulator register (divided into AH / AL): 1. Generates shortest machine code 2. Arithmetic, logic and data transfer 3. One
More informationData Transfers, Addressing, and Arithmetic. Part 2
Islamic University Of Gaza Assembly Language Faculty of Engineering Discussion Computer Department Chapter 4 Created By: Eng. Ahmed M. Ayash Modified and Presented by: Eng. Eihab S. El-Radie Chapter 4
More informationCSC 8400: Computer Systems. Machine-Level Representation of Programs
CSC 8400: Computer Systems Machine-Level Representation of Programs Towards the Hardware High-level language (Java) High-level language (C) assembly language machine language (IA-32) 1 Compilation Stages
More information16.317: Microprocessor Systems Design I Spring 2015
16.317: Microprocessor Systems Design I Spring 2015 Exam 2 Solution 1. (16 points, 4 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by
More informationBasic Assembly Instructions
Basic Assembly Instructions Ned Nedialkov McMaster University Canada SE 3F03 January 2013 Outline Multiplication Division FLAGS register Branch Instructions If statements Loop instructions 2/21 Multiplication
More informationAssembly Language for Intel-Based Computers, 5 th Edition. Kip R. Irvine. Chapter 6: Conditional Processing
Assembly Language for Intel-Based Computers, 5 th Edition Kip R. Irvine Chapter 6: Conditional Processing Chapter Overview Boolean and Comparison Instructions Conditional Jumps Conditional Loop Instructions
More informationSPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY
BACKGROUND Segment The "SEGMENT" and "ENDS" directives indicate to the assembler the beginning and ending of a segment and have the following format label SEGMENT [options] ;place the statements belonging
More informationIt is possible to define a number using a character or multiple numbers (see instruction DB) by using a string.
1 od 5 17. 12. 2017 23:53 (https://github.com/schweigi/assembler-simulator) Introduction This simulator provides a simplified assembler syntax (based on NASM (http://www.nasm.us)) and is simulating a x86
More informationADVANCE MICROPROCESSOR & INTERFACING
VENUS INTERNATIONAL COLLEGE OF TECHNOLOGY Gandhinagar Department of Computer Enggineering ADVANCE MICROPROCESSOR & INTERFACING Name : Enroll no. : Class Year : 2014-15 : 5 th SEM C.E. VENUS INTERNATIONAL
More informationLab 4: Basic Instructions and Addressing Modes
COE 205 Lab Manual Lab 4: Basic Instructions and Addressing Modes - page 36 Lab 4: Basic Instructions and Addressing Modes Contents 4.1. Data Transfer Instructions 4.2. Addition and Subtraction 4.3. Data
More informationAM2: Protected-Mode Programming
: Protected-Mode Programming Duration: 3 hours Components: Lab exercises and report. Objectives: (a) To examine how protected-mode programming is done on x86 based computer. (b) To evaluate the advantages
More informationFACULTY OF ENGINEERING LAB SHEET
FACULTY OF ENGINEERING LAB SHEET ECE366: ADVANCED MICROPROCESSORS TRIMESTER (08/09) AM: Real- Mode Programming *Note: On-the-spot evaluation may be carried out during or at the end of the experiment. Students
More informationSOEN228, Winter Revision 1.2 Date: October 25,
SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003 1 Contents Flags Mnemonics Basic I/O Exercises Overview of sample programs 2 Flag Register The flag register stores the condition flags that retain
More informationLibraries and Procedures
Libraries and Procedures COE 205 Computer Organization and Assembly Language Computer Engineering Department King Fahd University of Petroleum and Minerals Presentation Outline Link Library Overview The
More informationCS-202 Microprocessor and Assembly Language
CS-202 Microprocessor and Assembly Language Lecture 2 Introduction to 8086 Assembly Language Dr Hashim Ali Spring - 2019 Department of Computer Science and Engineering HITEC University Taxila!1 Lecture
More informationConditional Processing
Announcements Conditional Processing Midterm exam: Room 103, 10:00am-12:00am next Thursday, open book, chapters 1-5. Assignment #2 is online. Computer Organization and Assembly Languages Yung-Yu Chuang
More informationAssembly Language. Lecture 5 Procedures
Assembly Language Lecture 5 Procedures Ahmed Sallam Slides based on original lecture slides by Dr. Mahmoud Elgayyar Data Transfer Instructions Operand types MOV, MOVZX, MOVSX instructions LAHF, SAHF instructions
More information8086 INSTRUCTION SET
8086 INSTRUCTION SET Complete 8086 instruction set Quick reference: AAA AAD AAM AAS ADC ADD AND CALL CBW CLC CLD CLI CMC CMP CMPSB CMPSW CWD DAA DAS DEC DIV HLT IDIV IMUL IN INC INT INTO I JA JAE JB JBE
More informationWeek /8086 Microprocessor Programming
Week 5 8088/8086 Microprocessor Programming Multiplication and Division Multiplication Multiplicant Operand Result (MUL or IMUL) (Multiplier) Byte * Byte AL Register or memory Word * Word AX Register or
More information8086 programming Control Flow Instructions and Program Structures
8086 programming Control Flow Instructions and Program Structures Example: write a procedure named Square that squares the contents of BL and places the result in BX. Square: PUSH AX MOV AL, BL MUL BL
More informationAssembly Language for Intel-Based Computers, 4 th Edition. Chapter 6: Conditional Processing
Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 6: Conditional Processing (c) Pearson Education, 2002. All rights reserved. Chapter Overview Boolean and Comparison Instructions
More informationSHEET-2 ANSWERS. [1] Rewrite Program 2-3 to transfer one word at a time instead of one byte.
SHEET-2 ANSWERS [1] Rewrite Program 2-3 to transfer one word at a time instead of one byte. TITLE PROG2-3 PURPOSE: TRANSFER 6 WORDS OF DATA PAGE 60,132.MODEL SMALL.STACK 64.DATA ORG 10H DATA_IN DW 234DH,
More informationChapter 3: Addressing Modes
Chapter 3: Addressing Modes Chapter 3 Addressing Modes Note: Adapted from (Author Slides) Instructor: Prof. Dr. Khalid A. Darabkh 2 Introduction Efficient software development for the microprocessor requires
More informationLABORATORY WORK NO. 7 FLOW CONTROL INSTRUCTIONS
LABORATORY WORK NO. 7 FLOW CONTROL INSTRUCTIONS 1. Object of laboratory The x86 microprocessor family has a large variety of instructions that allow instruction flow control. We have 4 categories: jump,
More informationMarking Scheme. Examination Paper Department of CE. Module: Microprocessors (630313)
Philadelphia University Faculty of Engineering Marking Scheme Examination Paper Department of CE Module: Microprocessors (630313) Final Exam Second Semester Date: 08/06/2014 Section 1 Weighting 40% of
More informationAssembly Language for Intel-Based Computers, 4 th Edition
Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 5: Procedures Lecture 18 Linking to External Library The Book s Link Library Stack Operations Slides prepared by Kip R. Irvine
More informationExperiment N o 8. String Handling Instructions
Experiment N o 8 String Handling Instructions Introduction: In this experiment you will deal with string handling instructions, such as reading a string, moving a string from one memory location to another,
More informationQ1: Define a character string named CO_NAME containing "Internet Services" as a constant?
CS 321 Lab Model Answers ١ First Lab : Q1: Define a character string named CO_NAME containing "Internet Services" as a constant? ANS: CO_NAME EQU ' Internet Services' Q2: Define the following numeric values
More informationAssembly Language LAB
Assembly Language LAB Islamic University Gaza Engineering Faculty Department of Computer Engineering 2013 ECOM 2125: Assembly Language LAB Created by: Eng. Ahmed M. Ayash Modified and Presented By: Eihab
More informationAssembly Language for Intel-Based Computers, 4 th Edition
Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 13: 16-Bit MS-DOS Programming Interrupts Slide show prepared by Kip R. Irvine, Revision date: 08/04/02 Modified by Dr. Nikolay
More informationELEC 242 Time Delay Procedure
There are many occasions where we wish to time events. If we are using a personal computer, we have a number of ways to do this. The 8088/8086 computer had a Programmable Interval Timer like the 8253/54
More informationCOE 205. Computer Organization and Assembly Language Dr. Aiman El-Maleh
Libraries i and Procedures COE 205 Computer Organization and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals [Adapted from
More information16.317: Microprocessor Systems Design I Fall 2015
16.317: Microprocessor Systems Design I Fall 2015 Exam 2 Solution 1. (16 points, 4 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling
More informationRev101. spritzers - CTF team. spritz.math.unipd.it/spritzers.html
Rev101 spritzers - CTF team spritz.math.unipd.it/spritzers.html Disclaimer All information presented here has the only purpose of teaching how reverse engineering works. Use your mad skillz only in CTFs
More informationExperiment 3 3 Basic Input Output
Experiment 3 3 Basic Input Output Introduction The aim of this experiment is to introduce the use of input/output through the DOS interrupt. Objectives: INT Instruction Keyboard access using DOS function
More informationCSE351 Spring 2018, Midterm Exam April 27, 2018
CSE351 Spring 2018, Midterm Exam April 27, 2018 Please do not turn the page until 11:30. Last Name: First Name: Student ID Number: Name of person to your left: Name of person to your right: Signature indicating:
More informationmith College Computer Science CSC231 - Assembly Week #4 Dominique Thiébaut
mith College Computer Science CSC231 - Assembly Week #4 Dominique Thiébaut dthiebaut@smith.edu Homework Solutions Outline Review Hexdump Pentium Data Registers 32-bit, 16-bit and 8-bit quantities (registers
More informationLab 3: Defining Data and Symbolic Constants
COE 205 Lab Manual Lab 3: Defining Data and Symbolic Constants - page 25 Lab 3: Defining Data and Symbolic Constants Contents 3.1. MASM Data Types 3.2. Defining Integer Data 3.3. Watching Variables using
More informationMODE (mod) FIELD CODES. mod MEMORY MODE: 8-BIT DISPLACEMENT MEMORY MODE: 16- OR 32- BIT DISPLACEMENT REGISTER MODE
EXERCISE 9. Determine the mod bits from Figure 7-24 and write them in Table 7-7. MODE (mod) FIELD CODES mod 00 01 10 DESCRIPTION MEMORY MODE: NO DISPLACEMENT FOLLOWS MEMORY MODE: 8-BIT DISPLACEMENT MEMORY
More informationEEM336 Microprocessors I. Addressing Modes
EEM336 Microprocessors I Addressing Modes Introduction Efficient software development for the microprocessor requires a complete familiarity with the addressing modes employed by each instruction. This
More informationmith College Computer Science CSC231 Assembly Week #11 Fall 2017 Dominique Thiébaut
mith College Computer Science CSC231 Assembly Week #11 Fall 2017 Dominique Thiébaut dthiebaut@smith.edu Back to Conditional Jumps Review sub eax, 10 jz there xxx xxx there:yyy yyy Review cmp eax, 10 jz
More informationAssembly Language: g Part III. First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University
System Programming with Assembly Language: g Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University Outline A Few Basic Instructions Translation of high Level
More informationKingdom of Saudi Arabia Ministry of Higher Education. Taif University. Faculty of Computers & Information Systems
Kingdom of Saudi Arabia Ministry of Higher Education Taif University Faculty of Computers & Information Systems المملكة العربية السعودية وزارة التعليم العالي جامعة الطاي ف آلية الحاسبات ونظم المعلومات
More informationINSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI
Note: PUSHF / POPF have no operands The figure below shows that if (SS) = 3000H, (SP) = 0042H, so the execution of POP CX loads CX by the word 4050H form the stack segment. The SP is incremented by 2.
More informationECOM Computer Organization and Assembly Language. Computer Engineering Department CHAPTER 7. Integer Arithmetic
ECOM 2325 Computer Organization and Assembly Language Computer Engineering Department CHAPTER 7 Integer Arithmetic Presentation Outline Shift and Rotate Instructions Shift and Rotate Applications Multiplication
More information