Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 31st, 2013, 11:12 PM   #1
kayxxx
Newbie
 
Join Date: Feb 2013
Posts: 6
Rep Power: 0 kayxxx is on a distinguished road
Hi guys can someone please explain this code for i will know what is the logic?

.model small
.stack
org 100
.data
year db 10,13, "Year: $"
leapmsg db 10, 13, "That is a leap year! $"
notleapmsg db 10, 13, "That is not a leap year! $"
.code

start:

mov ax, @data
mov ds, ax

lea dx, year
mov ah, 09h
int 21h

call InputProc


leapTrue:

lea dx, leapmsg
mov ah, 09h
int 21h
jmp close

leapFalse:

lea dx, notleapmsg
mov ah, 09h
int 21h
jmp close

close:

mov ah, 4ch
int 21h


Proc InputProc


mov ah, 01h
int 21h
cmp al, 0dh
je FirstTest

mov ah, 0
sub al, 30h
push ax
mov ax, 10d
mul bx
pop bx
add bx, ax
jmp inputProc

call FirstTest
ENDP

Proc FirstTest

mov ax, bx
push ax
mov bx, 4
div bx
cmp dx, 0
je SecondTest
jmp leapFalse

RET
EndP

Proc SecondTest
pop ax
push ax
mov bx, 100
div bx
cmp dx, 0
je ThirdTest
jmp leapTrue
EndP

Proc ThirdTest

pop ax
mov bx, 400
div bx
cmp dx, 0
je leapTrue
jmp leapFalse

EndP

end start
kayxxx is offline   Reply With Quote
Old Jun 1st, 2013, 9:55 AM   #2
Ancient Dragon
Achieved Level 70

 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 4,345
Rep Power: 10 Ancient Dragon will become famous soon enoughAncient Dragon will become famous soon enough
Re: Hi guys can someone please explain this code for i will know what is the logic?

Explain the logic? That's why is very very important to comment the code, more important in assembly than in other languages. Do you know assembly language at all? If yes, then just begin reading at the start: label and follow the program as if you were the processor.
__________________
PFO's FAQ is here
Forum Rules

There is no cow level (Diablo III)
If you never push yourself you will never improve (Diablo III)
Ancient Dragon is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can someone explain this code? JavaJunior Python 2 May 2nd, 2012 12:48 PM
Need to make code more efficient. weatherman0516 Bash / Shell Scripting 4 Sep 18th, 2011 7:17 AM
Open source C++ projects for a source code analyzer? david.dda C++ 1 Sep 28th, 2009 12:15 AM
String to Morse Code - Copying from string to string Xenon C 29 Nov 10th, 2005 2:30 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:32 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC