Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8725645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:05:00+00:00 2026-06-13T08:05:00+00:00

I have a simple program here which is set to produce the output, The

  • 0

I have a simple program here which is set to produce the output,

The value of a is 2005

The value of b is 1959

The value of c is 1

The value of d is 0

The value of (a - b) * (c + d) is 46

I’m looking for the best ways to optimize my code, I’m repeating code ALOT! is it possible to print straight from other registers? e.g SWI 0 but for a integer not in R0?

    B   main
aval    DEFW    2005
bval    DEFW    1959
cval    DEFW    1
dval    DEFW    0
valOf   DEFB    'The value of \0'
isStr   DEFB    ' is \0'
lstStr  DEFB    'The value of (a - b) * (c + d) is \0'

    ALIGN

main    ADR R0, valOf   ;Value a
    SWI 3       
    MOV R0, #97     
    SWI 0       
    ADR R0, isStr   
    SWI 3
    LDR R0, aval    
    SWI 4
    MOV R0, #10     ;print new line
    SWI 0

    ADR R0, valOf   ;Value b
    SWI 3
    MOV R0, #98
    SWI 0
    ADR R0, isStr   
    SWI 3
    LDR R0, bval    
    SWI 4
    MOV R0, #10     ;print new line
    SWI 0

    ADR R0, valOf   ;Value c
    SWI 3
    MOV R0, #99
    SWI 0
    ADR R0, isStr   
    SWI 3
    LDR R0, cval    
    SWI 4
    MOV R0, #10     ;print new line
    SWI 0

    ADR R0, valOf   ;print 'value of '
    SWI 3
    MOV R0, #100
    SWI 0
    ADR R0, isStr   ;
    SWI 3
    LDR R0, dval    
    SWI 4   
    MOV R0, #10     ;print new line
    SWI 0

    ADR     R0, lstStr
    SWI 3
    LDR R3, aval
    LDR R4, bval
    LDR R5, cval
    LDR R6, dval
    SUB R1, R3, R4
    SUB R2, R5, R6
    MUL R0, R1, R2
    SWI 4

    SWI 2       ;exit

Any thoughts much appreciated 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:05:01+00:00Added an answer on June 13, 2026 at 8:05 am

    I was about to ask if you have to write in assembly but since you are using SWI (nowadays it is called SVC) obviously you are sitting on top of an OS, high chance Linux.

    Why you are not writing in C? That should be much easier for you except if this is solely for learning purposes which in that case why you would try to learn such a usage?

    About optimization, when your are sitting on top of a non-real-time OS and make system calls any performance expectation will be just lost. From the point of software interrupt kernel can delay your code variably and un-guaranteed fashion.

    So in this case if you are thinking about making your application fast, try to reduce number of system calls by preparing / caching print buffers in userspace where you can apply some plain and easy C idioms.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i found many related questions here. I have a simple java program . it
Well, i have written a simple python program that parses HTML with HTMLParser. Here
I have a simple program. I want to set the path and some properties
I have a simple program (written in Java) which uses the google protocol buffer
I have a simple program which is able to change the background color after
So I have been modifying the chat program found here: http://www.dreamincode.net/forums/topic/259777-a-simple-chat-program-with-clientserver-gui-optional/ and I am
Say I have simple program that emulates a board game with a number of
I have Simple java program named MainController.java. Wehn I try to compile it from
I have a simple program that checks webpages for strings, example: Private Sub Button1_Click(ByVal
I have a simple program on windows using visual studios 2008. In my code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.