Dereck
Dereck

Reputation: 1

In LMC,How create a table by self-modify it's size?

Actually i dont know how to put a data into a tab by different addresses in a tab ,like

TAB[1]=1,TAB[2]=2,TAB[3]=3.

there is my code in LMC, i have tried many times and check many LMC exemples in Stackoverflow ,but i'm still so confused hwo to realize that.


               INP
       
               STA     TAB            
       LOOP    INP
               STA     TAB
               LDA     TAB
               SUB     ONE
               BRZ     LEAVE
               BRA     LOOP
       LEAVE   LDA     TAB
               SUB     ONE
               STA     TAB
               BRA     LEAVE
               BRZ     TABOUT
               OUT        
    TABOUT     HLT

       TAB     DAT
       ONE     DAT     1
       

i want create a table which‘s. size is changed by the number I input, and then I input again the data I want to deposit into the table.

like input 3. #this is the size of this table and input 1 it's the first element in this table[1] input 2 it will input into the table[2] .

i dont want to create a fixed table ,i want to make a dynamic table , The size of the table is whatever I enter。

Upvotes: 0

Views: 139

Answers (0)

Related Questions