Article View: be.comp.programming
Article #4021newbie asembly language question
From: Yaqub Ali Sheikh
Date: Sun, 21 Sep 2003 01:35
Date: Sun, 21 Sep 2003 01:35
90 lines
2686 bytes
2686 bytes
hey whats up everyone i need help in a assembly language program im making, im just getting started in assembly language so this program is fairly simple The program will run in a loop which will prompt the user to enter an integer (a simple prompt will do). If the value entered is less than or equal to 0 the loop will terminate. Otherwise the program will add up all values from one to the user's chosen value and display the sum. (Please compute this sum using a loop, not a formula.) i am using xspim to compile it.and the language is RISC assembly language here is what i have so far, but my logic on the loop doesnt work right, im sortta confused on how for loops work in assmebly language or if i even need a for loop for this any suggestions on how to fix this? ######################################### # Text Segment # # # ######################################### .text .globl main main: la $a0, prompt # print prompt on screen li $v0, 4 # system call to print syscall next: li $v0, 5 # syscall 5 reads an integer syscall move $t3, $v0 add $t0, $t0, $v0 # adds the number to t0 move $a0, $t0 # print result li $v0, 1 syscall la $a0, endl # system call to print li $v0, 4 # out a new line syscall blez $t3, done li $t3, 0 bgez $t3, next # loop while user doesnt enter in 0 done: li $v0, 10 # system call to exit syscall ######################################### # Data Segment # # # ######################################### .data prompt: .asciiz "Enter in a a number and i will add that number to the last, enter 0 to exit " endl: .asciiz "\n"
Technical Details
Message-ID:
<Hf7bb.1631$a16.663@lakeread01>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!cox.net!news-xfer.cox.net!p01!lakeread01.POSTED!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fcea4,985ef1a80d1bafc4,start X-Google-Attributes: gidfcea4,public X-Google-ArrivalTime: 2003-09-20 18:35:39 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!cox.net!news-xfer.cox.net!p01!lakeread01.POSTED!not-for-mail From: "Yaqub Ali Sheikh" <asheikh2@cox.net> Newsgroups: be.comp.programming Subject: newbie asembly language question Lines: 93 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: <Hf7bb.1631$a16.663@lakeread01> Date: Sat, 20 Sep 2003 21:35:33 -0400 NNTP-Posting-Host: 68.100.150.203 X-Complaints-To: abuse@cox.net X-Trace: lakeread01 1064108135 68.100.150.203 (Sat, 20 Sep 2003 21:35:35 EDT) NNTP-Posting-Date: Sat, 20 Sep 2003 21:35:35 EDT Organization: Cox Communications