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
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.