Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Help 

Having a little trouble with emu8086

I am having a little trouble with an assignment that I have to complete in emu8086. What I have to do is, as the teacher states:

Quote:Write two lines to push a byte stored in dh on to myStack.
Write two lines to pop a byte stored in myStack into dl.


Here is the code that I have so far:

Code
;kevin o'keeffe

org 100h
jmp START

myStack db 8 dup (?)    
_myStackSize equ 8        

START:
mov si, _myStackSize    ;si holds size of myStack

mov dh, '1'                ;move '1' (which is ascii 31) to dh
mov cx,5                ;Wish to execute loop body 5 times (must use cx with loop command)
PUSH_LOOP:
    
    ;push myStack
    [color=#FF0000]mov si, 0h    [/color]            ;change si so myStack[si] is the new top of myStack
    [color=#FF0000]mov dh, myStack(si)[/color]                    ;mov dh to the new top of myStack
    
    inc dh                
    loop PUSH_LOOP        ;dec cx        jnz PUSH_LOOP

mov cx,5          
POP_LOOP:                ;Wish to execute loop body 5 times (must use cx with loop command)
    
    ;pop myStack
    ;[color=#FF0000]???    [/color]                ;mov (ie copy) the top element of myStack to dl
    ;[color=#FF0000]???    [/color]                ;change si so myStack[si] is the new top of myStack
    
    mov ah, 02h            ;Send rv
    int 21h                ;to screen
    
    ;Advance screen to new print line
    mov ah, 02h
    mov dl,0Dh
    int 21h
    mov dl,0Ah
    int 21h
    loop POP_LOOP    ;dec cx        jnz PUSH_LOOP      

ret

The four lines in red are what I have to change/make. Please help!
Why are you trying to use absolute values here?
Code
PUSH_LOOP:
    dec si
    mov myStack[si], dh

Code
POP_LOOP:
   mov dl, myStack[si]
   inc si


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Assembly] by 0x45Apr 14, 2014 12:22 AM 5 347 Apr 14, 2014 12:22 AM
Last Post: 0x45
[Assembly] by MatthewHodnickMar 9, 2012 06:54 PM 8 365 Mar 9, 2012 06:54 PM
Last Post: DexHacker
[Assembly] by pr0gr4merFeb 26, 2011 12:17 PM 0 132 Feb 26, 2011 12:17 PM
Last Post: pr0gr4mer