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

  • Home
  • SEARCH
  • 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 7607437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:39:44+00:00 2026-05-31T00:39:44+00:00

I am trying to create a truth table for the function F=(A&B) XOR (C&D’).

  • 0

I am trying to create a truth table for the function F=(A&B) XOR (C&D’). I’m using Intel assembly language and the whole code has to be fairly short.

The main problem that I keep running into is with the loop to manipulate the variables A,B,C and D to create all the possible inputs of a truth table. The way this would be typically done is to act like the variables are each a bit of a 4 bit binary number and count from 0 to 15, implementing each possible input. I only have 4 registers a stack and RAM memory to accomplish this so I assigned each variable to a register, and I use ram to store a counter and the outputs of the table. I can’t think of a good way to do this with a loop, but I have to use one because the simulator I’m using won’t function with code as long as mine has become. (It’s 256 bytes)

Here is the code, the subroutine called procedure 60 is the piece I want to condense. I don’t have to actually output a truth table just tell how many “Minterm’s” (outputs of 1) are produced by it.

        ;MAIN
    MOV AL,0    ;INITIALIZING VARIABLES
    MOV BL,0
    MOV CL,0
    MOV DL,0
    MOV [20],AL ;INITIALIZE CURRENT NUMBER OF MINTERMS WITH 0
    MOV [21],AL ;INITIALIZE COUNTER WITH 0
LOOP:   CALL    30
    CALL    60
    MOV [21],CL
    CMP CL,15
    JS  LOOP
    CALL    E0
    MOV AL,[20] ;MOVE NUMBER OF MINTERMS TO AL
    MOV [FF],AL ;OUPUT NUMBER OF MINTERMS TO VDU(LOCATIONS [C0] TO [FF])

        ;PROCEDURE 30, IMPLEMENTS THE GIVEN BOOLEAN FUNCTION
    ORG 30  ;WRITE CODE BEGINNING AT [30]
    PUSH    DL  ;CURRENT VALUE OF D
    PUSH    CL  ;CURRENT VALUE OF C
    PUSH    AL  ;CURRENT VALUE OF A, IMPLEMENTING FUNCTION WON'T CHANGE D
    AND AL,BL   ;PERFORMS (AL AND BL), STORES VALUE IN AL
    NOT DL  ;INVERSE OF DL STORED IN DL
    AND CL,DL   ;PERFORMS (CL AND DL), STORES VALUE IN CL
    XOR AL,CL   ;PERFORMS (AL XOR CL), STORES VALUE IN AL
    MOV BL,[20] ;MOVES CURRENT NUMBER OF MINTERMS TO BL
    ADD AL,BL   ;ADD TO CURRENT NUMBER OF MINTERMS IF MINTERM RESULTED FROM FUNCTION
    MOV [20],AL ;STORE NEW CURRENT NUMBER OF MINTERMS
    MOV CL,[21] ;MOVE COUNTER TO CL
    INC CL  ;INCREMENT CL, INCREMENTING COUNTER
    MOV [21],CL ;MOVE NEW VALUE OF COUNTER
    POP AL  ;RESTORE PREVIOUS VALUE OF D
    POP CL  ;RESTORE PREVIOUS VALUE OF C
    POP DL  ;RESTORE PREVIOUS VALUE OF A
    RET

        ;PROCEDURE 60, MANIPULATES VARIABLES TO IMPLEMENT FULL TRUTH TABLE
    ORG 60  ;WRITE CODE BEGINNING AT [60]
    MOV CL,[21] ;MOVE COUNTER VALUE TO CL REGISTER
    CMP CL,1    ;NEED TO MAKE THIS INTO A LOOP
    JZ  FIRST
    CMP CL,2
    JZ  SECOND
    CMP CL,3
    JZ  FIRST
    CMP CL,4
    JZ  FOURTH
    CMP CL,5
    JZ  FIRST
    CMP CL,6
    JZ  SECOND
    CMP CL,7
    JZ  FIRST
    CMP CL,8
    JZ  EIGHTH
    CMP CL,9
    JZ  FIRST
    CMP CL,10
    JZ  SECOND
    CMP CL,11
    JZ  FIRST
    CMP CL,12
    JZ  FOURTH
    CMP CL,13
    JZ  FIRST
    CMP CL,14
    JZ  SECOND
    CMP CL,15
    JZ  FIRST
    JMP LAST
FIRST:
    MOV AL,1
    JMP LAST
SECOND:
    MOV AL,0
    MOV BL,1
    JMP LAST
FOURTH:
    MOV AL,0
    MOV BL,0
    MOV CL,1
    JMP LAST
EIGHTH:
    MOV AL,0
    MOV BL,0
    MOV CL,0
    MOV DL,1
    JMP LAST
LAST:
    RET

        FINISH:
    ORG E0              ;WRITE CODE BEGINNING AT E0(OUTPUTS TO VDU)
    DB  "The number of Minterms in F is"    ;OUTPUT STATEMENT
    RET

        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-05-31T00:39:45+00:00Added an answer on May 31, 2026 at 12:39 am

    How about simply:

    mov cl, 0 ; CL contains DCBA bits
    L:
    mov bl, cl ; BL contains DCBAb
    and bl, 101b ; BL contains 0C0Ab
    mov al, cl ; AL contains DCBAb
    shr al, 1 ; AL contains 0DCBb
    and al, 101b ; AL contains 0D0Bb
    and bl, al ; BL contains 0(C&D)0(A&B)b
    mov al, bl ; AL contains 0(C&D)0(A&B)b
    and bl, 1 ; BL contains 000(A&B)b
    shr al, 2 ; AL contains 000(C&D)b
    xor al, bl ; AL contains 000((C&D) XOR (A&B))b
    inc cl ; increment DCBA as a 4-bit number
    cmp cl, 16 ; all 16 combinations?
    jne L ; not yet, repeat
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, I am trying create a 'to & fro' animation using jquery animate &
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
Ok so I am trying create a login script, here I am using PHP5
Trying to create several layers of folders at once C:\pie\applepie\recipies\ without using several different
hi I'm trying create chat using node.js I see example in http://chat.nodejs.org/ I have
I'm trying create a scaling layout for an Android application. The whole screen should
I'm trying create this function such that if any key besides any of the
I am trying create a table and add this table into tablecell (table inside
I am trying create alert dailog using glade,but its not working .am i doing
Trying to create an Oracle trigger that runs after a table is updated in

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.