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 8894689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:34:04+00:00 2026-06-14T23:34:04+00:00

What are the practical diffences between s and sf in the two code samples

  • 0

What are the practical diffences between s and sf in the two code samples below?

I understand that stack relative look like Mem[SP + OprndSpec] and deffered look like Mem[Mem[SP + OprndSpec]]. However what I don’t understand is how this is accomplished.

Stack deffered

         BR      main
a:       .BLOCK  2          ;global variable #2d
b:       .BLOCK  2          ;global variable #2d
;
;******* void swap (int& r, int& s)
r:       .EQUATE 6          ;formal parameter #2h
s:       .EQUATE 4          ;formal parameter #2h
temp:    .EQUATE 0          ;local variable #2d
swap:    SUBSP   2,i        ;allocate #temp
         LDA     r,sf       ;temp = r
         STA     temp,s
         LDA     s,sf       ;r = s
         STA     r,sf
         LDA     temp,s     ;s = temp
         STA     s,sf
         RET2               ;deallocate #temp, pop retAddr
;
;******* void order (int& x, int& y)
x:       .EQUATE 4          ;formal parameter #2h
y:       .EQUATE 2          ;formal parameter #2h
order:   LDA     x,sf       ;if (x > y)
         CPA     y,sf
         BRLE    endIf
         LDA     x,s        ;   push x
         STA     -2,s
         LDA     y,s        ;   push y
         STA     -4,s
         SUBSP   4,i        ;   push #r #s
         CALL    swap       ;   swap (x, y)
         ADDSP   4,i        ;   pop #s #r
endIf:   RET0               ;pop retAddr

;
;******* main ()
main:    STRO    msg1,d     ;cout << "Enter an integer: "
         DECI    a,d        ;cin >> a
         STRO    msg1,d     ;cout << "Enter an integer: "
         DECI    b,d        ;cin >> b
         LDA     a,i        ;push the address of a
         STA     -2,s
         LDA     b,i        ;push the address of b
         STA     -4,s
         SUBSP   4,i        ;push #x #y
         CALL    order      ;order (a, b)
ra1:     ADDSP   4,i        ;pop #y #x
         STRO    msg2,d     ;cout << "Ordered they are: "
         DECO    a,d        ;     << a
         STRO    msg3,d     ;     << ", "
         DECO    b,d        ;     << b
         CHARO   '\n',i     ;     << endl
         STOP
msg1:    .ASCII  "Enter an integer: \x00"
msg2:    .ASCII  "Ordered they are: \x00"
msg3:    .ASCII  ", \x00"
         .END   

Stack relative

         BR      main        
;
;******* int binomCoeff (int n, int k)
retVal:  .EQUATE 10          ;returned value #2d
n:       .EQUATE 8           ;formal parameter #2d
k:       .EQUATE 6           ;formal parameter #2d
y1:      .EQUATE 2           ;local variable #2d
y2:      .EQUATE 0           ;local variable #2d
binCoeff:SUBSP   4,i         ;allocate #y1 #y2
if:      LDA     k,s         ;if ((k == 0)
         BREQ    then        
         LDA     n,s         ;|| (n == k))
         CPA     k,s         
         BRNE    else        
then:    LDA     1,i         ;return 1
         STA     retVal,s    
         RET4                ;deallocate #y2 #y1, pop retAddr
else:    LDA     n,s         ;push n - 1
         SUBA    1,i         
         STA     -4,s        
         LDA     k,s         ;push k
         STA     -6,s        
         SUBSP   6,i         ;push #retVal #n #k
         CALL    binCoeff    
ra2:     ADDSP   6,i         ;pop #k #n #retVal
         LDA     -2,s        ;y1 = binomCoeff (n - 1, k)
         STA     y1,s        
         LDA     n,s         ;push n - 1
         SUBA    1,i         
         STA     -4,s        
         LDA     k,s         ;push k - 1
         SUBA    1,i         
         STA     -6,s        
         SUBSP   6,i         ;push #retVal #n #k
         CALL    binCoeff    
ra3:     ADDSP   6,i         ;pop #k #n #retVal
         LDA     -2,s        ;y2 = binomCoeff (n - 1, k - 1)
         STA     y2,s        
         LDA     y1,s        ;return y1 + y2
         ADDA    y2,s        
         STA     retVal,s    
endIf:   RET4                ;deallocate #y2 #y1, pop retAddr
;
;******* main ()
main:    STRO    msg,d       ;cout << "binCoeff (3, 1) = "
         LDA     3,i         ;push 3
         STA     -4,s        
         LDA     1,i         ;push 1
         STA     -6,s        
         SUBSP   6,i         ;push #retVal #n #k
         CALL    binCoeff    
ra1:     ADDSP   6,i         ;pop #k #n #retVal
         DECO    -2,s        ;<< binCoeff (3, 1)
         CHARO   '\n',i      ;cout << endl
         STOP                
msg:     .ASCII  "binCoeff (3, 1) = \x00"
         .END                  
  • 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-14T23:34:06+00:00Added an answer on June 14, 2026 at 11:34 pm

    Your question seems simple and has little to do with code other than they presumably contain examples.

    (I’m not familiar with this instruction set, but have been coding a long time in assembly.)

    According to the definition you provided, “stack relative” means taking an item from memory at a location determined by the stack pointer, plus a constant offset presumably embedded in an instruction. This is called indexed addressing by most folk, with the special note that it is stack-pointer indexed.

    “Deferred” (an old term) usually means “indirect through a memory location” and your definition of that is consistent with this idea: find the “stack relative” location, read that, and use that value as the memory location to fetch.

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

Sidebar

Related Questions

Can you help me understand the practical differences between these two; IList<int> myList =
What is the practical difference between the following two commands? Command A find .
I understand the differences between the two from the docs. uuid1() : Generate a
I'm aware of two methods to write code hints in CFScript. I would like
Are there any practical differences between these two ways of getting an exception for
First the practical application that led me to the problem: Given a set of
Has anyone got practical experience or a reference for a scheme that implements a
Are there any practical differences between special forms and macros? In what do they
Can anyone explain in a clear way the practical differences between the java.lang.annotation.RetentionPolicy constants
What are the practical differences between putting a service in a separate process or

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.