1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Decoder with multiple RAMs

Discussion in 'Assembly Language Programming (ALP) Forum' started by SilverKing, Nov 13, 2015.

  1. SilverKing

    SilverKing New Member

    Joined:
    Nov 13, 2015
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Hi everyone,

    I've a problem I want some help with.

    "For the figure in the attachments, write a code to make the values of the third chip all zeros, and copy the contents of the first chip to sixth and the seventh."


    I want you to help me with first steps to solve this problem.
     

    Attached Files:

  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,010
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Where exactly are you stuck? Do you understand the question?
    Have you figured out what value(s) of A16-A19 you need to enable the chip?

    If there were no custom hardware and you were just doing the same kind of thing with eight consecutive 8K blocks of RAM in a PC, do you know how you would solve the problem?
     
  3. SilverKing

    SilverKing New Member

    Joined:
    Nov 13, 2015
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Hi xpi0t0s,

    Thank you for your response.

    I understand that A16-A19 should be High all the time.
    I the first and the last addresses of all chips.
    Code:
    [B]Chip No.[/B]  [B]First Add.[/B]  [B]Last Add.[/B]
    1          E0000h      E1FFFh
    2          E2000h      E3FFFh
    3          E4000h      E5FFFh
    4          E6000h      E7FFFh
    5          E8000h      E9FFFh
    6          EA000h      EBFFFh
    7          EC000h      EDFFFh
    8          EE000h      EEFFFh
    
    What I need to know is how access these locations "programically". I mean, I know that (Physical Address)=(Logical Address)*10h+(Offset), how can I determine the offset I need?
     
  4. SilverKing

    SilverKing New Member

    Joined:
    Nov 13, 2015
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    *"programmatically"
     
  5. SilverKing

    SilverKing New Member

    Joined:
    Nov 13, 2015
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    I've found this page. (in attachments)

    I'm guessing it'll lead me to solve this problem. Can you help me understand it?
     

    Attached Files:

  6. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,010
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    >>(Physical Address)=(Logical Address)*10h+(Offset)

    Logical Address is also sometimes known as a segment. Might be easier to think of in those terms. You're going to be looping over 8K blocks, so it makes sense for the offset to be at least 13 bits (A0-A12). There's more than one way to do it (in fact there are 16 ways to do it...EDIT: scratch that, there are loads more than 16).

    With 13-bit offset addresses your segments are going to be at E000, E200, E400 etc and you'll need to use 3 segment registers to do the copy, i.e. copying from E0xxx to EAxxx and ECxxx. Clearing chip 3 is just a case of writing zeros from 0-1fff in segment E400.

    Alternatively since 8*8K fits into 64K you could do the whole lot as one 64K segment at E000 and include the chip address in the upper 3 bits of the offset. The first might be easier, and in fact might be how the exercise is intended to get you thinking.
     
    Last edited: Nov 15, 2015
    shabbir likes this.
  7. SilverKing

    SilverKing New Member

    Joined:
    Nov 13, 2015
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Depending on an example in the attachment, I did the following:
    Code:
    ;A program to make the addresses values' from E4000 to E5FFF equal to zero
    MOV AX,E400h
    MOV DS,AX
    MOV BX,0000h
    here:
    MOV [BX],0000h
    INC BX
    CMP BX, 1FFFh
    JBE here
    hlt
     

    Attached Files:

  8. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,010
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Looks OK. The only thing I would check if you're using the 16-bit mov[bx] (because you specified 0000h, not 00h), this writes 2 bytes: one to [bx] and one to [bx+1], so you're duplicating almost all writes, which is unnecessary. Secondly check if the loop includes or excludes the write to [1fff], because if this write is included then this will mean the 16-bit write will write to [2000], which is the 1st byte of the next memory chip (and further if you switch to the 8-bit write then make sure the write to [1fff] is definitely included. Boundary conditions always need checking).
     
  9. SilverKing

    SilverKing New Member

    Joined:
    Nov 13, 2015
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Here's my code.
    Code:
    ;A program to make the addresses values' from E4000 to E5FFF equal to zero
    MOV AX,E400h
    MOV DS,AX
    MOV BX,0000h
    here:
    MOV [BX],0000h
    INC BX
    CMP BX, 1FFFh
    JBE here
    
    ;Copying the 4th address' value of the 1st chip to DL
    MOV BX,0003h
    MOV DX,[BX]
    
    ;Copying the 4th address' value of the 1st chip to the 6th chip
    MOV AX,EA00h
    MOV DS,AX
    MOV BX,0000h
    there:
    MOV [BX],DX
    INC BX
    CMP BX,1FFFh
    JBE there
    
    ;Copying the 4th address' value of the 1st chip to the 7th chip
    MOV AX,EC00h
    MOV DS,AX
    MOV BX,0000h
    over:
    MOV [BX],DX
    INC BX
    CMP BX,1FFFh
    JBE over
    HLT
    I think I've some solution, which is to initially copy the "out of bound" addresses' values to some low registers and then returning them back.
     
  10. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,010
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    >>Copying the 4th address' value of the 1st chip to DL

    You need to re-read the assignment.
     
  11. SilverKing

    SilverKing New Member

    Joined:
    Nov 13, 2015
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    xpi0t0s,

    I've just mispelled, it's actually "the 4th address' value of the 1st chip".

    So going back to the code, is my approach acceptable?
     
  12. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,010
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    No, you haven't just misspelled. The assignment is not asking you to copy a single byte.
     

Share This Page