Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 1st, 2006, 12:53 AM
ghostrunner ghostrunner is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 4 ghostrunner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 53 m 47 sec
Reputation Power: 0
Beginning Assembly Troubles

In a computer architecture course that I'm taking, I have to write an x86 assembly program that displays information in the following format,
Code:
John Locke
Monday, July 25, 2006 @ 04:30pm
where the first line is my own name, and the second line is the system date and time.
I've got everything working just fine until I try to display the day of the week. The program compiles just fine in NASM, but after displaying my name, the program stops. It seems to be calculating, but never gets anywhere.
Can anybody help me figure out what's wrong?

This is the assignment description.

This is my progress so far (ZIP file containing the .ASM file).

Reply With Quote
  #2  
Old August 2nd, 2006, 06:40 PM
LinuxPenguin's Avatar
LinuxPenguin LinuxPenguin is offline
fork while true;
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: May 2005
Location: England, UK
Posts: 5,538 LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)  Folding Points: 11590 Folding Title: Novice Folder
Time spent in forums: 1 Month 3 Weeks 1 Day 19 h 30 m 28 sec
Reputation Power: 1050
Is there any reason you couldn't have just posted your script in [ code ] tags?

I'm going to do that for you... I assume it's windows asm, although i don't know for sure.

Code:
;JAMES GABRIELSEN CS2650 Assembler Program #3
[BITS 16]               ;Set code generation to 16 bit mode
%include 'exebin.mac'

EXE_Begin

[ORG 100H]		;set addressing to begin at 100H

;**********Clearing the Screen**********
cls:					;clearing the screen
	mov ah,06		;Clear/Scroll Screen Up		
	mov cx,0000		;Upper left corner
	mov dx,184fH	;Lower right corner
	mov al,00		;blank entire window
	mov bh,1fH		;make blanketed area blue
	int 10H			;call the interrupt with the preceeding properties

dspName: 
   mov ah,02h		;function 02h (Position the cursor)
	mov al,0			;Write mode is zero
	mov bh,0			;Use video page of zero
	mov dh,12		;position on row 12
	mov dl,00		;and column 0
	int 10H

   mov ah,09h		;function 09h (Display string at present cursor location)
	lea dx,[Name]	;load the offset address of string into DX
	int 21H


dspDoW: 
   mov ah,02h		;function 02h (Position the cursor)
	mov al,0			;Write mode is zero
	mov bh,0			;Use video page of zero
	mov dh,13		;position on row 13
	mov dl,00		;and column 0
	int 10H

	mov AH,2aH
	int 21			;reading the clock date

	dSun:
	CMP AL, 00		;checking if al=00
	JNZ dMon
	LEA DX,[Sunday]
	
	dMon:
	CMP AL,01
	JNZ dTue
	LEA DX, [Monday]
	
	dTue:
	CMP AL, 02
	JNZ dWed
	LEA DX,[Tuesday]
	
	dWed:
	CMP AL,03
	JNZ dThu
	LEA DX, [Wednesday]
	
	dThu:
	CMP AL, 04
	JNZ dFri
	LEA DX,[Thursday]
	
	dFri:
	CMP AL,05
	JNZ dTue
	LEA DX, [Friday]
	
	dSat:
	CMP AL, 06
	JNZ dSun
	LEA DX,[Saturday]

   mov ah,09h		;function 09h (Display string at present cursor location)	
	int 21H




		
stop:  	int 20H

Vars:
Name: 		db 'James Gabrielsen$'
Sunday:db 'Sunday, $'
Monday:db 'Monday, $'
Tuesday:db 'Tuesday, $'
Wednesday:db 'Wednesday, $'
Thursday:db 'Thursday, $'
Friday:db 'Friday, $'
Saturday:db 'Saturday, $'



EXE_End

Reply With Quote
  #3  
Old August 5th, 2006, 05:49 PM
Schol-R-LEA's Avatar
Schol-R-LEA Schol-R-LEA is offline
Commie Mutant Traitor
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jun 2004
Location: Norcross, GA (again)
Posts: 1,759 Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 3 h 38 m 3 sec
Reputation Power: 1568
Actually, LP, it's DOS assembly (it uses the DOS and BIOS interrupts), though it will run under Windows of course.

OK, a few things I've noticed offhand. First off, you don't actually need to include the exebin.mac file, as you don't seem to be using any macros. Mind you, it maybe that there are some macros you could use, but I'd need to see the macros your professor has set up to be sure. I assume it's something that your professor requires you to include, though.

Second, you are getting the day and date info, but then overwriting the date part when you load the address of the day string into DX (which keep in mind is general-purpose register D, full register). According to the interrupt list, the INT 0x21, function 0x2A DOS call (get system time) deposits the month into DH (General register D, high or upper half), and the day of the month into DL (General register D, lower half). You need to save those two values somewhere first, or else you'll lose them, and won't have the value later when you go to print the rest of the date. You haven't done that part of it yet, so it's not a big deal, but you'll need to have that for the final version later. I think that BH and BL should be free at this point; if not, you can use 'resb' ('reserve byte') to set aside some memory variables.

The main thing I see, though, is that you are letting the values fall through after it finds the correct value; that is to say,if it finds a value of zero, then it continues testing the results for all the others. You should have it jump to the end of the switch instead.

Finally, you don't have any sort of default or failure-mode handling; if a value is out of bounds, you have it jump back to the top without changing it, which would give an infinite loop. Since the value given by DOS shouldn't ever be above 6, this probably will never happen, but you might want to have a final 'dBad' case instead of jumping back to dSun just as a matter of sanity checking. This combined with the issue above may well be the source of the problem.

While testing the problem, you might want to start by trying to set it to print a fixed one of the strings, such as sunday. If that works, then the problem must be in the logic; otherwise, the problem is probably with the call to the DOS routine.

On a purely minor note, I might add that it would be slightly more efficient in terms of overall size (and avoid a trivial amount of redundancy) if you eliminated the spaces and the comma in the strings themselves, and printed it out separately. There would be a bit of extra overhead from the extra call, though. Which you do is a matter of personal coding aesthetics, really.

Also, I would have used a table lookup of some sort rather than a switch, but I don't know if your professor has covered enough that you would know how to do that yet; from the problem description, I gather that this is how he is expecting you to do this, so it's just as well.
__________________
Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
#define KINSEY (rand() % 7) λ Scheme is the Red Pill
Scheme in ShortUnderstanding the C/C++ Preprocessor
Taming PythonA Highly Opinionated Review of Programming Languages for the Novice, v1.1

FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov

Last edited by Schol-R-LEA : August 5th, 2006 at 06:38 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Beginning Assembly Troubles

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap