Current location: Hot Scripts Forums » Programming Languages » Other Languages » Assembly Language question


Assembly Language question

Reply
  #1 (permalink)  
Old 11-14-10, 02:12 PM
kyu09 kyu09 is offline
New Member
 
Join Date: Nov 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Assembly Language question

Is something wrong with my code?
It's a tower of hanoi in assembly language
Code:
BR main
n: .EQUATE 5
start: .EQUATE 4
dest: .EQUATE 3
spare: .EQUATE 2
msgMove: .ASCII "MOVE \x00"
msgTO: .ASCII " to \x00"

hanoi: LDA n,s ;loads the number of disks
CPA 0,i ;compares it if it's 0
BRLE endHanoi ;Else statement
;
LDA n,i ;loads the number of disks
SUBA 1,i ;subtracts one
STA -2,s ;stores it
LDBYTEA start,i ;loads start
STBYTEA -3,s ;stores start
LDBYTEA dest,i ;loads dest and store it on the stack
STBYTEA -4,s
LDBYTEA spare,i ;loads spare and stores it on the stack
STBYTEA -5,s
SUBSP 5,i ;allocates bytes
Call hanoi ;recursive function
ADDSP 5,i ;deallocate bytes

STRO msgMove,d ;this whole block of codes
STRO start,d ;are the outputs
STRO msgTO,d ; Move X to Y
STRO dest,d
Charo '\n',i

LDA n,i ;loads the number of disks
SUBA 1,i ;Subtract one from it
LDBYTEA spare,i ;loads spare and stores it on the stack
STBYTEA -3,s
LDBYTEA dest,i ;loads dest and stores it on the stack
STBYTEA -4,s
LDBYTEA start,i ;loads start and stores it on the stack
STBYTEA -5,s
SUBSP 5,i ;allocates bytes
Call hanoi ;recursive function
ADDSP 5,i ;deallocates byets

endHanoi: Ret0 ;return to main

msgInput: .ASCII "Enter number of disks: \x00"
disks: .EQUATE 0
main: STRO msgInput,d ;outputs the message
DECI disks,s ;inputs the # of disk
LDA disks,d
STA -2,s
LDBYTEA 'A',i
STBYTEA -3,s
LDBYTEA 'B',i
STBYTEA -4,s
LDBYTEA 'C',i
STBYTEA -5,s
SUBSP 5,i
Call hanoi
AddSP 5,i
.END
.STOP

Last edited by Nico; 11-15-10 at 02:56 AM.
Reply With Quote
  #2 (permalink)  
Old 11-14-11, 11:56 PM
collin2 collin2 is offline
Disabled
 
Join Date: Nov 2011
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
02The Globetrekker Phoenix Escort programmes arent Phoenix Escorts bad and can Phoenix Asian Escort be picked up on Ebay for Phoenix Asian Escorts a tenner. I particularly liked the London one. Rough Guide on Channel 5 are better then I thought but not a patch on the old Rough Guide by the BBC.
Reply With Quote
Reply

Bookmarks


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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I write a program in Assembly Language that displays four tables, n, 3n, 7n, and Fn? Thesel Other Languages 1 03-29-10 06:18 AM
about assembly language mobiseek Other Languages 0 03-30-09 01:19 AM
How to build a binary tree in assembly language? phingphing Other Languages 0 11-04-08 07:15 AM
Assembly Language question jessicayan Other Languages 1 02-13-07 03:07 PM
Question on language files rozojc PHP 4 11-08-03 07:40 AM


All times are GMT -5. The time now is 03:50 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.